Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Digital Raindrops Theme Flex Slider Options
- */
- function dr_slider_admin_enqueue_scripts( $hook_suffix ) {
- wp_admin_css( 'dashboard' );
- wp_enqueue_style( 'dr-flex-slider-admin', get_stylesheet_directory_uri() . '/css/flex-slider-admin.css', false, '2012-03-20' );
- wp_enqueue_script( 'dashboard' );
- }
- add_action( 'admin_print_styles-appearance_page_theme_setup', 'dr_slider_admin_enqueue_scripts' );
- function dr_slider_theme_options_init() {
- register_setting(
- 'dr_slider_options',
- 'dr_slider_theme_options',
- 'dr_slider_theme_options_validate'
- );
- }
- add_action( 'admin_init', 'dr_slider_theme_options_init' );
- /* Add our theme colors page to the admin menu */
- function dr_slider_theme_options_add_page() {
- $option_page = add_theme_page(
- __( 'Flex Slider Setup', 'dr_slider' ),
- __( 'Flex Slider Setup', 'dr_slider' ),
- 'edit_theme_options',
- 'theme_setup',
- 'dr_slider_options_render_page'
- );
- }
- add_action( 'admin_menu', 'dr_slider_theme_options_add_page' );
- function dr_slider_options_render_page() {
- ?>
- <div class="wrap">
- <?php screen_icon(); ?>
- <h2><?php printf( __( '%s - Flex Slider Setup', 'dr_slider' ), get_current_theme() ); ?></h2><br />
- <?php settings_errors(); ?>
- <form method="post" action="options.php">
- <?php
- settings_fields( 'dr_slider_options' );
- global $dr_slider_settings, $dr_slider_theme_options;
- $dr_slider_theme_options = dr_slider_theme_admin_options();
- ?>
- <div class='postbox-container' style='width:750px;'>
- <?php foreach ($dr_slider_theme_options as $value) {
- $default="";
- switch ( $value['type'] ) {
- case "section":
- ?>
- <div class="postbox<?php echo $style; ?>">
- <div class="handlediv" title="Click to toggle">
- </div>
- <h3 class="hndle">
- <span><?php echo $value['name']; ?></span>
- </h3>
- <div class="inside">
- <?php
- $style=" closed";
- break;
- case 'text':
- $id = $value["id"];
- if( isset( $dr_slider_settings[$id] ) ) {
- if( $dr_slider_settings[$id] ) $current_value = $dr_slider_settings[$id];
- else $current_value = $value['default'];
- }
- else $current_value = $value['default'];
- ?>
- <label for="dr_slider_theme_options[<?php echo $id;?>]"><?php echo $value["name"];?></label></th>
- <fieldset><legend class="screen-reader-text"><span><?php echo $value['name']; ?></span></legend>
- <input type="text" name="dr_slider_theme_options[<?php echo $id;?>]" value="<?php echo $current_value;?>" />
- <p><small><?php echo $value["desc"]; ?></small></p>
- <div class="clearfix"></div>
- </fieldset>
- <?php
- break;
- case "textarea":
- $id=$value['id'];
- ?>
- <label for="dr_slider_theme_options[<?php echo $id;?>]"><?php echo $value['name'];?></label></th>
- <fieldset><legend class="screen-reader-text"><span><?php echo $value['name']; ?></span></legend>
- <textarea name="dr_slider_theme_options[<?php echo $value["id"]; ?>]" cols="1" rows="1" >
- <?php if ( isset( $dr_slider_settings[$id] ) && $dr_slider_settings[$id] ) { echo $dr_slider_settings[$id] ; } else { echo $value['default']; } ?></textarea>
- <p><small><?php echo $value["desc"]; ?></small></p>
- <div class="clearfix"></div>
- </fieldset>
- <?php
- break;
- case 'select':
- $id=$value['id'];
- ?>
- <label for="dr_slider_theme_options[<?php echo $id;?>]"><?php echo $value['name']; ?></label></th>
- <fieldset><legend class="screen-reader-text"><span><?php echo $value['name']; ?></span></legend>
- <select id="dr_slider_theme_options[<?php echo $id; ?>]" name="dr_slider_theme_options[<?php echo $id; ?>]" style="width: <?php echo $value["width"]; ?>px;">
- <?php foreach ($value['options'] as $option) {
- $selected = ( isset($dr_slider_settings[$id]) && ($dr_slider_settings[$id] == esc_attr( $option['value']) ) ) ? ' selected = "selected" ' : '';
- $output = '<option '.$selected .'value="' . $option['value'];
- $output = $output .'">';
- $output = $output .$option['label'];
- $output = $output .'</option>';
- echo $output;
- } ?>
- </select>
- <p><small><?php echo $value["desc"]; ?></small></p>
- <div class="clearfix"></div>
- </fieldset>
- <?php
- break;
- case "checkbox":
- $id=$value['id'];
- ?>
- <label for="dr_slider_theme_options[<?php echo $id;?>]"><?php echo $value['name']; ?></label></th>
- <fieldset><legend class="screen-reader-text"><span><?php echo $value['name']; ?></span></legend>
- <?php if(isset( $dr_slider_settings[$id] ) && $dr_slider_settings[$id]){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
- <input type="checkbox" name="dr_slider_theme_options[<?php echo $id;?>]" value="true" <?php echo $checked; ?> />
- <p><small><?php echo $value["desc"]; ?></small></p>
- </fieldset>
- <?php break;
- case "close":
- ?>
- <?php submit_button(); ?>
- </div>
- </div>
- <?php
- break;
- }
- } ?>
- <div style="float: left; position: relative; line-height: 20px; font-size:12px; color: #777777; margin-bottom:10px;">Theme Flex Slider Options Page <a href="http://digitalraindrops.net/">created by Digital Raindrops</a></div>
- </div>
- </form>
- </div>
- <?php
- }
- function dr_slider_theme_options_validate( $input ) {
- global $dr_slider_theme_options;
- foreach($dr_slider_theme_options as $theme_option) {
- $option_type = $theme_option['type'];
- if (!$option_type=='open' && !$option_type=='close' && !$option_type=='section') {
- $id = $theme_option['id'];
- if( !isset( $input[$id] ) ) $input[$id] = $theme_option['default'];
- switch ($option_type) {
- case 'text':
- $input[$id] = trim( wp_filter_nohtml_kses( $input[$id] ) );
- break;
- case 'textarea':
- $input[$id] = trim( wp_filter_post_kses( $input[$id] ) );
- break;
- case 'select':
- $options = $theme_option['options'];
- if ( array_search( $input[$id], $options ) != 0 )
- $input[$id] = null;
- break;
- }
- if( !isset( $input[$id] ) ) $input[$id] = $theme_option['default'];
- }
- }
- return $input;
- }
- /* Options for the Theme Slider Setup page */
- function dr_slider_theme_admin_options() {
- /* Menu Options */
- $the_cats = get_categories();
- $theme_categories = array();
- $theme_categories[] = array( 'value'=>'', 'label'=>'' );
- if($the_cats) {
- foreach( $the_cats as $the_cat ) :
- $theme_categories[$the_cat->cat_ID] = array('value'=>$the_cat->cat_ID, 'label'=>$the_cat->cat_name );
- endforeach;
- }
- $menu = array(
- '' => array(
- 'value' => '',
- 'label' => 'Do Not Show'
- ),
- 'all' => array(
- 'value' => 'all',
- 'label' => 'Show on All'
- ),
- 'nohome' => array(
- 'value' => 'nohome',
- 'label' => 'Hidden on Home Page'
- ),
- 'home' => array(
- 'value' => 'home',
- 'label' => 'Only on Home Page'
- ),
- );
- $general_options = array (
- array(
- "name" => __('Main Flex Slider', THEME_NS),
- "type" => "section"),
- array( "type" => "open"),
- array(
- 'id' => 'main_slider',
- 'name' => __('Show Main Slider', THEME_NS),
- 'desc' => __('Select where to use the Main Flex Slider', THEME_NS),
- 'type' => 'select',
- 'width' => '200',
- 'options' => $menu,
- 'default' => '',
- ),
- array(
- 'id' => 'main_slider_pages',
- 'name' => __('Slider Pages', THEME_NS),
- 'desc' => __('Select to use Page Feature Images for Slider Images', THEME_NS),
- 'type' => 'checkbox',
- "default" => false,
- ),
- array(
- 'id' => 'main_slider_cat',
- 'name' => __('Slider Category', THEME_NS),
- 'type' => 'select',
- 'width' => '200',
- 'options' => $theme_categories,
- 'desc' => __('Use this Category to use the Featured Images for Slider Images', THEME_NS),
- 'default' => ''
- ),
- array(
- 'id' => 'main_slider_caption',
- 'name' => __('Slider Captions', THEME_NS),
- 'desc' => __('Select to use Post or Page titles as Slider Captions', THEME_NS),
- 'type' => 'checkbox',
- "default" => true,
- ),
- array(
- 'id' => 'main_image_links',
- 'name' => __('HyperLinks', THEME_NS),
- 'desc' => __('Select to Hyperlink Slider Content to the Post or Page', THEME_NS),
- 'type' => 'checkbox',
- "default" => false,
- ),
- array(
- 'id' => 'main_slider_excerpt',
- 'name' => __('Show Excerpt', THEME_NS),
- 'desc' => __('Select to show the Post or Page Excerpt', THEME_NS),
- 'type' => 'checkbox',
- "default" => false,
- ),
- array(
- 'id' => 'main_slider_count',
- 'name' => __('Slider Count', THEME_NS),
- 'type' => 'select',
- 'width' => '100',
- 'options' => array(
- array('value' => '3', 'label' => 'Three'),
- array('value' => '4', 'label' => 'Four'),
- array('value' => '5', 'label' => 'Five'),
- array('value' => '6', 'label' => 'Six'),
- array('value' => '7', 'label' => 'Seven'),
- array('value' => '8', 'label' => 'Eight'),
- array('value' => '9', 'label' => 'Nine'),
- array('value' => '10', 'label' => 'Ten'),
- ),
- 'desc' => __('Number of Image to Slide', THEME_NS),
- 'default' => '5'
- ),
- array(
- 'id' => 'main_animation',
- 'name' => __('Slider Animation', THEME_NS),
- 'type' => 'select',
- 'width' => '100',
- 'options' => array(
- array('value' => 'fade', 'label' => 'Fade'),
- array('value' => 'slide', 'label' => 'Slide'),
- ),
- 'desc' => __('Select your animation type Fade or Slide', THEME_NS),
- 'default' => 'fade'
- ),
- array(
- 'id' => 'main_slideDirection',
- 'name' => __('Slider Direction', THEME_NS),
- 'type' => 'select',
- 'width' => '100',
- 'options' => array(
- array('value' => 'horizontal', 'label' => 'Horizontal'),
- array('value' => 'vertical', 'label' => 'Vertical'),
- ),
- 'desc' => __('Select the sliding direction, Horizontal or Vertical', THEME_NS),
- 'default' => 'horizontal'
- ),
- array(
- 'id' => 'main_slideshow',
- 'name' => __('Slideshow', THEME_NS),
- 'desc' => __('Select to Animate the Slider Automatically', THEME_NS),
- 'type' => 'checkbox',
- "default" => true,
- ),
- array(
- 'id' => 'main_slideshowSpeed',
- 'name' => __('Slideshow Speed', THEME_NS),
- 'desc' => __('Set the Speed of the Slideshow Cycling in Milliseconds', THEME_NS),
- 'type' => 'text',
- 'integer' => true,
- 'size' => 5,
- 'maxlength' => 4,
- "default" => 7000,
- ),
- array(
- 'id' => 'main_animationDuration',
- 'name' => __('Animation Duration', THEME_NS),
- 'desc' => __('Set the Speed of Animations in Milliseconds', THEME_NS),
- 'type' => 'text',
- 'integer' => true,
- 'size' => 4,
- 'maxlength' => 3,
- "default" => 600,
- ),
- array(
- 'id' => 'main_directionNav',
- 'name' => __('Navigation', THEME_NS),
- 'desc' => __('Show Navigation for Previous and Next', THEME_NS),
- 'type' => 'checkbox',
- "default" => true,
- ),
- array(
- 'id' => 'main_prevText',
- 'name' => __('Previous Text', THEME_NS),
- 'desc' => __('Set the Text for the Previous Navigation', THEME_NS),
- 'type' => 'text',
- "default" => 'Previous',
- ),
- array(
- 'id' => 'main_nextText',
- 'name' => __('Next Text', THEME_NS),
- 'desc' => __('Set the Text for the Next Navigation', THEME_NS),
- 'type' => 'text',
- "default" => 'Next',
- ),
- array(
- 'id' => 'main_randomize',
- 'name' => __('Randomize Slides', THEME_NS),
- 'desc' => __('Randomize the Order of the Slides', THEME_NS),
- 'type' => 'checkbox',
- "default" => true,
- ),
- array( "type" => "close"),
- array(
- "name" => __('Widget Flex Slider', THEME_NS),
- "type" => "section"),
- array( "type" => "open"),
- array(
- 'id' => 'widget_slider',
- 'name' => __('Show Widget Slider', THEME_NS),
- 'desc' => __('Select where to use the Widget Flex Slider', THEME_NS),
- 'type' => 'select',
- 'width' => '200',
- 'options' => $menu,
- 'default' => '',
- ),
- array(
- 'id' => 'widget_slider_caption',
- 'name' => __('Slider Captions', THEME_NS),
- 'desc' => __('Select to use Post or Page titles as Slider Captions', THEME_NS),
- 'type' => 'checkbox',
- "default" => true,
- ),
- array(
- 'id' => 'widget_image_links',
- 'name' => __('Hyperlinks', THEME_NS),
- 'desc' => __('Select to Hyperlink Slider Content to the Post or Page', THEME_NS),
- 'type' => 'checkbox',
- "default" => false,
- ),
- array(
- 'id' => 'widget_slider_excerpt',
- 'name' => __('Show Excerpt', THEME_NS),
- 'desc' => __('Select to show the Post or Page Excerpt', THEME_NS),
- 'type' => 'checkbox',
- "default" => false,
- ),
- array(
- 'id' => 'widget_slider_count',
- 'name' => __('Slider Count', THEME_NS),
- 'type' => 'select',
- 'width' => '100',
- 'options' => array(
- array('value' => '3', 'label' => 'Three'),
- array('value' => '4', 'label' => 'Four'),
- array('value' => '5', 'label' => 'Five'),
- array('value' => '6', 'label' => 'Six'),
- array('value' => '7', 'label' => 'Seven'),
- array('value' => '8', 'label' => 'Eight'),
- array('value' => '9', 'label' => 'Nine'),
- array('value' => '10', 'label' => 'Ten'),
- ),
- 'desc' => __('Number of Image to Slide', THEME_NS),
- 'default' => '5'
- ),
- array(
- 'id' => 'widget_animation',
- 'name' => __('Slider Animation', THEME_NS),
- 'type' => 'select',
- 'width' => '100',
- 'options' => array(
- array('value' => 'fade', 'label' => 'Fade'),
- array('value' => 'slide', 'label' => 'Slide'),
- ),
- 'desc' => __('Select your animation type Fade or Slide', THEME_NS),
- 'default' => 'fade'
- ),
- array(
- 'id' => 'widget_slideDirection',
- 'name' => __('Slider Direction', THEME_NS),
- 'type' => 'select',
- 'width' => '100',
- 'options' => array(
- array('value' => 'horizontal', 'label' => 'Horizontal'),
- array('value' => 'vertical', 'label' => 'Vertical'),
- ),
- 'desc' => __('Select the sliding direction, Horizontal or Vertical', THEME_NS),
- 'default' => 'horizontal'
- ),
- array(
- 'id' => 'widget_slideshow',
- 'name' => __('Slideshow', THEME_NS),
- 'desc' => __('Select to Animate the Slider Automatically', THEME_NS),
- 'type' => 'checkbox',
- "default" => true,
- ),
- array(
- 'id' => 'widget_slideshowSpeed',
- 'name' => __('Slideshow Speed', THEME_NS),
- 'desc' => __('Set the Speed of the Slideshow Cycling in Milliseconds', THEME_NS),
- 'type' => 'text',
- 'integer' => true,
- 'size' => 5,
- 'maxlength' => 4,
- "default" => 7000,
- ),
- array(
- 'id' => 'widget_animationDuration',
- 'name' => __('Animation Duration', THEME_NS),
- 'desc' => __('Set the Speed of Animations in Milliseconds', THEME_NS),
- 'type' => 'text',
- 'integer' => true,
- 'size' => 4,
- 'maxlength' => 3,
- "default" => 600,
- ),
- array(
- 'id' => 'widget_directionNav',
- 'name' => __('Navigation', THEME_NS),
- 'desc' => __('Show Navigation for Previous and Next', THEME_NS),
- 'type' => 'checkbox',
- "default" => true,
- ),
- array(
- 'id' => 'widget_prevText',
- 'name' => __('Previous Text', THEME_NS),
- 'desc' => __('Set the Text for the Previous Navigation', THEME_NS),
- 'type' => 'text',
- "default" => 'Previous',
- ),
- array(
- 'id' => 'widget_nextText',
- 'name' => __('Next Text', THEME_NS),
- 'desc' => __('Set the Text for the Next Navigation', THEME_NS),
- 'type' => 'text',
- "default" => 'Next',
- ),
- array(
- 'id' => 'widget_randomize',
- 'name' => __('Randomize Slides', THEME_NS),
- 'desc' => __('Randomize the Order of the Slides', THEME_NS),
- 'type' => 'checkbox',
- "default" => true,
- ),
- array( "type" => "close"),
- );
- return $general_options;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement