当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_notify_postauthor函数代码示例

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


在下文中一共展示了wp_notify_postauthor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: xt_ajax_comment

function xt_ajax_comment($comment_ID, $comment_status)
{
    // If it's an AJAX-submitted comment
    if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        if ('spam' !== $comment_status) {
            // If it's spam save it silently for later crunching
            if ('0' == $comment_status) {
                wp_notify_moderator($comment_ID);
            }
            // wp_notify_postauthor() checks if notifying the author of their own comment.
            // By default, it won't, but filters can override this.
            if (get_option('comments_notify') && $comment_status) {
                wp_notify_postauthor($comment_ID);
            }
        }
        if (!empty($_POST["comment_post_ID"])) {
            $post_id = filter_input(INPUT_POST, 'comment_post_ID', FILTER_VALIDATE_INT);
            $comments_order = strtoupper(get_option('comment_order'));
            $reverse = $comments_order == 'ASC';
            $args = array('post_id' => $post_id, 'order' => $comments_order, 'status' => 'approve');
            if (get_option('page_comments')) {
                $args['number'] = get_option('comments_per_page');
            }
            $comments = get_comments($args);
            $comments_list = wp_list_comments(array('style' => 'ol', 'short_ping' => true, 'avatar_size' => 60, 'callback' => 'xt_comment', 'echo' => false, 'reverse_top_level' => $reverse, 'reverse_children' => $reverse), $comments);
        }
        // Kill the script, returning the comment HTML
        die(json_encode(array('id' => $comment_ID, 'status' => $comment_status, 'list' => $comments_list)));
    }
}
开发者ID:venturepact,项目名称:blog,代码行数:30,代码来源:functions-ajax.php

示例3: 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

示例4: 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

示例5: milky_way_ajax_comments

/**
 * Provide responses to comments.js based on detecting an XMLHttpRequest parameter.
 *
 * @param $comment_ID     ID of new comment.
 * @param $comment_status Status of new comment. 
 *
 * @return echo JSON encoded responses with HTML structured comment, success, and status notice.
 */
function milky_way_ajax_comments($comment_ID, $comment_status)
{
    if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        // This is an AJAX request. Handle response data.
        switch ($comment_status) {
            case '0':
                // Comment needs moderation; notify comment moderator.
                wp_notify_moderator($comment_ID);
                $return = array('response' => '', 'success' => 1, 'status' => __('Your comment has been sent for moderation. It should be approved soon!', 'milky-way'));
                wp_send_json($return);
                break;
            case '1':
                // Approved comment; generate comment output and notify post author.
                $comment = get_comment($comment_ID);
                $comment_class = comment_class('milky-way-ajax-comment', $comment_ID, $comment->comment_post_ID, false);
                $comment_output = '
						<li id="comment-' . $comment->comment_ID . '"' . $comment_class . ' tabindex="-1">
							<article id="div-comment-' . $comment->comment_ID . '" class="comment-body">
								<footer class="comment-meta">
								<div class="comment-author vcard">' . get_avatar($comment->comment_author_email) . '<b class="fn">' . __('You said:', 'milky-way') . '</b> </div>

								<div class="comment-meta commentmetadata"><a href="#comment-' . $comment->comment_ID . '">' . get_comment_date('F j, Y \\a\\t g:i a', $comment->comment_ID) . '</a>
								</div>
								</footer>
								
								<div class="comment-content">' . $comment->comment_content . '</div>
							</article>
						</li>';
                if ($comment->comment_parent == 0) {
                    $output = $comment_output;
                } else {
                    $output = "<ul class='children'>{$comment_output}</ul>";
                }
                wp_notify_postauthor($comment_ID);
                $return = array('response' => $output, 'success' => 1, 'status' => sprintf(__('Thanks for commenting! Your comment has been approved. <a href="%s">Read your comment</a>', 'milky-way'), "#comment-{$comment_ID}"));
                wp_send_json($return);
                break;
            default:
                // The comment status was not a valid value. Only 0 or 1 should be returned by the comment_post action.
                $return = array('response' => '', 'success' => 0, 'status' => __('There was an error posting your comment. Try again later!', 'milky-way'));
                wp_send_json($return);
        }
    }
}
开发者ID:joedolson,项目名称:milky-way,代码行数:52,代码来源:comments.php

