Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wpsmith
wpsmith / functions-example-1.php
Created July 17, 2012 15:21
Faulty genesis_register_sidebar_defaults Examples
<?php
add_filter( 'genesis_register_sidebar_defaults', 'wps_register_sidebar_defaults' );
/**
* Modify the Genesis sidebar defaults
*
* @param array $defaults Genesis defaults.
* @return array Modified Genesis defaults.
*/
function wps_register_sidebar_defaults( $defaults ) {
@wpsmith
wpsmith / genesis-sidebar-defaults.php
Created July 17, 2012 15:43
Modifies the Genesis Sidebar Defaults
<?php
/*
Plugin Name: Genesis Sidebars Defaults Plugin
Plugin URI: http://www.wpsmith.net/
Description: Modifies the Genesis Sidebar Defaults
Version: 0.0.1
Author: Travis Smith
Author URI: http://www.wpsmith.net/
License: GPLv2
@wpsmith
wpsmith / wps_enqueue_lt_ie9.php
Created July 22, 2012 02:49
Conditionally Enqueue Script for IE browsers less than IE 9
<?php
add_action( 'wp_enqueue_scripts', 'wps_enqueue_lt_ie9' );
/**
* Conditionally Enqueue Script for IE browsers less than IE 9
*
* @link http://php.net/manual/en/function.version-compare.php
* @uses wp_check_browser_version()
*/
function wps_enqueue_lt_ie9() {
global $is_IE;
@wpsmith
wpsmith / lt_ie9.html
Created July 22, 2012 02:54
HTML Conditional Markup
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
@wpsmith
wpsmith / wps_add_ie_html5_shim.php
Created July 22, 2012 02:57
Add IE conditional html5 shim to header
<?php
add_action( 'wp_head', 'wps_add_ie_html5_shim' );
/**
* Add IE conditional html5 shim to header
*/
function wps_add_ie_html5_shim() {
global $is_IE;
if ( $is_IE ) {
echo '<!--[if lt IE 9]>';
echo '<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>';
@wpsmith
wpsmith / bail.php
Created August 1, 2012 17:47
Bail out if running an autosave, ajax or a cron for use in save_post
<?php
/**
* Bail out if running an autosave, ajax or a cron
* or user does not have proper capabilities
*
* @return bool|int True if should bail, post ID if lacking cap
*/
function wps_bail( $post_id = '', $cap = 'edit_post' ) {
/** Bail out if running an autosave */
@wpsmith
wpsmith / inpost-metaboxes-save-patch.php
Created August 12, 2012 19:36
Genesis 1.8.x Post Class Patch for functions.php. This patch will be safe for Genesis 1.9.x re-write of this function.
<?php
add_action( 'save_post', 'wps_inpost_layout_check', 1 );
/**
* Checks the version of Genesis and executes accordingly.
*
* Executes for Genesis versions less than 1.9.x.
*
* @category Genesis
* @package Admin
@wpsmith
wpsmith / wp_user_query.php
Created August 14, 2012 21:37
WP_User_Query
<?php
/**
* WordPress WP_User_Query Comprehensive Reference
* Compiled by wpsmith - wpsmith.net
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_User_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/user.php
*/
$args = array(
@wpsmith
wpsmith / user_query.php
Created August 15, 2012 17:34
Orderby meta_value last_name via WP_User_Query Object
<?php
// Caveat: This creates 2 queries and any use of this code should also use site transients
// prepare arguments
$args = array(
'meta_key' => 'last_name',
);
// Create the WP_User_Query object
@wpsmith
wpsmith / user_query.php
Created August 15, 2012 17:40
Orderby meta_value last_name via pre_user_query in WP_User_Query
<?php
// prepare arguments
$args = array(
'meta_key' => 'last_name',
'query_id' => 'wps_last_name',
);
// Create the WP_User_Query object
$author_query = new WP_User_Query( $args );