Changeset 2053055
- Timestamp:
- 03/19/2019 03:14:29 AM (7 years ago)
- Location:
- content-repeater/trunk
- Files:
-
- 3 edited
-
content-repeater.php (modified) (1 diff)
-
includes/sorting.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
content-repeater/trunk/content-repeater.php
r2052424 r2053055 3 3 * Plugin Name: Content Repeater 4 4 * Description: Quickly set up custom content like Testimonials, Coupons, Products, Flipboxes, Portals, Portfolios, Before & Afters, etc. and display it in interesting ways: Ajax Reload, Masonry, Isotope, Slick Slider, Single Row. 5 * Version: 1.0. 55 * Version: 1.0.6 6 6 * Author: Denis Buka 7 7 * Text Domain: content-repeater -
content-repeater/trunk/includes/sorting.php
r2045559 r2053055 20 20 21 21 } 22 add_action( 'admin_init', array( 'Rptr_Sorting', 'rptr_refresh' ) ); 22 23 add_action( 'pre_get_posts', array( 'Rptr_Sorting', 'rptr_pre_get_posts' ) ); 23 24 add_filter( 'get_previous_post_where', array( 'Rptr_Sorting', 'rptr_previous_post_where' ) ); … … 56 57 action: 'rptr_ajax_menu_order', 57 58 order: $('#the-list').sortable('serialize'), 58 } 59 }/*, 60 success: function(result) { 61 console.log(result); 62 }*/ 59 63 }); 60 64 } … … 98 102 wp_die(); 99 103 } 100 104 105 public function rptr_refresh() { 106 global $wpdb; 107 $objects = self::rptr_sortable_objects(); 108 if (!empty($objects)) { 109 foreach ($objects as $object) { 110 $result = $wpdb->get_results(" 111 SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min 112 FROM $wpdb->posts 113 WHERE post_type = '" . $object . "' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') 114 "); 115 116 if ($result[0]->cnt == 0 || $result[0]->cnt == $result[0]->max) 117 continue; 118 119 // Here's the optimization 120 $wpdb->query("SET @row_number = 0;"); 121 $wpdb->query("UPDATE $wpdb->posts as pt JOIN ( 122 SELECT ID, (@row_number:=@row_number + 1) AS rank 123 FROM $wpdb->posts 124 WHERE post_type = '$object' AND post_status IN ( 'publish', 'pending', 'draft', 'private', 'future' ) 125 ORDER BY menu_order ASC 126 ) as pt2 127 ON pt.id = pt2.id 128 SET pt.menu_order = pt2.rank;"); 129 130 } 131 } 132 } 133 101 134 public function rptr_sortable_objects() { 102 135 $options = self::rptr_get_options(); -
content-repeater/trunk/readme.txt
r2052424 r2053055 83 83 = 1.0.5 = 84 84 field inserter improvements 85 = 1.0.6 = 86 fixed post sorting issue
Note: See TracChangeset
for help on using the changeset viewer.