示例6: ajaxify_comments

 function ajaxify_comments($comment_ID, $comment_status)
 {
     if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
         switch ($comment_status) {
             case "0":
                 wp_notify_moderator($comment_ID);
             case "1":
                 //Approved comment
                 echo "success";
                 $commentdata =& get_comment($comment_ID, ARRAY_A);
                 $post =& get_post($commentdata['comment_post_ID']);
                 wp_notify_postauthor($comment_ID, $commentdata['comment_type']);
                 break;
             default:
                 echo 0;
         }
         exit;
     }
 }
开发者ID:NallelyFlores89,项目名称:telesinergia,代码行数:19,代码来源:ajax.php

示例7: wpajax_load_comment

function wpajax_load_comment($comment_ID, $comment_status)
{
    if ($GLOBALS['is_ajax']) {
        switch ($comment_status) {
            case '0':
                //notify moderator of unapproved comment
                wp_notify_moderator($comment_ID);
                break;
            case '1':
                //Approved comment
                single_comment($comment_ID);
                wp_notify_postauthor($comment_ID);
                break;
            default:
                // $comment_status was null
                echo "error";
        }
        exit;
        // better than wp_die() ?
    }
}
开发者ID:arniebradfo,项目名称:Ajax-Boilerplate-Wordpress-Theme,代码行数:21,代码来源:functions.php

示例8: wdp_ajaxcomments_stop_for_ajax

function wdp_ajaxcomments_stop_for_ajax($comment_ID, $comment_status)
{
    if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        //If AJAX Request Then
        switch ($comment_status) {
            case '0':
                //notify moderator of unapproved comment
                wp_notify_moderator($comment_ID);
            case '1':
                //Approved comment
                echo "success";
                $commentdata =& get_comment($comment_ID, ARRAY_A);
                $post =& get_post($commentdata['comment_post_ID']);
                //Notify post author of comment
                if (get_option('comments_notify') && $commentdata['comment_approved'] && $post->post_author != $commentdata['user_ID']) {
                    wp_notify_postauthor($comment_ID, $commentdata['comment_type']);
                }
                break;
            default:
                echo "error";
        }
        exit;
    }
}
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:24,代码来源:das-gq-theme-functions.php

示例9: __

	$p = (int) $_GET['p'];
	if (isset($_GET['noredir'])) {
		$noredir = true;
	} else {
		$noredir = false;
	}

	if ( ! $comment = get_comment($comment) )
		die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));

	if ( !current_user_can('edit_post', $comment->comment_post_ID) )	
		die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );

	wp_set_comment_status($comment->comment_ID, "approve");
	if (get_settings("comments_notify") == true) {
		wp_notify_postauthor($comment->comment_ID);
	}


	if ((wp_get_referer() != "") && (false == $noredir)) {
		wp_redirect(wp_get_referer());
	} else {
		wp_redirect(get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
	}

	break;

case 'editedcomment':

	$comment_ID = (int) $_POST['comment_ID'];
	$comment_post_ID = (int)  $_POST['comment_post_ID'];
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:31,代码来源:post.php

示例10: cupid_ajaxComment

    function cupid_ajaxComment($comment_ID, $comment_status)
    {
        // If it's an AJAX-submitted comment
        if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
            // Get the comment data
            $comment = get_comment($comment_ID);
            // Allow the email to the author to be sent
            wp_notify_postauthor($comment_ID);
            // Get the comment HTML from my custom comment HTML function
            $comments = get_comments(array('post_id' => $comment->comment_post_ID));
            ob_start();
            $number = get_comments_number($comment->comment_post_ID);
            ?>
            <h4 class="comments-title"><?php 
            _e("Comments", 'cupid');
            ?>
 (<?php 
            echo esc_html($number);
            ?>
)</h4>
            <ul class="comment-list">
            <?php 
            wp_list_comments(array('style' => 'li', 'type' => 'comment', 'callback' => 'cupid_get_list_comments', 'avatar_size' => 82), $comments);
            ?>
            </ul>
            <?php 
            cupid_comment_form($comment->comment_post_ID);
            ?>
            <?php 
            $commentContent = ob_get_clean();
            // Kill the script, returning the comment HTML
            die($commentContent);
        }
    }
