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 | |
| // 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 | |
| // 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 | |
| // 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 | |
| /* | |
| 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
| /* | |
| 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
| 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
| <?php | |
| $args = array(...); | |
| $my_posts = new WP_Query( $args ); | |
| $the_year = ''; | |
| $the_month = ''; | |
| if ( $my_posts->have_posts() ) : | |
| while ( $my_posts->have_posts() ) : | |
| $my_posts->the_post(); | |
| // Get the year of the post in YYYY format | |
| $post_year = get_the_time( 'Y' ); |
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 | |
| include 'simple_html_dom.php'; | |
| $html = file_get_html('http://www.asia.si.edu/exhibitions/past.asp'); | |
| $output = array(); | |
| foreach( $html->find( '#filterarea li' ) as $elem ) { | |
| $h1 = $elem->find( 'h1', 0 ); | |
| if ( $h1 ) { | |
| continue; | |
| } |
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 | |
| /** | |
| * This script will parse our Slack history and pull email subscriber counts that were posted by our bots. | |
| * Place in the root of a WordPress install, add a Slack token for API access, and visit the URL | |
| * | |
| * A CSV file of the results will be downloaded. | |
| * For further analys import into a database (See Below) | |
| * | |
| */ |