Changeset 810295
- Timestamp:
- 11/25/2013 06:24:39 PM (12 years ago)
- Location:
- posts-order-widget
- Files:
-
- 9 added
- 2 edited
-
assets/screenshot-3.jpg (added)
-
tags/2.0.0 (added)
-
tags/2.0.0/languages (added)
-
tags/2.0.0/languages/post-order-widget-fr_FR.mo (added)
-
tags/2.0.0/languages/post-order-widget-fr_FR.po (added)
-
tags/2.0.0/post-order-widget.php (added)
-
tags/2.0.0/readme.txt (added)
-
tags/2.0.0/taxonomy.class.php (added)
-
trunk/post-order-widget.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/taxonomy.class.php (added)
Legend:
- Unmodified
- Added
- Removed
-
posts-order-widget/trunk/post-order-widget.php
r809236 r810295 14 14 load_plugin_textdomain('post-order-widget', false, dirname( plugin_basename( __FILE__ ) ). '/languages/'); 15 15 16 require( rtrim(plugin_dir_path(__FILE__), '/') . '/taxonomy.class.php'); 17 $pow_taxonomy = new POW_Taxonomy(); 18 16 19 //S'inspirer de wp-includes/default-widgets.php 17 20 $id_bytitle = "bytitle"; … … 20 23 $id_rand = "rand"; 21 24 25 //Modification de l'ordre d'affichage des articles et initialisation de divers attributs de la classe POW_Taxonomy. 26 add_filter('pre_get_posts', array($pow_taxonomy, 'frontend_initialiser'), -100); 27 22 28 //Déclaration de notre extention en tant que Widget 23 29 function register_POW_Widget() { … … 25 31 } 26 32 add_action( 'widgets_init', 'register_POW_Widget' ); 27 28 //Lecture du filtre choisi et initialisation pour utilisation lors du chargement des articles29 function POW_pre_get_posts($vars) {30 $params = POW_getOrderBySelect();31 32 $vars->set('orderby', $params['orderby']);33 $vars->set('order', $params['order']);34 //$vars->set('ignore_sticky_posts', 1);35 36 return $vars;37 }38 add_filter('pre_get_posts', 'POW_pre_get_posts');39 40 //Retourne le filtre à utiliser en fonction du choix de l'utilisateur41 function POW_getOrderBySelect() {42 $result = array();43 44 //Lecture du choix de l'utilisateur45 $selection = isset($_GET['pow']) ? $_GET['pow'] : 'dated';46 47 switch ($selection) {48 49 //Sélection par défaut : Tri du plus récent au plus ancien50 case 'dated':51 $result['orderby'] = "date";52 $result['order'] = "DESC";53 54 break;55 56 //Tri du plus ancien au plus récent57 case 'datea':58 $result['orderby'] = "date";59 $result['order'] = "ASC";60 61 break;62 63 //Tri du plus ancien au plus récent64 case 'title':65 $result['orderby'] = "title";66 $result['order'] = "ASC";67 68 break;69 70 //Pour les cas simples, la valeur de l'item de la combo correspond à ce qui sera utilisé dans le "order by" de la requête SQL.71 default:72 $result['orderby'] = $selection;73 $result['order'] = "DESC";74 75 }76 77 //Sélectionne l'item précédemment choisi par l'utilisateur78 $result[$selection] = ' selected="selected"';79 80 return $result;81 }82 add_filter('wp_head', 'POW_getOrderBySelect');83 33 84 34 // Documentation : http://codex.wordpress.org/Widgets_API … … 105 55 */ 106 56 public function widget( $args, $instance ) { 107 global $id_bytitle, $id_bydatea, $id_bymodified, $id_rand ;57 global $id_bytitle, $id_bydatea, $id_bymodified, $id_rand, $pow_taxonomy; 108 58 109 59 //On n'affiche pas le widget si nous sommes dans une page, un article, un média. 110 if(is_page() || is_single() || is_attachment())return;111 112 60 if(is_page() || is_single() || is_attachment())return; 113 61 … … 118 66 if ( ! empty( $title ) )echo $args['before_title'] . $title . $args['after_title']; 119 67 120 $params = POW_getOrderBySelect(); 68 //Ajout des options en fonction des paramètres du widget 69 $opt_title = $instance[$id_bytitle] ? $pow_taxonomy->getHTMLOption("title") : ""; 70 $opt_bydatea = $instance[$id_bydatea] ? $pow_taxonomy->getHTMLOption("datea") : ""; 71 $opt_bymodified = $instance[$id_bymodified] ? $pow_taxonomy->getHTMLOption("modified") : ""; 72 $opt_rand = $instance[$id_rand] ? $pow_taxonomy->getHTMLOption("rand") : ""; 73 $opt_bydated = $pow_taxonomy->getHTMLOption("dated"); 121 74 122 //Ajout des options en fonction des paramètres du widget123 $opt_title = $instance[$id_bytitle] ? "<option value=\"title\"{$params['title']}>". __('By title', 'post-order-widget'). "</option>" : "";124 $opt_bydatea = $instance[$id_bydatea] ? "<option value=\"datea\"{$params['datea']}>". __('Oldest to newest', 'post-order-widget'). "</option>" : "";125 $opt_bymodified = $instance[$id_bymodified] ? "<option value=\"modified\"{$params['modified']}>". __('By modification', 'post-order-widget'). "</option>" : "";126 $opt_rand = $instance[$id_rand] ? "<option value=\"rand\"{$params['rand']}>". __('Randomly', 'post-order-widget'). "</option>" : "";127 128 75 echo " 129 76 <form method=\"get\" id=\"order\"> 130 77 <select name=\"pow\" onchange=\"this.form.submit()\"> 131 78 $opt_title 132 <option value=\"dated\"{$params['dated']}>". __('Newest to oldest', 'post-order-widget'). "</option>79 $opt_bydated 133 80 $opt_bydatea 134 81 $opt_bymodified -
posts-order-widget/trunk/readme.txt
r809236 r810295 5 5 Requires at least: 3.6.1 6 6 Tested up to: 3.6.1 7 Stable tag: 1.3.27 Stable tag: 2.0.0 8 8 9 9 Add the ability to sort the posts by context rather than descending date. … … 19 19 * randomly 20 20 21 You can find a demo here : http://www. apreslafindumonde.fr/21 You can find a demo here : http://www.spoils.fr/ 22 22 The widget is named "Trier les articles" on the sidebar. 23 23 … … 33 33 * 3 checkboxes in order to display or not items in the drop-down list. 34 34 35 Since the version 2.0.0, it is now possible to change the default order for your categories. 36 In the category editing page, you will now find a dropdown list. 37 35 38 == Screenshots == 36 39 37 40 1. **From the backend, in the widget management page :** There is severals options in order to display (or not) items in the drop-down list. 38 41 2. **From the frontend, in the widget area.** 42 3. **From the backend, when editing a category : There is a dropdown list in order to select the default order.** 39 43 40 44 == Changelog == 45 46 = 2.0.0 = 47 * Plugin entirely re-encoded. 48 * It is now possible to define the default order for taxonomies (eg : category, tag, ...). 41 49 42 50 = 1.3.2 =
Note: See TracChangeset
for help on using the changeset viewer.