开发者ID:adwleg,项目名称:site,代码行数:34,代码来源:template-tags.php

示例11: pingback_ping


//.........这里部分代码省略.........
                $post_ID = $urltest['fragment'];
                $way = 'from the fragment (numeric)';
            } elseif (preg_match('/post-[0-9]+/', $urltest['fragment'])) {
                // ...a post id in the form 'post-###'
                $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']);
                $way = 'from the fragment (post-###)';
            } elseif (is_string($urltest['fragment'])) {
                // ...or a string #title, a little more complicated
                $title = preg_replace('/[^a-zA-Z0-9]/', '.', $urltest['fragment']);
                $sql = "SELECT ID FROM {$tableposts} WHERE post_title RLIKE '{$title}'";
                $post_ID = $wpdb->get_var($sql) or die("Query: {$sql}\n\nError: ");
                $way = 'from the fragment (title)';
            }
        } else {
            // TODO: Attempt to extract a post ID from the given URL
            $post_ID = -1;
            $way = 'no match';
        }
        logIO("O", "(PB) URI='{$pagelinkedto}' ID='{$post_ID}' Found='{$way}'");
        //debug_fwrite($log, "Found post ID $way: $post_ID\n");
        $sql = 'SELECT post_author FROM ' . $tableposts . ' WHERE ID = ' . $post_ID;
        $result = $wpdb->get_results($sql);
        if ($wpdb->num_rows) {
            //debug_fwrite($log, 'Post exists'."\n");
            // Let's check that the remote site didn't already pingback this entry
            $sql = 'SELECT * FROM ' . $tablecomments . ' 
				WHERE comment_post_ID = ' . $post_ID . ' 
					AND comment_author_url = \'' . $pagelinkedfrom . '\' 
					AND comment_content LIKE \'%<pingback />%\'';
            $result = $wpdb->get_results($sql);
            if ($wpdb->num_rows || 1 == 1) {
                // very stupid, but gives time to the 'from' server to publish !
                sleep(1);
                // Let's check the remote site
                $fp = @fopen($pagelinkedfrom, 'r');
                $puntero = 4096;
                while ($remote_read = fread($fp, $puntero)) {
                    $linea .= $remote_read;
                }
                // Work around bug in strip_tags():
                $linea = str_replace('<!DOCTYPE', '<DOCTYPE', $linea);
                $linea = strip_tags($linea, '<title><a>');
                $linea = strip_all_but_one_link($linea, $pagelinkedto);
                // I don't think we need this? -- emc3
                //$linea = preg_replace('#&([^amp\;])#is', '&amp;$1', $linea);
                if (empty($matchtitle)) {
                    preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
                }
                $pos2 = strpos($linea, $pagelinkedto);
                $pos3 = strpos($linea, str_replace('http://www.', 'http://', $pagelinkedto));
                if (is_integer($pos2) || is_integer($pos3)) {
                    //debug_fwrite($log, 'The page really links to us :)'."\n");
                    $pos4 = is_integer($pos2) ? $pos2 : $pos3;
                    $start = $pos4 - 100;
                    $context = substr($linea, $start, 250);
                    $context = str_replace("\n", ' ', $context);
                    $context = str_replace('&amp;', '&', $context);
                } else {
                    //debug_fwrite($log, 'The page doesn\'t link to us, here\'s an excerpt :'."\n\n".$linea."\n\n");
                }
                //}
                //debug_fwrite($log, '*****'."\n\n");
                fclose($fp);
                if (!empty($context)) {
                    // Check if pings are on, inelegant exit
                    $pingstatus = $wpdb->get_var("SELECT ping_status FROM {$tableposts} WHERE ID = {$post_ID}");
                    if ('closed' == $pingstatus) {
                        die('Sorry, pings are turned off for this post.');
                    }
                    $pagelinkedfrom = preg_replace('#&([^amp\\;])#is', '&amp;$1', $pagelinkedfrom);
                    $title = !strlen($matchtitle[1]) ? $pagelinkedfrom : $matchtitle[1];
                    $original_context = $context;
                    $context = '<pingback />[...] ' . addslashes(trim($context)) . ' [...]';
                    $context = format_to_post($context);
                    $original_pagelinkedfrom = $pagelinkedfrom;
                    $pagelinkedfrom = addslashes($pagelinkedfrom);
                    $original_title = $title;
                    $title = addslashes(strip_tags(trim($title)));
                    $now = current_time('mysql');
                    $consulta = $wpdb->query("INSERT INTO {$tablecomments} \n\t\t\t\t\t\t(comment_post_ID, comment_author, comment_author_url, comment_date, comment_content) \n\t\t\t\t\t\tVALUES \n\t\t\t\t\t\t({$post_ID}, '{$title}', '{$pagelinkedfrom}', '{$now}', '{$context}')\n\t\t\t\t\t\t");
                    $comment_ID = $wpdb->get_var('SELECT last_insert_id()');
                    if ($comments_notify) {
                        wp_notify_postauthor($comment_ID, 'pingback');
                    }
                } else {
                    // URL pattern not found
                    $message = "Page linked to: {$pagelinkedto}\nPage linked from:" . " {$pagelinkedfrom}\nTitle: {$title}\nContext: {$context}\n\n" . $messages[1];
                }
            } else {
                // We already have a Pingback from this URL
                $message = "Sorry, you already did a pingback to {$pagelinkedto}" . " from {$pagelinkedfrom}.";
            }
        } else {
            // Post_ID not found
            $message = $messages[2];
            //debug_fwrite($log, 'Post doesn\'t exist'."\n");
        }
    }
    return new xmlrpcresp(new xmlrpcval($message));
}
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:101,代码来源:xmlrpc.php

