Skip to content

Instantly share code, notes, and snippets.

function bg_video_scripts() {
wp_enqueue_script( 'bg-backgrounds', get_stylesheet_directory_uri() . '/assets/jquery.videoBG.js', array( 'jquery' ) );
wp_enqueue_script( 'bg-backgrounds-actuator', get_stylesheet_directory_uri() . '/assets/script.js', array( 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'bg_video_scripts' );
@topher1kenobe
topher1kenobe / pacc_cross_post.php
Created June 30, 2014 12:50
Example of cross posting from a WordPress subsite to the parent site
<?php
/*
Plugin Name: PACC Cross Post
Plugin URI: http://thepacc.com
Description: Allows subsites to cross post to the main site
Author: Topher
Version: 1.0
Author URI: http://codeventure.net
*/
@topher1kenobe
topher1kenobe / gist:8511994
Created January 19, 2014 22:42
Make WordPress image insert function use html5 figures
/**
* Swap Default TinyMCE Tags for Figure Tags on Images
*/
function html5_insert_image( $html, $id, $caption, $title, $align ) {
$title = esc_attr( $title );
$caption = sanitize_text_field( $caption );
$id = absint( $id );
$url = esc_url( wp_get_attachment_url( $id ) );
@topher1kenobe
topher1kenobe / Conditional SQL
Created September 1, 2013 11:54
Conditional SQL in MySQL
SELECT
SUM(
CASE
WHEN `home_school_id`= 42 THEN `away_score`
WHEN `away_school_id`= 42 THEN `home_score`
END
) as points_against
FROM
`games`
WHERE
@topher1kenobe
topher1kenobe / gist:5430861
Last active December 16, 2015 11:58
Delete WordPress transient under the proper conditions
// delete featured coaches transient on coach save
function delete_featured_transient($post_id) {
// First we want to make sure that this is a real save, not simply an auto save
if ( !wp_is_post_revision( $post_id ) ) {
// now we declare our custom content type, because we only want to run this
// on the save of this type
$slug = 'coaches';
@topher1kenobe
topher1kenobe / gist:5430835
Last active December 16, 2015 11:58
Store WordPress query in a transient
// Let's create the function to be used as a shortcode
function featured_coaches($atts) {
// My content type is for Motor Coaches, and we want to get the ones that have
// the Featured box checked, but not the Sold box.
// I'm starting out saying we want 3, and no sold
extract(shortcode_atts(array(
'num' => 3
,'sold' => false