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

PHP wp_notify_moderator函数代码示例

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

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



在下文中一共展示了wp_notify_moderator函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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


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


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


示例6: create

 /**
  * Create new comment.
  * 
  * @param string $content
  * @param int $userId
  * @param int $threadId
  * @param int $answerId (optional)
  * @throws Exception
  * @return CMA_Comment
  */
 public static function create($content, $userId, $threadId, $answerId = null)
 {
     $user = get_userdata($userId);
     if (empty($userId) or empty($user)) {
         throw new Exception(CMA::__('Invalid user.'));
     }
     $thread = CMA_Thread::getInstance($threadId);
     if (!$thread or !$thread->isVisible()) {
         throw new Exception(CMA::__('You have no permission to post this comment.'));
     }
     if ($answerId) {
         $answer = CMA_Answer::getById($answerId);
         if (!$answer or !$answer->isVisible()) {
             throw new Exception(CMA::__('You have no permission to post this comment.'));
         }
     }
     $content = str_replace(';)', ':)', strip_tags($content));
     if (empty($content)) {
         throw new Exception(CMA::__('Content cannot be empty'));
     }
     if (($badWord = CMA_BadWords::filterIfEnabled($content)) !== false) {
         throw new Exception(sprintf(CMA_Labels::getLocalized('msg_content_includes_bad_word'), $badWord));
     }
     $approved = CMA_Settings::getOption(CMA_Settings::OPTION_COMMENTS_AUTO_APPROVE) || CMA_Thread::isAuthorAutoApproved($userId) ? 1 : 0;
     $comment = new self(array('comment_post_ID' => $threadId, 'comment_author' => $user->display_name, 'comment_author_email' => $user->user_email, 'comment_author_IP' => $_SERVER['REMOTE_ADDR'], 'comment_parent' => intval($answerId), 'comment_content' => apply_filters('comment_text', $content), 'comment_approved' => intval($approved), 'comment_date' => current_time('mysql'), 'comment_type' => self::COMMENT_TYPE, 'user_id' => $userId));
     do_action('cma_comment_post_before', $comment);
     if ($comment->save()) {
         do_action('cma_comment_post_after', $comment);
         if ($approved) {
             $comment->sendNotifications();
         } else {
             wp_notify_moderator($comment->getId());
         }
         return $comment;
     } else {
         throw new Exception(CMA::__('Failed to add comment.'));
     }
 }
开发者ID:douglaswebdesigns,项目名称:ask-bio-expert,代码行数:48,代码来源:Comment.php


示例7: 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:JeffLuckett,项目名称:quickref,代码行数:24,代码来源:functions.php


示例8: wp_new_comment

/**
 * Adds a new comment to the database.
 *
 * Filters new comment to ensure that the fields are sanitized and valid before
 * inserting comment into database. Calls 'comment_post' action with comment ID
 * and whether comment is approved by WordPress. Also has 'preprocess_comment'
 * filter for processing the comment data before the function handles it.
 *
 * We use REMOTE_ADDR here directly. If you are behind a proxy, you should ensure
 * that it is properly set, such as in wp-config.php, for your environment.
 * See {@link http://core.trac.wordpress.org/ticket/9235}
 *
 * @since 1.5.0
 * @uses apply_filters() Calls 'preprocess_comment' hook on $commentdata parameter array before processing
 * @uses do_action() Calls 'comment_post' hook on $comment_ID returned from adding the comment and if the comment was approved.
 * @uses wp_filter_comment() Used to filter comment before adding comment.
 * @uses wp_allow_comment() checks to see if comment is approved.
 * @uses wp_insert_comment() Does the actual comment insertion to the database.
 *
 * @param array $commentdata Contains information on the comment.
 * @return int The ID of the comment after adding.
 */