示例12: berg_ajaxComment

function berg_ajaxComment($comment_ID, $comment_status)
{
    if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        $parentId = false;
        if (isset($_POST['comment_parent'])) {
            $parentId = (int) $_POST['comment_parent'];
        }
        $comment = get_comment($comment_ID);
        wp_notify_postauthor($comment_ID);
        $commentContent = 'barnelli_getCommentHTML($comment, $parentId);';
        header('Content-type: application/json');
        echo json_encode(array('status' => 'success', 'contents' => $commentContent, 'parentId' => $parentId));
        die;
    }
}
开发者ID:m-godefroid76,项目名称:devrestofactory,代码行数:15,代码来源:functions_def.php

示例13: wp_set_comment_status

/**
 * Sets the status of a comment.
 *
 * The 'wp_set_comment_status' action is called after the comment is handled.
 * If the comment status is not in the list, then false is returned.
 *
 * @since 1.0.0
 *
 * global wpdb $wpdb
 *
 * @param int $comment_id Comment ID.
 * @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'trash'.
 * @param bool $wp_error Whether to return a WP_Error object if there is a failure. Default is false.
 * @return bool|WP_Error True on success, false or WP_Error on failure.
 */
function wp_set_comment_status($comment_id, $comment_status, $wp_error = false)
{
    global $wpdb;
    switch ($comment_status) {
        case 'hold':
        case '0':
            $status = '0';
            break;
        case 'approve':
        case '1':
            $status = '1';
            if (get_option('comments_notify')) {
                wp_notify_postauthor($comment_id);
            }
            break;
        case 'spam':
            $status = 'spam';
            break;
        case 'trash':
            $status = 'trash';
            break;
        default:
            return false;
    }
    $comment_old = clone get_comment($comment_id);
    if (!$wpdb->update($wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id))) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    clean_comment_cache($comment_id);
    $comment = get_comment($comment_id);
    /**
     * Fires immediately before transitioning a comment's status from one to another
     * in the database.
     *
     * @since 1.5.0
     *
     * @param int         $comment_id     Comment ID.
     * @param string|bool $comment_status Current comment status. Possible values include
     *                                    'hold', 'approve', 'spam', 'trash', or false.
     */
    do_action('wp_set_comment_status', $comment_id, $comment_status);
    wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
    wp_update_comment_count($comment->comment_post_ID);
    return true;
}
开发者ID:TheTomorrowLab,项目名称:Wordpress-TTL,代码行数:64,代码来源:comment-functions.php

示例14: sk2_filter_comment

