Skip to content

Instantly share code, notes, and snippets.

Avatar

Weston Ruter westonruter

View GitHub Profile
View jquery.ba-bindandtrigger.js
/*!
* 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){
@westonruter
westonruter / gist:5475349
Last active Feb 6, 2017 — forked from markjaquith/gist:2653957
WordPress Fragment Caching convenience wrapper
View gist:5475349
<?php
/*
Usage:
cache_fragment_output( 'unique-key', 3600, function () {
functions_that_do_stuff_live();
these_should_echo();
});
*/
function cache_fragment_output( $key, $ttl, $function ) {
View multisite-network-upgrade.php
<?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 ) {
View entities.show.20s.json
{
"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"
}
View wpse-254735.php
<?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';
View functions.php
<?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' );
View nl_amp_set_schema_type.php
<?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);