Skip to content

Instantly share code, notes, and snippets.

View nfsarmento's full-sized avatar

Nuno Sarmento nfsarmento

View GitHub Profile
@nfsarmento
nfsarmento / debian-laravel.sh
Created March 4, 2020 13:17 — forked from butschster/debian-laravel.sh
LEMP server configured for Laravel (MySQL, NGINX, php7.2-fpm, Redis, Websocket server, MongoDB, Composer)
# ================================================
# PHP 7.2
#
# See https://www.colinodell.com/blog/201711/installing-php-72
# ================================================
apt-get install -y apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
apt-get update
apt-get install -y php7.2-cli php7.2-gd php7.2-mbstring php7.2-curl php7.2-xml php7.2-zip
@nfsarmento
nfsarmento / index.php
Last active February 28, 2020 23:40 — forked from rbk/index.php
Turn input placeholders into floating labels for WP Contact Form 7 fields
/*
*
* Description: Adds floating lables to all text inputs
*
*/
function ns_append_style_and_js( ){ ?>
<script type="text/javascript">
jQuery(document).ready(function($){
$(document).on('focus', 'input[type=text], input[type=email], textarea', function(e){
var ph = $(this).attr('placeholder');
@nfsarmento
nfsarmento / functions.php
Created February 26, 2020 17:04 — forked from jaredatch/functions.php
WordPress Search Autocomplete using admin-ajax.php
<?php
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ja_global_enqueues() {
wp_enqueue_style(
'jquery-auto-complete',
@nfsarmento
nfsarmento / nginx-wordpress.conf
Last active August 12, 2026 10:36
Harden wordpress security nginx
############ WordPress ####################
# Disable logging for favicon and robots.txt
location = /favicon.ico {
try_files /favicon.ico @empty;
access_log off;
log_not_found off;
expires max;
}
@nfsarmento
nfsarmento / content.php
Created February 13, 2020 10:09
NS Minimal WordPress Theme - First post in full, others show excerpts
<?php
/**
* The template used for displaying content
*
* @package ns-minimal
* @since ns-minimal 1.0.0
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
@nfsarmento
nfsarmento / .htaccess
Created February 6, 2020 14:07
Getting Media on Your Local WordPress Site
RewriteEngine On
RewriteBase /
RewriteRule ^wp-content/uploads(.*)$ https://www.nuno-sarmento.com/wp-content/uploads/$1 [L,R]
@nfsarmento
nfsarmento / Embed Gists with a URL on WordPress editor.php
Last active February 6, 2020 10:23
Embed Gists with a URL on WordPress editor
/**
* Embed Gists with a URL on WordPress editor.
*
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* https://gist.github.com/106134890a362a2a872055401f7fe743
*
* If a gist has multiple files you can select one using a url in the following format:
* https://gist.github.com/106134890a362a2a872055401f7fe743?file=embed-gist.php
*
@nfsarmento
nfsarmento / Extend Recent Posts Widget.php
Created February 5, 2020 15:45
Extend Recent Posts Widget with Thumbnail Image and others
/**
* Extend Recent Posts Widget
*
* Adds different formatting (images) to the default WordPress Recent Posts Widget
*/
Class Ns_Recent_Posts_Widget extends WP_Widget_Recent_Posts {
function widget($args, $instance) {
@nfsarmento
nfsarmento / popular-widget.php
Last active February 5, 2020 17:35 — forked from billerickson/gist:1888923
Popular Posts Widget
@nfsarmento
nfsarmento / breadcrumb.php
Last active January 26, 2024 17:26 — forked from timnovis/breadcrumb.php
WordPress Breadcrumbs & Schema Markup
<?php
/**
* Breadcrumbs
*
* @package nunosarmento
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;