Plugin Directory

Changeset 2889974


Ignore:
Timestamp:
03/30/2023 08:56:08 AM (3 years ago)
Author:
biztechc
Message:

Compatibility change with version 6.2 and Bug fixing

Location:
copy-or-move-comments/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • copy-or-move-comments/trunk/copy_move_comments.php

    r2837946 r2889974  
    44  Plugin URI:
    55  Description: Using Copy/Move WordPress Plugin the admin can copy or move any comment from several types of pages to any other page!
    6   Version: 5.0.3
     6  Version: 5.0.4
    77  Author: biztechc
    88  Author URI: https://www.appjetty.com/
     
    537537function prefix_admin_action_move()
    538538{
     539    if( !is_user_logged_in() ){
     540        $url = admin_url();
     541        wp_redirect($url . '/admin.php?page=copy-move&error=1');
     542        exit;
     543    }
     544    elseif( is_user_logged_in() ){
     545        $user = wp_get_current_user();
     546        if( !in_array( 'administrator', $user->roles ) ){
     547            $url = admin_url();
     548            wp_redirect($url . '/admin.php?page=copy-move&error=1');
     549            exit;   
     550        }
     551    }
     552   
    539553    global $wpdb;
    540     $get_source_id = $_REQUEST['source_post'];
    541     $get_target_id = $_REQUEST['target_post'];
    542     $get_action_type = $_REQUEST['copy-move'];
    543     $get_comment_type = $_REQUEST['comment_type'];
    544     $get_comment_ids = $_REQUEST['move_comment_id'];
     554    $get_source_id = isset( $_POST['source_post'] ) ? $_POST['source_post'] : 0;
     555    $get_target_id = isset( $_POST['target_post'] ) ? $_POST['target_post'] : 0;
     556    $get_action_type = isset( $_POST['copy-move'] ) ? $_POST['copy-move'] : '';
     557    $get_comment_type = isset( $_POST['comment_type'] ) ? $_POST['comment_type'] : 0;
     558    $get_comment_ids = isset( $_POST['move_comment_id'] ) ? $_POST['move_comment_id'] : [];
    545559
    546560    if (isset($get_comment_type) && $get_comment_type == '1') {
     
    601615
    602616        $transfer_comments = $perform_action->perform_action($get_source_id, $get_target_id, $get_action_type, $get_comment_id, $ary, $all_ids, $get_comment_type, $comment_cnt);
    603         $url = admin_url();
    604         wp_redirect($url . '/admin.php?page=copy-move&success=1');
    605         exit;
     617        if( $transfer_comments === false ){
     618            $url = admin_url();
     619            wp_redirect($url . '/admin.php?page=copy-move&error=1');
     620            exit;               
     621        }
     622        else{
     623            $url = admin_url();
     624            wp_redirect($url . '/admin.php?page=copy-move&success=1');
     625            exit;   
     626        }
    606627    } else {
    607628        $url = admin_url();
  • copy-or-move-comments/trunk/copy_move_functions.php

    r2837946 r2889974  
    4848        global $wpdb;
    4949
     50        if( get_post( $source_post_id ) == null || get_post( $target_post_id ) == null ){
     51            return false;
     52        }
     53
    5054        if ($get_action_type == 'move') {
    5155
     
    5761                foreach ($all_comments as $d1) {
    5862                    if (in_array($d1->comment_parent, $all_ids)) {
    59                         $sql[] = "update {$wpdb->comments} set comment_post_id = $target_post_id where comment_id IN ($d1->comment_ID)";
     63                        $sql[] =  $wpdb->prepare( "update {$wpdb->comments} set comment_post_id = %d where comment_id IN ($d1->comment_ID)", $target_post_id );
    6064
    6165                        //Decrement the comment_count in the $source_post_id
    62                         $sql[] = "update {$wpdb->posts} set comment_count = comment_count-1 where id = $source_post_id and post_status = 'publish'";
     66                        $sql[] = $wpdb->prepare( "update {$wpdb->posts} set comment_count = comment_count-1 where id = %d and post_status = 'publish'", $source_post_id );
    6367
    6468                        // Increment the comment_count in the $target_post_id
    65                         $sql[] = "update {$wpdb->posts} set comment_count = comment_count+1 where id = $target_post_id and post_status = 'publish'";
     69                        $sql[] =  $wpdb->prepare( "update {$wpdb->posts} set comment_count = comment_count+1 where id = %d and post_status = 'publish'", $target_post_id );
    6670                    } else {
    67                         $sql[] = "update {$wpdb->comments} set comment_post_id = $target_post_id , comment_parent = '0' where comment_id IN ($d1->comment_ID)";
     71                        $sql[] = $wpdb->prepare( "update {$wpdb->comments} set comment_post_id = %d , comment_parent = '0' where comment_id IN ($d1->comment_ID)", $target_post_id );
    6872
    6973                        //Decrement the comment_count in the $source_post_id
    70                         $sql[] = "update {$wpdb->posts} set comment_count = comment_count-1 where id = $source_post_id and post_status = 'publish'";
     74                        $sql[] = $wpdb->prepare( "update {$wpdb->posts} set comment_count = comment_count-1 where id = %d and post_status = 'publish'", $source_post_id );
    7175
    7276                        // Increment the comment_count in the $target_post_id
    73                         $sql[] = "update {$wpdb->posts} set comment_count = comment_count+1 where id = $target_post_id and post_status = 'publish'";
     77                        $sql[] = $wpdb->prepare( "update {$wpdb->posts} set comment_count = comment_count+1 where id = %d and post_status = 'publish'", $target_post_id );
    7478                    }
    7579                }
     
    8084            } else {
    8185
    82                 $sql[] = "update {$wpdb->comments} set comment_post_id = $target_post_id where comment_id IN ($comment_id)";
     86                $sql[] = $wpdb->prepare( "update {$wpdb->comments} set comment_post_id = %d where comment_id IN ($comment_id)", $target_post_id );
    8387
    8488                //Decrement the comment_count in the $source_post_id
    85                 $sql[] = "update {$wpdb->posts} set comment_count = comment_count-$comment_cnt where id = $source_post_id and post_status = 'publish'";
     89                $sql[] = $wpdb->prepare( "update {$wpdb->posts} set comment_count = comment_count-%d where id = %d and post_status = 'publish'", $comment_cnt, $source_post_id );
    8690
    8791                // Increment the comment_count in the $target_post_id
    88                 $sql[] = "update {$wpdb->posts} set comment_count = comment_count+$comment_cnt where id = $target_post_id and post_status = 'publish'";
     92                $sql[] = $wpdb->prepare( "update {$wpdb->posts} set comment_count = comment_count+%d where id = %d and post_status = 'publish'", $comment_cnt, $target_post_id );
    8993
    9094                foreach ($sql as $query) {
    91                     $wpdb->query($query);
     95                    $response[] = $wpdb->query($query);
    9296                }
     97
    9398            }
    9499        }
  • copy-or-move-comments/trunk/readme.txt

    r2837946 r2889974  
    33Tags: Copy/move all comments, migrate WP comments, Copy/Move Pages comment, Copy all comments, Move all comments
    44Requires at least: 3.5.2
    5 Tested up to: 6.1.1
    6 Stable tag: 5.0.3
     5Tested up to: 6.2
     6Stable tag: 5.0.4
    77License: GPLv2 or later
    88
     
    3737
    3838== Changelog ==
     39= 5.0.4 =
     40* Compatibility with word-press : 6.2
     41* Bug and vulnerability fixing.
    3942= 5.0.3 =
    4043* Compatibility with word-press : 6.1.1
Note: See TracChangeset for help on using the changeset viewer.