本文整理汇总了PHP中wp_delete_comment函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_delete_comment函数的具体用法?PHP wp_delete_comment怎么用?PHP wp_delete_comment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_delete_comment函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
/**
* Use this method to prevent excluding something that was not configured by FakerPress
*
* @param array|int|\WP_Comment $comment The ID for the Post or the Object
* @return bool
*/
public static function delete($comment)
{
if (is_array($comment)) {
$deleted = array();
foreach ($comment as $id) {
$id = $id instanceof \WP_Comment ? $id->comment_ID : $id;
if (!is_numeric($id)) {
continue;
}
$deleted[$id] = self::delete($id);
}
return $deleted;
}
if (is_numeric($comment)) {
$comment = \WP_Comment::get_instance($comment);
}
if (!$comment instanceof \WP_Comment) {
return false;
}
$flag = (bool) get_comment_meta($comment->comment_ID, self::$flag, true);
if (true !== $flag) {
return false;
}
return wp_delete_comment($comment->comment_ID, true);
}
示例2: delete_comment
public function delete_comment()
{
$args = $args = explode('-', sanitize_text_field($_REQUEST['args']));
if (!ap_user_can_delete_comment($args[0])) {
$result = array('status' => false, 'message' => __('You do not have permission to delete this comment', 'ap'));
die(json_encode($result));
}
$action = 'delete-comment-' . $args[0];
if (wp_verify_nonce($args[1], $action)) {
$comment = get_comment($args[0]);
$delete = wp_delete_comment($args[0], true);
if ($delete) {
$post_type = get_post_type($comment->comment_post_ID);
do_action('ap_after_delete_comment', $comment, $post_type);
if ($post_type == 'question') {
ap_do_event('delete_comment', $comment, 'question');
} elseif ($post_type == 'answer') {
ap_do_event('delete_comment', $comment, 'answer');
}
}
$result = array('status' => true, 'message' => __('Comment deleted successfully', 'ap'));
die(json_encode($result));
}
die;
}
示例3: rotary_set_default_pages
function rotary_set_default_pages()
{
wp_delete_post(1);
//delete sample post
wp_delete_comment(1);
//delete sample comment
wp_delete_post(2);
//delete sample page
if (!get_page_by_title('Member Information')) {
$args = array('post_name' => 'member-information', 'post_title' => 'Member Information', 'post_type' => 'page', 'post_status' => 'publish');
wp_insert_post($args);
}
if (!get_page_by_title('About')) {
$args = array('post_name' => 'about', 'post_title' => 'About', 'post_type' => 'page', 'post_status' => 'publish');
wp_insert_post($args);
}
if (!get_page_by_title('Home')) {
$args = array('post_name' => 'home', 'post_title' => 'Home', 'post_type' => 'page', 'post_status' => 'publish');
wp_insert_post($args);
}
if (!get_page_by_title('Posts')) {
$args = array('post_name' => 'posts', 'post_title' => 'Posts', 'post_type' => 'page', 'post_status' => 'publish');
wp_insert_post($args);
}
}
示例4: bp_groupblog_blog_defaults
function bp_groupblog_blog_defaults($blog_id)
{
global $bp, $wp_rewrite;
// only apply defaults to groupblog blogs
if (bp_is_groups_component()) {
switch_to_blog($blog_id);
// get the site options
$options = get_site_option('bp_groupblog_blog_defaults_options');
foreach ((array) $options as $key => $value) {
update_option($key, $value);
}
// override default themes
if (!empty($options['theme'])) {
// we want something other than the default theme
$values = explode("|", $options['theme']);
switch_theme($values[0], $values[1]);
}
// groupblog bonus options
if (strlen($options['default_cat_name']) > 0) {
global $wpdb;
$cat = $options['default_cat_name'];
$slug = str_replace(' ', '-', strtolower($cat));
$results = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->terms} SET name = %s, slug = %s WHERE term_id = 1", $cat, $slug));
}
if (strlen($options['default_link_cat']) > 0) {
global $wpdb;
$cat = $options['default_link_cat'];
$slug = str_replace(' ', '-', strtolower($cat));
$results = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->terms} SET name = %s, slug = %s WHERE term_id = 2", $cat, $slug));
}
if (isset($options['delete_first_post']) && $options['delete_first_post'] == 1) {
global $wpdb;
$statement = "UPDATE {$wpdb->posts} SET post_status = 'draft' WHERE id = 1";
$results = $wpdb->query($statement);
}
if (isset($options['delete_first_comment']) && $options['delete_first_comment'] == 1) {
wp_delete_comment(1);
}
if ($options['delete_blogroll_links'] == 1) {
wp_delete_link(1);
//delete Wordpress.com blogroll link
wp_delete_link(2);
//delete Wordpress.org blogroll link
}
if ($options['redirectblog'] == 2) {
$blog_page = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_name' => $options['pageslug'], 'post_title' => $options['pagetitle'], 'post_type' => 'page', 'post_content' => __('<p><strong>This page has been created automatically by the BuddyPress GroupBlog plugin.</strong></p><p>Please contact the site admin if you see this message instead of your blog posts. Possible solution: please advise your site admin to create the <a href="http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates">page template</a> needed for the BuddyPress GroupBlog plugin.<p>', 'groupblog'));
$blog_page_id = wp_insert_post($blog_page);
if ($blog_page_id) {
add_post_meta($blog_page_id, '_wp_page_template', 'blog.php');
}
add_post_meta($blog_page_id, 'created_by_groupblog_dont_change', '1');
// Set the Blog Reading Settings to load the template page as front page
if ($options['deep_group_integration'] == 1) {
update_option('show_on_front', 'page');
update_option('page_on_front', $blog_page_id);
}
}
restore_current_blog();
}
}
示例5: wpTearDownAfterClass
public static function wpTearDownAfterClass()
{
foreach (self::$comments as $c) {
wp_delete_comment($c, true);
}
wp_delete_post(self::$p, true);
}
示例6: delete_wrapped_object
/**
* Delete the comment corresponding to this container.
* This will actually move the comment to the trash in newer versions of WP.
*
* @return bool|WP_error
*/
function delete_wrapped_object()
{
if (wp_delete_comment($this->container_id)) {
return true;
} else {
return new WP_Error('delete_failed', sprintf(__('Failed to delete comment %d', 'broken-link-checker'), $this->container_id));
}
}
示例7: delete_comment_sync
function delete_comment_sync($activity_id, $comment_id)
{
global $wpdb;
$comment_id = $wpdb->get_var($wpdb->prepare("select comment_id from {$wpdb->commentmeta} where meta_key = 'activity_id' and meta_value=%s", $comment_id));
if ($comment_id) {
wp_delete_comment($comment_id, true);
}
}
示例8: wpTearDownAfterClass
public static function wpTearDownAfterClass()
{
foreach (self::$comment_ids as $comment_id) {
wp_delete_comment($comment_id, true);
}
wp_delete_post(self::$comment_post->ID, true);
wp_delete_post(self::$draft_post->ID, true);
}
示例9: test_delete_comment_deletes_data
public function test_delete_comment_deletes_data()
{
$this->assertEquals(1, $this->server_replica_storage->comment_count('approve'));
wp_delete_comment($this->comment->comment_ID, true);
$this->client->do_sync();
// there should be no comments at all
$this->assertEquals(0, $this->server_replica_storage->comment_count('approve'));
}
示例10: delete
/**
* Delete a comment.
*
* @synopsis <id> [--force]
*/
public function delete($args, $assoc_args)
{
list($comment_id) = $args;
if (wp_delete_comment($comment_id, isset($assoc_args['force']))) {
WP_CLI::success("Deleted comment {$comment_id}.");
} else {
WP_CLI::error("Failed deleting comment {$comment_id}");
}
}
示例11: set_defaults
/**
* Set default options
*/
function set_defaults()
{
// Update options to wpdp
foreach ($this->default_options as $name => $value) {
update_option($name, $value);
}
// Delete default post & comment
wp_delete_post(1, true);
wp_delete_comment(1);
}
示例12: delete
/**
* Delete a comment
*
* Example: wp comment delete 15 --force
*
* @param array $args}
* @param array $assoc_args
*/
public function delete($args, $assoc_args)
{
$comment_id = WP_CLI::get_numeric_arg($args, 0, "Comment ID");
// Boolean $force parameter to bypass trash and really delete
$force = isset($assoc_args['force']) ? true : false;
if (wp_delete_comment($comment_id, $force)) {
WP_CLI::success("Deleted comment {$comment_id}.");
} else {
WP_CLI::error("Failed deleting comment {$comment_id}");
}
}
示例13: ecs_delete_comment
function ecs_delete_comment()
{
$return_val = 'false';
if (is_numeric($_POST['comment_id'])) {
$delete_comment = wp_delete_comment($_POST['comment_id'], true);
if ($delete_comment) {
$return_val = 'true';
}
}
echo $return_val;
die;
}
示例14: delete
/**
* Delete a comment
*
* @param int $comment_id
* @param bool $force_delete
*/
function delete($comment_id, $force_delete = false)
{
do_action('cpm_comment_delete', $comment_id, $force_delete);
//delete any file attached to it
$files = get_comment_meta($comment_id, '_files', true);
if ($files) {
foreach ($files as $file_id) {
$this->delete_file($file_id);
}
}
//now delete the comment
wp_delete_comment($comment_id, $force_delete);
}
示例15: redirect_fail_captcha_comment
/**
* Add query string to the comment redirect location
*
* @param $location string location to redirect to after comment
* @param $comment object comment object
*
* @return string
*/
public static function redirect_fail_captcha_comment($location, $comment)
{
if (!empty(self::$captcha_error)) {
// delete the failed captcha comment
wp_delete_comment(absint($comment->comment_ID));
// add failed query string for @parent::display_captcha to display error message
$location = add_query_arg('captcha', 'failed', $location);
// remove the obnoxious comment string i.e comment-15
$deleted_comment_id = strstr($location, '#');
$location = str_replace($deleted_comment_id, '#comments', $location);
}
return $location;
}