Skip to content

Instantly share code, notes, and snippets.

Travis Smith wpsmith

Block or report user

Report or block wpsmith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@wpsmith
wpsmith / gist:1647598
Created Jan 20, 2012
Expanding taxonomy_select
View gist:1647598
case 'taxonomy_select':
echo '<select name="', $field['id'], '" id="', $field['id'], '">';
$names= wp_get_object_terms( $post->ID, $field['taxonomy'] );
$terms = get_terms( $field['taxonomy'], 'hide_empty=0' );
if ( $field['options'] ) {
foreach ($field['options'] as $option) {
echo '<option value="', $option['value'], '"', $meta == $option['value'] ? ' selected="selected"' : '', '>', $option['name'], '</option>';
}
}
foreach ( $terms as $term ) {
@wpsmith
wpsmith / gist:1690040
Created Jan 27, 2012
CMB: Post Type Select
View gist:1690040
add_action( 'ntg_render_post_type_select' , 'wps_post_type_select' , 10 , 3 );
function wps_post_type_select ( $field, $meta, $id ) {
global $post;
if ( $field['type'] == 'post_type_select' ) {
echo '<select name="', $id, '" id="', $id, '">';
$pts = get_post_types();
if ( $field['options'] ) {
foreach ($field['options'] as $option) {
@wpsmith
wpsmith / gist:1690166
Created Jan 27, 2012
Taxonomy and Terms Dropdown
View gist:1690166
add_action( 'ntg_render_taxonomy_terms_select' , 'wps_taxonomy_terms_select' , 10 , 3 );
function wps_taxonomy_terms_select ( $field, $meta, $id ) {
global $post;
if ( $field['type'] == 'taxonomy_terms_select' ) {
echo '<select name="', $id, '" id="', $id, '" style="margin-top: 5px;">';
$pts = get_post_types();
echo '<option style="padding-right:10px;" value=""', selected ( $meta, '' ), '>', __( 'All Taxonomies and Terms', WPS_SLIDER ).'</option>';
if ( $field['options'] ) {
@wpsmith
wpsmith / gist:1690169
Created Jan 27, 2012
default case for admin-builder.php
View gist:1690169
default:
do_action( 'ntg_render_' . $field['type'] , $field, $meta , $this->get_field_name( $field['id'] ) );
@wpsmith
wpsmith / nothing.php
Created Feb 15, 2012
Trying to add "last-post" class to the loop
View nothing.php
$post_classes = get_post_class();
$odd_or_even = 'even';
$post_counter = 0;
$post_counter++;
$odd_or_even = ( 'odd' == $odd_or_even ) ? 'even' : 'odd';
$post_classes[] = ( $post_counter == count( $posts ) ) ? 'last-post' :$odd_or_even;
echo '<div class="' . implode( ' ', $post_classes ) . '">';
@wpsmith
wpsmith / radio-latest-news-widget.php
Created Feb 15, 2012 — forked from gregrickaby/radio-latest-news-widget.php
If there's no content, don't display [Continue...]
View radio-latest-news-widget.php
if ( ! empty( $instance['show_content'] ) ) {
if ( 'excerpt' == $instance['show_content'] )
the_excerpt();
elseif ( 'content-limit' == $instance['show_content'] && strip_shortcodes( get_the_content() ) != '' )
the_content_limit( (int) $instance['content_limit'], esc_html( $instance['more_text'] ) );
else
the_content( esc_html( $instance['more_text'] ) );
}
@wpsmith
wpsmith / gist:1926880
Created Feb 27, 2012
get custom field
View gist:1926880
function genesis_get_custom_field($field, $single = true) {
global $id, $post;
if ( null === $id && null === $post ) {
return false;
}
$post_id = null === $id ? $post->ID : $id;
@wpsmith
wpsmith / genesis-favicon.php
Created Mar 3, 2012
Loads favicon from a specified URL
View genesis-favicon.php
// Loads favicon from specified URL
add_filter( 'genesis_pre_load_favicon', 'wps_custom_favicon_filter' );
function wps_custom_favicon_filter( $favicon_url ) {
return 'http://domain.com/path/mycustomfavicon.ico';
}
@wpsmith
wpsmith / embed-objects.php
Created Mar 3, 2012
Changes the default embed sizes based on conditionals
View embed-objects.php
add_filter( 'embed_defaults', 'wps_embed_defaults' );
/**
* Changes the default embed sizes based on site layout
* @author Travis Smith
*
* @param array height and width keys, values can be string/int
* @return array height and width keys and values
*/
function wps_embed_defaults( $defaults ) {
@wpsmith
wpsmith / genesis-embed-objects.php
Created Mar 3, 2012
Changes the default embed sizes based on site layout
View genesis-embed-objects.php
add_filter( 'embed_defaults', 'wps_embed_defaults' );
/**
* Changes the default embed sizes based on site layout
* via filtering wp_embed_defaults()
*
* @author Travis Smith
*
* @param array height and width keys, values can be string/int
* @return array height and width keys and values
*/
You can’t perform that action at this time.