本文整理汇总了PHP中wp_insert_comment函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_insert_comment函数的具体用法?PHP wp_insert_comment怎么用?PHP wp_insert_comment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_insert_comment函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: evc_comments_add_comment
function evc_comments_add_comment($comment, $post_id, $widget_api_id, $comment_parent = null)
{
if (isset($comment['cid'])) {
$comment['id'] = $comment['cid'];
}
$vk_item_id = 'app' . $widget_api_id . '_' . $comment['id'];
$comment_wp_id = evc_get_wpid_by_vkid($vk_item_id, 'comment');
if ($comment_wp_id && isset($comment_wp_id[$vk_item_id])) {
return $comment_wp_id[$vk_item_id];
}
if (isset($comment['user']) && !empty($comment['user'])) {
$user_wp_id = evc_get_wpid_by_vkid($comment['user']['id'], 'user');
if (!$user_wp_id) {
$user_wp_id = evc_add_user($comment['user']);
if (!$user_wp_id) {
return false;
}
} else {
$user_wp_id = $user_wp_id[$comment['user']['id']];
}
} else {
return false;
}
$args = array('comment_post_ID' => $post_id, 'comment_content' => $comment['text'], 'user_id' => $user_wp_id, 'comment_date' => date('Y-m-d H:i:s', $comment['date'] + get_option('gmt_offset') * 3600), 'comment_approved' => 1, 'comment_author_IP' => preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']), 'comment_agent' => substr($_SERVER['HTTP_USER_AGENT'], 0, 254));
if (isset($comment_parent) && !empty($comment_parent)) {
$args['comment_parent'] = $comment_parent;
}
$args = apply_filters('evc_comments_add_comment_args', $args, $comment);
//print__r($args); //
$comment_wp_id = wp_insert_comment($args);
if ($comment_wp_id) {
update_comment_meta($comment_wp_id, 'vk_item_id', $vk_item_id);
}
return $comment_wp_id;
}
开发者ID:prosenjit-itobuz,项目名称:upages,代码行数:35,代码来源:evc-comments-seo.php
示例2: customer_note_added
public function customer_note_added($data)
{
global $wpdb;
$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE id = %d", $data['order_id']));
if ($post && $post->post_type == 'order_shipment') {
$parent_id = $post->post_parent;
$is_customer_note = intval(1);
if (isset($_SERVER['HTTP_HOST'])) {
$comment_author_email = sanitize_email(strtolower(__('WooCommerce', 'woocommerce')) . '@' . str_replace('www.', '', $_SERVER['HTTP_HOST']));
} else {
$comment_author_email = sanitize_email(strtolower(__('WooCommerce', 'woocommerce')) . '@noreply.com');
}
$comment_post_ID = $parent_id;
$comment_author = __('WooCommerce', 'woocommerce');
$comment_author_url = '';
$comment_content = $data['customer_note'];
$comment_agent = 'WooCommerce';
$comment_type = 'order_note';
$comment_parent = 0;
$comment_approved = 1;
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_agent', 'comment_type', 'comment_parent', 'comment_approved');
$comment_id = wp_insert_comment($commentdata);
add_comment_meta($comment_id, 'is_customer_note', $is_customer_note);
}
}
开发者ID:RainyDayMedia,项目名称:carbide-probes,代码行数:25,代码来源:wcms-shipworks.php
示例3: p_ssc_process
function p_ssc_process($commentdata)
{
// if this is a trackback or pingback return
if ($commentdata['comment_type'] != '') {
return $commentdata;
}
global $post;
// Quick fix: $post no more available since WordPress 4.4
if (is_null($post)) {
//global $wpdb;
//$_postid = $wpdb->last_result[0]->ID;
// better, thanks to https://twitter.com/nosegraze
$_postid = $commentdata['comment_post_ID'];
} else {
$_postid = $post->ID;
}
$key = p_ssc_generateKey($_postid);
// if comment has key field return
if (isset($_POST['ssc_key_' . $key[0]]) && $_POST['ssc_key_' . $key[0]] == $key[1]) {
return $commentdata;
} elseif (strpos($commentdata['comment_content'], $key[1] . $key[0]) !== false) {
$commentdata['comment_content'] = str_replace($key[1] . $key[0], '', $commentdata['comment_content']);
return $commentdata;
} else {
do_action('stop_spam_comments_found_spam', $commentdata);
if (get_option('p_ssc_keepspam')) {
$commentdata['comment_approved'] = 'spam';
wp_insert_comment($commentdata);
}
wp_die(__('Notice: It seems you have Javascript disabled in your Browser. In order to submit a comment to this post, please write the code below the form along with your comment.', 'stop-spam-comments'));
}
}
开发者ID:quinntron,项目名称:greendot,代码行数:32,代码来源:stop-spam.php
示例4: import
function import() {
$comment_author = $this->author;
$comment_author_url = $this->authoruri;
$comment_author_email = $this->authoremail;
$comment_date = $this->updated;
$comment_content = $this->content;
$comment_post_ID = $this->post_ID;
$comment_author_IP = '127.0.0.1'; //Blogger does not supply the IP so default this
// Clean up content
// Simplepie does some cleaning but does not do these.
$comment_content = str_replace('<br>', '<br />', $comment_content);
$comment_content = str_replace('<hr>', '<hr />', $comment_content);
$comment_parent = isset($this->parentcommentid) ? $this->parentcommentid : 0;
$comment = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email','comment_author_IP','comment_date', 'comment_content', 'comment_parent');
$comment = wp_filter_comment($comment);
$comment_id = wp_insert_comment($comment);
//links of the form /feeds/417730729915399755/8397846992898424746/comments/default/7732208643735403000
add_comment_meta($comment_id, 'blogger_internal', $this->self, true);
return $comment_id;
}
开发者ID:niamherinoc,项目名称:rctractors,代码行数:28,代码来源:comment-entry.php
示例5: wp_new_comment
function wp_new_comment($commentdata)
{
$commentdata = apply_filters('preprocess_comment', $commentdata);
$commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
$commentdata['user_ID'] = (int) $commentdata['user_ID'];
$commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
$commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'];
$commentdata['comment_date'] = current_time('mysql');
$commentdata['comment_date_gmt'] = current_time('mysql', 1);
$commentdata = wp_filter_comment($commentdata);
$commentdata['comment_approved'] = wp_allow_comment($commentdata);
$comment_ID = wp_insert_comment($commentdata);
do_action('comment_post', $comment_ID, $commentdata['comment_approved']);
if ('spam' !== $commentdata['comment_approved']) {
// If it's spam save it silently for later crunching
if ('0' == $commentdata['comment_approved']) {
wp_notify_moderator($comment_ID);
}
$post =& get_post($commentdata['comment_post_ID']);
// Don't notify if it's your own comment
if (get_settings('comments_notify') && $commentdata['comment_approved'] && $post->post_author != $commentdata['user_ID']) {
wp_notify_postauthor($comment_ID, $commentdata['comment_type']);
}
}
return $comment_ID;
}
开发者ID:robertlange81,项目名称:Website,代码行数:26,代码来源:comment-functions.php
示例6: jobman_store_comment
function jobman_store_comment()
{
global $current_user;
get_currentuserinfo();
$comment = array('comment_post_ID' => $_REQUEST['interview'], 'comment_content' => $_REQUEST['comment'], 'user_id' => $current_user->ID);
wp_insert_comment($comment);
}
开发者ID:pduobert,项目名称:wordpress-job-manager,代码行数:7,代码来源:admin-comments.php
示例7: process_comments
function process_comments($post_id, $item_id)
{
if (empty($post_id)) {
return;
}
if (!is_numeric($post_id)) {
return;
}
$comments = $this->model->get_item_comments($item_id);
if (!$comments || !isset($comments['data'])) {
return;
}
$comments = $comments['data'];
if (!count($comments)) {
return false;
}
foreach ($comments as $comment) {
if ($this->model->comment_already_imported($comment['id'])) {
continue;
}
// We already have this comment, continue.
$data = array('comment_post_ID' => $post_id, 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime($comment['created_time'])), 'comment_author' => $comment['from']['name'], 'comment_author_url' => 'http://www.facebook.com/profile.php?id=' . $comment['from']['id'], 'comment_content' => $comment['message']);
$meta = array('fb_comment_id' => $comment['id'], 'fb_author_id' => $comment['from']['id']);
$data = wp_filter_comment($data);
$comment_id = wp_insert_comment($data);
add_comment_meta($comment_id, 'wdfb_comment', $meta);
if ($this->model->data->get_option('wdfb_comments', 'notify_authors')) {
wp_notify_postauthor($comment_id, 'comment');
}
}
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:31,代码来源:class_wdfb_comments_importer.php
示例8: import_comments
/**
* Import comments from Instagram and load as WP comments for an image and post
*
* @param $access_token
* @param $comments
* @param $image_id
* @param $post_id
* @param $id
* @param bool $sync
*/
public function import_comments($access_token, $comments, $image_id, $post_id, $id, $sync = false)
{
global $wpdb;
if ($comments == '') {
$comments = instagrate_pro()->accounts->get_comments($access_token, $image_id);
$data = array('comments' => isset($comments) ? base64_encode(serialize($comments)) : array());
$where = array('id' => $id);
$wpdb->update(instagrate_pro()->images->get_table_name(), $data, $where);
}
$meta_table = $wpdb->prefix . 'commentmeta';
if (!is_array($comments)) {
return;
}
foreach ($comments as $comment) {
$querystr = "\tSELECT count(*)\n\t\t\t\t\t\t\tFROM {$meta_table} m\n\t\t\t\t\t\t\tWHERE m.meta_key = '_igp_comment_id'\n\t\t\t\t\t\t\tAND m.meta_value = '{$comment->id}'\t";
$exists = $wpdb->get_var($querystr);
if ($exists > 0) {
continue;
}
// set comment data
$data = array('comment_post_ID' => $post_id, 'comment_author' => $comment->from->username, 'comment_author_email' => '@instagram_igp', 'comment_author_url' => 'http://instagram.com/' . $comment->from->username, 'comment_content' => instagrate_pro()->helper->clean_caption($comment->text), 'comment_type' => '', 'comment_parent' => 0, 'user_id' => 0, 'comment_author_IP' => '127.0.0.1', 'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)', 'comment_date' => date('Y-m-d H:i:s', $comment->created_time), 'comment_approved' => Instagrate_Pro_Helper::setting('igpsettings_comments_auto-approve', '0'));
$comment_id = wp_insert_comment($data);
//set comment meta ig comment id
add_comment_meta($comment_id, '_igp_comment_id', $comment->id, true);
//set comment meta with user image url
add_comment_meta($comment_id, '_igp_comment_avatar', $comment->from->profile_picture, true);
}
}
开发者ID:VizualAbstract,项目名称:Marilyn,代码行数:38,代码来源:class-comments.php
示例9: smamo_status_post
function smamo_status_post()
{
$response = array();
// Check om bruger er logget ind
if (!is_user_logged_in()) {
$response['code'] = '403';
$response['error'] = 'Du skal være logget ind for at kunne kommentere.';
wp_die(json_encode($response));
}
// Fang nuværende bruger
$user = wp_get_current_user();
$response['user'] = array('ID' => $user->ID, 'name' => $user->user_login);
// Fang tekst
$msg = esc_textarea($_POST['msg']);
$response['msg'] = $msg;
// fang ID på spørgsmål
$post_id = wp_strip_all_tags($_POST['post_id']);
// Opret ny kommmentar
$time = current_time('mysql');
$data = array('comment_post_ID' => $post_id, 'comment_author' => $user->user_login, 'comment_content' => $msg, 'user_id' => $user->ID, 'comment_date' => $time, 'comment_approved' => 1);
$new = wp_insert_comment($data);
if (is_wp_error($new)) {
$response['code'] = '503';
$response['error'] = $new->get_error_message();
wp_die(json_encode($response));
}
// Send succes tilbage
$response['code'] = 200;
$response['success'] = 'Successfully posted';
wp_die(json_encode($response));
}
开发者ID:JeppeSigaard,项目名称:faaborggym,代码行数:31,代码来源:ajax-status.php
示例10: fre_create_invite
/**
* create a comment with type fre_invite
* @param int $user_id
* @param int $project
* @return int $invite_id
* @since 1.3.1
* @author Dakachi
*/
function fre_create_invite($user_id, $project_id)
{
global $user_ID, $current_user;
$invite_id = wp_insert_comment(array('comment_post_ID' => $project_id, 'comment_author' => $current_user->data->user_login, 'comment_author_email' => $current_user->data->user_email, 'comment_content' => sprintf(__("Invite %s to bid project", 'invites-backend'), get_the_author_meta('display_name', $user_id)), 'comment_type' => 'fre_invite', 'user_id' => $user_ID, 'comment_approved' => 1));
update_comment_meta($invite_id, 'invite', $user_id);
return $invite_id;
}
开发者ID:linniepinski,项目名称:perssistant,代码行数:15,代码来源:invites.php
示例11: create_wp_comment
protected function create_wp_comment($action_id, $message, DateTime $date)
{
$comment_date_gmt = $date->format('Y-m-d H:i:s');
$date->setTimezone(ActionScheduler_TimezoneHelper::get_local_timezone());
$comment_data = array('comment_post_ID' => $action_id, 'comment_date' => $date->format('Y-m-d H:i:s'), 'comment_date_gmt' => $comment_date_gmt, 'comment_author' => self::AGENT, 'comment_content' => $message, 'comment_agent' => self::AGENT, 'comment_type' => self::TYPE);
return wp_insert_comment($comment_data);
}
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:7,代码来源:ActionScheduler_wpCommentLogger.php
示例12: wpSetUpBeforeClass
public static function wpSetUpBeforeClass(WP_UnitTest_Factory $factory)
{
self::$post_id = $factory->post->create();
self::$parent_comment_data = array('comment_post_ID' => self::$post_id, 'comment_author' => 'Test commenter', 'comment_author_url' => 'http://example.com/', 'comment_author_email' => '[email protected]', 'comment_content' => rand_str(100));
self::$parent_comment_id = wp_insert_comment(self::$parent_comment_data);
self::$child_comment_data = array('comment_post_ID' => self::$post_id, 'comment_author' => 'Test commenter 2', 'comment_author_url' => 'http://example.org/', 'comment_author_email' => '[email protected]', 'comment_parent' => self::$parent_comment_id, 'comment_content' => rand_str(100));
self::$child_comment_id = wp_insert_comment(self::$child_comment_data);
}
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:8,代码来源:getComment.php
示例13: test_erroneous_entry_id
public function test_erroneous_entry_id()
{
$comment = wp_insert_comment(array('comment_post_ID' => 1, 'comment_author' => 'test', 'comment_content' => 'this is not a log entry'));
$logger = ActionScheduler::logger();
$entry = $logger->get_entry($comment);
$this->assertEquals('', $entry->get_action_id());
$this->assertEquals('', $entry->get_message());
}
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:8,代码来源:ActionScheduler_wpCommentLogger_Test.php
示例14: setUp
function setUp()
{
parent::setUp();
$this->post_id = $this->factory->post->create();
$this->parent_comment_data = array('comment_post_ID' => $this->post_id, 'comment_author' => 'Test commenter', 'comment_author_url' => 'http://example.com/', 'comment_author_email' => '[email protected]', 'comment_content' => rand_str(100));
$this->parent_comment_id = wp_insert_comment($this->parent_comment_data);
$this->child_comment_data = array('comment_post_ID' => $this->post_id, 'comment_author' => 'Test commenter 2', 'comment_author_url' => 'http://example.org/', 'comment_author_email' => '[email protected]', 'comment_parent' => $this->parent_comment_id, 'comment_content' => rand_str(100));
$this->child_comment_id = wp_insert_comment($this->child_comment_data);
}
开发者ID:boonebgorges,项目名称:wp,代码行数:9,代码来源:getComment.php
示例15: save_subscription_data
/**
* Create a data comment with data for a potential new subscriber.
*
* @since 1.0.0
*
* @param Prompt_Interface_Subscribable[]|Prompt_Interface_Subscribable $lists
* @param string $email
* @param array $user_data
*/
public function save_subscription_data($lists, $email, $user_data = array())
{
$remote_address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
$comment_id = wp_insert_comment(array('comment_author_email' => $email, 'comment_author_IP' => preg_replace('/[^0-9a-fA-F:., ]/', '', $remote_address), 'comment_agent' => 'Postmatic/' . Prompt_Core::version(), 'comment_content' => serialize($lists), 'comment_type' => self::$comment_type, 'comment_approved' => 'Postmatic'));
if (!empty($user_data)) {
add_comment_meta($comment_id, self::$user_data_meta_key, $user_data);
}
$this->keys = array($comment_id);
}
开发者ID:postmatic,项目名称:beta-dist,代码行数:18,代码来源:register-subscribe-command.php
示例16: theme_comment_form
function theme_comment_form()
{
$result = array();
$result["isOk"] = true;
if ($_POST["name"] != "" && $_POST["email"] != "" && preg_match("#^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*(\\.[a-zA-Z]{2,4})\$#", $_POST["email"]) && $_POST["message"] != "") {
$values = array("name" => $_POST["name"], "email" => $_POST["email"], "website" => $_POST["website"], "message" => $_POST["message"]);
if ((bool) ini_get("magic_quotes_gpc")) {
$values = array_map("stripslashes", $values);
}
$values = array_map("htmlspecialchars", $values);
$time = current_time('mysql');
$data = array('comment_post_ID' => (int) $_POST['post_id'], 'comment_author' => $values['name'], 'comment_author_email' => $values['email'], 'comment_author_url' => $values['website'] != __("Website (optional)", 'medicenter') ? $values['website'] : "", 'comment_content' => $values['message'], 'comment_parent' => (int) $_POST['parent_comment_id'], 'comment_date' => $time, 'comment_approved' => (int) get_option('comment_moderation') ? 0 : 1, 'comment_parent' => (int) $_POST['comment_parent_id']);
if ($comment_id = wp_insert_comment($data)) {
$result["submit_message"] = __("Your comment has been added", 'medicenter');
if (get_option('comments_notify')) {
wp_notify_postauthor($comment_id);
}
//get post comments
//post
query_posts("p=" . (int) $_POST['post_id'] . "&post_type=" . $_POST["post_type"]);
if (have_posts()) {
the_post();
ob_start();
$result['comment_id'] = $comment_id;
if ((int) $_POST['comment_parent_id'] == 0) {
global $wpdb;
$query = "SELECT COUNT(*) AS count FROM {$wpdb->comments} WHERE comment_approved = 1 AND comment_post_ID = " . get_the_ID() . " AND comment_parent = 0";
$parents = $wpdb->get_row($query);
$_GET["paged"] = ceil($parents->count / 5);
$result["change_url"] = "#page-" . $_GET["paged"];
} else {
$_GET["paged"] = (int) $_POST["paged"];
}
comments_template();
$result['html'] = ob_get_contents();
ob_end_clean();
}
} else {
$result["isOk"] = false;
$result["submit_message"] = __("Error while adding comment", 'medicenter');
}
} else {
$result["isOk"] = false;
if ($_POST["name"] == "" || $_POST["name"] == __("Your name", 'medicenter')) {
$result["error_name"] = __("Please enter your name", 'medicenter');
}
if ($_POST["email"] == "" || $_POST["email"] == __("Your email", 'medicenter') || !preg_match("#^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*(\\.[a-zA-Z]{2,4})\$#", $_POST["email"])) {
$result["error_email"] = __("Please enter valid e-mail", 'medicenter');
}
if ($_POST["message"] == "" || $_POST["message"] == __("Message", 'medicenter')) {
$result["error_message"] = __("Please enter your message", 'medicenter');
}
}
echo @json_encode($result);
exit;
}
开发者ID:farkbarn,项目名称:hcudamp,代码行数:56,代码来源:comments-functions.php
示例17: do_save
public function do_save($return_val, $data, $module)
{
$comment_id = wp_insert_comment($data);
if (!is_numeric($comment_id)) {
return false;
}
// Flag the Object as FakerPress
update_post_meta($comment_id, self::$flag, 1);
return $comment_id;
}
开发者ID:vassix,项目名称:fakerpress,代码行数:10,代码来源:comment.php
示例18: test_trash_comment
function test_trash_comment()
{
$this->make_user_by_role('administrator');
$post_id = self::factory()->post->create();
$comment_data = array('comment_post_ID' => $post_id, 'comment_author' => 'Test commenter', 'comment_author_url' => 'http://example.com/', 'comment_author_email' => '[email protected]', 'comment_content' => rand_str(100), 'comment_approved' => '1');
$comment_id = wp_insert_comment($comment_data);
$this->assertEquals('1', get_comment($comment_id)->comment_approved);
$this->myxmlrpcserver->wp_editComment(array(1, 'administrator', 'administrator', $comment_id, array('status' => 'trash')));
$this->assertEquals('trash', get_comment($comment_id)->comment_approved);
}
开发者ID:dd32,项目名称:wordpress.develop,代码行数:10,代码来源:editComment.php
示例19: do_save
public function do_save($return_val, $params, $metas, $module)
{
$comment_id = wp_insert_comment($params);
if (!is_numeric($comment_id)) {
return false;
}
foreach ($metas as $key => $value) {
update_comment_meta($comment_id, $key, $value);
}
return $comment_id;
}
开发者ID:juanfra,项目名称:fakerpress,代码行数:11,代码来源:comment.php
示例20: _insertTestData
protected function _insertTestData()
{
$post_id_a = wp_insert_post(array('post_status' => 'publish', 'post_type' => 'post', 'post_author' => 1, 'post_parent' => 0, 'menu_order' => 0, 'post_content_filtered' => '', 'post_excerpt' => 'This is the excerpt.', 'post_content' => 'This is the content.', 'post_title' => 'Hello World A!', 'post_date' => '2013-04-30 20:33:36', 'post_date_gmt' => '2013-04-30 20:33:36', 'comment_status' => 'open'));
$post_id_b = wp_insert_post(array('post_status' => 'publish', 'post_type' => 'post', 'post_author' => 1, 'post_parent' => 0, 'menu_order' => 0, 'post_content_filtered' => '', 'post_excerpt' => 'This is the excerpt 2.', 'post_content' => 'This is the content 2.', 'post_title' => 'Hello World A!', 'post_date' => '2013-04-30 20:33:36', 'post_date_gmt' => '2013-04-30 20:33:36', 'comment_status' => 'open'));
$comment_approved_minus_10 = wp_insert_comment(array('comment_post_ID' => $post_id_a, 'comment_author' => 'Some Guy', 'comment_author_email' => '[email protected]', 'comment_content' => 'This is my comment text', 'user_id' => 1, 'comment_date' => gmdate('Y-m-d H:i:s', time() - 10 * MINUTE_IN_SECONDS + get_option('gmt_offset') * HOUR_IN_SECONDS), 'comment_date_gmt' => gmdate('Y-m-d H:i:s', time() - 10 * MINUTE_IN_SECONDS), 'comment_approved' => 1));
$comment_approved_minus_20 = wp_insert_comment(array('comment_post_ID' => $post_id_a, 'comment_author' => 'Some Guy', 'comment_author_email' => '[email protected]', 'comment_content' => 'This is my earlier comment text', 'user_id' => 1, 'comment_date' => gmdate('Y-m-d H:i:s', time() - 20 * MINUTE_IN_SECONDS + get_option('gmt_offset') * HOUR_IN_SECONDS), 'comment_date_gmt' => gmdate('Y-m-d H:i:s', time() - 20 * MINUTE_IN_SECONDS), 'comment_approved' => 1));
$comment_approved_no_user = wp_insert_comment(array('comment_post_ID' => $post_id_a, 'comment_author' => 'Some Guy 3', 'comment_author_email' => '[email protected]', 'comment_content' => 'This is another comment text', 'user_id' => 1, 'comment_date' => gmdate('Y-m-d H:i:s', time() - 20 * MINUTE_IN_SECONDS + get_option('gmt_offset') * HOUR_IN_SECONDS), 'comment_date_gmt' => gmdate('Y-m-d H:i:s', time() - 20 * MINUTE_IN_SECONDS), 'comment_approved' => 1));
$comment_pending_minus_20 = wp_insert_comment(array('comment_post_ID' => $post_id_a, 'comment_author' => 'Some Guy 2', 'comment_author_email' => '[email protected]', 'comment_content' => 'This is my pending comment text', 'user_id' => null, 'comment_date' => gmdate('Y-m-d H:i:s', time() - 20 * MINUTE_IN_SECONDS + get_option('gmt_offset') * HOUR_IN_SECONDS), 'comment_date_gmt' => gmdate('Y-m-d H:i:s', time() - 20 * MINUTE_IN_SECONDS), 'comment_approved' => 0));
$comment_approved_post_b = wp_insert_comment(array('comment_post_ID' => $post_id_b, 'comment_author' => 'Some Guy 2', 'comment_author_email' => '[email protected]', 'comment_content' => 'This is my pending comment text', 'user_id' => null, 'comment_date' => gmdate('Y-m-d H:i:s', time() - 20 * MINUTE_IN_SECONDS + get_option('gmt_offset') * HOUR_IN_SECONDS), 'comment_date_gmt' => gmdate('Y-m-d H:i:s', time() - 20 * MINUTE_IN_SECONDS), 'comment_approved' => 1));
return compact('post_id_a', 'post_id_b', 'comment_approved_minus_10', 'comment_approved_minus_20', 'comment_pending_minus_20', 'comment_approved_post_b');
}
开发者ID:katymdc,项目名称:thermal-api,代码行数:11,代码来源:test-Comments.php
注:本文中的wp_insert_comment函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论