Skip to content

Instantly share code, notes, and snippets.

View s3rgiosan's full-sized avatar

Sérgio Santos s3rgiosan

View GitHub Profile
@JayWood
JayWood / default.conf
Created January 13, 2019 03:57
Don't want to download your uploads from the remote, me either...
# Directives to send expires headers and turn off 404 error logging.
location ~* .(js|css|png|jpg|jpeg|gif|ico|mp3|mov|tif|tiff|swf|txt|html)$ {
expires 24h;
log_not_found off;
try_files $uri $uri/ @production;
}
location @production {
resolver 8.8.8.8;
# replace www.livesite.com with the production site URL
<?php
/**
* Include all non-core taxonomies in the sync request, limiting by publicly queryable.
*
* @param array The list of existing taxonomies.
* @return array The new array list.
*/
function sync_non_core_taxonomies( $taxonomies ) {
$taxes = get_taxonomies();
foreach ( $taxes as $taxonomy ) {
@gmazzap
gmazzap / VersionNumber.php
Created March 24, 2019 19:37
Version number parser and comparator compatible with both Semver and WordPress version numbers.
<?php
/**
* Copyright 2019 Inpsyde GmbH
*
* @license MIT https://opensource.org/licenses/MIT
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@kopepasah
kopepasah / wpsnapshots.sh
Created August 2, 2018 15:33
Shortcut for using WP Snapshots in wp-local-docker: https://github.com/10up/wp-local-docker#wp-snapshots
#!/usr/bin/env bash
# Shortcut for WP Snapshots usage in wp-local-docker
#
# @link: https://github.com/10up/wp-local-docker#wp-snapshots
function snap() {
if [ -f "$PWD/bin/wpsnapshots.sh" ]; then
sh ./bin/wpsnapshots.sh "$@"
fi
}
@felixarntz
felixarntz / amp-image-lightbox-links.php
Created August 12, 2019 09:57
WordPress mini plugin for AMP that transforms all images linking to themselves to open in an `amp-image-lightbox` overlaying the website content. For docs on the component, see https://amp.dev/documentation/components/amp-image-lightbox/
<?php
/**
* Make an internal REST request
*
* @global WP_REST_Server $wp_rest_server ResponseHandler instance (usually WP_REST_Server).
* @param $request_or_method WP_REST_Request|string A WP_REST_Request object or a request method
* @param $path (optional) if the path is not specific in the rest request, specify it here
* @param $data (optional) option data for the request.
* @return WP_Error|mixed
@chrisvanpatten
chrisvanpatten / readme.md
Last active September 18, 2020 14:16
Super-simple way to grab a few Instagram images and cache them w/ WordPress

This is an easy way to integrate a basic Instagram feed into a WordPress site.

Setup

First, register with Instagram's developer program, then register a client. Set the client ID they provide you in line 4.

Second, get your Instagram user ID by running this in your terminal:

curl -X GET https://api.instagram.com/v1/users/search\?q\=USERNAME\&client_id\=CLIENT_ID
@windyjonas
windyjonas / wordpress-escaping.md
Last active September 21, 2020 16:10
Most of the escaping functions in WordPress, with a short explanation and example.

WordPress escaping functions

By: Jonas Nordström, @windyjonas
Date: 2013-04-16

esc_attr( $text );
Encodes the <, >, &, " and ' (less than, greater than, ampersand, double quote and single quote) characters. Will never double encode entities.
Example:

@phpbits
phpbits / format-underline.js
Last active April 27, 2021 17:45
Create custom Underline rich text format for Gutenberg editor. Learn more at https://jeffreycarandang.com/how-to-create-custom-text-formats-for-gutenberg-block-editor/
/**
* WordPress dependencies
*/
const { __ } = wp.i18n;
const { Fragment } = wp.element;
const { toggleFormat } = wp.richText;
const { RichTextToolbarButton, RichTextShortcut } = wp.editor;
const { registerFormatType } = wp.richText;
/**