Skip to content

Instantly share code, notes, and snippets.

@GreggFranklin
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GreggFranklin/29cd0697f3e6dee14402 to your computer and use it in GitHub Desktop.
Save GreggFranklin/29cd0697f3e6dee14402 to your computer and use it in GitHub Desktop.
File to create the reveal.js settings in the customizer
<?php
/**
* Adds the individual panel, sections, settings, and controls to the theme customizer
*
* // Setup Customizer For Presentation Settings - include requirein fucntions.php
* require_once( get_template_directory() . '/inc/customizer.php' );
*/
function wppresentor_customizer_register( $wp_customize ) {
/*
* Create Panel
*/
$wp_customize->add_panel( 'panel_id', array(
'priority' => 125,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __( 'Presentation Settings', 'wppresentor' ),
'description' => __( 'Provides gloabl settings for your slide presentations', 'wppresentor' ),
) );
/*
* General Setting Section
*/
$wp_customize->add_section( 'general_settings', array(
'priority' => 10,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __( 'General Settings', 'wppresentor' ),
'description' => '',
'panel' => 'panel_id',
) );
// Base Width
$wp_customize->add_setting( 'base_width', array(
'default' => '960',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => '',
'sanitize_callback' => '',
) );
$wp_customize->add_control( 'base_width', array(
'type' => 'text',
'priority' => 10,
'section' => 'general_settings',
'label' => __( 'Base Width', 'wppresentor' ),
'description' => 'The "normal" width of the presentation; aspect ratio will be preserved when the presentation is scaled to fit different resolutions',
) );
// Base Height
$wp_customize->add_setting( 'base_height', array(
'default' => '700',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => '',
'sanitize_callback' => '',
) );
$wp_customize->add_control( 'base_height', array(
'type' => 'text',
'priority' => 20,
'section' => 'general_settings',
'label' => __( 'Base Height', 'wppresentor' ),
'description' => 'The "normal" height of the presentation; aspect ratio will be preserved when the presentation is scaled to fit different resolutions',
) );
// Margin
$wp_customize->add_setting( 'margin', array(
'default' => '0.1',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => '',
'sanitize_callback' => '',
) );
$wp_customize->add_control( 'margin', array(
'type' => 'text',
'priority' => 30,
'section' => 'general_settings',
'label' => __( 'Margin', 'wppresentor' ),
'description' => 'Factor of the display size that should remain empty around the content',
) );
// Bounds for smallest scale
$wp_customize->add_setting( 'small_scale', array(
'default' => '0.2',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => '',
'sanitize_callback' => '',
) );
$wp_customize->add_control( 'small_scale', array(
'type' => 'text',
'priority' => 40,
'section' => 'general_settings',
'label' => __( 'Smallest Scale', 'wppresentor' ),
'description' => 'Bounds for smallest possible scale to apply to content',
) );
// Bounds for largest scale
$wp_customize->add_setting( 'largest_scale', array(
'default' => '1',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => '',
'sanitize_callback' => '',
) );
$wp_customize->add_control( 'largest_scale', array(
'type' => 'text',
'priority' => 50,
'section' => 'general_settings',
'label' => __( 'Largest Scale', 'wppresentor' ),
'description' => 'Bounds for largest possible scale to apply to content',
) );
// Apply a 3D roll to links on hover
$wp_customize->add_setting('3d_hover', array(
'default' => '0'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'3d_hover',
array(
'priority' => 50,
'label' => __('Apply a 3D roll to links on hover', 'wppresentor'),
'section' => 'general_settings',
'settings' => '3d_hover',
'type' => 'checkbox',
)
) );
// Focus body for keyboard shortcuts
$wp_customize->add_setting('focus_body', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'focus_body',
array(
'priority' => 60,
'label' => __('Focus body when page changes visiblity to ensure keyboard shortcuts work', 'wppresentor'),
'section' => 'general_settings',
'settings' => 'focus_body',
'type' => 'checkbox',
)
) );
/*
* Display Settings Section
*/
$wp_customize->add_section( 'display_settings', array(
'priority' => 20,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __( 'Display Settings', 'wppresentor' ),
'description' => '',
'panel' => 'panel_id',
) );
// Select Theme
$wp_customize->add_setting('select_theme', array(
'default' => 'default',
));
$wp_customize->add_control(
'select_theme',
array(
'priority' => 10,
'type' => 'select',
'label' => 'Select Theme:',
'section' => 'display_settings',
'choices' => array(
'default' => 'Default',
'beige' => 'Beige',
'blood' => 'Blood',
'moon' => 'Moon',
'night' => 'Night',
'serif' => 'Serif',
'simple' => 'Simple',
'sky' => 'Sky',
'solarized' => 'solarized',
),
)
);
// Display controls in the bottom right corner
$wp_customize->add_setting('controls_right_corner', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'controls_right_corner',
array(
'priority' => 20,
'label' => __('Display controls in the bottom right corner', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'controls_right_corner',
'type' => 'checkbox',
)
) );
// Display a presentation progress bar
$wp_customize->add_setting('presentation_progress_bar', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'presentation_progress_bar',
array(
'priority' => 30,
'label' => __('Display a presentation progress bar', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'presentation_progress_bar',
'type' => 'checkbox',
)
) );
// Display the page number of the current slide
$wp_customize->add_setting('slide_page_number', array(
'default' => '0'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'slide_page_number',
array(
'priority' => 40,
'label' => __('Display the page number of the current slide', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'slide_page_number',
'type' => 'checkbox',
)
) );
// Push each slide change to the browser history
$wp_customize->add_setting('push_slide_history', array(
'default' => '0'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'push_slide_history',
array(
'priority' => 50,
'label' => __('Push each slide change to the browser history', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'push_slide_history',
'type' => 'checkbox',
)
) );
// Enable keyboard shortcuts for navigation
$wp_customize->add_setting('keyboard_shortcuts', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'keyboard_shortcuts',
array(
'priority' => 60,
'label' => __('Enable keyboard shortcuts for navigation', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'keyboard_shortcuts',
'type' => 'checkbox',
)
) );
// Enable the slide overview mode
$wp_customize->add_setting('slide_overview_mode', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'slide_overview_mode',
array(
'priority' => 70,
'label' => __('Enable the slide overview mode', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'slide_overview_mode',
'type' => 'checkbox',
)
) );
// Vertically center slides
$wp_customize->add_setting('vertically_center_slides', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'vertically_center_slides',
array(
'priority' => 80,
'label' => __('Vertically center slides', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'vertically_center_slides',
'type' => 'checkbox',
)
) );
// Enable touch navigation on devices with touch input
$wp_customize->add_setting('touch_navigation', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'touch_navigation',
array(
'priority' => 90,
'label' => __('Enable touch navigation on devices with touch input', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'touch_navigation',
'type' => 'checkbox',
)
) );
// Loop the presentation
$wp_customize->add_setting('loop_presentation', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'loop_presentation',
array(
'priority' => 100,
'label' => __('Loop the presentation', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'loop_presentation',
'type' => 'checkbox',
)
) );
// Change the presentation direction to be RTL
$wp_customize->add_setting('rtl_direction', array(
'default' => '0'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'rtl_direction',
array(
'priority' => 110,
'label' => __('Change the presentation direction to be RTL', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'rtl_direction',
'type' => 'checkbox',
)
) );
// Enable fragments
$wp_customize->add_setting('fragments', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'fragments',
array(
'priority' => 120,
'label' => __('Enable fragments', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'fragments',
'type' => 'checkbox',
)
) );
// Run in embed mode
$wp_customize->add_setting('embed_mode', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'embed_mode',
array(
'priority' => 130,
'label' => __('Run in embed mode', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'embed_mode',
'type' => 'checkbox',
)
) );
// Number of milliseconds between automatically proceeding to the next slide
$wp_customize->add_setting( 'milliseconds_slides', array(
'default' => '0',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => '',
'sanitize_callback' => '',
) );
$wp_customize->add_control( 'milliseconds_slides', array(
'type' => 'text',
'priority' => 140,
'section' => 'display_settings',
'label' => __( 'Number of milliseconds between automatically proceeding to the next slide', 'wppresentor' ),
'description' => 'Disabled when set to 0, this value can be overwritten by using a data-autoslide attribute on your slides',
) );
// Stop auto-sliding after user input
$wp_customize->add_setting('stop_auto_sliding', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'stop_auto_sliding',
array(
'priority' => 150,
'label' => __('Stop auto-sliding after user input', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'stop_auto_sliding',
'type' => 'checkbox',
)
) );
// Enable slide navigation via mouse wheel
$wp_customize->add_setting('navigate_via_mouse', array(
'default' => '0'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'navigate_via_mouse',
array(
'priority' => 160,
'label' => __('Enable slide navigation via mouse wheel', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'navigate_via_mouse',
'type' => 'checkbox',
)
) );
// Hide the address bar on mobile devices
$wp_customize->add_setting('hide_address_bar', array(
'default' => '1'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'hide_address_bar',
array(
'priority' => 170,
'label' => __('Hide the address bar on mobile devices', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'hide_address_bar',
'type' => 'checkbox',
)
) );
// Open links in an iframe preview overlay
$wp_customize->add_setting('links_in_iframe', array(
'default' => '0'
));
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'links_in_iframe',
array(
'priority' => 180,
'label' => __('Open links in an iframe preview overlay', 'wppresentor'),
'section' => 'display_settings',
'settings' => 'links_in_iframe',
'type' => 'checkbox',
)
) );
/*
* Transition & Parallax Settings Section
*/
$wp_customize->add_section( 'transition_parallax_settings', array(
'priority' => 30,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __( 'Transition & Parallax Settings', 'wppresentor' ),
'description' => '',
'panel' => 'panel_id',
) );
// Transition Style
$wp_customize->add_setting('transition_style', array(
'default' => 'default',
));
$wp_customize->add_control(
'transition_style',
array(
'priority' => 10,
'type' => 'select',
'label' => 'Transition Style:',
'section' => 'transition_parallax_settings',
'choices' => array(
'default' => 'Default',
'cube' => 'Cube',
'page' => 'Page',
'concave' => 'Concave',
'zoom' => 'Zoom',
'linear' => 'Linear',
'fade' => 'Fade',
'none' => 'none',
),
)
);
// Transition Speed
$wp_customize->add_setting('transition_speed', array(
'default' => 'default',
));
$wp_customize->add_control(
'transition_speed',
array(
'priority' => 20,
'type' => 'select',
'label' => 'Transition Speed:',
'section' => 'transition_parallax_settings',
'choices' => array(
'default' => 'Default',
'fast' => 'Fast',
'slow' => 'Slow',
),
)
);
// Transition Style for full page
$wp_customize->add_setting('transition_style_full_page', array(
'default' => 'default',
));
$wp_customize->add_control(
'transition_style_full_page',
array(
'priority' => 30,
'type' => 'select',
'label' => 'Transition style for full page slide backgrounds:',
'section' => 'transition_parallax_settings',
'choices' => array(
'default' => 'Default',
'none' => 'None',
'slide' => 'Slide',
'concave' => 'Concave',
'convex' => 'Convex',
'zoom' => 'Zoom',
),
)
);
// Number of slides away from the current that are visible
$wp_customize->add_setting( 'number_slides', array(
'default' => '3',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => '',
'sanitize_callback' => '',
) );
$wp_customize->add_control( 'number_slides', array(
'type' => 'text',
'priority' => 40,
'section' => 'transition_parallax_settings',
'label' => __( 'Number of slides', 'wppresentor' ),
'description' => 'Number of slides away from the current that are visible',
) );
// Parallax background image
$wp_customize->add_setting( 'parallax_background_image' );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'parallax_background_image', array(
'priority' => 50,
'label' => __( 'Parallax background image', 'wppresentor' ),
'section' => 'transition_parallax_settings',
'settings' => 'parallax_background_image',
) ) );
// Parallax background size
$wp_customize->add_setting( 'parallax_background_size', array(
'default' => '',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'transport' => '',
'sanitize_callback' => '',
) );
$wp_customize->add_control( 'parallax_background_size', array(
'type' => 'text',
'priority' => 60,
'section' => 'transition_parallax_settings',
'label' => __( 'Parallax background size', 'wppresentor' ),
'description' => 'CSS syntax, e.g. "2100px 900px"',
) );
}
add_action( 'customize_register', 'wppresentor_customizer_register' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment