Changeset 2889974
- Timestamp:
- 03/30/2023 08:56:08 AM (3 years ago)
- Location:
- copy-or-move-comments/trunk
- Files:
-
- 3 edited
-
copy_move_comments.php (modified) (3 diffs)
-
copy_move_functions.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
copy-or-move-comments/trunk/copy_move_comments.php
r2837946 r2889974 4 4 Plugin URI: 5 5 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. 36 Version: 5.0.4 7 7 Author: biztechc 8 8 Author URI: https://www.appjetty.com/ … … 537 537 function prefix_admin_action_move() 538 538 { 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 539 553 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'] : []; 545 559 546 560 if (isset($get_comment_type) && $get_comment_type == '1') { … … 601 615 602 616 $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 } 606 627 } else { 607 628 $url = admin_url(); -
copy-or-move-comments/trunk/copy_move_functions.php
r2837946 r2889974 48 48 global $wpdb; 49 49 50 if( get_post( $source_post_id ) == null || get_post( $target_post_id ) == null ){ 51 return false; 52 } 53 50 54 if ($get_action_type == 'move') { 51 55 … … 57 61 foreach ($all_comments as $d1) { 58 62 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 ); 60 64 61 65 //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 ); 63 67 64 68 // 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 ); 66 70 } 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 ); 68 72 69 73 //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 ); 71 75 72 76 // 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 ); 74 78 } 75 79 } … … 80 84 } else { 81 85 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 ); 83 87 84 88 //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 ); 86 90 87 91 // 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 ); 89 93 90 94 foreach ($sql as $query) { 91 $ wpdb->query($query);95 $response[] = $wpdb->query($query); 92 96 } 97 93 98 } 94 99 } -
copy-or-move-comments/trunk/readme.txt
r2837946 r2889974 3 3 Tags: Copy/move all comments, migrate WP comments, Copy/Move Pages comment, Copy all comments, Move all comments 4 4 Requires at least: 3.5.2 5 Tested up to: 6. 1.16 Stable tag: 5.0. 35 Tested up to: 6.2 6 Stable tag: 5.0.4 7 7 License: GPLv2 or later 8 8 … … 37 37 38 38 == Changelog == 39 = 5.0.4 = 40 * Compatibility with word-press : 6.2 41 * Bug and vulnerability fixing. 39 42 = 5.0.3 = 40 43 * Compatibility with word-press : 6.1.1
Note: See TracChangeset
for help on using the changeset viewer.