function wp_new_comment($commentdata)
{
    $commentdata = apply_filters('preprocess_comment', $commentdata);
    $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
    if (isset($commentdata['user_ID'])) {
        $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
    } elseif (isset($commentdata['user_id'])) {
        $commentdata['user_id'] = (int) $commentdata['user_id'];
    }
    $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
    $parent_status = 0 < $commentdata['comment_parent'] ? wp_get_comment_status($commentdata['comment_parent']) : '';
    $commentdata['comment_parent'] = 'approved' == $parent_status || 'unapproved' == $parent_status ? $commentdata['comment_parent'] : 0;
    $commentdata['comment_author_IP'] = preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']);
    $commentdata['comment_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? substr($_SERVER['HTTP_USER_AGENT'], 0, 254) : '';
    $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_option('comments_notify') && $commentdata['comment_approved'] && (!isset($commentdata['user_id']) || $post->post_author != $commentdata['user_id'])) {
            wp_notify_postauthor($comment_ID, isset($commentdata['comment_type']) ? $commentdata['comment_type'] : '');
        }
    }
    return $comment_ID;
}
开发者ID:palimadra,项目名称:bubblegraphics-wpsite,代码行数:55,代码来源:comment.php


示例9: wp_new_comment


//.........这里部分代码省略.........
 * @global wpdb $wpdb
 *
 * @param array $commentdata {
 *     Comment data.
 *
 *     @type string $comment_author       The name of the comment author.
 *     @type string $comment_author_email The comment author email address.
 *     @type string $comment_author_url   The comment author URL.
 *     @type string $comment_content      The content of the comment.
 *     @type string $comment_date         The date the comment was submitted. Default is the current time.
 *     @type string $comment_date_gmt     The date the comment was submitted in the GMT timezone.
 *                                        Default is `$comment_date` in the GMT timezone.
 *     @type int    $comment_parent       The ID of this comment's parent, if any. Default 0.
 *     @type int    $comment_post_ID      The ID of the post that relates to the comment.
 *     @type int    $user_id              The ID of the user who submitted the comment. Default 0.
 *     @type int    $user_ID              Kept for backward-compatibility. Use `$user_id` instead.
 *     @type string $comment_agent        Comment author user agent. Default is the value of 'HTTP_USER_AGENT'
 *                                        in the `$_SERVER` superglobal sent in the original request.
 *     @type string $comment_author_IP    Comment author IP address in IPv4 format. Default is the value of
 *                                        'REMOTE_ADDR' in the `$_SERVER` superglobal sent in the original request.
 * }
 * @return int|false The ID of the comment on success, false on failure.
 */
function wp_new_comment($commentdata)
{
    global $wpdb;
    if (isset($commentdata['user_ID'])) {
        $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
    }
    $prefiltered_user_id = isset($commentdata['user_id']) ? (int) $commentdata['user_id'] : 0;
    /**
     * Filter a comment's data before it is sanitized and inserted into the database.
     *
     * @since 1.5.0
     *
     * @param array $commentdata Comment data.
     */
    $commentdata = apply_filters('preprocess_comment', $commentdata);
    $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
    if (isset($commentdata['user_ID']) && $prefiltered_user_id !== (int) $commentdata['user_ID']) {
        $commentdata['user_id'] = $commentdata['user_ID'] = (int) $commentdata['user_ID'];
    } elseif (isset($commentdata['user_id'])) {
        $commentdata['user_id'] = (int) $commentdata['user_id'];
    }
    $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0;
    $parent_status = 0 < $commentdata['comment_parent'] ? wp_get_comment_status($commentdata['comment_parent']) : '';
    $commentdata['comment_parent'] = 'approved' == $parent_status || 'unapproved' == $parent_status ? $commentdata['comment_parent'] : 0;
    if (!isset($commentdata['comment_author_IP'])) {
        $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
    }
    $commentdata['comment_author_IP'] = preg_replace('/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP']);
    if (!isset($commentdata['comment_agent'])) {
        $commentdata['comment_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
    }
    $commentdata['comment_agent'] = substr($commentdata['comment_agent'], 0, 254);
    if (empty($commentdata['comment_date'])) {
        $commentdata['comment_date'] = current_time('mysql');
    }
    if (empty($commentdata['comment_date_gmt'])) {
        $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);
    if (!$comment_ID) {
        $fields = array('comment_author', 'comment_author_email', 'comment_author_url', 'comment_content');
        foreach ($fields as $field) {
            if (isset($commentdata[$field])) {
                $commentdata[$field] = $wpdb->strip_invalid_text_for_column($wpdb->comments, $field, $commentdata[$field]);
            }
        }
        $commentdata = wp_filter_comment($commentdata);
        $commentdata['comment_approved'] = wp_allow_comment($commentdata);
        $comment_ID = wp_insert_comment($commentdata);
        if (!$comment_ID) {
            return false;
        }
    }
    /**
     * Fires immediately after a comment is inserted into the database.
     *
     * @since 1.2.0
     *
     * @param int $comment_ID       The comment ID.
     * @param int $comment_approved 1 (true) if the comment is approved, 0 (false) if not.
     */
    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);
        }
        // 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') && $commentdata['comment_approved']) {
            wp_notify_postauthor($comment_ID);
        }
    }
    return $comment_ID;
}
开发者ID:TheTomorrowLab,项目名称:Wordpress-TTL,代码行数:101,代码来源:comment-functions.php


