Skip to content

Instantly share code, notes, and snippets.

View theukedge's full-sized avatar

Dave Clements theukedge

View GitHub Profile
<?php // IN THE SPOTLIGHT QUERY
$pttimestamp = time() + get_option('gmt_offset') * 60*60;
$its_query = new WP_Query( array(
'post_type' => 'spotlight',
'posts_per_page' => 1,
'post__not_in' => $do_not_duplicate,
'meta_query' => array(
array(
'key' => '_hpc_spotlight_end_time',
'value' => $pttimestamp,
<?php // IN THE SPOTLIGHT QUERY
if( false === ( $its_query = get_transient( 'its_query' ) ) ) {
$pttimestamp = time() + get_option('gmt_offset') * 60*60;
$its_query = new WP_Query( array(
'post_type' => 'spotlight',
'posts_per_page' => 1,
'post__not_in' => $do_not_duplicate,
'meta_query' => array(
array(
'key' => '_hpc_spotlight_end_time',
<?php
if ( has_nav_menu( 'header-menu' ) ) {
wp_nav_menu( array(
'menu' => '33',
'depth' => 3,
'container' => 'nav',
'menu_class' => 'nav nav-pills',
'fallback_cb' => 'wp_page_menu',
'walker' => new wp_bootstrap_navwalker()
) );
<?php
$header_menu_query = get_transient( 'header_menu_query' );
if( $header_menu_query === false ) {
if ( has_nav_menu( 'header-menu' ) ) {
$header_menu_query = wp_nav_menu( array(
'menu' => '33',
'depth' => 3,
'container' => 'nav',
'menu_class' => 'nav nav-pills',
'fallback_cb' => 'wp_page_menu',
<?php // MENU TRANSIENTS
function hpc_delete_menu_transients() {
delete_transient( 'header_menu_query' );
delete_transient( 'footer_menu1_query' );
delete_transient( 'footer_menu2_query' );
}
add_action( 'wp_update_nav_menu', 'hpc_delete_menu_transients' );
<?php // SPECIAL FEATURE CONTENT SHORTCODE
function hpc_special_feature_shortcode( $atts ) {
extract( shortcode_atts(
array(
'type' => '',
'showposts' => -1,
'feature' => '',
'cat' => '',
'offset' => '',
<?php // SPECIAL FEATURE CONTENT SHORTCODE
function hpc_special_feature_shortcode( $atts ) {
extract( shortcode_atts(
array(
'type' => '',
'showposts' => -1,
'feature' => '',
'cat' => '',
'offset' => '',
<?php // HIDE EMAILL ADDRESSES
function hide_email_from_scrapers( $atts , $content = null ) {
if ( ! is_email( $content ) ) {
return;
}
return '<a href="mailto:' . antispambot( $content, 1 ) . '">' . antispambot( $content, 1 ) . '</a>';
}
add_shortcode( 'hide_email', 'hide_email_from_scrapers' );
<a href="mailto:&#109;e&#64;%6d%79%73&#105;%74e&#46;c%6f%6d">%6d%65&#64;&#109;&#121;s%69te&#46;%63%6fm</a>
<?php
function hpc_spotlight_metaboxes( $meta_boxes ) {
$prefix = '_hpc_spotlight_'; // Prefix for all fields
$meta_boxes[] = array(
'id' => 'hpc_spotlight_meta',
'title' => 'In The Spotlight settings',
'pages' => array('spotlight'), // post type
'context' => 'normal',
'priority' => 'high',