Created
July 30, 2018 08:46
-
-
Save KennethEhmsen/fa0170ae4a9edfd45d460c41eab015f0 to your computer and use it in GitHub Desktop.
Adding a ‘Slider Animations’ section to the Theme Customizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ====================== Slider Animations ====================== | |
function ds_slider_animation_options($wp_customize) { | |
// Add Image / Video Animation Options | |
$wp_customize->add_setting('ds_slide_description', array( | |
'default' => 'auto', | |
'type' => 'option', | |
'capability' => 'edit_theme_options', | |
)); | |
// Add Image / Video Animation Options | |
$wp_customize->add_control('ds_slide_description', array( | |
'label' => __('Slide Description Animation'), | |
'section' => 'et_pagebuilder_slider', | |
'type' => 'select', | |
'priority' => 60, | |
'settings' => 'ds_slide_description', | |
'choices' => array( | |
'fadeLeft' => 'Fade Left', | |
'fadeBottom' => 'Fade Bottom', | |
'fadeRight' => 'Fade Right', | |
'fadeTop' => 'Fade Top', | |
'fadeInRight' => 'Fade In Right', | |
'fadeInLeft' => 'Fade In Left', | |
'fadeInTop' => 'Fade In Top', | |
'fadeInBottom' => 'Fade In Bottom', | |
'Grow' => 'Grow', | |
'flipInX' => 'Flip In X axis', | |
'flipInY' => 'Flip In Y axis', | |
), | |
)); | |
// Add Image / Video Animation Options | |
$wp_customize->add_setting('ds_slide_image', array( | |
'default' => 'auto', | |
'type' => 'option', | |
'capability' => 'edit_theme_options', | |
)); | |
// Add Image / Video Animation Options | |
$wp_customize->add_control('ds_slide_image', array( | |
'label' => __('Slide Image Animation'), | |
'section' => 'et_pagebuilder_slider', | |
'type' => 'select', | |
'priority' => 60, | |
'settings' => 'ds_slide_image', | |
'choices' => array( | |
'fadeLeft' => 'Fade Left', | |
'fadeBottom' => 'Fade Bottom', | |
'fadeRight' => 'Fade Right', | |
'fadeTop' => 'Fade Top', | |
'fadeInRight' => 'Fade In Right', | |
'fadeInLeft' => 'Fade In Left', | |
'fadeInTop' => 'Fade In Top', | |
'fadeInBottom' => 'Fade In Bottom', | |
'Grow' => 'Grow', | |
'flipInX' => 'Flip In X axis', | |
'flipInY' => 'Flip In Y axis', | |
), | |
)); | |
} | |
add_action('customize_register', 'ds_slider_animation_options'); | |
function ds_slider_animation_options_css() { | |
$slide_description = get_option('ds_slide_description','fadeInRight'); | |
$slide_image = get_option('ds_slide_image','fadeInRight'); | |
?> | |
<style> | |
.et-pb-active-slide .et_pb_slide_description { | |
animation-name: <?php echo $slide_description; ?>; | |
} | |
.et-pb-active-slide .et_pb_slide_image, .et-pb-active-slide .et_pb_slide_video { | |
animation-name: <?php echo $slide_image; ?>; | |
} | |
</style> | |
<?php | |
} | |
add_action( 'wp_head', 'ds_slider_animation_options_css' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment