Skip to content

Commit

Permalink
🐛 Fixed: Check before re-order CPO
Browse files Browse the repository at this point in the history
  • Loading branch information
daomapsieucap committed Sep 26, 2022
1 parent fa0fb24 commit 6d24f6f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 26 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
== Changelog ==

= 2.0.13 =
*Release Date - 26 September 2022*

* Fixed: Check before re-order CPO.

= 2.0.12 =
*Release Date - 20 September 2022*

Expand Down
2 changes: 1 addition & 1 deletion fiberadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Fiber Admin
* Plugin URI: https://wordpress.org/plugins/fiber-admin/
* Description: 💈 Bring multiple customization features to make your own WordPress admin.
* Version: 2.0.12
* Version: 2.0.13
* Requires at least: 5.2
* Requires PHP: 7.0
* Author: Dao
Expand Down
46 changes: 25 additions & 21 deletions includes/cpo.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,27 +106,31 @@ public function fiad_cpo_update(){
}

public function fiad_cpo_insert($post_id, $post, $update){
if(!$update){
global $wpdb;
$order_start = 0;

$wpdb->update($wpdb->posts, array('menu_order' => $order_start), array('ID' => intval($post_id)));

$update_posts_args = array(
'post_type' => $post->post_type,
'posts_per_page' => - 1,
'post_status' => 'publish',
'orderby' => 'menu_order',
'order' => 'ASC',
'post__not_in' => array($post_id),
'suppress_filters' => false,
'fields' => 'ids'
);
$update_posts_query = new WP_Query($update_posts_args);
if($update_posts_query->have_posts()){
foreach($update_posts_query->posts as $index => $id){
$wpdb->update($wpdb->posts, array('menu_order' => intval($index + 1)), array('ID' => intval($id)));
$order_start ++;
$post_types = fiad_get_cpo_option('post_types');
if(!$update && $post_types){
$current_post_type = $post->post_type;
if(in_array($current_post_type, $post_types)){
global $wpdb;
$order_start = 0;

$wpdb->update($wpdb->posts, array('menu_order' => $order_start), array('ID' => intval($post_id)));

$update_posts_args = array(
'post_type' => $post->post_type,
'posts_per_page' => - 1,
'post_status' => 'publish',
'orderby' => 'menu_order',
'order' => 'ASC',
'post__not_in' => array($post_id),
'suppress_filters' => false,
'fields' => 'ids'
);
$update_posts_query = new WP_Query($update_posts_args);
if($update_posts_query->have_posts()){
foreach($update_posts_query->posts as $index => $id){
$wpdb->update($wpdb->posts, array('menu_order' => intval($index + 1)), array('ID' => intval($id)));
$order_start ++;
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: white label, admin tool, duplicate post, content protection
Requires at least: 4.7
Tested up to: 6.0.1
Requires PHP: 7.0
Stable tag: 2.0.12
Stable tag: 2.0.13
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -46,7 +46,7 @@ At the first time using this setting, Fiber Admin will ask you to save it to cre

== Changelog ==

= 2.0.12 =
*Release Date - 20 September 2022*
= 2.0.13 =
*Release Date - 26 September 2022*

* Fixed: Fix issue CPO creating new post.
* Fixed: Check before re-order CPO.

0 comments on commit 6d24f6f

Please sign in to comment.