Changeset 688465
- Timestamp:
- 03/28/2013 03:15:47 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-parallax-content-slider/trunk/wp-parallax-content-slider.php
r687192 r688465 24 24 wp_enqueue_script( 'wp-parallax-content-slider-jswipe', plugins_url( 'js/jquery.jswipe.js', __FILE__ ) ); 25 25 wp_enqueue_script( 'wp-parallax-content-slider-cslider', plugins_url( 'js/jquery.cslider.js', __FILE__ ) ); 26 26 27 27 // CSS Init 28 28 wp_enqueue_style( 'wp-parallax-content-slider-css', plugins_url( 'css/style.css', __FILE__ ) ); 29 29 30 30 // Register hooks that are fired when the plugin is activated, deactivated, and uninstalled, respectively. 31 31 register_activation_hook( __FILE__, array( $this, 'activate' ) ); 32 32 //register_deactivation_hook( __FILE__, array( $this, 'uninstall' ) ); // TODO: Doing this on deactivation should require an extra parameter (user choice) 33 33 register_uninstall_hook( __FILE__, array( $this, 'uninstall' ) ); 34 34 35 35 // Parallax slider plugin specific actions 36 36 add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 37 37 add_shortcode( 'parallaxcontentslider', array( $this, 'parallaxcontentslider_shortcode_call' ) ); 38 38 } // end constructor 39 39 40 40 /** 41 41 * Fired when the plugin is activated. … … 46 46 /* 47 47 * Creating one option entry in the database to store user settings 48 * Parameters have default values 48 * Parameters have default values 49 49 * All this parameters can be changed easyly in the plugin admin section 50 */ 50 */ 51 51 $prlx_slider_settings = array( 52 52 'mode' => 'static', // Slider display mode (static / dynamic) … … 66 66 'content_type' => 'post' // Slider content type (post / page / both) 67 67 ); 68 68 69 69 /* 70 70 * Useful for old versions users : if old settings exist in DB (< v0.9.3), update to new system … … 87 87 $prlx_slider_settings['text_content'] = get_option( 'prlx_text_content' ); 88 88 $prlx_slider_settings['content_type'] = get_option( 'prlx_slider_content_type' ); 89 90 // Deletes obsolete DB entries 89 90 // Deletes obsolete DB entries 91 91 delete_option( 'prlx_slider_mode' ); 92 92 delete_option( 'prlx_slider_theme' ); … … 103 103 delete_option( 'prlx_slider_categories' ); 104 104 delete_option( 'prlx_text_content' ); 105 delete_option( 'prlx_slider_content_type' ); 105 delete_option( 'prlx_slider_content_type' ); 106 106 } 107 107 108 108 add_option( 'prlx_slider_settings', $prlx_slider_settings ); 109 109 } // end activate 110 110 111 111 /** 112 112 * Fired when the plugin is uninstalled. … … 118 118 if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) 119 119 exit (); 120 120 121 121 // Clean options in the database 122 122 delete_option( 'prlx_slider_settings' ); 123 123 124 124 } // end uninstall 125 125 … … 138 138 get_wp_parallax_content_slider( $categ ); 139 139 } 140 140 141 141 /** 142 142 * Return the plugin HTML code for output … … 147 147 148 148 // Retrieving plugin parameters (user choices or default values) 149 $prlx_slider_settings = get_option( 'prlx_slider_settings' );149 $prlx_slider_settings = get_option( 'prlx_slider_settings' ); 150 150 151 151 $prlx_slider_mode = $prlx_slider_settings['mode']; … … 209 209 'orderby' => $prlx_sort, 210 210 'order' => $prlx_order, 211 'numberposts' => $prlx_slider_nb_articles,212 'cat egory' => $cat,213 'suppress_filters' =>0 ); // Added for WPML support211 'numberposts' => $prlx_slider_nb_articles, 212 'cat' => $cat, 213 'suppress_filters'=>0 ); // Added for WPML support 214 214 215 215 $myposts = get_posts( $args ); … … 252 252 endforeach; wp_reset_postdata(); 253 253 254 // TODO: Améliorer le code ici (Utiliser l'output buffer ? ob_start, ob_get_clean...) 255 254 256 $outputDynamic .= <<<DYNAMICOUTPUT 255 257 <nav class="da-arrows"> … … 271 273 272 274 jQuery('#da-slider').swipe({ 273 swipeLeft: function() { jQuery('#da-slider').find('span.da-arrows-next').click() },274 swipeRight: function() { jQuery('#da-slider').find('span.da-arrows-prev').click() },275 swipeLeft: function() { jQuery('#da-slider').find('span.da-arrows-next').click() }, 276 swipeRight: function() { jQuery('#da-slider').find('span.da-arrows-prev').click() }, 275 277 }) 276 278 … … 295 297 include('static-slides-sample.php'); 296 298 if ($prlx_slider_mode === 'dynamic') 297 {298 print $outputDynamic.$outputScript;299 }300 else301 {302 print $outputStatic.$outputScript;303 }299 { 300 print $outputDynamic.$outputScript; 301 } 302 else 303 { 304 print $outputStatic.$outputScript; 305 } 304 306 305 307 // HTML Output end … … 408 410 } 409 411 } 410 412 411 413 // Creating option database array 412 414 $prlx_slider_settings = array( 413 'mode' => $_POST['prlx_slider_mode'], 414 'theme' => $_POST['prlx_slider_theme'], 415 'bgincrement' => $_POST['prlx_slider_bgincrement'], 416 'autoplay' => $_POST['prlx_slider_autoplay'], 417 'interval' => $_POST['prlx_slider_interval'], 415 'mode' => $_POST['prlx_slider_mode'], 416 'theme' => $_POST['prlx_slider_theme'], 417 'bgincrement' => $_POST['prlx_slider_bgincrement'], 418 'autoplay' => $_POST['prlx_slider_autoplay'], 419 'interval' => $_POST['prlx_slider_interval'], 418 420 'first_slide' => $_POST['prlx_slider_first_slide'], 419 421 'nb_articles' => $_POST['prlx_slider_nb_articles'], … … 430 432 // Update options in database 431 433 update_option( 'prlx_slider_settings', $prlx_slider_settings); 432 434 433 435 echo "<div class='updated fade'><p>" . __( 'Settings updated', 'wp-parallax-content-slider' ) ."</p></div>".$debug; 434 436 } … … 438 440 } 439 441 } 440 442 441 443 // Retrieve settings from database 442 $prlx_slider_settings = get_option( 'prlx_slider_settings'); 443 444 $prlx_slider_settings = get_option( 'prlx_slider_settings'); 445 444 446 ?> 445 447 <script type="text/javascript"> … … 519 521 <td> 520 522 <select name="prlx_slider_mode" id="prlx_slider_mode"> 521 <option value="dynamic"><?php _e( 'Dynamic : display last posts', 'wp-parallax-content-slider' ); ?></option>522 <option value="static" <?php if ( $prlx_slider_settings['mode'] === "static") echo 'selected="selected"'; ?>><?php _e( 'Static : display static HTML content', 'wp-parallax-content-slider' ); ?></option>523 </select>523 <option value="dynamic"><?php _e( 'Dynamic : display last posts', 'wp-parallax-content-slider' ); ?></option> 524 <option value="static" <?php if ( $prlx_slider_settings['mode'] === "static") echo 'selected="selected"'; ?>><?php _e( 'Static : display static HTML content', 'wp-parallax-content-slider' ); ?></option> 525 </select> 524 526 </td> 525 527 </tr> … … 552 554 <td> 553 555 <select name="prlx_slider_theme" id="prlx_slider_theme"> 554 <option value="default"><?php _e( 'Default : Yellow waves', 'wp-parallax-content-slider' ); ?></option>555 <option value="dark" <?php if ( $prlx_slider_settings['theme'] === "dark") echo 'selected="selected"'; ?>><?php _e( 'Dark', 'wp-parallax-content-slider' ); ?></option>556 <option value="retro" <?php if ( $prlx_slider_settings['theme'] === "retro") echo 'selected="selected"'; ?>><?php _e( 'Retro Red', 'wp-parallax-content-slider' ); ?></option>557 <option value="silver" <?php if ( $prlx_slider_settings['theme'] === "silver") echo 'selected="selected"'; ?>><?php _e( 'Silver', 'wp-parallax-content-slider' ); ?></option>558 </select>556 <option value="default"><?php _e( 'Default : Yellow waves', 'wp-parallax-content-slider' ); ?></option> 557 <option value="dark" <?php if ( $prlx_slider_settings['theme'] === "dark") echo 'selected="selected"'; ?>><?php _e( 'Dark', 'wp-parallax-content-slider' ); ?></option> 558 <option value="retro" <?php if ( $prlx_slider_settings['theme'] === "retro") echo 'selected="selected"'; ?>><?php _e( 'Retro Red', 'wp-parallax-content-slider' ); ?></option> 559 <option value="silver" <?php if ( $prlx_slider_settings['theme'] === "silver") echo 'selected="selected"'; ?>><?php _e( 'Silver', 'wp-parallax-content-slider' ); ?></option> 560 </select> 559 561 </td> 560 562 </tr> … … 587 589 <td> 588 590 <select name="prlx_slider_content_type" id="prlx_slider_content_type"> 589 <option value="post" <?php if ( $prlx_slider_settings['content_type'] === "post") echo 'selected="selected"'; ?>><?php _e( 'Posts', 'wp-parallax-content-slider' ); ?></option>590 <option value="page" <?php if ( $prlx_slider_settings['content_type'] === "page") echo 'selected="selected"'; ?>><?php _e( 'Pages', 'wp-parallax-content-slider' ); ?></option>591 <option value="both" <?php if ( $prlx_slider_settings['content_type'] === "both") echo 'selected="selected"'; ?>><?php _e( 'Post and pages', 'wp-parallax-content-slider' ); ?></option>592 </select>591 <option value="post" <?php if ( $prlx_slider_settings['content_type'] === "post") echo 'selected="selected"'; ?>><?php _e( 'Posts', 'wp-parallax-content-slider' ); ?></option> 592 <option value="page" <?php if ( $prlx_slider_settings['content_type'] === "page") echo 'selected="selected"'; ?>><?php _e( 'Pages', 'wp-parallax-content-slider' ); ?></option> 593 <option value="both" <?php if ( $prlx_slider_settings['content_type'] === "both") echo 'selected="selected"'; ?>><?php _e( 'Post and pages', 'wp-parallax-content-slider' ); ?></option> 594 </select> 593 595 <label for="prlx_slider_content_type"><?php _e( 'Choose what type of content you want to see in the slider', 'wp-parallax-content-slider' ); ?></label><br /> 594 596 </td> … … 607 609 <td> 608 610 <select name="prlx_slider_sort_by" id="prlx_slider_sort_by"> 609 <option value="date" <?php if ( $prlx_slider_settings['sort_by'] === "date") echo 'selected="selected"'; ?>><?php _e( 'Date', 'wp-parallax-content-slider' ); ?></option>610 <option value="rand" <?php if ( $prlx_slider_settings['sort_by'] === "rand") echo 'selected="selected"'; ?>><?php _e( 'Random', 'wp-parallax-content-slider' ); ?></option>611 <option value="title" <?php if ( $prlx_slider_settings['sort_by'] === "title") echo 'selected="selected"'; ?>><?php _e( 'Title', 'wp-parallax-content-slider' ); ?></option>612 <option value="author" <?php if ( $prlx_slider_settings['sort_by'] === "author") echo 'selected="selected"'; ?>><?php _e( 'Author', 'wp-parallax-content-slider' ); ?></option>613 <option value="comment_count" <?php if ( $prlx_slider_settings['sort_by'] === "comment_count") echo 'selected="selected"'; ?>><?php _e( 'Number of comments', 'wp-parallax-content-slider' ); ?></option>614 <option value="modified" <?php if ( $prlx_slider_settings['sort_by'] === "modified") echo 'selected="selected"'; ?>><?php _e( 'Last modified date', 'wp-parallax-content-slider' ); ?></option>615 </select>611 <option value="date" <?php if ( $prlx_slider_settings['sort_by'] === "date") echo 'selected="selected"'; ?>><?php _e( 'Date', 'wp-parallax-content-slider' ); ?></option> 612 <option value="rand" <?php if ( $prlx_slider_settings['sort_by'] === "rand") echo 'selected="selected"'; ?>><?php _e( 'Random', 'wp-parallax-content-slider' ); ?></option> 613 <option value="title" <?php if ( $prlx_slider_settings['sort_by'] === "title") echo 'selected="selected"'; ?>><?php _e( 'Title', 'wp-parallax-content-slider' ); ?></option> 614 <option value="author" <?php if ( $prlx_slider_settings['sort_by'] === "author") echo 'selected="selected"'; ?>><?php _e( 'Author', 'wp-parallax-content-slider' ); ?></option> 615 <option value="comment_count" <?php if ( $prlx_slider_settings['sort_by'] === "comment_count") echo 'selected="selected"'; ?>><?php _e( 'Number of comments', 'wp-parallax-content-slider' ); ?></option> 616 <option value="modified" <?php if ( $prlx_slider_settings['sort_by'] === "modified") echo 'selected="selected"'; ?>><?php _e( 'Last modified date', 'wp-parallax-content-slider' ); ?></option> 617 </select> 616 618 <label for="prlx_slider_sort_by"><?php _e( 'Choose how do you want to sort the posts in the slider', 'wp-parallax-content-slider' ); ?></label><br /> 617 619 </td> … … 622 624 <td> 623 625 <select name="prlx_slider_order_by" id="prlx_slider_order_by"> 624 <option value="asc" <?php if ( $prlx_slider_settings['order_by'] === "asc") echo 'selected="selected"'; ?>><?php _e( 'Ascending', 'wp-parallax-content-slider' ); ?></option>625 <option value="desc" <?php if ( $prlx_slider_settings['order_by'] === "desc") echo 'selected="selected"'; ?>><?php _e( 'Descending', 'wp-parallax-content-slider' ); ?></option>626 </select>626 <option value="asc" <?php if ( $prlx_slider_settings['order_by'] === "asc") echo 'selected="selected"'; ?>><?php _e( 'Ascending', 'wp-parallax-content-slider' ); ?></option> 627 <option value="desc" <?php if ( $prlx_slider_settings['order_by'] === "desc") echo 'selected="selected"'; ?>><?php _e( 'Descending', 'wp-parallax-content-slider' ); ?></option> 628 </select> 627 629 <label for="prlx_slider_order_by"><?php _e( 'Choose how do you want to order the posts in the slider', 'wp-parallax-content-slider' ); ?></label><br /> 628 630 </td> … … 641 643 <td> 642 644 <select name="prlx_slider_categories[]" id="prlx_slider_categories" multiple="multiple" size="3" style="vertical-align: top;"> 643 <?php644 $args = array( 'orderby' => 'name',645 <?php 646 $args = array( 'orderby' => 'name', 645 647 'order' => 'ASC', 646 'hide_empty' => 1, // Set to 0 if you want to show empty categories647 'suppress_filters'=>0); // Added for WPML support648 $wp_categories = get_categories( $args );649 650 // Get selected values651 $prlx_slider_categories_array = preg_split("/[\s,]+/",$prlx_slider_settings['categories']);652 653 foreach ($wp_categories as $i => $categ)654 {655 echo '<option value="'.$categ->term_id.'" ';656 if (in_array($categ->term_id, $prlx_slider_categories_array))657 echo 'selected="selected"';658 echo '>'.$categ->name.'</option>\n';659 }660 ?>661 </select>648 'hide_empty' => 1, // Set to 0 if you want to show empty categories 649 'suppress_filters'=>0); // Added for WPML support 650 $wp_categories = get_categories( $args ); 651 652 // Get selected values 653 $prlx_slider_categories_array = preg_split("/[\s,]+/",$prlx_slider_settings['categories']); 654 655 foreach ($wp_categories as $i => $categ) 656 { 657 echo '<option value="'.$categ->term_id.'" '; 658 if (in_array($categ->term_id, $prlx_slider_categories_array)) 659 echo 'selected="selected"'; 660 echo '>'.$categ->name.'</option>\n'; 661 } 662 ?> 663 </select> 662 664 663 665 <label for="prlx_slider_categories"><?php _e( 'Categories to display (multiple selection). Empty selection will display all categories.', 'wp-parallax-content-slider' ); ?></label><br /> … … 684 686 <td> 685 687 <select name="prlx_text_content" id="prlx_text_content"> 686 <option value="content" <?php if ( $prlx_slider_settings['text_content'] === "content") echo 'selected="selected"'; ?>><?php _e( 'Content', 'wp-parallax-content-slider' ); ?></option>687 <option value="excerpt" <?php if ( $prlx_slider_settings['text_content'] === "excerpt") echo 'selected="selected"'; ?>><?php _e( 'Excerpt', 'wp-parallax-content-slider' ); ?></option>688 </select>688 <option value="content" <?php if ( $prlx_slider_settings['text_content'] === "content") echo 'selected="selected"'; ?>><?php _e( 'Content', 'wp-parallax-content-slider' ); ?></option> 689 <option value="excerpt" <?php if ( $prlx_slider_settings['text_content'] === "excerpt") echo 'selected="selected"'; ?>><?php _e( 'Excerpt', 'wp-parallax-content-slider' ); ?></option> 690 </select> 689 691 <label for="prlx_text_content"><?php _e( 'Choose if you want to display the full content or the excerpt in the slider', 'wp-parallax-content-slider' ); ?></label><br /> 690 692 </td>
Note: See TracChangeset
for help on using the changeset viewer.