示例10: wp_new_comment_notify_moderator

/**
 * Send a comment moderation notification to the comment moderator.
 *
 * @since 4.4.0
 *
 * @param int $comment_ID ID of the comment.
 * @return bool True on success, false on failure.
 */
function wp_new_comment_notify_moderator($comment_ID)
{
    $comment = get_comment($comment_ID);
    // Only send notifications for pending comments.
    if ('0' != $comment->comment_approved) {
        return false;
    }
    return wp_notify_moderator($comment_ID);
}
开发者ID:RussWilkie,项目名称:WordPress,代码行数:17,代码来源:comment-functions.php


示例11: ajaxify_comments

 function ajaxify_comments($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']);
                 //wp_notify_postauthor($comment_ID, $commentdata['comment_type']);
                 break;
             default:
                 echo "error";
         }
         exit;
     }
 }
开发者ID:Nguyenkain,项目名称:Elearning,代码行数:21,代码来源:init.php


示例12: save_aggregated_comments

 /**
  * Saves the aggregated comments.
  *
  * @param  object  $post
  * @return void
  */
 public function save_aggregated_comments(&$post)
 {
     if (isset($post->results[$this->_key])) {
         global $wpdb;
         foreach ($post->results[$this->_key] as $result) {
             $commentdata = array('comment_post_ID' => $post->ID, 'comment_author_email' => $wpdb->escape($this->_key . '.' . $result->id . '@example.com'), 'comment_author_IP' => $_SERVER['SERVER_ADDR'], 'comment_agent' => 'Social Aggregator');
             if (isset($result->parent)) {
                 if ($wp_parent = $this->get_comment_from_fb_id($result->parent->id)) {
                     $commentdata['comment_parent'] = $wp_parent->comment_id;
                 }
             }
             if (!isset($result->like)) {
                 $commentdata = array_merge($commentdata, array('comment_type' => 'social-facebook', 'comment_author' => $wpdb->escape($result->from->name), 'comment_author_url' => $result->from->link, 'comment_content' => $wpdb->escape($result->message), 'comment_date' => date('Y-m-d H:i:s', strtotime($result->created_time) + get_option('gmt_offset') * 3600), 'comment_date_gmt' => gmdate('Y-m-d H:i:s', strtotime($result->created_time))));
             } else {
                 // v2.0+ returns app scoped ids, both app scoped ids and real ids redirect to the profile with
                 // https://www.facebook.com/{user-id}|{app-scoped-id}
                 $url = 'https://www.facebook.com/' . $result->id . '/';
                 $commentdata = array_merge($commentdata, array('comment_type' => 'social-facebook-like', 'comment_author' => $wpdb->escape($result->name), 'comment_author_url' => $url, 'comment_content' => $wpdb->escape('<a href="' . $url . '" target="_blank">' . $result->name . '</a> liked this on Facebook.'), 'comment_date' => current_time('mysql'), 'comment_date_gmt' => current_time('mysql', 1)));
             }
             $user_id = isset($result->like) ? $result->from_id : $result->from->id;
             $commentdata = array_merge($commentdata, array('comment_post_ID' => $post->ID, 'comment_author_email' => $this->_key . '.' . $user_id . '@example.com'));
             if (apply_filters('social_approve_likes_and_retweets', false) && isset($result->like)) {
                 $commentdata['comment_approved'] = 1;
             } else {
                 if (($commentdata = $this->allow_comment($commentdata, $result->id, $post)) === false) {
                     continue;
                 }
             }
             Social::log('Saving #:result_id.', array('result_id' => $result->id));
             $comment_id = 0;
             try {
                 Social::Log('Attempting to save commentdata: :commentdata', array('commentdata' => print_r($commentdata, true)));
                 $comment_id = wp_insert_comment($commentdata);
                 update_comment_meta($comment_id, 'social_account_id', addslashes_deep($user_id));
                 update_comment_meta($comment_id, 'social_profile_image_url', addslashes_deep('https://graph.facebook.com/' . $user_id . '/picture'));
                 update_comment_meta($comment_id, 'social_status_id', addslashes_deep($result->status_id));
                 update_comment_meta($comment_id, 'social_broadcast_id', addslashes_deep($result->id));
                 if ($result->reply_to_id) {
                     update_comment_meta($comment_id, 'social_reply_to_id', addslashes_deep($result->reply_to_id));
                 }
                 if (!isset($result->raw)) {
                     $result = (object) array_merge((array) $result, array('raw' => $result));
                 }
                 update_comment_meta($comment_id, 'social_raw_data', addslashes_deep(base64_encode(json_encode($result->raw))));
                 if ($commentdata['comment_approved'] !== 'spam') {
                     if ($commentdata['comment_approved'] == '0') {
                         wp_notify_moderator($comment_id);
                     }
                     if (get_option('comments_notify') and $commentdata['comment_approved'] and (!isset($commentdata['user_id']) or $post->post_author != $commentdata['user_id'])) {
                         wp_notify_postauthor($comment_id, 'comment');
                     }
                 }
             } catch (Exception $e) {
                 // Something went wrong, remove the aggregated ID.
                 if (($key = array_search($result->id, $post->aggregated_ids['facebook'])) !== false) {
                     unset($post->aggregated_ids['facebook'][$key]);
                 }
                 if ((int) $comment_id) {
                     // Delete the comment in case it wasn't the insert that failed.
                     wp_delete_comment($comment_id);
                 }
             }
         }
     }
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:71,代码来源:facebook.php


示例13: pingback_ping


//.........这里部分代码省略.........
                require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
                $snoopy = new Snoopy();
                if ($snoopy->fetch($pagelinkedfrom)) {
                    $linea = $snoopy->results;
                } else {
                    $linea = '';
                }
                logIO('O', "(PB) CHARSET='" . $GLOBALS['blog_charset']);
                $linea = mb_conv($linea, $GLOBALS['blog_charset'], 'auto');
                // 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
                if (empty($matchtitle)) {
                    preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
                }
                $pos2 = strpos($linea, $pagelinkedto);
                $pos3 = strpos($linea, str_replace('http://www.', 'http://', $pagelinkedto));
                logIO('O', "(PB) POS='{$pos2}, {$pos3}'");
                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 - 50;
                    if (function_exists('mb_convert_encoding')) {
                        $tmp1 = mb_strcut($linea, 0, $start, $GLOBALS['blog_charset']);
                    } else {
                        $tmp1 = substr($linea, 0, $start);
                    }
                    if (preg_match('/<[^>]*?$/', $tmp1, $match)) {
                        logIO('O', "(PB) MATCH='{$match[0]}");
                        $offset = strlen($match[0]);
                    } else {
                        $offset = 0;
                    }
                    if (function_exists('mb_convert_encoding')) {
                        $context = mb_strcut($linea, $start - $offset, 150 + $offset, $GLOBALS['blog_charset']);
                    } else {
                        $context = substr($linea, $star - $offsett, 150 + $offset);
                    }
                    $context = str_replace("\n", ' ', $context);
                    $context = str_replace('&amp;', '&', $context);
                    logIO('O', "(PB) CONTENT='{$context}");
                } else {
                    logIO('O', "(PB) CONTEXT=The page doesn't link to us, here's an excerpt");
                    exit;
                }
                //				fclose($fp);
                if (!empty($context)) {
                    // Check if pings are on, inelegant exit
                    $pingstatus = $wpdb->get_var("SELECT ping_status FROM " . wp_table('posts') . " WHERE ID = {$post_ID}");
                    if ('closed' == $pingstatus) {
                        logIO('O', '(PB) Sorry, pings are turned off for this post.');
                        exit;
                    }
                    $pagelinkedfrom = preg_replace('#&([^amp\\;])#is', '&amp;$1', $pagelinkedfrom);
                    $title = !strlen($matchtitle[1]) ? $pagelinkedfrom : $matchtitle[1];
                    $context = strip_tags($context);
                    $context = '<pingback />[...] ' . htmlspecialchars(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', 0);
                    if (get_settings('comment_moderation') == 'manual') {
                        $approved = 0;
                    } else {
                        if (get_settings('comment_moderation') == 'auto') {
                            $approved = 0;
                        } else {
                            // none
                            $approved = 1;
                        }
                    }
                    $consulta = $wpdb->query("INSERT INTO " . wp_table('comments') . " \n\t\t\t\t\t\t(comment_post_ID, comment_author, comment_author_url, comment_date, comment_content,comment_approved, comment_type) \n\t\t\t\t\t\tVALUES \n\t\t\t\t\t\t({$post_ID}, '{$title}', '{$pagelinkedfrom}', '{$now}', '{$context}', '{$approved}', 'pingback')\n\t\t\t\t\t\t");
                    $comment_ID = $wpdb->get_var('SELECT last_insert_id()');
                    do_action('pingback_post', $comment_ID);
                    if (get_settings('moderation_notify') && !$approved) {
                        wp_notify_moderator($comment_ID, 'pingback');
                    }
                    if (get_settings('comments_notify') && $approved) {
                        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:nobunobuta,项目名称:xoops_mod_WordPress,代码行数:101,代码来源:xmlrpc.php


示例14: wp_new_comment_notify_moderator

/**
 * Send a comment moderation notification to the comment moderator.
 *
 * @since 4.4.0
 *
 * @param int $comment_ID ID of the comment.
 * @return bool True on success, false on failure.
 */
function wp_new_comment_notify_moderator($comment_ID)
{
    $comment = get_comment($comment_ID);
    // Only send notifications for pending comments.
    $maybe_notify = '0' == $comment->comment_approved;
    /** This filter is documented in wp-includes/comment-functions.php */
    $maybe_notify = apply_filters('notify_moderator', $maybe_notify, $comment_ID);
    if (!$maybe_notify) {
        return false;
    }
    return wp_notify_moderator($comment_ID);
}
开发者ID:hadywisam,项目名称:WordPress,代码行数:20,代码来源:comment-functions.php


示例15: Comments_array

 function Comments_array($comments, $post_ID)
 {
     $post = get_post($post_ID);
     $user_ID = self::Get_user_ID($post);
     update_option(c_al2fb_log_importing, true);
     // Integration?
     if ($user_ID && !self::Is_excluded($post) && $post->post_type != 'reply' && !get_post_meta($post->ID, c_al2fb_meta_nointegrate, true) && $post->comment_status == 'open') {
         // Get time zone offset
         $tz_off = get_option('gmt_offset');
         if (empty($tz_off)) {
             $tz_off = 0;
         }
         $tz_off = apply_filters('al2fb_gmt_offset', $tz_off);
         $tz_off = $tz_off * 3600;
         // Get Facebook comments
         if (self::Is_recent($post) && get_user_meta($user_ID, c_al2fb_meta_fb_comments, true)) {
             $fb_comments = WPAL2Int::Get_comments_or_likes($post, false);
             if ($fb_comments && $fb_comments->data) {
                 // Get WordPress comments
                 $stored_comments = get_comments('post_id=' . $post->ID);
                 $stored_comments = array_merge($stored_comments, get_comments('status=spam&post_id=' . $post->ID));
                 $stored_comments = array_merge($stored_comments, get_comments('status=trash&post_id=' . $post->ID));
                 $stored_comments = array_merge($stored_comments, get_comments('status=hold&post_id=' . $post->ID));
                 $deleted_fb_comment_ids = get_post_meta($post->ID, c_al2fb_meta_fb_comment_id, false);
                 foreach ($fb_comments->data as $fb_comment) {
                     if (!empty($fb_comment->id)) {
                         $search_comment_id = end(explode('_', $fb_comment->id));
                         // Check if stored comment
                         $stored = false;
                         if ($stored_comments) {
                             foreach ($stored_comments as $comment) {
                                 $fb_comment_id = get_comment_meta($comment->comment_ID, c_al2fb_meta_fb_comment_id, true);
                                 if ($search_comment_id == end(explode('_', $fb_comment_id))) {
                                     $stored = true;
                                     break;
                                 }
                             }
                         }
                         // Check if deleted comment
                         if (!$stored && $deleted_fb_comment_ids) {
                             foreach ($deleted_fb_comment_ids as $deleted_fb_comment_id) {
                                 if ($search_comment_id == end(explode('_', $deleted_fb_comment_id))) {
                                     $stored = true;
                                     break;
                                 }
                             }
                         }
                         // Create new comment
                         if (!$stored) {
                             $name = $fb_comment->from->name . ' ' . __('on Facebook', c_al2fb_text_domain);
                             if ($post->post_type == 'topic') {
                                 // bbPress
                                 $reply_id = bbp_insert_reply(array('post_parent' => $post_ID, 'post_content' => $fb_comment->message, 'post_status' => 'draft'), array('forum_id' => bbp_get_topic_forum_id($post_ID), 'topic_id' => $post_ID, 'anonymous_name' => $name));
                                 // Add data
                                 add_post_meta($reply_id, c_al2fb_meta_link_id, $fb_comment->id);
                                 add_post_meta($post_ID, c_al2fb_meta_fb_comment_id, $fb_comment->id);
                                 // Publish
                                 $reply = array();
                                 $reply['ID'] = $reply_id;
                                 $reply['post_status'] = 'publish';
                                 wp_update_post($reply);
                             } else {
                                 $comment_ID = $fb_comment->id;
                                 $commentdata = array('comment_post_ID' => $post_ID, 'comment_author' => $name, 'comment_author_email' => $fb_comment->from->id . '@facebook.com', 'comment_author_url' => WPAL2Int::Get_fb_profilelink($fb_comment->from->id), 'comment_author_IP' => '', 'comment_date' => date('Y-m-d H:i:s', strtotime($fb_comment->created_time) + $tz_off), 'comment_date_gmt' => date('Y-m-d H:i:s', strtotime($fb_comment->created_time)), 'comment_content' => $fb_comment->message, 'comment_karma' => 0, 'comment_approved' => 1, 'comment_agent' => 'AL2FB', 'comment_type' => '', 'comment_parent' => 0, 'user_id' => 0);
                                 // Assign parent comment id
                                 if (!empty($fb_comment->parent->id)) {
                                     $parent_args = array('post_id' => $post_ID, 'meta_query' => array(array('key' => c_al2fb_meta_fb_comment_id, 'value' => $fb_comment->parent->id)));
                                     $parent_comments_query = new WP_Comment_Query();
                                     $parent_comments = $parent_comments_query->query($parent_args);
                                     if (isset($parent_comments) && count($parent_comments) == 1) {
                                         $commentdata['comment_parent'] = $parent_comments[0]->comment_ID;
                                     }
                                 }
                                 $commentdata = apply_filters('al2fb_preprocess_comment', $commentdata, $post);
                                 // Copy Facebook comment to WordPress database
                                 if (get_user_meta($user_ID, c_al2fb_meta_fb_comments_copy, true)) {
                                     // Apply filters
                                     if (get_option(c_al2fb_option_nofilter_comments)) {
                                         $commentdata['comment_approved'] = '1';
                                     } else {
                                         $commentdata = apply_filters('preprocess_comment', $commentdata);
                                         $commentdata = wp_filter_comment($commentdata);
                                         $commentdata['comment_approved'] = wp_allow_comment($commentdata);
                                     }
                                     // Insert comment in database
                                     $comment_ID = wp_insert_comment($commentdata);
                                     add_comment_meta($comment_ID, c_al2fb_meta_fb_comment_id, $fb_comment->id);
                                     do_action('comment_post', $comment_ID, $commentdata['comment_approved']);
                                     // Notify
                                     if ('spam' !== $commentdata['comment_approved']) {
                                         if ('0' == $commentdata['comment_approved']) {
                                             wp_notify_moderator($comment_ID);
                                         }
                                         if (get_option('comments_notify') && $commentdata['comment_approved']) {
                                             wp_notify_postauthor($comment_ID, $commentdata['comment_type']);
                                         }
                                     }
                                 } else {
                                     $commentdata['comment_approved'] = '1';
                                 }
//.........这里部分代码省略.........
开发者ID:kxt5258,项目名称:fullcircle,代码行数:101,代码来源:add-link-to-facebook-class.php


示例16: wp_new_comment

function wp_new_comment($commentdata, $spam = false)
{
    global $wpdb;
    $commentdata = apply_filters('preprocess_comment', $commentdata);
    extract($commentdata);
    $comment_post_ID = (int) $comment_post_ID;
    $user_id = apply_filters('pre_user_id', $user_ID);
    $author = apply_filters('pre_comment_author_name', $comment_author);
    $email = apply_filters('pre_comment_author_email', $comment_author_email);
    $url = apply_filters('pre_comment_author_url', $comment_author_url);
    $comment = apply_filters('pre_comment_content', $comment_content);
    $comment = apply_filters('post_comment_text', $comment);
    // Deprecated
    $comment = apply_filters('comment_content_presave', $comment);
    // Deprecated
    $user_ip = apply_filters('pre_comment_user_ip', $_SERVER['REMOTE_ADDR']);
    $user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($user_ip));
    $user_agent = apply_filters('pre_comment_user_agent', $_SERVER['HTTP_USER_AGENT']);
    $now = current_time('mysql');
    $now_gmt = current_time('mysql', 1);
    if ($user_id) {
        $userdata = get_userdata($user_id);
        $post_author = $wpdb->get_var("SELECT post_author FROM {$wpdb->posts} WHERE ID = '{$comment_post_ID}' LIMIT 1");
    }
    // Simple duplicate check
    $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$author}' ";
    if ($email) {
        $dupe .= "OR comment_author_email = '{$email}' ";
    }
    $dupe .= ") AND co 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wp_notify_postauthor函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_normalize_path函数代码示例发布时间: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