Skip to content

Instantly share code, notes, and snippets.

View designbuildtest's full-sized avatar

designbuildtest

View GitHub Profile
@designbuildtest
designbuildtest / gist:10c68c382040d39d53bc
Last active August 29, 2015 14:03
Activate WebDevStudio's cmb class
<?php
/**
* Initialize Custom Metabox class.
* https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress
* https://github.com/mustardBees/cmb_field_map
*/
function sendtheme_initialize_metaboxes() {
if ( !class_exists( 'cmb_Meta_Box' ) ) {
require_once get_template_directory() . '/metaboxes-1.2.0/init.php';
$latest_posts = new WP_Query( array(
'posts_per_page'=>3,
'ignore_sticky_posts' => true
)
);
if ( $latest_posts->have_posts()) : ?>
<ul class="latest-posts clear">
<?php while($latest_posts->have_posts()) : $latest_posts->the_post(); ?>
<li id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
@designbuildtest
designbuildtest / gist:367037e18fbee47f5ccf
Created July 30, 2014 23:12
Featured Image with captions
if ( ! function_exists( 'mytheme_entry_image' ) ) :
/**
* Display an optional entry thumbnail.
*/
function mytheme_entry_image() {
if ( ! has_post_thumbnail() ) {
return;
}
$featured_image = get_post_thumbnail_id();
$attachment_page = esc_url( get_attachment_link( $featured_image ) );
@designbuildtest
designbuildtest / gist:17b8d10a7ac30ba65758
Last active August 29, 2015 14:04
Get featured tag name
/**
* Print the featured tag name, but only if the user has chosen not
* to hide this tag (as per Theme Customizer setting).
*/
$featured_tag_options = get_option('featured-content');
$tag_name = $featured_tag_options['tag-name'];
$hide_tag = $featured_tag_options['hide-tag'];
@designbuildtest
designbuildtest / gist:562bcd4ee45e14be3d9e
Last active August 29, 2015 14:04
Auto-advance slider
/**
* Add an option to auto-advance the Featured Content Slider.
*/
$wp_customize->add_setting( 'featured_content_autoplay', array(
'default' => 'off',
'sanitize_callback' => 'mytheme_sanitize_autoplay',
) );
$wp_customize->add_control( 'featured_content_autoplay', array(
'label' => __( 'Autoplay', 'sendtheme' ),
'section' => 'featured_content',
<?php
function mytheme_wrap_oembed_with_div( $html ) {
return '<div class="oembed-container">' . $html . '</div>';
}
add_filter( 'embed_oembed_html', 'mytheme_wrap_oembed_with_div', 10, 3);
add_filter( 'video_embed_html', 'mytheme_wrap_oembed_with_div' );
?>
.oembed-container {
display: block;
@designbuildtest
designbuildtest / gist:bc5908df335a9e886027
Created August 21, 2014 04:04
wp_attachment_is_image() & post_class()
<?php
/**
* Add custom classes to the array of post classes.
*/
function sendtheme_post_classes( $classes ) {
if ( wp_attachment_is_image() ) {
$classes[] = 'attachment-image';
}
return $classes;
@designbuildtest
designbuildtest / gist:3679ed35ee94e708bac1
Last active August 29, 2015 14:05
Image navigation
<?php
// http://wordpress.org/support/topic/previous_image_link
function mytheme_get_previous_image() {
$image = mytheme_adjacent_image_link( true );
if ( $image ) : ?>
<div class="nav-previous odd summary">
<div class="entry-meta entry-meta-above"><?php _e('Previous Image','sendtheme'); ?></div>
<div class="entry-image"><?php echo $image; ?></div>
@designbuildtest
designbuildtest / gist:dec4286f34d12c15701a
Created November 3, 2014 11:17
Logged in user toolbar node
<?php
global $current_user;
get_currentuserinfo();
$salon_user = array(
'id' => 'salon-user',
'title' => __('Hi there, ','salon') . $current_user->display_name,
'href' => site_url() . '/wp-admin/profile.php',
'meta' => array('class' => 'salon-user', 'title' => __('Profile','salon'))
// I am using Gravity Forms together with the 'User Registration' and 'PayPal Standard' Add-On's
// to create new sites on a Multisite network.
// Upon confirmation of a successful PayPal payment, a new site is created with some default pages
// created and custom options applied.
// An abbreviated version of my new site creation function is shown below:
function new_site_setup($blog_id) {