mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-01 03:58:07 +08:00
34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
class MainWP_Child_Robot {
|
|
public static $instance = null;
|
|
|
|
static function Instance() {
|
|
if ( null === self::$instance ) {
|
|
self::$instance = new MainWP_Child_Robot();
|
|
}
|
|
|
|
return self::$instance;
|
|
}
|
|
|
|
public function wpr_insertcomments( $postid, $comments ) {
|
|
remove_filter( 'comment_text', 'make_clickable', 9 );
|
|
foreach ( $comments as $comment ) {
|
|
$comment_post_ID = $postid;
|
|
$comment_date = $comment['dts'];
|
|
$comment_date = date( 'Y-m-d H:i:s', $comment_date );
|
|
$comment_date_gmt = $comment_date;
|
|
$rnd = rand( 1, 9999 );
|
|
$comment_author_email = "someone$rnd@domain.com";
|
|
$comment_author = $comment['author'];
|
|
$comment_author_url = '';
|
|
$comment_content = '';
|
|
$comment_content .= $comment['content'];
|
|
$comment_type = '';
|
|
$user_ID = '';
|
|
$comment_approved = 1;
|
|
$commentdata = compact( 'comment_post_ID', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID', 'comment_approved' );
|
|
$comment_id = wp_insert_comment( $commentdata );
|
|
}
|
|
}
|
|
}
|