Changeset 2578596
- Timestamp:
- 08/05/2021 09:34:20 AM (4 years ago)
- Location:
- copy-or-move-comments/trunk
- Files:
-
- 3 edited
-
copy_move_comments.php (modified) (24 diffs)
-
copy_move_functions.php (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
copy-or-move-comments/trunk/copy_move_comments.php
r2273822 r2578596 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. 16 Version: 5.0.2 7 7 Author: biztechc 8 8 Author URI: https://www.appjetty.com/ … … 38 38 if (isset($_REQUEST['settings-updated']) == 'true') { 39 39 ?> 40 <div class="updated notice notice-success is-dismissible" id="message"><p>Setting updated.</p><button class="notice-dismiss" type="button"><span class="screen-reader-text">Dismiss this notice.</span></button></div> 40 <div class="updated notice notice-success is-dismissible" id="message"><p>Setting updated.</p><button class="notice-dismiss" type="button"><span class="screen-reader-text">Dismiss this notice.</span></button></div> 41 41 <?php 42 42 } … … 57 57 } 58 58 ?> 59 <input type="checkbox" id="all_private_post_type" name="all_private_post_type" <?php if (isset($checked)) echo $checked; ?> /> 60 <label for="all_private_post_type">Include Private Posts?</label><br> 59 <input type="checkbox" name="all_private_post_type" <?php if (isset($checked)) echo $checked; ?>><label>Include Private Posts?</label><br> 61 60 <?php 62 61 $checked = ''; … … 99 98 ?> 100 99 <div class="tablenav top"> 101 <big style="float: left; margin-top: 5px; margin-right: 7px;"><?php _e("Action"); ?>:</big> 100 <big style="float: left; margin-top: 5px; margin-right: 7px;"><?php _e("Action"); ?>:</big> 102 101 <div class="alignleft actions"> 103 102 <label class="screen-reader-text">Select Action</label> … … 108 107 </select> 109 108 </div> 110 <big style="float: left; margin-top: 5px; margin-right: 7px;"><?php _e("Source"); ?>:</big> 109 <big style="float: left; margin-top: 5px; margin-right: 7px;"><?php _e("Source"); ?>:</big> 111 110 <div class="alignleft actions"> 112 111 <?php … … 122 121 foreach ($post_types as $post_type) { 123 122 ?> 124 <option value="<?php echo $post_type; ?>"><?php echo $post_type; ?></option> 123 <option value="<?php echo $post_type; ?>"><?php echo $post_type; ?></option> 125 124 126 125 <?php } … … 137 136 </div> 138 137 <div class="alignleft actions" id="comment_history"> 139 <big style="float: left; margin-top: 5px; margin-right: 7px;"><?php _e("Select Comment Type"); ?>:</big> 138 <big style="float: left; margin-top: 5px; margin-right: 7px;"><?php _e("Select Comment Type"); ?>:</big> 140 139 <select id="comment_type" name="comment_type"> 141 140 <option value="0">Select Comment Type</option> … … 150 149 <div id="get_comments"></div> 151 150 <div class="tablenav bottom" style="display: none;"> 152 <big style="float: left; margin-top: 5px; margin-right: 10px;"><?php _e("Target"); ?>:</big> 153 <div class="alignleft actions"> 151 <big style="float: left; margin-top: 5px; margin-right: 10px;"><?php _e("Target"); ?>:</big> 152 <div class="alignleft actions"> 154 153 <?php 155 154 $target_post_types = get_post_types('', 'names'); … … 157 156 unset($target_post_types['revision']); 158 157 unset($target_post_types['nav_menu_item']); 159 ?> 158 ?> 160 159 <select name="target_all_post_types" id="target_all_post_types"> 161 160 <option value="0">Select Post Type</option> … … 163 162 foreach ($target_post_types as $target_post_type) { 164 163 ?> 165 <option value="<?php echo $target_post_type; ?>"><?php echo $target_post_type; ?></option> 164 <option value="<?php echo $target_post_type; ?>"><?php echo $target_post_type; ?></option> 166 165 <?php 167 166 } 168 167 ?> 169 </select> 168 </select> 170 169 </div> 171 170 <div class="alignleft actions"> 172 171 <select id="target_post" name="target_post"> 173 <option value="0">Select Post</option> 172 <option value="0">Select Post</option> 174 173 </select> 175 174 <span id="target_bc_loader" style="display: none;"><img src="<?php echo plugins_url('ajax-loader.gif', __FILE__); ?>" alt=""></span></div> 176 <input type="submit" value="Perform Action" class="button action" id="doaction2" name="" onclick="return chk_val();"> 175 <!-- <input type="submit" value="Perform Action" class="button action" id="doaction2" name="" onclick="return chk_val();"> --> 176 <input type="submit" value="Perform Action" class="button action" id="do_action2" name="do_action2" onclick="return chk_val();"> 177 177 </div> 178 <input type="hidden" name="action" value="action_move"> 178 <input type="hidden" name="action" value="action_move"> 179 179 </form> 180 180 <script type="text/javascript"> … … 304 304 $.post(ajaxurl, data, function (response) { 305 305 jQuery("#get_comments").html(response); 306 //jQuery("#bc_loader").hide(); 306 //jQuery("#bc_loader").hide(); 307 307 }); 308 308 }); 309 309 }); 310 </script> 310 </script> 311 311 <?php 312 312 } … … 323 323 <option value="">Select Post</option> 324 324 <?php foreach ($get_posts as $get_post) { ?> 325 <option value="<?php echo $get_post->id; ?>"><?php echo $get_post->post_title; ?></option> 325 <option value="<?php echo $get_post->id; ?>"><?php echo $get_post->post_title; ?></option> 326 326 <?php 327 327 } … … 366 366 <tr> 367 367 <td class="source_error" colspan="4" align="center">No Comments found. Please change Comment Type.</td> 368 </tr> 368 </tr> 369 369 370 370 <?php … … 411 411 if (!in_array($get_comment_ids_1[$i], $ids)) { 412 412 ?> 413 <td></td> 413 <td></td> 414 414 <?php 415 415 } else { … … 420 420 } else { 421 421 ?> 422 <td><input type="checkbox" value="<?php echo $get_comment->comment_ID; ?>" name="move_comment_id[]" class="chkbox_val"></td> 422 <td><input type="checkbox" value="<?php echo $get_comment->comment_ID; ?>" name="move_comment_id[]" class="chkbox_val"></td> 423 423 <?php 424 424 } … … 465 465 } 466 466 } 467 if ($i == count($get_comment_ids_1)) {467 if ($i == count($get_comment_ids_1)) 468 468 @$get_comment_ids = array_pop($temp); 469 }470 } while (count($get_comment_ids) > 0);471 }else {469 }while (count($get_comment_ids) > 0); 470 } 471 else { 472 472 ?> 473 473 <tr> … … 546 546 547 547 } 548 </script> 548 </script> 549 549 <?php 550 550 } … … 564 564 } else { 565 565 $ids = $get_comment_ids; 566 $ary = array();567 566 do { 568 567 $tem = $ids; … … 570 569 for ($i = 0; $i < count($tem); $i++) { 571 570 $s = "select * from $wpdb->comments where comment_parent = '" . $tem[$i] . "' and comment_Approved != 'trash'"; 572 //$data = $wpdb->get_results($wpdb->prepare("", $id));571 $data = $wpdb->get_results($wpdb->prepare("", $id)); 573 572 $res = $wpdb->get_results($s); 574 573 if ($res) { … … 581 580 } while (count($ids) > 0); 582 581 583 //$ids = $get_comment_ids; 584 $ printed = array();582 583 $ids = $get_comment_ids; 585 584 do { 586 585 $get_comment_ids_1 = $get_comment_ids; … … 591 590 else { 592 591 $printed[] = $get_comment_ids_1[$i]; 593 592 echo "<br>"; 593 if (!in_array($get_comment_ids_1[$i], $ids)) { 594 echo str_repeat(" - ", count($temp)); 595 } 596 echo $get_comment_ids_1[$i]; 594 597 $all_ids[] = $get_comment_ids_1[$i]; 595 if (isset($ary)) { 596 if (isset($ary[$get_comment_ids_1[$i]]) && count($ary[$get_comment_ids_1[$i]]) > 0) { 597 $temp[] = $get_comment_ids_1; 598 $get_comment_ids = $ary[$get_comment_ids_1[$i]]; 599 break; 600 } 598 if (count($ary[$get_comment_ids_1[$i]]) > 0) { 599 $temp[] = $get_comment_ids_1; 600 $get_comment_ids = $ary[$get_comment_ids_1[$i]]; 601 break; 601 602 } 602 603 } 603 604 } 604 if ($i == count($get_comment_ids_1)) { 605 if (isset($temp)) { 606 $get_comment_ids = array_pop($temp); 607 } 608 } 609 } while (count($get_comment_ids) > 0); 605 if ($i == count($get_comment_ids_1)) 606 $get_comment_ids = array_pop($temp); 607 }while (count($get_comment_ids) > 0); 610 608 } 611 609 … … 620 618 $perform_action = new copy_move_functions(); 621 619 622 $ perform_action->perform_action($get_source_id, $get_target_id, $get_action_type, $get_comment_id, $all_ids, $get_comment_type, $comment_cnt);620 $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); 623 621 $url = admin_url(); 624 622 wp_redirect($url . '/admin.php?page=copy-move&success=1'); … … 640 638 <div class="notice notice-success"> 641 639 <p><?php _e('Comments moved/copied successfully. Click here to <a href="' . $all_comment . '">view.</a>'); ?></p> 642 </div> 640 </div> 643 641 644 642 <?php … … 648 646 <div class="error"> 649 647 <p><?php _e('Please select action OR select atleast one comment to copy/move.'); ?></p> 650 </div> 648 </div> 651 649 <?php 652 650 } -
copy-or-move-comments/trunk/copy_move_functions.php
r1990750 r2578596 1 <?php 2 1 <?php 3 2 //ini_set("display_errors", "1"); if you want to debug then uncheck this commnet. 4 class copy_move_functions { 5 6 function get_posts($post_type, $set_privet_post_type) { 7 global $wpdb; 8 $data = array(); 9 if ($set_privet_post_type == 'on') { 10 $data = $wpdb->get_results($wpdb->prepare("select id, post_title from $wpdb->posts where post_status in ('publish','private') and post_type = %s order by post_title asc", $post_type)); 11 } else { 12 $data = $wpdb->get_results($wpdb->prepare("select id, post_title from $wpdb->posts where post_status = 'publish' and post_type = %s order by post_title asc", $post_type)); 13 } 14 3 class copy_move_functions 4 { 5 function get_posts($post_type,$set_privet_post_type) 6 { 7 global $wpdb; 8 $data = array(); 9 if($set_privet_post_type == 'on'){ 10 $data = $wpdb->get_results( $wpdb->prepare( "select id, post_title from $wpdb->posts where post_status in ('publish','private') and post_type = %s order by post_title asc", $post_type ) ); 11 }else{ 12 $data = $wpdb->get_results( $wpdb->prepare( "select id, post_title from $wpdb->posts where post_status = 'publish' and post_type = %s order by post_title asc", $post_type ) ); 13 } 14 15 15 //$data = $wpdb->get_results("select id, post_title from $wpdb->posts where post_status = 'publish' and post_type='".$post_type."' order by id desc"); 16 16 return $data; 17 17 } 18 19 function get_all_comments_by_postid($id) { 20 global $wpdb; 21 $data = array(); 22 23 if (is_numeric($id)) { 24 $data = $wpdb->get_results($wpdb->prepare("select comment_id from $wpdb->comments where comment_post_id = %s and comment_Approved != 'trash' and comment_parent=0 order by comment_id asc", $id)); 18 19 function get_all_comments_by_postid($id) 20 { 21 global $wpdb; 22 $data = array(); 23 24 if(is_numeric($id)) 25 { 26 $data = $wpdb->get_results( $wpdb->prepare( "select comment_id from $wpdb->comments where comment_post_id = %s and comment_Approved != 'trash' and comment_parent=0 order by comment_id asc", $id ) ); 25 27 //$data = $wpdb->get_results("select comment_id, comment_author,comment_date, comment_content from $wpdb->comments where comment_post_id = $id order by comment_id desc"); 26 28 } 27 29 return $data; 28 30 } 29 30 function get_current_all_posts($post_type, $post_id) { 31 global $wpdb; 32 $post_types = get_post_types('', 'names'); 33 //unset($post_types['attachment']); 34 unset($post_types['revision']); 35 unset($post_types['nav_menu_item']); 36 $post_type = "'" . implode("','", $post_types) . "'"; 37 //DebugBreak(); 38 $data = array(); 39 $data = $wpdb->get_results($wpdb->prepare("select ID, post_title from $wpdb->posts where post_status = 'publish' and post_type IN (%d) and ID NOT IN(SELECT ID FROM $wpdb->posts where ID=%s) order by id desc", $post_type, $post_id)); 31 32 function get_current_all_posts($post_type,$post_id) 33 { 34 global $wpdb; 35 $post_types = get_post_types( '', 'names' ); 36 //unset($post_types['attachment']); 37 unset($post_types['revision']); 38 unset($post_types['nav_menu_item']); 39 $post_type = "'".implode("','",$post_types)."'"; 40 //DebugBreak(); 41 $data = array(); 42 $data = $wpdb->get_results( $wpdb->prepare("select ID, post_title from $wpdb->posts where post_status = 'publish' and post_type IN (%d) and ID NOT IN(SELECT ID FROM $wpdb->posts where ID=%s) order by id desc", $post_type,$post_id ) ); 40 43 //$data = $wpdb->get_results("select ID, post_title from $wpdb->posts where post_status = 'publish' and post_type IN ($post_type) and ID NOT IN(SELECT ID FROM $wpdb->posts where ID='$post_id') order by id desc"); 41 44 return $data; 42 45 } 43 44 function perform_action($source_post_id, $target_post_id, $get_action_type, $comment_id, $all_ids, $get_comment_type, $comment_cnt) { 45 global $wpdb; 46 47 if ($get_action_type == 'move') { 48 49 if (isset($get_comment_type) && $get_comment_type == '1') { 50 51 $all_comments = $wpdb->get_results("select * from $wpdb->comments where comment_id IN ($comment_id)"); 52 53 foreach ($all_comments as $d1) { 54 if (in_array($d1->comment_parent, $all_ids)) { 55 $sql[] = "update {$wpdb->comments} set comment_post_id = $target_post_id where comment_id IN ($d1->comment_ID)"; 56 57 //Decrement the comment_count in the $source_post_id 58 $sql[] = "update {$wpdb->posts} set comment_count = comment_count-1 where id = $source_post_id and post_status = 'publish'"; 59 60 // Increment the comment_count in the $target_post_id 61 $sql[] = "update {$wpdb->posts} set comment_count = comment_count+1 where id = $target_post_id and post_status = 'publish'"; 62 } else { 63 $sql[] = "update {$wpdb->comments} set comment_post_id = $target_post_id , comment_parent = '0' where comment_id IN ($d1->comment_ID)"; 64 65 //Decrement the comment_count in the $source_post_id 66 $sql[] = "update {$wpdb->posts} set comment_count = comment_count-1 where id = $source_post_id and post_status = 'publish'"; 67 68 // Increment the comment_count in the $target_post_id 69 $sql[] = "update {$wpdb->posts} set comment_count = comment_count+1 where id = $target_post_id and post_status = 'publish'"; 70 } 46 47 function perform_action($source_post_id, $target_post_id, $get_action_type,$comment_id,$ary,$all_ids,$get_comment_type,$comment_cnt) 48 { 49 global $wpdb; 50 51 if($get_action_type == 'move') 52 { 53 54 // update the comment_post_id to $target_post_id 55 /* if(isset($get_comment_type) && $get_comment_type == '1') 56 { 57 $all_comments = $wpdb->get_results("select * from $wpdb->comments where comment_id IN ($comment_id)"); 58 59 foreach($all_comments as $data1) 60 { 61 62 if($data1->comment_parent !='0') 63 { 64 $data = array( 65 'comment_post_ID' => $target_post_id, 66 'comment_author' => $data1->comment_author, 67 'comment_author_email' => $data1->comment_author_email, 68 'comment_author_url' => $data1->comment_author_url, 69 'comment_content' => $data1->comment_content, 70 'comment_type' => $data1->comment_type, 71 'comment_parent' => '0', 72 'user_id' => $data1->user_id, 73 'comment_author_IP' => $data1->comment_author_IP, 74 'comment_agent' => $data1->comment_agent, 75 'comment_date' => $data1->comment_date, 76 'comment_approved' => $data1->comment_approved, 77 ); 78 wp_insert_comment($data); 79 80 $del_qry = "DELETE FROM wp_comments WHERE comment_ID = $data1->comment_ID"; 81 $wpdb->query($del_qry); 82 83 }else{ 84 85 $sql[] = "update {$wpdb->comments} set comment_post_id = $target_post_id where comment_id IN ($data1->comment_ID)"; 86 87 //Decrement the comment_count in the $source_post_id 88 $sql[] = "update {$wpdb->posts} set comment_count = comment_count-1 where id = $source_post_id and post_status = 'publish'"; 89 90 // Increment the comment_count in the $target_post_id 91 $sql[] = "update {$wpdb->posts} set comment_count = comment_count+1 where id = $target_post_id and post_status = 'publish'"; 92 93 foreach($sql as $query) 94 { 95 $wpdb->query($wpdb->prepare($query)); 96 } 71 97 } 72 73 foreach ($sql as $query) { 74 $wpdb->query($query); 75 } 76 } else { 77 98 99 } 100 101 }*/ 102 if(isset($get_comment_type) && $get_comment_type == '1') 103 { 104 105 $all_comments = $wpdb->get_results("select * from $wpdb->comments where comment_id IN ($comment_id)"); 106 107 foreach($all_comments as $d1){ 108 if(in_array($d1->comment_parent,$all_ids)) 109 { 110 $sql[] = "update {$wpdb->comments} set comment_post_id = $target_post_id where comment_id IN ($d1->comment_ID)"; 111 112 //Decrement the comment_count in the $source_post_id 113 $sql[] = "update {$wpdb->posts} set comment_count = comment_count-1 where id = $source_post_id and post_status = 'publish'"; 114 115 // Increment the comment_count in the $target_post_id 116 $sql[] = "update {$wpdb->posts} set comment_count = comment_count+1 where id = $target_post_id and post_status = 'publish'"; 117 118 }else{ 119 $sql[] = "update {$wpdb->comments} set comment_post_id = $target_post_id , comment_parent = '0' where comment_id IN ($d1->comment_ID)"; 120 121 //Decrement the comment_count in the $source_post_id 122 $sql[] = "update {$wpdb->posts} set comment_count = comment_count-1 where id = $source_post_id and post_status = 'publish'"; 123 124 // Increment the comment_count in the $target_post_id 125 $sql[] = "update {$wpdb->posts} set comment_count = comment_count+1 where id = $target_post_id and post_status = 'publish'"; 126 } 127 } 128 129 foreach($sql as $query) 130 { 131 $wpdb->query($query); 132 } 133 } 134 else 135 { 136 78 137 $sql[] = "update {$wpdb->comments} set comment_post_id = $target_post_id where comment_id IN ($comment_id)"; 79 80 //Decrement the comment_count in the $source_post_id 81 $sql[] = "update {$wpdb->posts} set comment_count = comment_count-$comment_cnt where id = $source_post_id and post_status = 'publish'"; 82 83 // Increment the comment_count in the $target_post_id 84 $sql[] = "update {$wpdb->posts} set comment_count = comment_count+$comment_cnt where id = $target_post_id and post_status = 'publish'"; 85 86 foreach ($sql as $query) { 87 $wpdb->query($query); 88 } 89 } 90 } 91 if ($get_action_type == 'copy') { 92 93 if (isset($get_comment_type) && $get_comment_type == '1') { 94 $all_comments = $wpdb->get_results("select * from $wpdb->comments where comment_id IN ($comment_id)"); 95 foreach ($all_comments as $data1) { 96 /* * ******************************* */ 97 98 /* * ******************************* */ 99 100 $data_new = array( 101 'comment_post_ID' => $target_post_id, 102 'comment_author' => $data1->comment_author, 103 'comment_author_email' => $data1->comment_author_email, 104 'comment_author_url' => $data1->comment_author_url, 105 'comment_content' => $data1->comment_content, 106 'comment_type' => $data1->comment_type, 107 'comment_parent' => '0', 108 'user_id' => $data1->user_id, 109 'comment_author_IP' => $data1->comment_author_IP, 110 'comment_agent' => $data1->comment_agent, 111 'comment_date' => $data1->comment_date, 112 'comment_approved' => $data1->comment_approved, 113 ); 114 115 wp_insert_comment($data_new); 116 } 117 } else { 118 // $all_comments = $wpdb->get_results($wpdb->prepare( "select * from $wpdb->comments where comment_id IN (%s)", $comment_id )); 119 $all_comments = $wpdb->get_results("select * from $wpdb->comments where comment_id IN ($comment_id)"); 120 foreach ($all_comments as $data1) { 121 /* * ******************************* */ 122 123 /* * ******************************* */ 124 125 $data = array( 126 'comment_post_ID' => $target_post_id, 127 'comment_author' => $data1->comment_author, 128 'comment_author_email' => $data1->comment_author_email, 129 'comment_author_url' => $data1->comment_author_url, 130 'comment_content' => $data1->comment_content, 131 'comment_type' => $data1->comment_type, 132 'comment_parent' => $data1->comment_parent, 133 'user_id' => $data1->user_id, 134 'comment_author_IP' => $data1->comment_author_IP, 135 'comment_agent' => $data1->comment_agent, 136 'comment_date' => $data1->comment_date, 137 'comment_approved' => $data1->comment_approved, 138 ); 139 140 $new_comment_ids[] = wp_insert_comment($data); 141 } 142 //if($get_comment_type == '2') 143 { 144 for ($i = 0; $i < count($all_ids); $i++) { 145 $sql2[$i] = "update {$wpdb->comments} set comment_parent = " . $new_comment_ids[$i] . " where comment_post_id = " . $target_post_id . " and comment_parent = " . $all_ids[$i] . ""; 146 $wpdb->query($sql2[$i]); 147 } 148 } 149 } 150 } 151 } 152 153 function get_single_comment($id) { 154 global $wpdb; 155 $data = array(); 156 157 if (is_numeric($id)) { 158 $data = $wpdb->get_row($wpdb->prepare("select * from $wpdb->comments where comment_id = %s", $id)); 159 } 160 return $data; 161 } 162 138 139 //Decrement the comment_count in the $source_post_id 140 $sql[] = "update {$wpdb->posts} set comment_count = comment_count-$comment_cnt where id = $source_post_id and post_status = 'publish'"; 141 142 // Increment the comment_count in the $target_post_id 143 $sql[] = "update {$wpdb->posts} set comment_count = comment_count+$comment_cnt where id = $target_post_id and post_status = 'publish'"; 144 145 foreach($sql as $query) 146 { 147 $wpdb->query($wpdb->prepare($query)); 148 } 149 150 } 151 152 153 } 154 if($get_action_type == 'copy') 155 { 156 157 if(isset($get_comment_type) && $get_comment_type == '1') 158 { 159 $all_comments = $wpdb->get_results("select * from $wpdb->comments where comment_id IN ($comment_id)"); 160 foreach($all_comments as $data1) 161 { 162 /**********************************/ 163 164 /**********************************/ 165 166 $data_new = array( 167 'comment_post_ID' => $target_post_id, 168 'comment_author' => $data1->comment_author, 169 'comment_author_email' => $data1->comment_author_email, 170 'comment_author_url' => $data1->comment_author_url, 171 'comment_content' => $data1->comment_content, 172 'comment_type' => $data1->comment_type, 173 'comment_parent' => '0', 174 'user_id' => $data1->user_id, 175 'comment_author_IP' => $data1->comment_author_IP, 176 'comment_agent' => $data1->comment_agent, 177 'comment_date' => $data1->comment_date, 178 'comment_approved' => $data1->comment_approved, 179 ); 180 181 wp_insert_comment($data_new); 182 } 183 } 184 else 185 { 186 // $all_comments = $wpdb->get_results($wpdb->prepare( "select * from $wpdb->comments where comment_id IN (%s)", $comment_id )); 187 $all_comments = $wpdb->get_results("select * from $wpdb->comments where comment_id IN ($comment_id)"); 188 foreach($all_comments as $data1) 189 { 190 /**********************************/ 191 192 /**********************************/ 193 194 $data = array( 195 'comment_post_ID' => $target_post_id, 196 'comment_author' => $data1->comment_author, 197 'comment_author_email' => $data1->comment_author_email, 198 'comment_author_url' => $data1->comment_author_url, 199 'comment_content' => $data1->comment_content, 200 'comment_type' => $data1->comment_type, 201 'comment_parent' => $data1->comment_parent, 202 'user_id' => $data1->user_id, 203 'comment_author_IP' => $data1->comment_author_IP, 204 'comment_agent' => $data1->comment_agent, 205 'comment_date' => $data1->comment_date, 206 'comment_approved' => $data1->comment_approved, 207 ); 208 209 $new_comment_ids[] = wp_insert_comment($data); 210 211 } 212 //if($get_comment_type == '2') 213 { 214 for($i=0;$i<count($all_ids);$i++) 215 { 216 $sql2[$i] = "update {$wpdb->comments} set comment_parent = ".$new_comment_ids[$i]." where comment_post_id = ".$target_post_id." and comment_parent = ".$all_ids[$i].""; 217 $wpdb->query($sql2[$i]); 218 219 } 220 } 221 222 } 223 224 225 226 227 } 228 } 229 230 function get_single_comment($id) 231 { 232 global $wpdb; 233 $data = array(); 234 235 if(is_numeric($id)) 236 { 237 $data = $wpdb->get_row( $wpdb->prepare( "select * from $wpdb->comments where comment_id = %s", $id ) ); 238 } 239 return $data; 240 } 163 241 } 164 165 242 ?> -
copy-or-move-comments/trunk/readme.txt
r2273822 r2578596 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: 5. 46 Stable tag: 5.0. 15 Tested up to: 5.8 6 Stable tag: 5.0.2 7 7 License: GPLv2 or later 8 8 … … 18 18 6. Admin can have select option for target post types. 19 19 7. After select post type next drop down selection will displaying all the post's title in which admin can copy comments or moving comments for that selected post. 20 20 21 21 22 22 == Installation == … … 40 40 * First release this pluign 41 41 = 1.0.1 = 42 * Solve vulnerability 42 * Solve vulnerability 43 43 = 2.0.0 = 44 * For Copy/Move comments, Added Target Post Type also. 44 * For Copy/Move comments, Added Target Post Type also. 45 45 = 3.0.0 = 46 * Release new feature that is copy/move comments whole replies history. 46 * Release new feature that is copy/move comments whole replies history. 47 47 = 3.0.1 = 48 * Search filter in source and destination post selection 48 * Search filter in source and destination post selection 49 49 = 4.0.0 = 50 50 * Add setting page which allows admin to displaying private posts/ pages into Source as well as Target section. … … 53 53 = 4.0.2 = 54 54 * Compatibility with word-press : 4.7. 55 = 4.0.3 = 56 * Solving bug on PHP7 and Compatibility with word-press : 4.8.2. 57 = 5.0.0 = 58 * Compatibility with word-press : 5.3. 59 = 5.0.1 = 60 * Compatibility with word-press : 5.4. 55 = 5.0.2 = 56 * Compatibility with word-press : 5.8. 57 * Solving Perform Action Button issue.
Note: See TracChangeset
for help on using the changeset viewer.