本文整理汇总了PHP中delete_comment_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_comment_meta函数的具体用法?PHP delete_comment_meta怎么用?PHP delete_comment_meta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_comment_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_comment
function update_comment($comment_id)
{
$comment = get_comment($comment_id);
delete_comment_meta($comment_id, $this->meta_key);
$terms = $this->update_comment_terms($comment_id, $comment);
foreach ($terms as $term) {
add_comment_meta($comment_id, $this->meta_key, $term);
}
$this->update_terms($comment->comment_post_ID);
}
示例2: loaded
/**
* Loaded, check request
*/
public function loaded()
{
// check to delete att
if (isset($_GET['deleteAtt']) && $_GET['deleteAtt'] == '1') {
if (isset($_GET['c']) && is_numeric($_GET['c'])) {
WPLMS_Assignments::deleteAttachment($_GET['c']);
delete_comment_meta($_GET['c'], 'attachmentId');
add_action('admin_notices', array($this, 'mynotice'));
}
}
}
示例3: update_comment
function update_comment($comment_id)
{
if (!$this->should_process_terms()) {
return;
}
$comment = get_comment($comment_id);
delete_comment_meta($comment_id, $this->meta_key);
$terms = $this->update_comment_terms($comment_id, $comment);
foreach ($terms as $term) {
add_comment_meta($comment_id, $this->meta_key, $term);
}
$this->update_terms($comment->comment_post_ID);
}
示例4: loaded
/**
* Loaded, check request
*/
public function loaded()
{
// check to delete att
if (isset($_GET['deleteAtt']) && $_GET['deleteAtt'] == '1') {
if (isset($_GET['c']) && is_numeric($_GET['c'])) {
wpCommentAttachment::deleteAttachment($_GET['c']);
delete_comment_meta($_GET['c'], 'attachmentId');
add_action('admin_notices', function () {
echo "<div class='updated'><p>Comment Attachment deleted.</p></div>";
});
}
}
}
示例5: wp_set_comment_status
function wp_set_comment_status($comment_id, $status)
{
global $wpdb;
if ($status != '1' && $status != 'approve') {
return;
}
if (!empty($_POST['probation'])) {
update_comment_meta($comment_id, self::meta_key, '1');
} else {
$commentdata = get_comment($comment_id);
$comment_ids = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_author = %s AND comment_author_email = %s AND comment_approved = '1'", $commentdata->comment_author, $commentdata->comment_author_email));
foreach ($comment_ids as $comment_id) {
delete_comment_meta($comment_id, self::meta_key);
}
}
}
示例6: bp_blogs_remove_activity_meta_for_trashed_comments
/**
* When a post is trashed, remove each comment's associated activity meta.
*
* When a post is trashed and later untrashed, we currently don't reinstate
* activity items for these comments since their activity entries are already
* deleted when initially trashed.
*
* Since these activity entries are deleted, we need to remove the deleted
* activity comment IDs from each comment's meta when a post is trashed.
*
* @since BuddyPress (2.0.0)
*
* @param int $post_id The post ID
* @param array $comments Array of comment statuses. The key is comment ID, the
* value is the $comment->comment_approved value.
*/
function bp_blogs_remove_activity_meta_for_trashed_comments( $post_id = 0, $comments = array() ) {
if ( ! empty( $comments ) ) {
foreach ( array_keys( $comments ) as $comment_id ) {
delete_comment_meta( $comment_id, 'bp_activity_comment_id' );
}
}
}
示例7: save_comment_meta
/**
* Save a comment meta
*
* @param int $id Comment ID
* @param array $comment_meta (optional) All meta to be saved (set value to null to delete)
* @param bool $strict (optional) Whether to delete previously saved meta not in $comment_meta
* @param array $fields (optional) The array of fields and their options, for further processing with
*
* @return int Comment ID
*
* @since 2.0
*/
public function save_comment_meta($id, $comment_meta = null, $strict = false, $fields = array())
{
$simple_tableless_objects = PodsForm::simple_tableless_objects();
$conflicted = pods_no_conflict_check('comment');
if (!$conflicted) {
pods_no_conflict_on('comment');
}
if (!is_array($comment_meta)) {
$comment_meta = array();
}
$id = (int) $id;
$meta = get_comment_meta($id);
foreach ($comment_meta as $meta_key => $meta_value) {
if (null === $meta_value) {
$old_meta_value = '';
if (isset($meta[$meta_key])) {
$old_meta_value = $meta[$meta_key];
}
delete_comment_meta($id, $meta_key, $old_meta_value);
} else {
$simple = false;
if (isset($fields[$meta_key])) {
$field_data = $fields[$meta_key];
$simple = 'pick' == $field_data['type'] && in_array(pods_var('pick_object', $field_data), $simple_tableless_objects);
}
if ($simple) {
delete_comment_meta($id, $meta_key);
if (!is_array($meta_value)) {
$meta_value = array($meta_value);
}
foreach ($meta_value as $value) {
add_comment_meta($id, $meta_key, $value);
}
} else {
update_comment_meta($id, $meta_key, $meta_value);
}
}
}
if ($strict) {
foreach ($meta as $meta_key => $meta_value) {
if (!isset($comment_meta[$meta_key])) {
delete_comment_meta((int) $id, $meta_key, $comment_meta[$meta_key]);
}
}
}
if (!$conflicted) {
pods_no_conflict_off('comment');
}
return $id;
}
示例8: wp_scheduled_delete
/**
* Permanently delete comments or posts of any type that have held a status
* of 'trash' for the number of days defined in EMPTY_TRASH_DAYS.
*
* The default value of `EMPTY_TRASH_DAYS` is 30 (days).
*
* @since 2.9.0
*
* @global wpdb $wpdb
*/
function wp_scheduled_delete()
{
global $wpdb;
$delete_timestamp = time() - DAY_IN_SECONDS * EMPTY_TRASH_DAYS;
$posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
foreach ((array) $posts_to_delete as $post) {
$post_id = (int) $post['post_id'];
if (!$post_id) {
continue;
}
$del_post = get_post($post_id);
if (!$del_post || 'trash' != $del_post->post_status) {
delete_post_meta($post_id, '_wp_trash_meta_status');
delete_post_meta($post_id, '_wp_trash_meta_time');
} else {
wp_delete_post($post_id);
}
}
$comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
foreach ((array) $comments_to_delete as $comment) {
$comment_id = (int) $comment['comment_id'];
if (!$comment_id) {
continue;
}
$del_comment = get_comment($comment_id);
if (!$del_comment || 'trash' != $del_comment->comment_approved) {
delete_comment_meta($comment_id, '_wp_trash_meta_time');
delete_comment_meta($comment_id, '_wp_trash_meta_status');
} else {
wp_delete_comment($del_comment);
}
}
}
示例9: remove_comment_notification
/**
* delete notification of a comment perticular commnet
* @param int $comment_id
*/
function remove_comment_notification($comment_id)
{
$comment_notification_id = (int) get_comment_meta($comment_id, 'comment_notification_id', true);
BP_Notifications_Notification::delete(array('id' => $comment_notification_id));
delete_comment_meta($comment_id, 'comment_notification_id');
}
示例10: cron_recheck
public static function cron_recheck()
{
global $wpdb;
$api_key = self::get_api_key();
$status = self::verify_key($api_key);
if (get_option('akismet_alert_code') || $status == 'invalid') {
// since there is currently a problem with the key, reschedule a check for 6 hours hence
wp_schedule_single_event(time() + 21600, 'akismet_schedule_cron_recheck');
do_action('akismet_scheduled_recheck', 'key-problem-' . get_option('akismet_alert_code') . '-' . $status);
return false;
}
delete_option('akismet_available_servers');
$comment_errors = $wpdb->get_col("SELECT comment_id FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'\tLIMIT 100");
load_plugin_textdomain('akismet');
foreach ((array) $comment_errors as $comment_id) {
// if the comment no longer exists, or is too old, remove the meta entry from the queue to avoid getting stuck
$comment = get_comment($comment_id);
if (!$comment || strtotime($comment->comment_date_gmt) < strtotime("-15 days")) {
delete_comment_meta($comment_id, 'akismet_error');
delete_comment_meta($comment_id, 'akismet_delayed_moderation_email');
continue;
}
add_comment_meta($comment_id, 'akismet_rechecking', true);
$status = self::check_db_comment($comment_id, 'retry');
$event = '';
if ($status == 'true') {
$event = 'cron-retry-spam';
} elseif ($status == 'false') {
$event = 'cron-retry-ham';
}
// If we got back a legit response then update the comment history
// other wise just bail now and try again later. No point in
// re-trying all the comments once we hit one failure.
if (!empty($event)) {
delete_comment_meta($comment_id, 'akismet_error');
self::update_comment_history($comment_id, '', $event);
update_comment_meta($comment_id, 'akismet_result', $status);
// make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.
$comment = get_comment($comment_id);
if ($comment && 'unapproved' == wp_get_comment_status($comment_id)) {
if ($status == 'true') {
wp_spam_comment($comment_id);
} elseif ($status == 'false') {
// comment is good, but it's still in the pending queue. depending on the moderation settings
// we may need to change it to approved.
if (check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type)) {
wp_set_comment_status($comment_id, 1);
} else {
if (get_comment_meta($comment_id, 'akismet_delayed_moderation_email', true)) {
wp_notify_moderator($comment_id);
}
}
}
}
delete_comment_meta($comment_id, 'akismet_delayed_moderation_email');
} else {
// If this comment has been pending moderation for longer than MAX_DELAY_BEFORE_MODERATION_EMAIL,
// send a moderation email now.
if (intval(gmdate('U')) - strtotime($comment->comment_date_gmt) < self::MAX_DELAY_BEFORE_MODERATION_EMAIL) {
delete_comment_meta($comment_id, 'akismet_delayed_moderation_email');
wp_notify_moderator($comment_id);
}
delete_comment_meta($comment_id, 'akismet_rechecking');
wp_schedule_single_event(time() + 1200, 'akismet_schedule_cron_recheck');
do_action('akismet_scheduled_recheck', 'check-db-comment-' . $status);
return;
}
delete_comment_meta($comment_id, 'akismet_rechecking');
}
$remaining = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE meta_key = 'akismet_error'");
if ($remaining && !wp_next_scheduled('akismet_schedule_cron_recheck')) {
wp_schedule_single_event(time() + 1200, 'akismet_schedule_cron_recheck');
do_action('akismet_scheduled_recheck', 'remaining');
}
}
示例11: hq_unspam_comment
/**
* Removes a comment from the Spam
*
* @since 0.0.1
*
* @param int $comment_id Comment ID.
* @return bool True on success, false on failure.
*/
function hq_unspam_comment($comment_id)
{
if (!(int) $comment_id) {
return false;
}
/**
* Fires immediately before a comment is unmarked as Spam.
*
* @since 0.0.1
*
* @param int $comment_id The comment ID.
*/
do_action('unspam_comment', $comment_id);
$status = (string) get_comment_meta($comment_id, '_hq_trash_meta_status', true);
if (empty($status)) {
$status = '0';
}
if (hq_set_comment_status($comment_id, $status)) {
delete_comment_meta($comment_id, '_hq_trash_meta_status');
/**
* Fires immediately after a comment is unmarked as Spam.
*
* @since 0.0.1
*
* @param int $comment_id The comment ID.
*/
do_action('unspammed_comment', $comment_id);
return true;
}
return false;
}
示例12: wp_set_comment_status
/**
* Sets the comment to be approved.
*
* @wp-action wp_set_comment_status
* @param int $comment_id
* @param string $comment_status
* @return void
*/
public function wp_set_comment_status($comment_id, $comment_status)
{
if ($comment_status == 'approve') {
global $wpdb;
$results = $wpdb->get_results($wpdb->prepare("\n\t\t\t\tSELECT user_id, m.meta_value\n\t\t\t\t FROM {$wpdb->commentmeta} AS m\n\t\t\t\t JOIN {$wpdb->comments} AS c\n\t\t\t\t ON m.comment_id = c.comment_ID\n\t\t\t\t WHERE m.meta_key = %s\n\t\t\t\t AND m.comment_id = %s\n\t\t\t", 'social_to_broadcast', $comment_id));
if (!empty($results)) {
$result = reset($results);
$accounts = get_user_meta($result->user_id, 'social_accounts', true);
if (!empty($accounts)) {
foreach ($accounts as $service => $accounts) {
$service = $this->service($service);
if ($service !== false) {
$account = null;
if (!$service->account_exists($result->meta_value)) {
foreach ($accounts as $id => $account) {
if ($id == $result->meta_value) {
$class = 'Social_Service_' . $service->key() . '_Account';
$account = new $class($account);
break;
}
}
} else {
$account = $service->account($result->meta_value);
}
if ($account !== null) {
Social::log(sprintf(__('Broadcasting comment #%s to %s using account #%s.', 'social'), $comment_id, $service->title(), $account->id()));
$comment = get_comment($comment_id);
$in_reply_to_status_id = get_comment_meta($comment_id, 'social_in_reply_to_status_id', true);
$args = array();
if (!empty($in_reply_to_status_id)) {
$args['in_reply_to_status_id'] = $in_reply_to_status_id;
delete_comment_meta($comment_id, 'social_in_reply_to_status_id');
}
$output = $service->format_comment_content($comment, Social::option('comment_broadcast_format'));
$response = $service->broadcast($account, $output, $args, null, $comment_id);
if ($response === false || $response->body()->result !== 'success') {
wp_delete_comment($comment_id);
Social::log(sprintf(__('Error: Broadcast comment #%s to %s using account #%s, please go back and try again.', 'social'), $comment_id, $service->title(), $account->id()));
}
$wpdb->query($wpdb->prepare("\n\t\t\t\t\t\t\t\t\tUPDATE {$wpdb->comments}\n\t\t\t\t\t\t\t\t\t SET comment_type = %s\n\t\t\t\t\t\t\t\t\t WHERE comment_ID = %s\n\t\t\t\t\t\t\t\t", 'social-' . $service->key(), $comment_id));
$this->set_comment_aggregated_id($comment_id, $service->key(), $response->body()->response);
// Feed posts return id with property, comment posts return raw id
if (isset($response->body()->response->id)) {
add_comment_meta($comment_ID, 'social_status_id', addslashes_deep($response->body()->response->id), true);
} else {
add_comment_meta($comment_ID, 'social_status_id', addslashes_deep($response->body()->response), true);
}
update_comment_meta($comment_id, 'social_raw_data', addslashes_deep(base64_encode(json_encode($response->body()->response))));
Social::log(sprintf(__('Broadcasting comment #%s to %s using account #%s COMPLETE.', 'social'), $comment_id, $service->title(), $account->id()));
}
}
}
}
delete_comment_meta($comment_id, 'social_to_broadcast');
}
}
}
示例13: delete_all_item_data
/**
* Deletes all (meta) checked states for the current/given comment.
*
* @param int $comment_id (optional)
*/
function delete_all_item_data( $comment_id = 0 ) {
$comment_id = $this->get_object_id( $comment_id );
$task_id_meta_keys = $this->get_all_item_data( $comment_id );
foreach ( $task_id_meta_keys as $task_id_meta_key ) {
delete_comment_meta( $comment_id, $task_id_meta_key );
}
}
示例14: delete_user_data
/**
* Delete the Sensei user data for the given key, Sensei post type and user combination.
*
* @param int $data_key
* @param int $post_id
* @param int $user_id
*
* @return bool $deleted
*/
public static function delete_user_data($data_key, $post_id, $user_id)
{
$deleted = true;
if (!($user_id > 0)) {
$user_id = get_current_user_id();
}
$supported_post_types = array('course', 'lesson');
$post_type = get_post_type($post_id);
if (empty($post_id) || empty($data_key) || !is_int($post_id) || !(intval($post_id) > 0) || !(intval($user_id) > 0) || !get_userdata($user_id) || !in_array($post_type, $supported_post_types)) {
return false;
}
// check if there and existing Sensei status on this post type if not create it
// and get the activity ID
$status_function = 'user_' . $post_type . '_status';
$sensei_user_status = self::$status_function($post_id, $user_id);
if (!isset($sensei_user_status->comment_ID)) {
return false;
}
$sensei_user_activity_id = $sensei_user_status->comment_ID;
$deleted = delete_comment_meta($sensei_user_activity_id, $data_key);
return $deleted;
}
示例15: comment_status
/**
Action subscribe requests made on comment forms when comments are approved
*/
function comment_status($comment_ID = 0)
{
global $wpdb;
// get meta data
$subscribe = get_comment_meta($comment_ID, 's2_comment_request', true);
if ($subscribe != '1') {
return $comment_ID;
}
// Retrieve the information about the comment
$sql = $wpdb->prepare("SELECT comment_author_email, comment_approved FROM {$wpdb->comments} WHERE comment_ID=%s LIMIT 1", $comment_ID);
$comment = $wpdb->get_row($sql, OBJECT);
if (empty($comment)) {
return $comment_ID;
}
switch ($comment->comment_approved) {
case '0':
// Unapproved
break;
case '1':
// Approved
$is_public = $this->is_public($comment->comment_author_email);
if ($is_public == 0) {
$this->toggle($comment->comment_author_email);
}
$is_registered = $this->is_registered($comment->comment_author_email);
if (!$is_public && !$is_registered) {
$this->add($comment->comment_author_email, true);
}
delete_comment_meta($comment_ID, 's2_comment_request');
break;
default:
// post is trash, spam or deleted
delete_comment_meta($comment_ID, 's2_comment_request');
break;
}
return $comment_ID;
}