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_action( 'cmb2_admin_init', function() { | |
$prefix = 'mk_add_thickbox_'; | |
$metabox = new_cmb2_box( array( | |
'id' => $prefix.'box', | |
'title' => 'Signature', | |
'object_types' => array( 'post', ), | |
) ); | |
$metabox->add_field( array( |
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_action('loop_start', function() { | |
// Only for archive | |
if (is_archive()) { | |
echo '<!--- Start loop wrap --><div class="wrap">'; | |
} | |
}); | |
add_action('loop_end', function() { | |
// Only for archive | |
if (is_archive()) { |
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
// Set program archive to order on post meta date/time | |
add_action('pre_get_posts', function($query) { | |
// Order on time | |
$query->set( 'meta_key', 'start_time' ); | |
$query->set( 'orderby', 'meta_value_num' ); | |
$query->set( 'order', 'ASC' ); | |
}); |
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
add_filter( 'posts_clauses', function( $pieces, $obj ) { | |
global $wpdb; | |
$pieces['join'] .= " LEFT JOIN `$wpdb->term_relationships` AS trs ON ($wpdb->posts.ID = trs.object_id)"; | |
$pieces['join'] .= " LEFT JOIN `$wpdb->term_taxonomy` AS tt ON (trs.term_taxonomy_id = tt.term_taxonomy_id)"; | |
$pieces['join'] .= " LEFT JOIN `$wpdb->terms` AS t ON (tt.term_id = t.term_id)"; | |
$pieces['join'] .= " LEFT JOIN `$wpdb->term_taxonomy` AS parent ON (parent.parent = trs.term_taxonomy_id)"; | |
$pieces['join'] .= " LEFT JOIN `$wpdb->terms` AS parent_terms ON (parent.term_id = parent_terms.term_id)"; | |
$pieces['where'] .= " AND (tt.taxonomy = '*YOUR_TAXONOMY*')"; |
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
add_action( 'rest_api_init', function () { | |
register_rest_route( 'myplugin/v1', '/author/(?P<id>\d+)', array( | |
'methods' => 'GET', | |
'callback' => function($request) { | |
print_r($request->get_params()); | |
}, | |
) ); | |
} ); |
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
// Used mainly for live reload with Chrome workspaces | |
add_filter( 'style_loader_src', 'mk_remove_version_numbers', 9999 ); | |
add_filter( 'script_loader_src', 'mk_remove_version_numbers', 9999 ); | |
function mk_remove_version_numbers( $src ) { | |
if ( strpos( $src, 'ver=' ) ) | |
$src = remove_query_arg( 'ver', $src ); | |
return $src; | |
} |
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
// Only show images owned by user | |
add_filter( 'ajax_query_attachments_args', function ( $query ) { | |
$query['author'] = get_current_user_id(); | |
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
var data = new FormData() | |
// Add data/files to formdata var | |
jQuery.ajax({ | |
url: wpApiSettings.root + 'routehere/v1/subroute/save', | |
type: 'POST', | |
beforeSend: function(xhr) { | |
xhr.setRequestHeader( 'X-WP-Nonce', wpApiSettings.nonce ); | |
}, |
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 | |
function my_email_function($email, $header, $content) { | |
// We'll use Woocommerce e-mail function to send e-mail to users | |
ob_start(); | |
// Get WC e-mail header | |
do_action( 'woocommerce_email_header', $header, $email ); | |
// Content | |
echo $content; |
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
@import url('https://fonts.googleapis.com/css?family=Lato:400,700,900') |
OlderNewer