This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iframe { | |
display: block; | |
margin-left: auto; | |
margin-right: auto; | |
max-width: 1000px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Here we're filtering the site_url() and get_site_url() functions which are called dozens and dozens of times during a request. | |
In this case we only want to modify $url if the filter was called from a particular PHP class (rtCamp\WP\Nginx\Helper) | |
*/ | |
add_filter( 'site_url', function( $url = '' ) { | |
$backtrace = wp_debug_backtrace_summary(); | |
if ( stripos( $backtrace, 'rtCamp\WP\Nginx\Helper' ) ) { | |
$url = str_replace( 'https://', 'http://', $url ); | |
} | |
return $url; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Bogworld's Special Neat-o Plugin | |
Description: See https://twitter.com/boagworld/status/844200551017562112 | |
Author: kingkool68 | |
Version: 0.0.1 | |
Author URI: https://twitter.com/kingkool68 | |
*/ | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// In this brief example we'll scrape an Instagram post and save it as a WordPress post | |
// Go to a URL and get the contents back | |
// See https://developer.wordpress.org/reference/functions/wp_remote_get/ | |
$instagram_request = wp_remote_get( 'https://www.instagram.com/p/BSBvNVIF8tI/' ); | |
// If it's succesful, the payload of the request will be in $instagram_request['body'] | |
$instagram_html = $instagram_request['body']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Force MySQL to not cache queries. Helpful for database performance testing. | |
// DO NOT LEAVE THIS ON IN PRODUCTION! | |
add_filter( 'query', function( $query ) { | |
$query = preg_replace( '/SELECT /', 'SELECT SQL_NO_CACHE ', $query, 1 ); | |
return $query; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Throw this in your theme and include it in your functions.php file | |
/** | |
* Helper function for fetching SVG icons | |
* | |
* @param string $icon Name of the SVG file in the icons directory | |
* @return string Inline SVG markup | |
*/ | |
function wp_svg_icon( $icon = '' ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'wp_kses_allowed_html', function( $allowed_tags, $context ) { | |
if ( isset( $allowed_tags['span'] ) ) { | |
unset( $allowed_tags['span'] ); | |
} | |
foreach ( $allowed_tags as $tag => $attrs ) { | |
$allowed_tags[ $tag ]['style'] = false; | |
$allowed_tags[ $tag ]['dir'] = false; | |
} | |
return $allowed_tags; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add `SQL_NO_CACHE` to every SELECT statement | |
// Helpful for debugging query performance | |
add_filter( 'query', function( $query ) { | |
$query = preg_replace( '/SELECT(\s)/i', 'SELECT SQL_NO_CACHE$1', $query, 1 ); | |
return $query; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is a simple AWS Lambda function that will look for a given file on S3 and return it | |
* passing along all of the headers of the S3 file. To make this available via a URL use | |
* API Gateway with an AWS Lambda Proxy Integration. | |
* | |
* Set the S3_REGION and S3_BUCKET global parameters in AWS Lambda | |
* Make sure the Lambda function is passed an object with `{ pathParameters : { proxy: 'path/to/file.jpg' } }` set | |
*/ | |
var AWS = require('aws-sdk'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! function_exists( 'wp_dump' ) ) : | |
/** | |
* Dump variables preserving whitespace so they are easier to read. | |
*/ | |
function wp_dump() { | |
$is_xdebug = false; | |
if ( function_exists( 'xdebug_dump_superglobals' ) ) { | |
$is_xdebug = true; |