• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_delete_comment函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_delete_comment函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_delete_comment函数的具体用法?PHP wp_delete_comment怎么用?PHP wp_delete_comment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_delete_comment函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
 }
开发者ID:arobbins,项目名称:sblog,代码行数:31,代码来源:comment.php


示例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;
 }
开发者ID:Byrlyne,项目名称:anspress,代码行数:25,代码来源:form.php


示例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);
    }
}
开发者ID:nmedia82,项目名称:rotary,代码行数:25,代码来源:admin-options.php


示例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();
    }
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:60,代码来源:bp-groupblog-admin.php


示例5: wpTearDownAfterClass

 public static function wpTearDownAfterClass()
 {
     foreach (self::$comments as $c) {
         wp_delete_comment($c, true);
     }
     wp_delete_post(self::$p, true);
 }
开发者ID:nkeat12,项目名称:dv,代码行数:7,代码来源:getCommentLink.php


示例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));
     }
 }
开发者ID:slaFFik,项目名称:l10n-ru,代码行数:14,代码来源:comment.php


示例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);
     }
 }
开发者ID:fs-contributor,项目名称:rtMedia,代码行数:8,代码来源:RTMediaBuddyPressActivity.php


示例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);
 }
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:8,代码来源:ReplytoComment.php


示例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'));
 }
开发者ID:elliott-stocks,项目名称:jetpack,代码行数:8,代码来源:test_class.jetpack-sync-comments.php


示例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}");
     }
 }
开发者ID:netcon-source,项目名称:wp-cli,代码行数:14,代码来源:comment.php


示例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);
 }
开发者ID:nordsoftware,项目名称:WP-base-theme,代码行数:13,代码来源:Initialization.php


示例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}");
     }
 }
开发者ID:rpeterson,项目名称:wp-cli,代码行数:19,代码来源:comment.php


示例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;
}
开发者ID:Johnystardust,项目名称:ecs-247-bereikbaar,代码行数:12,代码来源:custom.php


示例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);
 }
开发者ID:nizamuddin,项目名称:wp-project-manager,代码行数:19,代码来源:comment.php


示例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;
 }
开发者ID:phongvan212,项目名称:ctsv,代码行数:21,代码来源:comment-form.php


示例16: delete_comment

 public function delete_comment()
 {
     if (!isset($_GET['_wpnonce']) || !wp_verify_nonce(sanitize_text_field($_GET['_wpnonce']), '_dwqa_delete_comment')) {
         wp_die(__('Are you cheating huh?', 'dwqa'));
     }
     if (!dwqa_current_user_can('delete_comment')) {
         wp_die(__('You do not have permission to edit comment.', 'dwqa'));
     }
     if (!isset($_GET['comment_id'])) {
         wp_die(__('Comment ID must be showed.', 'dwqa'));
     }
     wp_delete_comment(intval($_GET['comment_id']));
     $comment = get_comment($_GET['comment_id']);
     exit(wp_safe_redirect(dwqa_get_question_link($comment->comment_post_ID)));
 }
开发者ID:layoutzweb,项目名称:dw-question-answer,代码行数:15,代码来源:Ajax.php


示例17: rotary_delete_announcement

function rotary_delete_announcement()
{
    $comment_id = $_REQUEST['comment_id'];
    //check again if I can delete this comment
    $user_can_delete = current_user_can('delete_others_announcements') || get_current_user_id() == $announcement->user_id || current_user_can('manage_options');
    if (!$user_can_delete) {
        $error = array('error' => 'You do not have permission to delete this announcment!');
        echo json_encode($error);
        die;
    }
    if (wp_delete_comment($comment_id)) {
        echo json_encode(array('success' => 'Comment ' . $_REQUEST['comment_id'] . ' deleted'));
        die;
    } else {
        echo json_encode(array('error' => 'Comment ' . $_REQUEST['comment_id'] . ' could not be deleted'));
        die;
    }
}
开发者ID:nmedia82,项目名称:rotary,代码行数:18,代码来源:ajax-announcements.php


示例18: delete_shared_fixtures

 /**
  * Clean up shared fixtures.
  *
  * @since 4.1.0
  */
 public static function delete_shared_fixtures()
 {
     self::delete_user(self::$author_id);
     foreach (self::$post_ids as $pid) {
         wp_delete_post($pid, true);
     }
     foreach (self::$comment_ids as $cid) {
         wp_delete_comment($cid, true);
     }
     foreach (self::$term_ids as $tid => $tax) {
         wp_delete_term($tid, $tax);
     }
     self::$author_id = null;
     self::$post_ids = array();
     self::$comment_ids = array();
     self::$term_ids = array();
     self::$terms = array();
 }
