Skip to content

Instantly share code, notes, and snippets.

View shawnsandy's full-sized avatar

Shawn Sandy shawnsandy

View GitHub Profile
@shawnsandy
shawnsandy / custom-menu.php
Created July 11, 2012 00:58
wp_custom menu
<?php
/*-----------------------------------------------------------------------------------*/
/* Register Custom Menus, and Create Default Menus, Assign to Theme Locations
$defaults = array(
'menu-item-db-id' => $menu_item_db_id,
'menu-item-object-id' => 0,
'menu-item-object' => '',
@shawnsandy
shawnsandy / twentyeleven_customize_register.php
Created July 15, 2012 14:25
Implements Twenty Eleven theme options into Theme Customizer *
<?php
/**
*
* @param $wp_customize Theme Customizer object
* @return void
*
* @since Twenty Eleven 1.3
*/
function ( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
@shawnsandy
shawnsandy / my_post.php
Created August 23, 2012 12:08
Wordpress Post Class
<?php
class my_post {
public function __construct() {
}
@shawnsandy
shawnsandy / default_thumbnail.php
Created November 18, 2012 02:13
How to define a default post thumbnail....
function default_thumbnail($html) {
global $_wp_additional_image_sizes;
$isize = $_wp_additional_image_sizes;
$w = $isize['post-thumbnail']['width'];
$h = $isize['post-thumbnail']['height'];
if (empty($html)) {
$html = '<figure class="default-post-thumbnail">';
$html .= '<img src="http://placehold.it/'.$w.'x'.$h.'" alt="" />';
$html .='</figure>';
}
@shawnsandy
shawnsandy / cpt_class.php
Created November 28, 2012 19:04
Custom post type class
<?php
/**
* @package WordPress
* @subpackage Core-WP
* @author shawnsandy
*/
class cwp_post_type {
/*
* post vars
@shawnsandy
shawnsandy / AL_Tweets.php
Created December 8, 2012 23:46
WordPress Twitter Feed class / plugin
<?php
/*
Plugin Name: EXT_Tweets
Plugin URI: http://blog.shawnsandy.com
Description: A WordPress drop-in plugin class for loading and displaying tweets. (Add to mu-plugin directory for auto install / use)
Version: 0.1 - beta
Author: Shawn Sandy
Author URI: http://shawnsandy.com
License: GPL2
@shawnsandy
shawnsandy / Selected_Users_Control.php
Created December 18, 2012 04:04
A simple custom control I wrote for the WordPress theme customizer that allows you to create user select drop-down list...
<?php
if (class_exists('WP_Customize_Control')):
class Selected_Users_Control extends WP_Customize_Control {
public $type = 'option';
public $query = array('orderby' => 'nicename');
public $description = '';
public function render_content() {
$query = $this->query;
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@shawnsandy
shawnsandy / Sample-Customizer.php
Last active December 16, 2015 08:59
Customizer
<?php
/** create the section */
$cust = Customizer_Settings::add_section('test-section', __('Custom Sections','test'));
/** add text control(s) ***/
Customizer_Settings::add_option($cust, 'test-setting', 'Custom Setting')->customizer();
Customizer_Settings::add_option($cust, 'test-setting-1', 'Another Setting 1')->customizer();
/** add a checkbox control **/
Customizer_Settings::add_option($cust, 'test-setting-2', 'Checkbox Option')->set_control_type('checkbox')->customizer();
Customizer_Settings::add_option($cust, 'test-upload', 'Upload Control')->set_control_type('')->customizer('add_color_control');
Customizer_Settings::add_option($cust, 'image-upload', 'Image Control')->set_control_type('')->customizer('add_image_control');
@shawnsandy
shawnsandy / cpt_custom.php
Last active December 16, 2015 18:59
Use custom post types names as templates in WordPress
<?php
/**
*
* @link Blog post info and description
*/
function post_type_templates($template) {