From 3479f506d3e68719344967657bc0efbedf292505 Mon Sep 17 00:00:00 2001 From: aurovrata Date: Sat, 9 May 2020 17:42:12 +0530 Subject: [PATCH] v2.4.5 --- README.txt | 3 +++ admin/class-reorder-post-within-categories-admin.php | 2 +- .../class-reorder-post-within-categories-public.php | 11 +++++------ reorder-post-within-categories.php | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.txt b/README.txt index d7d9573..522edb4 100755 --- a/README.txt +++ b/README.txt @@ -240,6 +240,9 @@ NOTE: note that this will effect front-end mixed-queries trying to display both **NOTE**: in all 3 cases, you may use the reset button (see screenshot #3) on the reorder admin page to get the filters to change the order. == Changelog == += 2.5.4 = +* change get_adjacent_post_where SQL for older DB. +* fix admin reverse order saving. = 2.5.3 = * fix adjacent post functionality. = 2.5.2 = diff --git a/admin/class-reorder-post-within-categories-admin.php b/admin/class-reorder-post-within-categories-admin.php index c23ca65..26aa867 100755 --- a/admin/class-reorder-post-within-categories-admin.php +++ b/admin/class-reorder-post-within-categories-admin.php @@ -469,7 +469,7 @@ protected function _save_order($post_type, $order=array(), $term_id=0, $start=0) if(empty($order) || 0==$term_id) return false; global $wpdb; // debug_msg($order, 'saving order '); - $query =$wpdb->prepare("SELECT rpwc_pm.meta_id, rpwc_p.ID FROM {$wpdb->posts} as rpwc_p LEFT JOIN {$wpdb->postmeta} as rpwc_pm on rpwc_p.ID = rpwc_pm.post_id WHERE rpwc_p.post_type like '%s' AND rpwc_pm.meta_key ='_rpwc2' AND rpwc_pm.meta_value=%d", $post_type, $term_id); + $query =$wpdb->prepare("SELECT rpwc_pm.meta_id, rpwc_p.ID FROM {$wpdb->posts} as rpwc_p LEFT JOIN {$wpdb->postmeta} as rpwc_pm on rpwc_p.ID = rpwc_pm.post_id WHERE rpwc_p.post_type like '%s' AND rpwc_pm.meta_key ='_rpwc2' AND rpwc_pm.meta_value=%d ORDER BY rpwc_pm.meta_id ASC", $post_type, $term_id); /** @since 2.4.3 */ $this->filter_query($query, "SELECT rpwc_pm.meta_id, rpwc_p.ID"); $ranked_rows = $wpdb->get_results($query); diff --git a/public/class-reorder-post-within-categories-public.php b/public/class-reorder-post-within-categories-public.php index 34f2936..396e26e 100755 --- a/public/class-reorder-post-within-categories-public.php +++ b/public/class-reorder-post-within-categories-public.php @@ -295,12 +295,11 @@ protected function get_adjacent_post_where($where, $in_same_term, $excluded_term global $wpdb; // debug_msg($wpdb->db_version(), 'version '); - $adj_id = $wpdb->get_var("SELECT {$pos}_id from - ( SELECT meta_id, lag(`post_id`) over ( ORDER BY `meta_id` ) as prev_id , - `post_id` , lead(`post_id`) over ( ORDER BY `meta_id` ) as next_id - FROM {$wpdb->postmeta} as pm, {$wpdb->posts} as p - WHERE pm.post_id=p.ID and p.post_type like '{$post->post_type}' and meta_key like '_rpwc2' and meta_value={$term} ) as rp - WHERE rp.post_id = {$post->ID}"); + $adj_id = $wpdb->get_var("SELECT ( + SELECT rankpm.post_id FROM {$wpdb->postmeta} as rankpm LEFT JOIN {$wpdb->posts} AS rankp ON rankp.ID=rankpm.post_id + WHERE rankpm.meta_key like '_rpwc2' AND rankpm.meta_value={$term} AND rankp.post_type LIKE '{$post->post_type}' AND rankpm.meta_id{$compare}selectp.meta_id ORDER BY rankpm.meta_id ASC LIMIT 1 OFFSET 0 + ) AS next_post FROM {$wpdb->postmeta} AS selectp + WHERE selectp.meta_id = (SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id={$post->ID} AND meta_key LIKE '_rpwc2' AND meta_value={$term})"); // debug_msg($wpdb->last_query, $pos.' SQL QUERY:'); if(!empty($adj_id)){ diff --git a/reorder-post-within-categories.php b/reorder-post-within-categories.php index 2d15977..dddeeb5 100755 --- a/reorder-post-within-categories.php +++ b/reorder-post-within-categories.php @@ -16,7 +16,7 @@ * Plugin Name: ReOrder Posts within Categories * Plugin URI: https://github.com/aurovrata/ReOrder-posts-within-categories * Description: This is a short description of what the plugin does. It's displayed in the WordPress admin area. - * Version: 2.5.3 + * Version: 2.5.4 * Author: Aurorata V. * Author URI: https://profiles.wordpress.org/aurovrata/ * License: GPL-2.0+ @@ -33,7 +33,7 @@ /** * Current plugin version. */ -define( 'REORDER_POST_WITHIN_CATEGORIES_VERSION', '2.5.3' ); +define( 'REORDER_POST_WITHIN_CATEGORIES_VERSION', '2.5.4' ); //options for plugin used in both public and admin classes. define('RPWC_OPTIONS', 'deefuse_ReOrderOrderedCategoriesOptions');