开发者ID:lucatume,项目名称:wp-browser,代码行数:23,代码来源:testcase-canonical.php


示例19: kkb_comment_delete

 public function kkb_comment_delete($cid, $inputpwd)
 {
     $comment = get_comment($cid);
     $entry_id = $comment->comment_post_ID;
     $controller = new kkbController();
     $post_id = $controller->getMeta($entry_id, 'guid');
     $board_id = $controller->getMeta($entry_id, 'board_id');
     if (is_user_logged_in()) {
         $user = wp_get_current_user();
         if ($controller->actionCommentPermission($board_id, $cid, 'delete') == true) {
             $status = wp_delete_comment($cid);
             if (!is_wp_error($status)) {
                 $result['status'] = 'success';
             } else {
                 $result['status'] = 'failed';
                 $result['message'] = __('삭제에 문제가 발생하였습니다.', 'kingkongboard');
             }
         } else {
             $result['status'] = 'failed';
             $result['message'] = __('본인 댓글이 아닙니다.', 'kingkongboard');
         }
     } else {
         if (!is_user_logged_in() && $inputpwd != null) {
             $pwd = get_comment_meta($cid, 'kkb_comment_password', true);
             if ($controller->actionCommentPermission($board_id, $cid, 'delete') == true && $pwd == md5($inputpwd)) {
                 $status = wp_delete_comment($cid);
                 if (!is_wp_error($status)) {
                     $result['status'] = 'success';
                     $result['url'] = add_query_arg(array('view' => 'read', 'id' => $entry_id), get_the_permalink($post_id));
                 } else {
                     $result['status'] = 'failed';
                     $result['message'] = __('삭제에 문제가 발생하였습니다.', 'kingkongboard');
                 }
             } else {
                 $result['status'] = 'failed';
                 $result['message'] = __('비밀번호가 일치하지 않습니다.', 'kingkongboard');
             }
         } else {
             $result['status'] = 'check';
             $result['url'] = add_query_arg(array('view' => 'cmtcheck', 'cid' => $cid, 'id' => $comment->comment_post_ID, 'mod' => 'delete'), get_the_permalink($post_id));
         }
     }
     return $result;
 }
开发者ID:ksw2342,项目名称:kau_webstudio_12,代码行数:44,代码来源:class.comment.php


示例20: ing_theme_setup

    function ing_theme_setup()
    {
        // First we check to see if our default theme settings have been applied.
        $the_theme_status = get_option('theme_setup_status');
        // If the theme has not yet been used we want to run our default settings.
        if ($the_theme_status !== '1') {
            // Delete dummy post, page and comment.
            wp_delete_post(1, true);
            wp_delete_post(2, true);
            wp_delete_comment(1);
            // Create pages
            $home_page = array('post_title' => 'Home', 'post_content' => 'Home Page Content.', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
            $blog_page = array('post_title' => 'Blog', 'post_content' => '', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
            $about_page = array('post_title' => 'About us', 'post_content' => 'Home Page Content.', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
            // Insert the pages into the database
            $home = wp_insert_post($home_page);
            $blog = wp_insert_post($blog_page);
            $about = wp_insert_post($about_page);
            // Setup Default WordPress settings
            $core_settings = array('avatar_default' => 'mystery', 'avatar_rating' => 'G', 'default_role' => 'subscriber', 'show_on_front' => 'page', 'page_on_front' => $home, 'page_for_posts' => $blog);
            foreach ($core_settings as $k => $v) {
                update_option($k, $v);
            }
            //////////////////////////////////////////////////////////////////////
            ////////////////////// WRAP UP
            // Once done, we register our setting to make sure we don't duplicate everytime we activate.
            update_option('theme_setup_status', '1');
            // Lets let the admin know whats going on.
            $msg = '
		<div class="error">
			<p>The ' . get_option('current_theme') . 'theme has changed your WordPress default <a href="' . admin_url('options-general.php') . '" title="See Settings">settings</a> and deleted default posts & comments.</p>
		</div>';
            add_action('admin_notices', $c = create_function('', 'echo "' . addcslashes($msg, '"') . '";'));
        } elseif ($the_theme_status === '1' and isset($_GET['activated'])) {
            $msg = '
		<div class="updated">
			<p>The ' . get_option('current_theme') . ' theme was successfully re-activated.</p>
		</div>';
            add_action('admin_notices', $c = create_function('', 'echo "' . addcslashes($msg, '"') . '";'));
        }
    }
开发者ID:beardon,项目名称:okprop,代码行数:41,代码来源:theme-setup.php



注:本文中的wp_delete_comment函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_delete_file函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_delete_category函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap