Advertisement
adige72

Untitled

Oct 13th, 2011
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.82 KB | None | 0 0
  1. <?php
  2.  
  3. add_action('admin_menu', 'slider_admin_menu');
  4. add_action('admin_init', 'slider_init');
  5.  
  6.  
  7. function slider_admin_menu() {
  8.     global $customslides, $theme_optionTree; $theme_optionTree = get_option('option_tree');
  9.  
  10.  
  11.     if(get_option('customslides')) {
  12.         $customslides = get_option('customslides');
  13.     }
  14.  
  15.     if(isset($_GET['page']) && $_GET['page'] == 'slidemanager') {
  16.        
  17.         if(isset($_POST['action']) && $_POST['action'] == 'save') {
  18.        
  19.         //---  
  20.             if($theDawn_optionTree['slider_type'] == 'Sayan kayak') {
  21.                 $customslides = array();
  22.                 foreach($_POST['src'] as $k => $v) {
  23.                     $customslides[] = array(
  24.                         'src' => $v,
  25.                         'desc' => stripslashes($_POST['desc'][$k]),
  26.                         'desc2' => stripslashes($_POST['desc2'][$k]),
  27.                         'addbutton' => stripslashes($_POST['addbutton'][$k]),
  28.                         'link' => $_POST['link'][$k],
  29.                         'selected' => $_POST['selected'][$k],
  30.                         'color' => $_POST['color'][$k],                    
  31.                         'slidename' => $_POST['slidename'][$k],
  32.                     );
  33.                     update_option('customslides', $customslides);
  34.                 }
  35.             }
  36.         //---
  37.        
  38.         }
  39.     }
  40.    
  41.     global $slider_help_hook;
  42.     $slider_help_hook = add_menu_page('Slide Manager', 'Slide Manager', 'edit_themes', 'slidemanager', 'slider_admin_page', '', 9);
  43.    
  44. }
  45.  
  46.  
  47. function slider_admin_page() {
  48.         global $customslides;
  49.         global $theme_optionTree; $theme_optionTree = get_option('option_tree');
  50.     ?>
  51.     <script type="text/javascript">
  52.     jQuery.noConflict();
  53.     jQuery(document).ready( function($){   
  54.         var buttons = { previous:$('#lofslidecontent45 .lof-previous') , next:$('#lofslidecontent45 .lof-next') };
  55.         $obj = $('#lofslidecontent45')
  56.         .lofJSidernews( { interval : <?php echo $interval; ?>,
  57.         <?php if($transition=='slide') echo "easing : 'easeInOutExpo'";
  58.             if($transition=='smooth') echo "easing : 'easeInOutQuad'";
  59.         if($transition=='fade') echo "direction : 'opacity'";
  60.             if($transition=='swipe') echo "easing : 'easeOutBack'";
  61.             if($transition=='bounce') echo "easing : 'easeOutBounce'"; ?>,
  62.         duration : <?php echo $transpeed; ?>,
  63.         auto : true,
  64.         maxItemDisplay : 10,
  65.         startItem:<?php if($start=='1') echo '0';
  66.         if($start=='2') echo '1';
  67.         if($start=='3') echo '2';
  68.         if($start=='4') echo '3';
  69.         if($start=='5') echo '4';
  70.         if($start=='6') echo '5';
  71.         if($start=='7') echo '6';
  72.         if($start=='8') echo '7';
  73.         if($start=='9') echo '8';
  74.         if($start=='10') echo '9'; ?>,
  75.         navPosition     : 'horizontal', // horizontal
  76.         navigatorHeight : 15,
  77.         navigatorWidth  : 25,
  78.         buttons : buttons,
  79.         mainWidth:<?php echo $width; ?>} );
  80.     });</script>
  81.         <div class="wrap">
  82.             <div id="icon-options-general" class="icon32"><br /></div>
  83.             <h2>Theme Settings - Slide Manager</h2>
  84.            
  85.             <div class="form-wrap">
  86.             <form name="form" action="" id="slider_form" method="post">
  87.  
  88.             <!-- Those divs are belong to standard WP classes & ids for styling puropses-->
  89.             <div id="poststuff" class="metabox-holder"><div id="normal-sortables" class="meta-box-sortables ui-sortable">
  90.                
  91.                 <ul id="sliders-wrap">
  92.                
  93.                 <?php elseif($theDawn_optionTree['slider_type'] == 'Default Slider') :?>
  94.                    
  95.                 <?php if(get_option('customslides')) : ?>
  96.  
  97.                     <?php $i=1; ?>
  98.                    
  99.                         <?php function addPicture() {
  100.                             wp_enqueue_script('media-upload');
  101.                             wp_enqueue_script('thickbox');
  102.                             wp_register_script('my-upload', bloginfo('template_directory').'/wp-includes/themes/sayan/add-picture.js', array('jquery','media-upload','thickbox'));
  103.                             wp_enqueue_script('upload');
  104.                         }
  105.  
  106.                         add_action('admin_print_scripts', 'addPicture');
  107.                         ?>
  108.                    
  109. //FOREACH STARTS HERE           <?php foreach($customslides as $k => $slide) : ?>
  110.                    
  111.                     <li class="slide">
  112.                         <div class="postbox">
  113.                             <div class="handlediv"></div>
  114.                             <h3 class="hndle"><span class="slide-num"></span><span><input type="text" name="slidename[]" class="slide_slidename" value="<?php echo $slide['slidename'] ?>" size="40" /></span></h3>
  115.                             <div class="inside">
  116.                                 <div class="slider-settings-column alignright">
  117.                                     <p class="slide_desc_p nivo_caption"><textarea type="text" name="desc[]" class="slide_desc" cols="32" rows="3" ><?php echo $slide['desc'] ?></textarea></p>
  118.                                     <p class="slide_desc_p nivo_caption"><textarea type="text" name="desc2[]" class="slide_desc" cols="32" rows="3" ><?php echo $slide['desc2'] ?></textarea></p>
  119.                                 </div>
  120.                                 <div class="slider-settings-column alignleft">
  121.                                    
  122.                                     <p><input class="upload_image" type="text" size="97" name="src[]" value="<?php echo $slide['src'] ?>" /></p>
  123.                                     <p><input class="upload_image_button" type="button" value="Add Picture" name="addbutton[]" /></p>
  124.  
  125.                             <?php
  126.                             echo '<table style="margin-bottom: 20px;" class="widefat">';
  127.                             echo '<thead><tr><th></th></tr></thead>';
  128.                             echo '<tbody style="background:#f9f9f9;"><tr><td>';
  129.                             ?>
  130.  
  131.             <script language="JavaScript"><!--
  132.                 function onChange() {
  133.                     var Current =
  134.                     document.form.link.selectedIndex;
  135.                     document.form.currentText3.value =
  136.                     document.form.link.options[Current].value;
  137.                 }
  138.                
  139.                 //-->
  140.             </script>                      
  141.  
  142.             <select name="link" onChange="this.form.currentText3.value = this.value;">
  143.             <?php
  144.             if($_POST['action'] == save ) {
  145.                 $selected = "selected";
  146.                 }
  147.                 else{
  148.                 $selected = "";
  149.                 }
  150.                 echo '<option value="">...... Choose One ...... </option>';
  151.                 $args = array(
  152.                 'post_type' => 'post',
  153.                 'nopaging'  => true
  154.                 );
  155.  
  156.                 $the_query = new WP_Query( $args );
  157.                
  158.                 while ( $the_query->have_posts() ) : $the_query->the_post();
  159.                 echo '<option '.$selected.' value="'.get_permalink( $post->ID ).'">';
  160.                 the_title();
  161.                 echo '</option>';
  162.                 endwhile;
  163.  
  164.                 ?>
  165.             </select>          
  166.  
  167.             <input name="currentText3" type="text" value="">           
  168.  
  169.                             <?php
  170.                             echo '<p></p>';
  171.                             echo '</td></tr></tbody></table>';                             
  172.                             ?>
  173.                    
  174.                                 </div>
  175.                             </div>
  176.                             <div class="delete-slide-wrap"><span style="" class="delete-slide" >Delete this slide</span></div>
  177.                         </div>
  178.                         <br class="clear"/>
  179.                     </li>
  180.                     <?php $i++; ?>
  181. //FOREACH ENDS HERE         <?php endforeach; ?>
  182.                    
  183.                 <?php endif; // end if slider type ?>
  184.                
  185.                 </ul>
  186.                 <br />
  187.                 <input type="submit" id="slider-submit" class="button-primary" value="Save Pictures" />
  188.                 <input type="hidden" name="action" value="save" />
  189.                
  190.             </div></div><!-- End of WP Divs -->
  191.  
  192.             </form>
  193.             </div>
  194.         </div>
  195.     <?php
  196. }
  197.  
  198.  
  199. function slider_init() {
  200.        
  201.     if(isset($_GET['page']) && $_GET['page'] == 'slidemanager') {
  202.        
  203.         wp_enqueue_style('slider-manager', THEDAWN_ADMIN . '/css/thedawn-style.css');
  204.        
  205.         wp_enqueue_script('jquery-ui-core');
  206.         wp_enqueue_script('jquery-ui-sortable');
  207.         wp_enqueue_script('jquery-appendo', THEDAWN_ADMIN . '/scripts/jquery.appendo.js');
  208.         wp_enqueue_script('slider-manager', THEDAWN_ADMIN . '/scripts/slider.js');
  209.     }
  210. }
  211.  
  212. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement