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
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,
'meta_query' => array(
array(
'key' => '_hpc_spotlight_end_time',
'value' => $pttimestamp,
<?php
// LOGOUT LINK IN MENU
function diww_menu_logout_link( $nav, $args ) {
$logoutlink = '<li><a href="'.wp_logout_url().'">Logout</a></li>';
if( $args->theme_location == 'main_menu' && is_user_logged_in() ) {
return $nav.$logoutlink ;
} else {
return $nav;
<?php // load parent theme CSS
function load_parent_theme_css() {
wp_enqueue_style( 'parent-theme', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'load_parent_theme_css' );
&copy;<?php echo date( 'Y' ); ?>
<?php
global $post;
$tmp_post = $post;
$args = array( 'post_type' => 'events', 'numberposts' => $soupnumber, 'no_paging' => '1', 'post_status' => $posttype, 'order' => 'ASC', 'orderby' => $postorder, 'ignore_sticky_posts' => '1', 'category' => $soup_cat);
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li><?php the_title(); ?></li>
<?php endforeach; ?>
<?php $post = $tmp_post; ?>
<?php // REGISTER TESTIMONIAL CPT
if ( ! function_exists('twpb_testimonial_cpt') ) {
function twpb_testimonial_cpt() {
$labels = array(
'name' => _x( 'Testimonials', 'Post Type General Name', 'twpb' ),
'singular_name' => _x( 'Testimonial', 'Post Type Singular Name', 'twpb' ),
'menu_name' => __( 'Testimonial', 'twpb' ),
@theukedge
theukedge / gist:3ab56ab58614e3baa0b4
Created January 28, 2015 18:17
Force HTTPS on all pages in WordPress
<?php function force_https () {
if ( !is_ssl() ) {
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
exit();
}
}
add_action ( 'template_redirect', 'force_https', 1 );
<?php /* Disable specified plugins in development environment */
if ( defined( 'WP_ENV' ) && WP_ENV == 'dev' ) {
$plugins = array(
'iwp-client/init.php',
'google-analytics-for-wordpress/googleanalytics.php',
);
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
deactivate_plugins($plugins);
<?php
// Enable the plugin only when Jetpack and Sharedaddy are enabled
function shortlinks_for_sharing_buttons() {
if (
class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'get_active_modules' ) && in_array( 'sharedaddy', Jetpack::get_active_modules() )
) {
add_filter( 'sharing_permalink', 'get_shortlink_for_post' );
}