Skip to content

Instantly share code, notes, and snippets.

View designbuildtest's full-sized avatar

designbuildtest

View GitHub Profile
@designbuildtest
designbuildtest / gist:54145bd7b03b3273a6cb
Created January 7, 2015 05:21
Customizer Upload Image / Use as Custom Header
$wp_customize->add_section( 'header_background', array(
'title' => __( 'Custom Header Image', 'onehundred' ),
'priority' => 40,
) );
$wp_customize->add_setting( 'header_background', array(
'sanitize_callback' => 'construction_sanitize_file_url',
) );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'header_background', array(
function onehundred_testimonials_register_post_type() {
$args = array(
'labels' => array(
'name' => _x( 'Testimonials', 'post type general name', 'onehundred' ),
'singular_name' => _x( 'Testimonial', 'post type singular name', 'onehundred' ),
'add_new' => _x( 'Add New', 'location', 'onehundred' ),
'add_new_item' => __( 'Add Testimonial', 'onehundred' ),
'edit_item' => __( 'Edit Testimonial', 'onehundred' ),
'new_item' => __( 'New Testimonial', 'onehundred' ),
'all_items' => __( 'All Testimonials', 'onehundred' ),
@designbuildtest
designbuildtest / gist:8d77c02c54b1ebf2b2cb
Created December 22, 2014 05:16
Modular Custom CSS reloaded
/**
* Enable Administrators to add a Custom CSS Control to the Customiser.
*/
function onehundred_enable_custom_css() {
if ( current_user_can('create_users') ) {
function onehundred_enable_custom_css_option() {
register_setting('general', 'onehundred_enable_custom_css', 'wp_filter_nohtml_kses');
add_settings_field('onehundred_enable_custom_css', __('Enable Custom CSS?', 'onehundred') , 'onehundred_enable_custom_css_form', 'general');
// 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) {
@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'))
@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: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;
<?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: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',
@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'];