Changeset 1364414
- Timestamp:
- 03/05/2016 01:40:09 AM (10 years ago)
- Location:
- wp-order-by/trunk
- Files:
-
- 5 edited
-
admin-options.php (modified) (10 diffs)
-
js/wpob.js (modified) (5 diffs)
-
readme.txt (modified) (6 diffs)
-
views/form_elements.php (modified) (3 diffs)
-
wp-order-by.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-order-by/trunk/admin-options.php
r1314584 r1364414 67 67 68 68 private static function draw_posts_select_box($type = '', $select_default_text='', $post_ids) { 69 69 //var_dump($post_ids); 70 70 $post_type = WpobPlugin::get_admin_screen_current_post_type(); 71 71 $posts = WpobPlugin::get_all_posts_of_current_post_type(); … … 76 76 foreach($posts as $p) { //iterate posts 77 77 $selected = ''; 78 78 79 foreach($post_ids as $pid) { //iterate selected posts 79 80 if($p->ID == $pid && !empty( $post_ids[0] ) ) { … … 111 112 public function process_form_vals() { 112 113 if(!empty($_POST['_wpnonce']) && !empty($_POST['_wp_http_referer']) ) { 114 $cf_arr = array(); 115 $ptype = !empty($_POST["post_type"]) ? $_POST["post_type"] : ''; 116 $cf_arr[] = $_POST["wpob-options-".$ptype]; 113 117 if(!empty($_POST["wpob-cf-type"])) { 114 $cf_arr = array();115 $ptype = !empty($_POST["post_type"]) ? $_POST["post_type"] : '';116 $cf_arr[] = $_POST["wpob-options-".$ptype];117 118 $cf_arr[] = $_POST["wpob-cf-type"]; 118 119 $cf_arr[] = !empty($_POST["wpob_other_posts"]); 119 $cf_arr[] = $_POST["wpob_cf_order"]; 120 $_POST["wpob-options-".$ptype] = $cf_arr; 121 } 120 //$cf_arr[] = $_POST["wpob_cf_order"]; 121 //$_POST["wpob-options-".$ptype] = $cf_arr; 122 } 123 $cf_arr[] = $_POST["wpob_cf_order"]; 124 //var_dump($cf_arr); 125 $_POST["wpob-options-".$ptype] = $cf_arr; 122 126 } 123 127 } … … 179 183 180 184 public function merge_excluded($exclude) { 181 185 182 186 $pt = !empty( $_POST['post_type'] ) ? $_POST['post_type'] : ''; 183 184 187 $db_exclude = get_option('wpob-exclude-posts'); 188 //var_dump($exclude); 189 185 190 if( !is_array( $db_exclude ) ) $db_exclude = array(); 191 $tmp_exclude = array(); 186 192 foreach ( $db_exclude as $key => $val ) { 187 193 188 194 $tmp_post = get_post( $val ); 189 195 $tmp_pt = $tmp_post->post_type; 196 190 197 if($tmp_pt == $pt) { 191 unset($db_exclude[$key]); 192 $db_exclude = array_values($db_exclude); 193 } 194 195 } 196 197 if( !empty( $exclude[0] ) ) { 198 $db_exclude = array_unique( array_merge( $exclude, $db_exclude ) ); 199 } 198 $tmp_exclude[] = $db_exclude[$key]; 199 //var_dump( key ($db_exclude)); 200 //unset($db_exclude[$key]); 201 //$db_exclude = array_values($db_exclude); 202 } 203 204 } 205 206 $new_db_exclude = array_diff( $db_exclude, $tmp_exclude ); 207 if( empty( $exclude[0] ) ) { 208 $exclude = array(); 209 } 210 $db_exclude = array_unique( array_merge( $exclude, $new_db_exclude ) ); 211 200 212 201 213 return $db_exclude; … … 229 241 if(empty($exclude)) $exclude = array(''); 230 242 if($exclude != get_option( 'wpob-exclude-posts' )) { 231 $is_update_general = update_option( 'wpob-exclude-posts', $exclude ); 243 if( empty( $exclude[0] ) ) { 244 $exclude_empty = array( $exclude[0] ); 245 $is_update_general = update_option( 'wpob-exclude-posts', $exclude_empty ); 246 } else { 247 $is_update_general = update_option( 'wpob-exclude-posts', $exclude ); 248 } 232 249 if(!$is_update_general) $updated = 'false'; 233 250 } … … 247 264 248 265 $options = get_option('wpob-options-'.$args['post_type']); 249 if($options=='' || !$options) $options = 'date desc';266 if($options=='' || !$options) $options = 'date'; 250 267 if(!empty($_POST['wpob-options-']) ) $options = $_POST['wpob-options-']; //global settings for all post types 251 268 $args['options'] = $options; … … 361 378 $option = get_option('wpob-options-'.$post_type); 362 379 380 363 381 if($option) { 364 382 … … 371 389 } 372 390 } 373 391 //var_dump($post_type); 374 392 switch ($opt) { 375 case " abcasc":393 case "title": 376 394 $query->set( 'orderby', 'title' ); 377 $query->set( 'order', 'ASC' ); 378 break; 379 case "abcdesc": 395 break; 396 /*case "abcdesc": 380 397 $query->set( 'orderby', 'title' ); 381 398 $query->set( 'order', 'DESC' ); 382 break; 399 break;*/ 383 400 case "name": 384 401 $query->set( 'orderby', 'name' ); 385 402 break; 386 case "date desc":403 case "date": 387 404 $query->set( 'orderby', 'date' ); 388 $query->set( 'order', 'DESC' );389 405 break; 390 406 case "modified": 391 407 $query->set( 'orderby', 'modified' ); 392 $query->set( 'order', 'DESC' );393 408 break; 394 409 case "author": 395 410 $query->set( 'orderby', 'author' ); 396 $query->set( 'order', 'ASC' );397 411 break; 398 412 case "parent": … … 414 428 default: 415 429 $query->set('orderby', $m_val); 416 if(is_array($option)) $query->set( 'order', $option[3] );430 //if(is_array($option)) $query->set( 'order', $option[3] ); 417 431 $query->set('meta_key', $opt); 418 432 … … 423 437 424 438 } 439 $order = end($option); 440 $query->set( 'order', $order ); 425 441 426 442 } -
wp-order-by/trunk/js/wpob.js
r1293180 r1364414 21 21 $('input[name="wpob-cf-type"]').prop('disabled',true); 22 22 $('input[name="wpob_other_posts"]').prop('disabled',true); 23 $('input[name="wpob_cf_order"]').prop('disabled',true);23 //$('input[name="wpob_cf_order"]').prop('disabled',true); 24 24 } else { 25 25 if($('#order_custom_fields option:selected').val() == "") { … … 27 27 $('input[name="wpob-cf-type"]').prop('disabled',true); 28 28 $('input[name="wpob_other_posts"]').prop('disabled',true); 29 $('input[name="wpob_cf_order"]').prop('disabled',true);29 //$('input[name="wpob_cf_order"]').prop('disabled',true); 30 30 } 31 31 } … … 33 33 //init custom type radio buttons 34 34 if($('#order_custom_fields').attr('value') == '') { 35 $('#cf_desc').attr('checked',true)35 //$('#cf_desc').attr('checked',true) 36 36 } 37 37 … … 45 45 $('input[name="wpob_other_posts"]').prop('checked',false); 46 46 $('input[name="wpob_other_posts"]').prop('disabled',true); 47 $('input[name="wpob_cf_order"]').prop('disabled',true);47 //$('input[name="wpob_cf_order"]').prop('disabled',true); 48 48 49 49 }) … … 54 54 $('input[name="wpob-cf-type"]').prop('disabled',false); 55 55 $('input[name="wpob_other_posts"]').prop('disabled',false); 56 $('input[name="wpob_cf_order"]').prop('disabled',false);56 //$('input[name="wpob_cf_order"]').prop('disabled',false); 57 57 }) 58 58 -
wp-order-by/trunk/readme.txt
r1345984 r1364414 5 5 Requires at least: 4.1 6 6 Tested up to: 4.4 7 Stable tag: 1. 37 Stable tag: 1.4 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 12 12 13 13 == Description == 14 Simple and easy way to order your posts, pages or any other custom post-type in a various options, with the ability to define a different logic for each content type. 15 This plugin suits for large amount of posts/pages ordering when it is not convenient to manually order them by drag and drop. 14 Simple and easy way to order your posts, pages or any other custom post-type in a various options, with the ability to define a different order option for each content type. 16 15 17 16 A new menu will appear on the admin side-menu under each content type that is defined on your site (posts, pages etc.) and it will also be added automatically to future custom post types you will add in the future. … … 25 24 **Ordering Options** 26 25 27 * Date Descending (WordPress default) 28 * Last Modified Date (Descending) 29 * Title Ascending 30 * Title Descending 31 * Author (Alphabet Ascending order) 26 * Date 27 * Last Modified Date 28 * Title 29 * Author 32 30 * Post,Page or post-type Id 33 * Post/Page Parent Id (Descending)34 * Menu Order (Descending)31 * Post/Page Parent Id 32 * Menu Order 35 33 * Randomly 36 * Number of Comments (Descending, from many to few)34 * Number of Comments 37 35 * By Custom Field 38 36 … … 41 39 * Exclude ordering for a specific page/s on your site 42 40 43 I'll appreciate if you rate me o n the plugin page.41 I'll appreciate if you rate me or write a review on the plugin page. 44 42 I'm doing my best to maintain and improve this plugin. if you feel like donating a small amount, of your choice, through the donation link on the plugin page, I will be very glad :) 45 43 … … 54 52 = What if I want to retrieve settings to default? = 55 53 56 You should update your settings to the first option - *Date Descending (from new to old)*which is WordPress default ordering.54 You should update your settings to the first option - *Date* and check the *Descending* order radio button, which is WordPress default ordering. 57 55 You can make the update for a specific content type (e.g. posts) or from the main settings page under *settings -> WP Order By Settings* if you want to make the change for all page/post/post-types on your site. 58 56 … … 66 64 67 65 == Changelog == 66 67 = 1.4 = 68 Order direction option added to all order-by options. 69 Bug fix on the exclude pages feature. 68 70 69 71 = 1.3 = -
wp-order-by/trunk/views/form_elements.php
r1317715 r1364414 1 <?php //if( !is_array( $args['options'] ) ) $args['options'] = array( $args['options'] ); var_dump($args['options']); ?> 1 2 <div class="wpob_option"> 2 3 3 <input id="order_date_desc" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="date desc" <?php if($args['options']=='datedesc') echo ' checked'; ?> />4 <label for="order_date_desc">Date Descending (from new to old)</label>4 <input id="order_date_desc" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="date" <?php if($args['options'][0]=='date') echo ' checked'; ?> /> 5 <label for="order_date_desc">Date Created</label> 5 6 </div> 6 7 <div class="wpob_option"> 7 8 8 <input id="order_modified" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="modified" <?php if($args['options'] =='modified') echo ' checked'; ?> />9 <input id="order_modified" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="modified" <?php if($args['options'][0]=='modified') echo ' checked'; ?> /> 9 10 <label for="order_modified">Last Modified Date </label> 10 11 </div> 11 12 <div class="wpob_option"> 12 13 13 <input id="order_ abcasc" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="abcasc" <?php if($args['options']=='abcasc') echo ' checked'; ?> />14 <label for="order_ abcasc">Title Ascending</label>14 <input id="order_title" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="title" <?php if($args['options'][0]=='title') echo ' checked'; ?> /> 15 <label for="order_title">Title</label> 15 16 </div> 17 16 18 <div class="wpob_option"> 17 19 18 <input id="order_abcdesc" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="abcdesc" <?php if($args['options']=='abcdesc') echo ' checked'; ?> /> 19 <label for="order_abcdesc">Title Descending</label> 20 </div> 21 <div class="wpob_option"> 22 23 <input id="order_author" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="author" <?php if($args['options']=='author') echo ' checked'; ?> /> 20 <input id="order_author" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="author" <?php if($args['options'][0]=='author') echo ' checked'; ?> /> 24 21 <label for="order_author">Author</label> 25 22 </div> 26 23 <div class="wpob_option"> 27 24 28 <input id="order_post_id" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="ID" <?php if($args['options'] =='ID') echo ' checked'; ?> />25 <input id="order_post_id" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="ID" <?php if($args['options'][0]=='ID') echo ' checked'; ?> /> 29 26 <label for="order_post_id">Post/Page Id</label> 30 27 </div> 31 28 <div class="wpob_option"> 32 29 33 <input id="order_parent" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="parent" <?php if($args['options'] =='parent') echo ' checked'; ?> />34 <label for="order_parent">Post/Page Parent Id (Highest first)</label>30 <input id="order_parent" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="parent" <?php if($args['options'][0]=='parent') echo ' checked'; ?> /> 31 <label for="order_parent">Post/Page Parent Id</label> 35 32 </div> 36 33 <div class="wpob_option"> 37 34 38 <input id="order_menu_order" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="menu_order" <?php if($args['options'] =='menu_order') echo ' checked'; ?> />39 <label for="order_menu_order">Menu Order - the order value in the Attributes box. usually on the buttom-right of the page/post-type. (Highest first)</label>35 <input id="order_menu_order" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="menu_order" <?php if($args['options'][0]=='menu_order') echo ' checked'; ?> /> 36 <label for="order_menu_order">Menu Order - the order value in the Attributes box. usually on the buttom-right of the page/post-type.</label> 40 37 </div> 41 38 <div class="wpob_option"> 42 39 43 <input id="order_rand" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="rand" <?php if($args['options'] =='rand') echo ' checked'; ?> />40 <input id="order_rand" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="rand" <?php if($args['options'][0]=='rand') echo ' checked'; ?> /> 44 41 <label for="order_rand">Random</label> 45 42 </div> 46 43 <div class="wpob_option"> 47 44 48 <input id="order_comments" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="comment_count" <?php if($args['options'] =='comment_count') echo ' checked'; ?> />49 <label for="order_comments">Number of Comments (descending, from many to few)</label>45 <input id="order_comments" name="wpob-options-<?php echo $args['post_type']; ?>" type="radio" value="comment_count" <?php if($args['options'][0]=='comment_count') echo ' checked'; ?> /> 46 <label for="order_comments">Number of Comments</label> 50 47 </div> 51 48 <div class="wpob_option"> … … 67 64 ?> 68 65 </select> 69 70 Ascending <input type="radio" value="ASC" name="wpob_cf_order" id="cf_asc" <?php if(is_array($args['options']) && !empty($args['options'][3]) && $args['options'][3]=='ASC') echo ' checked'; ?>>71 Descending <input type="radio" value="DESC" name="wpob_cf_order" id="cf_desc" <?php if(is_array($args['options']) && !empty($args['options'][3]) && $args['options'][3]=='DESC') echo ' checked'; ?> <?php if( empty($args['options'][3]) ) echo ' checked '; ?>>72 66 <div class="custom_fields_type_container"> 73 67 <div class="description">What type of values this custom field contains:</div> … … 78 72 <p class="warning">Warning: if your custom field contains both numeric and string values this order option may give an unpredictable results </p> 79 73 </div> 74 <?php $order = end($args['options']); //var_dump($order); ?> 75 <br> 76 <h3>Order Direction:</h3> 77 <input type="radio" value="ASC" name="wpob_cf_order" id="cf_asc" <?php if(is_array($args['options']) && !empty($order) && $order=='ASC') echo ' checked'; ?>><label for="cf_asc"> Ascending </label> 78 <input type="radio" value="DESC" name="wpob_cf_order" id="cf_desc" <?php if(is_array($args['options']) && !empty($order) && $order=='DESC') echo ' checked'; ?> <?php if( empty($order) ) echo ' checked '; ?>><label for="cf_desc"> Descending</label> 79 80 80 81 81 </div> -
wp-order-by/trunk/wp-order-by.php
r1314584 r1364414 4 4 * Plugin URI: https://wordpress.org/plugins/wp-order-by/ 5 5 * Description: A wordpress post, post types and pages ordering plugin 6 * Version: 1. 36 * Version: 1.4 7 7 * Author: Uri Weil 8 8 * Text Domain: wp-order-by
Note: See TracChangeset
for help on using the changeset viewer.