Version Description
Download this release
Release Info
Developer | giucu91 |
Plugin | Simple Custom Post Order |
Version | 2.5.1 |
Comparing to | |
See all releases |
Code changes from version 2.5.0 to 2.5.1
- assets/scporder.js +18 -6
- readme.txt +6 -2
- settings.php +5 -1
- simple-custom-post-order.php +27 -11
assets/scporder.js
CHANGED
@@ -36,16 +36,21 @@
|
|
36 |
// make the array for the sizes
|
37 |
var td_array = new Array();
|
38 |
var i = 0;
|
|
|
39 |
jQuery('#the-list tr:first-child').find('td').each(function () {
|
|
|
40 |
td_array[i] = $(this).outerWidth();
|
41 |
-
|
42 |
i += 1;
|
43 |
});
|
44 |
|
45 |
jQuery('#the-list').find('tr').each(function () {
|
46 |
var j = 0;
|
47 |
$(this).find('td').each(function () {
|
48 |
-
|
|
|
|
|
|
|
49 |
j += 1;
|
50 |
});
|
51 |
});
|
@@ -55,13 +60,20 @@
|
|
55 |
// check if there are no items in the table
|
56 |
if(jQuery('#the-list > tr.no-items').length == 0){
|
57 |
jQuery('#the-list').parent().find('thead').find('th').each(function () {
|
58 |
-
|
|
|
|
|
|
|
59 |
y += 1;
|
60 |
});
|
61 |
|
|
|
62 |
jQuery('#the-list').parent().find('tfoot').find('th').each(function () {
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
65 |
});
|
66 |
}
|
67 |
|
@@ -71,4 +83,4 @@
|
|
71 |
* End table breaking fix
|
72 |
*/
|
73 |
|
74 |
-
})(jQuery)
|
36 |
// make the array for the sizes
|
37 |
var td_array = new Array();
|
38 |
var i = 0;
|
39 |
+
|
40 |
jQuery('#the-list tr:first-child').find('td').each(function () {
|
41 |
+
|
42 |
td_array[i] = $(this).outerWidth();
|
43 |
+
|
44 |
i += 1;
|
45 |
});
|
46 |
|
47 |
jQuery('#the-list').find('tr').each(function () {
|
48 |
var j = 0;
|
49 |
$(this).find('td').each(function () {
|
50 |
+
|
51 |
+
var paddingx = parseInt($(this).css('padding-left').replace('px', '')) + parseInt($(this).css('padding-right').replace('px', ''));
|
52 |
+
$(this).width(td_array[j] - paddingx);
|
53 |
+
|
54 |
j += 1;
|
55 |
});
|
56 |
});
|
60 |
// check if there are no items in the table
|
61 |
if(jQuery('#the-list > tr.no-items').length == 0){
|
62 |
jQuery('#the-list').parent().find('thead').find('th').each(function () {
|
63 |
+
|
64 |
+
var paddingx = parseInt($(this).css('padding-left').replace('px', '')) + parseInt($(this).css('padding-right').replace('px', ''));
|
65 |
+
$(this).width(td_array[y] - paddingx);
|
66 |
+
|
67 |
y += 1;
|
68 |
});
|
69 |
|
70 |
+
var z = 0;
|
71 |
jQuery('#the-list').parent().find('tfoot').find('th').each(function () {
|
72 |
+
|
73 |
+
var paddingx = parseInt($(this).css('padding-left').replace('px', '')) + parseInt($(this).css('padding-right').replace('px', ''));
|
74 |
+
$(this).width(td_array[z] - paddingx);
|
75 |
+
|
76 |
+
z += 1;
|
77 |
});
|
78 |
}
|
79 |
|
83 |
* End table breaking fix
|
84 |
*/
|
85 |
|
86 |
+
})(jQuery)
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: silkalns
|
|
3 |
Tags: custom post order, post order, js post order, page order, posts order, category order, sort posts, sort pages, sort custom posts
|
4 |
Requires at least: 4.6
|
5 |
Requires PHP: 5.6
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag: 2.5.
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -36,6 +36,10 @@ An answer to that question.
|
|
36 |
|
37 |
== Changelog ==
|
38 |
|
|
|
|
|
|
|
|
|
39 |
= Version 2.5.0 =
|
40 |
* Fixed post list table width when sorting is enabled
|
41 |
* Review dismiss fix
|
3 |
Tags: custom post order, post order, js post order, page order, posts order, category order, sort posts, sort pages, sort custom posts
|
4 |
Requires at least: 4.6
|
5 |
Requires PHP: 5.6
|
6 |
+
Tested up to: 5.5
|
7 |
+
Stable tag: 2.5.1
|
8 |
License: GPLv3 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
36 |
|
37 |
== Changelog ==
|
38 |
|
39 |
+
= Version 2.5.1 =
|
40 |
+
* Improve fix for post list table width when sorting is enabled ( thanks to gedeminas )
|
41 |
+
* Fix for admin ajax overriding queries ( thanks to igritsay )
|
42 |
+
|
43 |
= Version 2.5.0 =
|
44 |
* Fixed post list table width when sorting is enabled
|
45 |
* Review dismiss fix
|
settings.php
CHANGED
@@ -125,6 +125,7 @@ $advanced_view = isset($scporder_options['show_advanced_view']) ? $scporder_opti
|
|
125 |
<tr valign="top">
|
126 |
<th scope="row"><?php _e('Check to Sort Post Types', 'simple-custom-post-order') ?></th>
|
127 |
<td>
|
|
|
128 |
<label>
|
129 |
<div class="epsilon-toggle">
|
130 |
<input id="scporder_allcheck_objects" class="epsilon-toggle__input" type="checkbox">
|
@@ -195,6 +196,7 @@ $advanced_view = isset($scporder_options['show_advanced_view']) ? $scporder_opti
|
|
195 |
<tr valign="top">
|
196 |
<th scope="row"><?php _e('Check to Sort Taxonomies', 'simple-custom-post-order') ?></th>
|
197 |
<td>
|
|
|
198 |
<label>
|
199 |
<div class="epsilon-toggle">
|
200 |
<input id="scporder_allcheck_tags" class="epsilon-toggle__input" type="checkbox">
|
@@ -212,6 +214,7 @@ $advanced_view = isset($scporder_options['show_advanced_view']) ? $scporder_opti
|
|
212 |
</div>
|
213 |
</div>
|
214 |
<?php _e('Check All', 'simple-custom-post-order') ?></label><br>
|
|
|
215 |
<?php
|
216 |
$taxonomies = get_taxonomies(array(
|
217 |
'show_ui' => true,
|
@@ -254,7 +257,6 @@ $advanced_view = isset($scporder_options['show_advanced_view']) ? $scporder_opti
|
|
254 |
</table>
|
255 |
|
256 |
</div>
|
257 |
-
|
258 |
<div id="scporder_advanved_view">
|
259 |
<table class="form-table">
|
260 |
<tbody>
|
@@ -289,6 +291,7 @@ $advanced_view = isset($scporder_options['show_advanced_view']) ? $scporder_opti
|
|
289 |
</tbody>
|
290 |
</table>
|
291 |
</div>
|
|
|
292 |
<p class="submit">
|
293 |
<input type="submit" class="button-primary" name="scporder_submit" value="<?php _e('Update', 'simple-custom-post-order'); ?>">
|
294 |
</p>
|
@@ -339,6 +342,7 @@ $advanced_view = isset($scporder_options['show_advanced_view']) ? $scporder_opti
|
|
339 |
<span class="scpo-reset-response"></span>
|
340 |
</div>
|
341 |
</div>
|
|
|
342 |
<h3>Like this simple plugin?</h3>
|
343 |
<p>Make sure to <a href="https://wordpress.org/support/plugin/simple-custom-post-order/reviews/?filter=5"><strong>rate it</strong></a> and visit us at <a href="https://colorlib.com/wp/"><strong>Colorlib.com</strong></a></p>
|
344 |
|
125 |
<tr valign="top">
|
126 |
<th scope="row"><?php _e('Check to Sort Post Types', 'simple-custom-post-order') ?></th>
|
127 |
<td>
|
128 |
+
|
129 |
<label>
|
130 |
<div class="epsilon-toggle">
|
131 |
<input id="scporder_allcheck_objects" class="epsilon-toggle__input" type="checkbox">
|
196 |
<tr valign="top">
|
197 |
<th scope="row"><?php _e('Check to Sort Taxonomies', 'simple-custom-post-order') ?></th>
|
198 |
<td>
|
199 |
+
|
200 |
<label>
|
201 |
<div class="epsilon-toggle">
|
202 |
<input id="scporder_allcheck_tags" class="epsilon-toggle__input" type="checkbox">
|
214 |
</div>
|
215 |
</div>
|
216 |
<?php _e('Check All', 'simple-custom-post-order') ?></label><br>
|
217 |
+
|
218 |
<?php
|
219 |
$taxonomies = get_taxonomies(array(
|
220 |
'show_ui' => true,
|
257 |
</table>
|
258 |
|
259 |
</div>
|
|
|
260 |
<div id="scporder_advanved_view">
|
261 |
<table class="form-table">
|
262 |
<tbody>
|
291 |
</tbody>
|
292 |
</table>
|
293 |
</div>
|
294 |
+
|
295 |
<p class="submit">
|
296 |
<input type="submit" class="button-primary" name="scporder_submit" value="<?php _e('Update', 'simple-custom-post-order'); ?>">
|
297 |
</p>
|
342 |
<span class="scpo-reset-response"></span>
|
343 |
</div>
|
344 |
</div>
|
345 |
+
|
346 |
<h3>Like this simple plugin?</h3>
|
347 |
<p>Make sure to <a href="https://wordpress.org/support/plugin/simple-custom-post-order/reviews/?filter=5"><strong>rate it</strong></a> and visit us at <a href="https://colorlib.com/wp/"><strong>Colorlib.com</strong></a></p>
|
348 |
|
simple-custom-post-order.php
CHANGED
@@ -3,10 +3,10 @@
|
|
3 |
* Plugin Name: Simple Custom Post Order
|
4 |
* Plugin URI: https://wordpress.org/plugins-wp/simple-custom-post-order/
|
5 |
* Description: Order Items (Posts, Pages, and Custom Post Types) using a Drag and Drop Sortable JavaScript.
|
6 |
-
* Version: 2.5.
|
7 |
* Author: Colorlib
|
8 |
* Author URI: https://colorlib.com/
|
9 |
-
* Tested up to: 5.
|
10 |
* Requires: 4.6 or higher
|
11 |
* License: GPLv3 or later
|
12 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
@@ -36,7 +36,7 @@
|
|
36 |
|
37 |
define('SCPORDER_URL', plugins_url('', __FILE__));
|
38 |
define('SCPORDER_DIR', plugin_dir_path(__FILE__));
|
39 |
-
define('SCPORDER_VERSION', '2.5.
|
40 |
|
41 |
$scporder = new SCPO_Engine();
|
42 |
|
@@ -52,6 +52,7 @@ class SCPO_Engine {
|
|
52 |
|
53 |
add_action('admin_init', array( $this, 'refresh' ) );
|
54 |
|
|
|
55 |
add_action('admin_init', array($this, 'update_options'));
|
56 |
add_action('admin_init', array($this, 'load_script_css'));
|
57 |
|
@@ -93,6 +94,7 @@ class SCPO_Engine {
|
|
93 |
}
|
94 |
|
95 |
public function load_scpo_textdomain(){
|
|
|
96 |
load_plugin_textdomain( 'simple-custom-post-order', false, basename( dirname( __FILE__ ) ) . '/languages/' );
|
97 |
}
|
98 |
|
@@ -227,13 +229,14 @@ class SCPO_Engine {
|
|
227 |
wp_enqueue_script('jquery');
|
228 |
wp_enqueue_script('jquery-ui-sortable');
|
229 |
wp_enqueue_script('scporderjs', SCPORDER_URL . '/assets/scporder.js', array('jquery'), SCPORDER_VERSION, true);
|
230 |
-
|
231 |
wp_enqueue_style('scporder', SCPORDER_URL . '/assets/scporder.css', array(), SCPORDER_VERSION );
|
|
|
232 |
}
|
233 |
}
|
234 |
|
235 |
public function refresh() {
|
236 |
|
|
|
237 |
if ( scporder_doing_ajax() ) {
|
238 |
return;
|
239 |
}
|
@@ -243,7 +246,7 @@ class SCPO_Engine {
|
|
243 |
$tags = $this->get_scporder_options_tags();
|
244 |
|
245 |
if (!empty($objects)) {
|
246 |
-
|
247 |
foreach ($objects as $object) {
|
248 |
$result = $wpdb->get_results("
|
249 |
SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min
|
@@ -257,6 +260,7 @@ class SCPO_Engine {
|
|
257 |
// Here's the optimization
|
258 |
$wpdb->query("SET @row_number = 0;");
|
259 |
$wpdb->query("UPDATE $wpdb->posts as pt JOIN (
|
|
|
260 |
SELECT ID, (@row_number:=@row_number + 1) AS `rank`
|
261 |
FROM $wpdb->posts
|
262 |
WHERE post_type = '$object' AND post_status IN ( 'publish', 'pending', 'draft', 'private', 'future' )
|
@@ -265,6 +269,7 @@ class SCPO_Engine {
|
|
265 |
ON pt.id = pt2.id
|
266 |
SET pt.menu_order = pt2.`rank`;");
|
267 |
|
|
|
268 |
}
|
269 |
}
|
270 |
|
@@ -325,6 +330,7 @@ class SCPO_Engine {
|
|
325 |
}
|
326 |
|
327 |
do_action('scp_update_menu_order');
|
|
|
328 |
}
|
329 |
|
330 |
public function update_menu_order_tags() {
|
@@ -358,6 +364,7 @@ class SCPO_Engine {
|
|
358 |
}
|
359 |
|
360 |
do_action('scp_update_menu_order_tags');
|
|
|
361 |
}
|
362 |
|
363 |
public function update_options() {
|
@@ -373,6 +380,7 @@ class SCPO_Engine {
|
|
373 |
$input_options['tags'] = isset($_POST['tags']) ? $_POST['tags'] : '';
|
374 |
$input_options['show_advanced_view'] = isset($_POST['show_advanced_view']) ? $_POST['show_advanced_view'] : '';
|
375 |
|
|
|
376 |
update_option('scporder_options', $input_options);
|
377 |
|
378 |
$objects = $this->get_scporder_options_objects();
|
@@ -491,14 +499,17 @@ class SCPO_Engine {
|
|
491 |
public function scporder_pre_get_posts($wp_query) {
|
492 |
$objects = $this->get_scporder_options_objects();
|
493 |
|
|
|
494 |
if (empty($objects))
|
495 |
return false;
|
496 |
-
if (is_admin()) {
|
497 |
|
498 |
if (isset($wp_query->query['post_type']) && !isset($_GET['orderby'])) {
|
499 |
if (in_array($wp_query->query['post_type'], $objects)) {
|
500 |
-
|
501 |
-
|
|
|
|
|
502 |
}
|
503 |
}
|
504 |
} else {
|
@@ -531,12 +542,12 @@ class SCPO_Engine {
|
|
531 |
if (!$wp_query->get('order'))
|
532 |
$wp_query->set('order', 'ASC');
|
533 |
}
|
534 |
-
|
535 |
}
|
536 |
}
|
537 |
|
538 |
public function scporder_get_terms_orderby($orderby, $args) {
|
539 |
-
|
|
|
540 |
return $orderby;
|
541 |
|
542 |
$tags = $this->get_scporder_options_tags();
|
@@ -544,6 +555,7 @@ class SCPO_Engine {
|
|
544 |
if (!isset($args['taxonomy']))
|
545 |
return $orderby;
|
546 |
|
|
|
547 |
if(is_array($args['taxonomy'])){
|
548 |
if(isset($args['taxonomy'][0])){
|
549 |
$taxonomy = $args['taxonomy'][0];
|
@@ -555,6 +567,7 @@ class SCPO_Engine {
|
|
555 |
$taxonomy = $args['taxonomy'];
|
556 |
}
|
557 |
|
|
|
558 |
if (!in_array($taxonomy, $tags))
|
559 |
return $orderby;
|
560 |
|
@@ -565,7 +578,8 @@ class SCPO_Engine {
|
|
565 |
public function scporder_get_object_terms($terms) {
|
566 |
$tags = $this->get_scporder_options_tags();
|
567 |
|
568 |
-
|
|
|
569 |
return $terms;
|
570 |
|
571 |
foreach ($terms as $key => $term) {
|
@@ -600,6 +614,7 @@ class SCPO_Engine {
|
|
600 |
return $tags;
|
601 |
}
|
602 |
|
|
|
603 |
/**
|
604 |
* SCPO reset order for post types/taxonomies
|
605 |
*/
|
@@ -681,3 +696,4 @@ function scporder_uninstall_db() {
|
|
681 |
}
|
682 |
delete_option('scporder_install');
|
683 |
}
|
|
3 |
* Plugin Name: Simple Custom Post Order
|
4 |
* Plugin URI: https://wordpress.org/plugins-wp/simple-custom-post-order/
|
5 |
* Description: Order Items (Posts, Pages, and Custom Post Types) using a Drag and Drop Sortable JavaScript.
|
6 |
+
* Version: 2.5.1
|
7 |
* Author: Colorlib
|
8 |
* Author URI: https://colorlib.com/
|
9 |
+
* Tested up to: 5.5
|
10 |
* Requires: 4.6 or higher
|
11 |
* License: GPLv3 or later
|
12 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
36 |
|
37 |
define('SCPORDER_URL', plugins_url('', __FILE__));
|
38 |
define('SCPORDER_DIR', plugin_dir_path(__FILE__));
|
39 |
+
define('SCPORDER_VERSION', '2.5.1');
|
40 |
|
41 |
$scporder = new SCPO_Engine();
|
42 |
|
52 |
|
53 |
add_action('admin_init', array( $this, 'refresh' ) );
|
54 |
|
55 |
+
|
56 |
add_action('admin_init', array($this, 'update_options'));
|
57 |
add_action('admin_init', array($this, 'load_script_css'));
|
58 |
|
94 |
}
|
95 |
|
96 |
public function load_scpo_textdomain(){
|
97 |
+
|
98 |
load_plugin_textdomain( 'simple-custom-post-order', false, basename( dirname( __FILE__ ) ) . '/languages/' );
|
99 |
}
|
100 |
|
229 |
wp_enqueue_script('jquery');
|
230 |
wp_enqueue_script('jquery-ui-sortable');
|
231 |
wp_enqueue_script('scporderjs', SCPORDER_URL . '/assets/scporder.js', array('jquery'), SCPORDER_VERSION, true);
|
|
|
232 |
wp_enqueue_style('scporder', SCPORDER_URL . '/assets/scporder.css', array(), SCPORDER_VERSION );
|
233 |
+
|
234 |
}
|
235 |
}
|
236 |
|
237 |
public function refresh() {
|
238 |
|
239 |
+
|
240 |
if ( scporder_doing_ajax() ) {
|
241 |
return;
|
242 |
}
|
246 |
$tags = $this->get_scporder_options_tags();
|
247 |
|
248 |
if (!empty($objects)) {
|
249 |
+
|
250 |
foreach ($objects as $object) {
|
251 |
$result = $wpdb->get_results("
|
252 |
SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min
|
260 |
// Here's the optimization
|
261 |
$wpdb->query("SET @row_number = 0;");
|
262 |
$wpdb->query("UPDATE $wpdb->posts as pt JOIN (
|
263 |
+
|
264 |
SELECT ID, (@row_number:=@row_number + 1) AS `rank`
|
265 |
FROM $wpdb->posts
|
266 |
WHERE post_type = '$object' AND post_status IN ( 'publish', 'pending', 'draft', 'private', 'future' )
|
269 |
ON pt.id = pt2.id
|
270 |
SET pt.menu_order = pt2.`rank`;");
|
271 |
|
272 |
+
|
273 |
}
|
274 |
}
|
275 |
|
330 |
}
|
331 |
|
332 |
do_action('scp_update_menu_order');
|
333 |
+
|
334 |
}
|
335 |
|
336 |
public function update_menu_order_tags() {
|
364 |
}
|
365 |
|
366 |
do_action('scp_update_menu_order_tags');
|
367 |
+
|
368 |
}
|
369 |
|
370 |
public function update_options() {
|
380 |
$input_options['tags'] = isset($_POST['tags']) ? $_POST['tags'] : '';
|
381 |
$input_options['show_advanced_view'] = isset($_POST['show_advanced_view']) ? $_POST['show_advanced_view'] : '';
|
382 |
|
383 |
+
|
384 |
update_option('scporder_options', $input_options);
|
385 |
|
386 |
$objects = $this->get_scporder_options_objects();
|
499 |
public function scporder_pre_get_posts($wp_query) {
|
500 |
$objects = $this->get_scporder_options_objects();
|
501 |
|
502 |
+
|
503 |
if (empty($objects))
|
504 |
return false;
|
505 |
+
if (is_admin() && ! wp_doing_ajax()) {
|
506 |
|
507 |
if (isset($wp_query->query['post_type']) && !isset($_GET['orderby'])) {
|
508 |
if (in_array($wp_query->query['post_type'], $objects)) {
|
509 |
+
if (!$wp_query->get('orderby'))
|
510 |
+
$wp_query->set('orderby', 'menu_order');
|
511 |
+
if (!$wp_query->get('order'))
|
512 |
+
$wp_query->set('order', 'ASC');
|
513 |
}
|
514 |
}
|
515 |
} else {
|
542 |
if (!$wp_query->get('order'))
|
543 |
$wp_query->set('order', 'ASC');
|
544 |
}
|
|
|
545 |
}
|
546 |
}
|
547 |
|
548 |
public function scporder_get_terms_orderby($orderby, $args) {
|
549 |
+
|
550 |
+
if (is_admin() && ! wp_doing_ajax())
|
551 |
return $orderby;
|
552 |
|
553 |
$tags = $this->get_scporder_options_tags();
|
555 |
if (!isset($args['taxonomy']))
|
556 |
return $orderby;
|
557 |
|
558 |
+
|
559 |
if(is_array($args['taxonomy'])){
|
560 |
if(isset($args['taxonomy'][0])){
|
561 |
$taxonomy = $args['taxonomy'][0];
|
567 |
$taxonomy = $args['taxonomy'];
|
568 |
}
|
569 |
|
570 |
+
|
571 |
if (!in_array($taxonomy, $tags))
|
572 |
return $orderby;
|
573 |
|
578 |
public function scporder_get_object_terms($terms) {
|
579 |
$tags = $this->get_scporder_options_tags();
|
580 |
|
581 |
+
|
582 |
+
if (is_admin() && ! wp_doing_ajax() && isset($_GET['orderby']))
|
583 |
return $terms;
|
584 |
|
585 |
foreach ($terms as $key => $term) {
|
614 |
return $tags;
|
615 |
}
|
616 |
|
617 |
+
|
618 |
/**
|
619 |
* SCPO reset order for post types/taxonomies
|
620 |
*/
|
696 |
}
|
697 |
delete_option('scporder_install');
|
698 |
}
|
699 |
+
|