Skip to content

Instantly share code, notes, and snippets.

@designbuildtest
Created June 6, 2014 04:19
Show Gist options
  • Save designbuildtest/70e6f9895630f64560bc to your computer and use it in GitHub Desktop.
Save designbuildtest/70e6f9895630f64560bc to your computer and use it in GitHub Desktop.
Slider autoplay
<?php
// Slider autoplay toggle.
$wp_customize->add_setting( 'slider_autoplay', array(
'default' => 'disabled',
'sanitize_callback' => 'twentyfourteen_sanitize_slider_autoplay',
) );
$wp_customize->add_control( 'slider_autoplay', array(
'label' => __( 'Slider Autoplay', 'twentyfourteen' ),
'section' => 'featured_content',
'type' => 'select',
'choices' => array(
'disabled' => __( 'Disabled', 'twentyfourteen' ),
'enabled' => __( 'Enabled', 'twentyfourteen' ),
),
'priority' => 2,
) );
/**
* Sanitize the Slider Autoplay value.
*
* @since Twenty Fourteen 1.0
*
* @param string $layout Layout type.
* @return string Filtered autoplay value (disabled|enabled).
*/
function twentyfourteen_sanitize_slider_autoplay( $autoplay ) {
if ( ! in_array( $autoplay, array( 'disabled', 'enabled' ) ) ) {
$autoplay = 'disabled';
}
return $autoplay;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment