Skip to content

Commit

Permalink
v2.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
aurovrata committed May 9, 2020
1 parent c2cbded commit 3479f50
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion admin/class-reorder-post-within-categories-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 5 additions & 6 deletions public/class-reorder-post-within-categories-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down
4 changes: 2 additions & 2 deletions reorder-post-within-categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand All @@ -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');

Expand Down

0 comments on commit 3479f50

Please sign in to comment.