function sk2_filter_comment($comment_ID)
{
    include_once dirname(__FILE__) . "/sk2_core_class.php";
    if (!$comment_ID) {
        $sk2_log->log_msg(__("Structural failure: no comment ID sent to comment hook", 'sk2'), 10, 0, "web_UI", true, false);
        die(__("Aborting Spam Karma", 'sk2'));
    }
    $sk2_core = new sk2_core($comment_ID, false);
    $sk2_core->process_comment();
    $approved = $sk2_core->cur_comment->approved;
    $sk2_settings->save_settings();
    // should also save/display logs here...
    // doing notification ourselves (since we killed WP's)
    if ($approved == 'spam') {
        // your adventure stops here, cowboy...
        header("HTTP/1.1 403 Forbidden");
        header("Status: 403 Forbidden");
        _e("Sorry, but your comment has been flagged by the spam filter running on this blog: this might be an error, in which case all apologies. Your comment will be presented to the blog admin who will be able to restore it immediately.<br/>You may want to contact the blog admin via e-mail to notify him.", 'sk2');
        //		echo "<!-- ";
        //		$sk2_log->dump_logs();
        //		echo "-->";
        die;
    } else {
        if ('0' == $approved) {
            if ($sk2_core->cur_comment->can_unlock()) {
                // redirect to Second Chance page
                header('Expires: Mon, 26 Aug 1980 09:00:00 GMT');
                header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
                header('Cache-Control: no-cache, must-revalidate');
                header('Pragma: no-cache');
                $location = get_bloginfo('wpurl') . "/" . strstr(str_replace("\\", "/", dirname(__FILE__)), "wp-content/") . "/" . sk2_second_chance_file . "?c_id={$comment_ID}&c_author=" . urlencode($sk2_core->cur_comment->author_email);
                //$location = str_replace($_SERVER['DOCUMENT_ROOT'], "/", dirname(__FILE__)) . "/" . sk2_second_chance_file ."?c_id=$comment_ID&c_author=" . urlencode($sk2_core->cur_comment->author_email);
                $can_use_location = @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ? false : true;
                if (!$can_use_location && $phpver >= '4.0.1' && @preg_match('/Microsoft/', getenv('SERVER_SOFTWARE')) && php_sapi_name() == 'isapi') {
                    $can_use_location = true;
                }
                if ($can_use_location) {
                    header("Location: {$location}");
                } else {
                    header("Refresh: 0;url={$location}");
                }
                exit;
            } else {
                wp_notify_moderator($comment_ID);
            }
        } elseif (get_settings('comments_notify')) {
            wp_notify_postauthor($comment_ID, $sk2_core->cur_comment->type);
        }
    }
}
开发者ID:jbogota,项目名称:blog-king,代码行数:50,代码来源:spam_karma_2_plugin.php

示例15: wp_set_comment_status

/**
 * Sets the status of a comment.
 *
 * The 'wp_set_comment_status' action is called after the comment is handled.
 * If the comment status is not in the list, then false is returned.
 *
 * @since 1.0.0
 * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
 *
 * @param int $comment_id Comment ID.
 * @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'trash'.
 * @param bool $wp_error Whether to return a WP_Error object if there is a failure. Default is false.
 * @return bool|WP_Error True on success, false or WP_Error on failure.
 */
function wp_set_comment_status($comment_id, $comment_status, $wp_error = false)
{
    global $wpdb;
    $status = '0';
    switch ($comment_status) {
        case 'hold':
        case '0':
            $status = '0';
            break;
        case 'approve':
        case '1':
            $status = '1';
            if (get_option('comments_notify')) {
                $comment = get_comment($comment_id);
                wp_notify_postauthor($comment_id, $comment->comment_type);
            }
            break;
        case 'spam':
            $status = 'spam';
            break;
        case 'trash':
            $status = 'trash';
            break;
        default:
            return false;
    }
    $comment_old = clone get_comment($comment_id);
    if (!$wpdb->update($wpdb->comments, array('comment_approved' => $status), array('comment_ID' => $comment_id))) {
        if ($wp_error) {
            return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error);
        } else {
            return false;
        }
    }
    clean_comment_cache($comment_id);
    $comment = get_comment($comment_id);
    do_action('wp_set_comment_status', $comment_id, $comment_status);
    wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
    wp_update_comment_count($comment->comment_post_ID);
    return true;
}
开发者ID:palimadra,项目名称:bubblegraphics-wpsite,代码行数:55,代码来源:comment.php


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