This file contains 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 | |
/** | |
* Register scripts with a `defer` or `async` strategy in a backwards compatible manner. | |
* | |
* From WordPress 6.3 onwards, the `wp_register_script` function accepts an `$args` array that | |
* can include a `strategy` key with a value of either `async` or `defer`. | |
* | |
* This helper function handles the backwards compatibility for older versions of WordPress. When a | |
* `strategy` key is present in the `$args` array (and is either `defer` or `async`), the |
This file contains 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 | |
/* | |
Usage: | |
cache_fragment_output( 'unique-key', 3600, function () { | |
functions_that_do_stuff_live(); | |
these_should_echo(); | |
}); | |
*/ | |
function cache_fragment_output( $key, $ttl, $function ) { |
This file contains 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 | |
/** | |
* AMP Disable ES Modules by Default plugin. | |
* | |
* @package AMP_Disable_ESM | |
* @author Weston Ruter | |
* @link https://gist.github.com/westonruter/279bcb54336449ce55d8887fb0fcf5b9 | |
* @license GPL-2.0-or-later | |
* | |
* @wordpress-plugin |
This file contains 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 | |
function nl_amp_set_schema_type( $metadata, $post ) { | |
if ($post->post_type == 'recipe') { | |
$metadata['@type'] = 'Recipe'; | |
$metadata['name'] = $post->post_title; | |
$metadata["recipeYield"] = get_field('new_serves', $post->ID); | |
$metadata['description'] = get_field('description', $post->ID); |
This file contains 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: Multisite Network Upgrade WP-CLI Command | |
* Plugin URI: https://gist.github.com/westonruter/beb6120e61e9691e88ac | |
* Author: Weston Ruter, Mo Jangda | |
* Description: From command line run <code>wp multisite-network-upgrade</code>. Script converted into WP-CLI command from Mo's <a href="https://gist.github.com/mjangda/986838">CLI script</a>. | |
* License: GPL2 | |
*/ | |
if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) { |
This file contains 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: WPSE 282139 | |
* Plugin URI: https://wordpress.stackexchange.com/questions/282139/how-to-make-get-theme-mod-work-with-ajax-in-the-customizer-preview | |
*/ | |
add_action( 'wp_ajax_my_request', function () { | |
ob_start(); | |
echo get_theme_mod( 'position', 'top' ); |
This file contains 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 | |
function my_styles_method() { | |
wp_enqueue_style( 'custom-style', get_template_directory_uri() . '/custom-css.css' ); | |
$colors = array( | |
'headings_color' => get_theme_mod( 'wpt_heading_color' ), | |
); | |
$css_output = "{color: {$colors['headings_color']}; }"; | |
$selector = 'h1,h2,h3,h4,h5,h6'; |
This file contains 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
{ | |
"premiereDate": "2016-08-08T16:00:00.000Z", | |
"votingDate": "2016-11-08T16:00:00.000Z", | |
"finaleDate": "2016-11-15T16:00:00.000Z", | |
"logo": "http://placekitten.com/200/200" | |
} |
This file contains 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
/*! | |
* bindAndTrigger - v0.2 - 04/30/2010 | |
* http://benalman.com/ (original v0.1 at http://gist.github.com/384866 ) | |
* http://weston.ruter.net/ (playing around with improving variable args) | |
* | |
* http://jsfiddle.net/cowboy/fJnA2/ | |
*/ | |
(function($,undefined){ | |