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


PHP bbp_get_public_status_id函数代码示例

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


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

示例1: get_all_forums

 public function get_all_forums()
 {
     $bbp_f = bbp_parse_args($args, array('post_type' => bbp_get_forum_post_type(), 'post_parent' => 'any', 'post_status' => bbp_get_public_status_id(), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'ignore_sticky_posts' => true, 'orderby' => 'menu_order title', 'order' => 'ASC'), 'has_forums');
     $bbp = bbpress();
     $bbp->forum_query = new WP_Query($bbp_f);
     $data = array();
     foreach ($bbp->forum_query->posts as $post) {
         $type = 'forum';
         $is_parent = false;
         $is_category = bbp_forum_get_subforums($post->ID);
         if ($is_category) {
             $type = 'category';
             $parent = true;
         }
         $settings = $this->wlm->GetOption('bbpsettings');
         if ($settings && count($settings) > 0) {
             foreach ($settings as $setting) {
                 if ($setting["id"] == $post->ID) {
                     $data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => $setting["sku"], "protection" => $setting["protection"], "type" => $type, "parent" => $parent, "date" => "");
                 }
             }
             if (!isset($data[$post->ID])) {
                 $data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => "", "protection" => "", "type" => $type, "parent" => $parent, "date" => "");
             }
         } else {
             $data[$post->ID] = array("id" => $post->ID, "name" => $post->post_title, "level" => "", "protection" => "", "type" => $type, "parent" => $parent, "date" => "");
         }
     }
     echo json_encode($data);
     die;
 }
开发者ID:brooklyntri,项目名称:btc-plugins,代码行数:31,代码来源:integration.other.bbpress.php

示例2: widget

        function widget($args, $instance)
        {
            extract($args, EXTR_SKIP);
            $title = !empty($instance['title']) ? $instance['title'] : __('Recent Topics');
            $title = apply_filters('widget_title', $title, $instance, $this->id_base);
            $number = !empty($instance['number']) ? absint($instance['number']) : 5;
            $orderby = !empty($instance['number']) ? strip_tags($instance['order_by']) : 'newness';
            if ($orderby == 'newness') {
                $cb_meta_key = $cb_order_by = NULL;
            } elseif ($orderby == 'popular') {
                $cb_meta_key = '_bbp_reply_count';
                $cb_order_by = 'meta_value';
            } elseif ($orderby == 'freshness') {
                $cb_meta_key = '_bbp_last_active_time';
                $cb_order_by = 'meta_value';
            }
            if (!$number) {
                $number = 5;
            }
            $cb_qry = new WP_Query(array('post_type' => bbp_get_topic_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'order' => 'DESC', 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => $cb_meta_key, 'orderby' => $cb_order_by));
            echo $before_widget;
            echo $before_title . $title . $after_title;
            ?>
            <ul class="cb-bbp-recent-topics">

                <?php 
            while ($cb_qry->have_posts()) {
                $cb_qry->the_post();
                ?>

                    <li>

                        <?php 
                $cb_reply_id = bbp_get_reply_id($cb_qry->post->ID);
                $cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>';
                $cb_number_replies = bbp_get_topic_reply_count($cb_reply_id);
                $cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60));
                $cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name'));
                echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_reply_url . '<div class="cb-bbp-byline">' . __('Started by', 'cubell') . ' ' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_number_replies . ' replies</div></div>';
                ?>

                    </li>

                <?php 
            }
            ?>

            </ul>

<?php 
            echo $after_widget;
            // Reset the $post global
            wp_reset_postdata();
        }
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:54,代码来源:cb-bbp-recent-topics.php

示例3: widget

        function widget($args, $instance)
        {
            extract($args, EXTR_SKIP);
            $title = !empty($instance['title']) ? $instance['title'] : __('Recent Comments');
            $title = apply_filters('widget_title', $title, $instance, $this->id_base);
            $number = !empty($instance['number']) ? absint($instance['number']) : 5;
            if (!$number) {
                $number = 5;
            }
            $cb_qry = new WP_Query(array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true));
            echo $before_widget;
            echo $before_title . $title . $after_title;
            ?>
            <ul class="cb-bbp-recent-replies">

                <?php 
            while ($cb_qry->have_posts()) {
                $cb_qry->the_post();
                ?>

                    <li>

                        <?php 
                $cb_reply_id = bbp_get_reply_id($cb_qry->post->ID);
                $cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>';
                $cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60));
                $cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name'));
                echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_reply_url . '<div class="cb-bbp-recent-replies-time">' . bbp_get_time_since(get_the_time('U')) . '</div></div>';
                ?>

                    </li>

                <?php 
            }
            ?>

            </ul>

        <?php 
            echo $after_widget;
            // Reset the $post global
            wp_reset_postdata();
        }
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:43,代码来源:cb-bbp-recent-replies.php

示例4: tehnik_bpp_filter_forums_by_permissions

/**
 * This function filters the list of forums based on the users rank as set by the Mebmers plugin
 */
function tehnik_bpp_filter_forums_by_permissions($args = '')
{
    $bbp = bbpress();
    // Setup possible post__not_in array
    $post_stati[] = bbp_get_public_status_id();
    // Check if user can read private forums
    if (current_user_can('read_private_forums')) {
        $post_stati[] = bbp_get_private_status_id();
    }
    // Check if user can read hidden forums
    if (current_user_can('read_hidden_forums')) {
        $post_stati[] = bbp_get_hidden_status_id();
    }
    // The default forum query for most circumstances
    $meta_query = array('post_type' => bbp_get_forum_post_type(), 'post_parent' => bbp_is_forum_archive() ? 0 : bbp_get_forum_id(), 'post_status' => implode(',', $post_stati), 'posts_per_page' => get_option('_bbp_forums_per_page', 50), 'orderby' => 'menu_order', 'order' => 'ASC');
    //Get an array of IDs which the current user has permissions to view
    $allowed_forums = tehnik_bpp_get_permitted_post_ids(new WP_Query($meta_query));
    // The default forum query with allowed forum ids array added
    $meta_query['post__in'] = $allowed_forums;
    $bbp_f = bbp_parse_args($args, $meta_query, 'has_forums');
    // Run the query
    $bbp->forum_query = new WP_Query($bbp_f);
    return apply_filters('bpp_filter_forums_by_permissions', $bbp->forum_query->have_posts(), $bbp->forum_query);
}
开发者ID:dnaleor,项目名称:Tehnik-bbPress-Permissions,代码行数:27,代码来源:tehnik_bpp_forum.php

示例5: bbp_admin_repair_freshness

/**
 * Recaches the last post in every topic and forum
 *
 * @since 2.0.0 bbPress (r3040)
 *
 * @uses wpdb::query() To run our recount sql queries
 * @uses is_wp_error() To check if the executed query returned {@link WP_Error}
 * @uses bbp_get_forum_post_type() To get the forum post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses bbp_get_public_status_id() To get the public status id
 * @uses bbp_is_forum_category() To check if the forum is a ategory
 * @uses bbp_update_forum() To update the forums forum id
 * @return array An array of the status code and the message
 */
function bbp_admin_repair_freshness()
{
    // Define variables
    $bbp_db = bbp_db();
    $statement = __('Recomputing latest post in every topic and forum&hellip; %s', 'bbpress');
    $result = __('Failed!', 'bbpress');
    // First, delete everything.
    if (is_wp_error($bbp_db->query("DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` IN ( '_bbp_last_reply_id', '_bbp_last_topic_id', '_bbp_last_active_id', '_bbp_last_active_time' );"))) {
        return array(1, sprintf($statement, $result));
    }
    // Post types and status
    $fpt = bbp_get_forum_post_type();
    $tpt = bbp_get_topic_post_type();
    $rpt = bbp_get_reply_post_type();
    $pps = bbp_get_public_status_id();
    // Next, give all the topics with replies the ID their last reply.
    if (is_wp_error($bbp_db->query("INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`)\n\t\t\t( SELECT `topic`.`ID`, '_bbp_last_reply_id', MAX( `reply`.`ID` )\n\t\t\tFROM `{$bbp_db->posts}` AS `topic` INNER JOIN `{$bbp_db->posts}` AS `reply` ON `topic`.`ID` = `reply`.`post_parent`\n\t\t\tWHERE `reply`.`post_status` = '{$pps}' AND `topic`.`post_type` = '{$tpt}' AND `reply`.`post_type` = '{$rpt}'\n\t\t\tGROUP BY `topic`.`ID` );"))) {
        return array(2, sprintf($statement, $result));
    }
    // For any remaining topics, give a reply ID of 0.
    if (is_wp_error($bbp_db->query("INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`)\n\t\t\t( SELECT `ID`, '_bbp_last_reply_id', 0\n\t\t\tFROM `{$bbp_db->posts}` AS `topic` LEFT JOIN `{$bbp_db->postmeta}` AS `reply`\n\t\t\tON `topic`.`ID` = `reply`.`post_id` AND `reply`.`meta_key` = '_bbp_last_reply_id'\n\t\t\tWHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' );"))) {
        return array(3, sprintf($statement, $result));
    }
    // Now we give all the forums with topics the ID their last topic.
    if (is_wp_error($bbp_db->query("INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`)\n\t\t\t( SELECT `forum`.`ID`, '_bbp_last_topic_id', `topic`.`ID`\n\t\t\tFROM `{$bbp_db->posts}` AS `forum` INNER JOIN `{$bbp_db->posts}` AS `topic` ON `forum`.`ID` = `topic`.`post_parent`\n\t\t\tWHERE `topic`.`post_status` = '{$pps}' AND `forum`.`post_type` = '{$fpt}' AND `topic`.`post_type` = '{$tpt}'\n\t\t\tGROUP BY `forum`.`ID` );"))) {
        return array(4, sprintf($statement, $result));
    }
    // For any remaining forums, give a topic ID of 0.
    if (is_wp_error($bbp_db->query("INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`)\n\t\t\t( SELECT `ID`, '_bbp_last_topic_id', 0\n\t\t\tFROM `{$bbp_db->posts}` AS `forum` LEFT JOIN `{$bbp_db->postmeta}` AS `topic`\n\t\t\tON `forum`.`ID` = `topic`.`post_id` AND `topic`.`meta_key` = '_bbp_last_topic_id'\n\t\t\tWHERE `topic`.`meta_id` IS NULL AND `forum`.`post_type` = '{$fpt}' );"))) {
        return array(5, sprintf($statement, $result));
    }
    // After that, we give all the topics with replies the ID their last reply (again, this time for a different reason).
    if (is_wp_error($bbp_db->query("INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`)\n\t\t\t( SELECT `topic`.`ID`, '_bbp_last_active_id', MAX( `reply`.`ID` )\n\t\t\tFROM `{$bbp_db->posts}` AS `topic` INNER JOIN `{$bbp_db->posts}` AS `reply` ON `topic`.`ID` = `reply`.`post_parent`\n\t\t\tWHERE `reply`.`post_status` = '{$pps}' AND `topic`.`post_type` = '{$tpt}' AND `reply`.`post_type` = '{$rpt}'\n\t\t\tGROUP BY `topic`.`ID` );"))) {
        return array(6, sprintf($statement, $result));
    }
    // For any remaining topics, give a reply ID of themself.
    if (is_wp_error($bbp_db->query("INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`)\n\t\t\t( SELECT `ID`, '_bbp_last_active_id', `ID`\n\t\t\tFROM `{$bbp_db->posts}` AS `topic` LEFT JOIN `{$bbp_db->postmeta}` AS `reply`\n\t\t\tON `topic`.`ID` = `reply`.`post_id` AND `reply`.`meta_key` = '_bbp_last_active_id'\n\t\t\tWHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' );"))) {
        return array(7, sprintf($statement, $result));
    }
    // Give topics with replies their last update time.
    if (is_wp_error($bbp_db->query("INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`)\n\t\t\t( SELECT `topic`.`ID`, '_bbp_last_active_time', MAX( `reply`.`post_date` )\n\t\t\tFROM `{$bbp_db->posts}` AS `topic` INNER JOIN `{$bbp_db->posts}` AS `reply` ON `topic`.`ID` = `reply`.`post_parent`\n\t\t\tWHERE `reply`.`post_status` = '{$pps}' AND `topic`.`post_type` = '{$tpt}' AND `reply`.`post_type` = '{$rpt}'\n\t\t\tGROUP BY `topic`.`ID` );"))) {
        return array(8, sprintf($statement, $result));
    }
    // Give topics without replies their last update time.
    if (is_wp_error($bbp_db->query("INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`)\n\t\t\t( SELECT `ID`, '_bbp_last_active_time', `post_date`\n\t\t\tFROM `{$bbp_db->posts}` AS `topic` LEFT JOIN `{$bbp_db->postmeta}` AS `reply`\n\t\t\tON `topic`.`ID` = `reply`.`post_id` AND `reply`.`meta_key` = '_bbp_last_active_time'\n\t\t\tWHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' );"))) {
        return array(9, sprintf($statement, $result));
    }
    // Forums need to know what their last active item is as well. Now it gets a bit more complex to do in the database.
    $forums = $bbp_db->get_col("SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$fpt}' and `post_status` != 'auto-draft';");
    if (is_wp_error($forums)) {
        return array(10, sprintf($statement, $result));
    }
    // Loop through forums
    foreach ($forums as $forum_id) {
        if (!bbp_is_forum_category($forum_id)) {
            bbp_update_forum(array('forum_id' => $forum_id));
        }
    }
    // Loop through categories when forums are done
    foreach ($forums as $forum_id) {
        if (bbp_is_forum_category($forum_id)) {
            bbp_update_forum(array('forum_id' => $forum_id));
        }
    }
    // Complete results
    return array(0, sprintf($statement, __('Complete!', 'bbpress')));
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:82,代码来源:tools.php

示例6: bbp_trash_topic

/**
 * Called before trashing a topic
 *
 * This function is supplemental to the actual topic being trashed which is
 * handled by WordPress core API functions. It is used to clean up after
 * a topic that is being trashed.
 *
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_is_topic() To check if the passed id is a topic
 * @uses do_action() Calls 'bbp_trash_topic' with the topic id
 * @uses wp_trash_post() To trash the reply
 * @uses update_post_meta() To save a list of just trashed replies for future use
 */
function bbp_trash_topic($topic_id = 0)
{
    // Validate topic ID
    $topic_id = bbp_get_topic_id($topic_id);
    if (empty($topic_id) || !bbp_is_topic($topic_id)) {
        return false;
    }
    do_action('bbp_trash_topic', $topic_id);
    // Topic is being trashed, so its replies are trashed too
    $replies = new WP_Query(array('suppress_filters' => true, 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'post_parent' => $topic_id, 'posts_per_page' => -1, 'nopaging' => true, 'fields' => 'id=>parent'));
    if (!empty($replies->posts)) {
        // Prevent debug notices
        $pre_trashed_replies = array();
        // Loop through replies, trash them, and add them to array
        foreach ($replies->posts as $reply) {
            wp_trash_post($reply->ID);
            $pre_trashed_replies[] = $reply->ID;
        }
        // Set a post_meta entry of the replies that were trashed by this action.
        // This is so we can possibly untrash them, without untrashing replies
        // that were purposefully trashed before.
        update_post_meta($topic_id, '_bbp_pre_trashed_replies', $pre_trashed_replies);
        // Reset the $post global
        wp_reset_postdata();
    }
    // Cleanup
    unset($replies);
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:41,代码来源:functions.php

示例7: bbp_trash_forum_topics

/**
 * Trash all topics inside a forum
 *
 * @since bbPress (r3668)
 *
 * @param int $forum_id
 * @uses bbp_get_forum_id() To validate the forum ID
 * @uses bbp_is_forum() To make sure it's a forum
 * @uses bbp_get_public_status_id() To return public post status
 * @uses bbp_get_closed_status_id() To return closed post status
 * @uses bbp_get_pending_status_id() To return pending post status
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses wp_trash_post() To trash the post
 * @uses update_post_meta() To update the forum meta of trashed topics
 * @return If forum is not valid
 */
function bbp_trash_forum_topics($forum_id = 0)
{
    // Validate forum ID
    $forum_id = bbp_get_forum_id($forum_id);
    if (empty($forum_id)) {
        return;
    }
    // Allowed post statuses to pre-trash
    $post_stati = implode(',', array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_pending_status_id()));
    // Forum is being trashed, so its topics and replies are trashed too
    $topics = new WP_Query(array('suppress_filters' => true, 'post_type' => bbp_get_topic_post_type(), 'post_parent' => $forum_id, 'post_status' => $post_stati, 'posts_per_page' => -1, 'nopaging' => true, 'fields' => 'id=>parent'));
    // Loop through and trash child topics. Topic replies will get trashed by
    // the bbp_trash_topic() action.
    if (!empty($topics->posts)) {
        // Prevent debug notices
        $pre_trashed_topics = array();
        // Loop through topics, trash them, and add them to array
        foreach ($topics->posts as $topic) {
            wp_trash_post($topic->ID, true);
            $pre_trashed_topics[] = $topic->ID;
        }
        // Set a post_meta entry of the topics that were trashed by this action.
        // This is so we can possibly untrash them, without untrashing topics
        // that were purposefully trashed before.
        update_post_meta($forum_id, '_bbp_pre_trashed_topics', $pre_trashed_topics);
        // Reset the $post global
        wp_reset_postdata();
    }
    // Cleanup
    unset($topics);
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:47,代码来源:functions.php

示例8: bbp_is_reply_published

/**
 * Is the reply not spam or deleted?
 *
 * @since bbPress (r3496)
 *
 * @param int $reply_id Optional. Topic id
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_reply_status() To get the reply status
 * @return bool True if published, false if not.
 */
function bbp_is_reply_published($reply_id = 0)
{
    $reply_status = bbp_get_reply_status(bbp_get_reply_id($reply_id)) === bbp_get_public_status_id();
    return (bool) apply_filters('bbp_is_reply_published', (bool) $reply_status, $reply_id);
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:15,代码来源:template.php

示例9: bbp_template_include_theme_compat

/**
 * Reset main query vars and filter 'the_content' to output a bbPress
 * template part as needed.
 *
 * @since bbPress (r3032)
 * @param string $template
 * @uses bbp_is_single_user() To check if page is single user
 * @uses bbp_get_single_user_template() To get user template
 * @uses bbp_is_single_user_edit() To check if page is single user edit
 * @uses bbp_get_single_user_edit_template() To get user edit template
 * @uses bbp_is_single_view() To check if page is single view
 * @uses bbp_get_single_view_template() To get view template
 * @uses bbp_is_forum_edit() To check if page is forum edit
 * @uses bbp_get_forum_edit_template() To get forum edit template
 * @uses bbp_is_topic_merge() To check if page is topic merge
 * @uses bbp_get_topic_merge_template() To get topic merge template
 * @uses bbp_is_topic_split() To check if page is topic split
 * @uses bbp_get_topic_split_template() To get topic split template
 * @uses bbp_is_topic_edit() To check if page is topic edit
 * @uses bbp_get_topic_edit_template() To get topic edit template
 * @uses bbp_is_reply_edit() To check if page is reply edit
 * @uses bbp_get_reply_edit_template() To get reply edit template
 * @uses bbp_set_theme_compat_template() To set the global theme compat template
 */
function bbp_template_include_theme_compat($template = '')
{
    // Bail if the template already matches a bbPress template. This includes
    // archive-* and single-* WordPress post_type matches (allowing
    // themes to use the expected format) as well as all bbPress-specific
    // template files for users, topics, forums, etc...
    if (!empty(bbpress()->theme_compat->bbpress_template)) {
        return $template;
    }
    /** Users *************************************************************/
    if (bbp_is_single_user_edit() || bbp_is_single_user()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => esc_attr(bbp_get_displayed_user_field('display_name')), 'post_status' => bbp_get_public_status_id(), 'is_archive' => false, 'comment_status' => 'closed'));
        /** Forums ************************************************************/
        // Forum archive
    } elseif (bbp_is_forum_archive()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_forum_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Forum
    } elseif (bbp_is_forum_edit() || bbp_is_single_forum()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_forum_id()), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed'));
        /** Topics ************************************************************/
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_topic_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Topic
    } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_topic_id(), 'post_title' => bbp_get_topic_title(), 'post_author' => bbp_get_topic_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_topic_id()), 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_topic_status(), 'is_single' => true, 'comment_status' => 'closed'));
        /** Replies ***********************************************************/
        // Reply archive
    } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => __('Replies', 'bbpress'), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        // Single Reply
    } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_reply_id(), 'post_title' => bbp_get_reply_title(), 'post_author' => bbp_get_reply_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_reply_id()), 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_reply_status(), 'comment_status' => 'closed'));
        /** Views *************************************************************/
    } elseif (bbp_is_single_view()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_view_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        /** Topic Tags ********************************************************/
        // Topic Tag Edit
    } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) {
        // Stash the current term in a new var
        set_query_var('bbp_topic_tag', get_query_var('term'));
        // Reset the post with our new title
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => sprintf(__('Topic Tag: %s', 'bbpress'), '<span>' . bbp_get_topic_tag_name() . '</span>'), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
    }
    /**
     * If we are relying on bbPress's built in theme compatibility to load
     * the proper content, we need to intercept the_content, replace the
     * output, and display ours instead.
     *
     * To do this, we first remove all filters from 'the_content' and hook
     * our own function into it, which runs a series of checks to determine
     * the context, and then uses the built in shortcodes to output the
     * correct results from inside an output buffer.
     *
     * Uses bbp_get_theme_compat_templates() to provide fall-backs that
     * should be coded without superfluous mark-up and logic (prev/next
     * navigation, comments, date/time, etc...)
     * 
     * Hook into the 'bbp_get_bbpress_template' to override the array of
     * possible templates, or 'bbp_bbpress_template' to override the result.
     */
    if (bbp_is_theme_compat_active()) {
        // Remove all filters from the_content
        bbp_remove_all_filters('the_content');
        // Add a filter on the_content late, which we will later remove
        add_filter('the_content', 'bbp_replace_the_content');
        // Find the appropriate template file
        $template = bbp_get_theme_compat_templates();
//.........这里部分代码省略.........
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:theme-compat.php

示例10: bbp_unspam_reply

/**
 * Unspams a reply
 *
 * @since bbPress (r2740)
 *
 * @param int $reply_id Reply id
 * @uses bbp_get_reply() To get the reply
 * @uses do_action() Calls 'bbp_unspam_reply' with the reply ID
 * @uses get_post_meta() To get the previous status meta
 * @uses delete_post_meta() To delete the previous status meta
 * @uses wp_update_post() To insert the updated post
 * @uses do_action() Calls 'bbp_unspammed_reply' with the reply ID
 * @return mixed False or {@link WP_Error} on failure, reply id on success
 */
function bbp_unspam_reply($reply_id = 0)
{
    // Get reply
    $reply = bbp_get_reply($reply_id);
    if (empty($reply)) {
        return $reply;
    }
    // Bail if already not spam
    if (bbp_get_spam_status_id() !== $reply->post_status) {
        return false;
    }
    // Execute pre unspam code
    do_action('bbp_unspam_reply', $reply_id);
    // Get pre spam status
    $reply->post_status = get_post_meta($reply_id, '_bbp_spam_meta_status', true);
    // If no previous status, default to publish
    if (empty($reply->post_status)) {
        $reply->post_status = bbp_get_public_status_id();
    }
    // Delete pre spam meta
    delete_post_meta($reply_id, '_bbp_spam_meta_status');
    // No revisions
    remove_action('pre_post_update', 'wp_save_post_revision');
    // Update the reply
    $reply_id = wp_update_post($reply);
    // Execute post unspam code
    do_action('bbp_unspammed_reply', $reply_id);
    // Return reply_id
    return $reply_id;
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:44,代码来源:functions.php

示例11: row_actions

 /**
  * Topic Row actions
  *
  * Remove the quick-edit action link under the topic title and add the
  * content and close/stick/spam links
  *
  * @since 2.0.0 bbPress (r2485)
  *
  * @param array $actions Actions
  * @param array $topic Topic object
  * @uses bbp_get_topic_post_type() To get the topic post type
  * @uses bbp_topic_content() To output topic content
  * @uses bbp_get_topic_permalink() To get the topic link
  * @uses bbp_get_topic_title() To get the topic title
  * @uses current_user_can() To check if the current user can edit or
  *                           delete the topic
  * @uses bbp_is_topic_open() To check if the topic is open
  * @uses bbp_is_topic_spam() To check if the topic is marked as spam
  * @uses bbp_is_topic_sticky() To check if the topic is a sticky or a
  *                              super sticky
  * @uses get_post_type_object() To get the topic post type object
  * @uses add_query_arg() To add custom args to the url
  * @uses remove_query_arg() To remove custom args from the url
  * @uses wp_nonce_url() To nonce the url
  * @uses get_delete_post_link() To get the delete post link of the topic
  * @return array $actions Actions
  */
 public function row_actions($actions, $topic)
 {
     if ($this->bail()) {
         return $actions;
     }
     unset($actions['inline hide-if-no-js']);
     // Show view link if it's not set, the topic is trashed and the user can view trashed topics
     if (empty($actions['view']) && bbp_get_trash_status_id() === $topic->post_status && current_user_can('view_trash')) {
         $actions['view'] = '<a href="' . esc_url(bbp_get_topic_permalink($topic->ID)) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;', 'bbpress'), bbp_get_topic_title($topic->ID))) . '" rel="permalink">' . esc_html__('View', 'bbpress') . '</a>';
     }
     // Only show the actions if the user is capable of viewing them :)
     if (current_user_can('moderate', $topic->ID)) {
         // Pending
         // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only
         $approve_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'approve-topic_' . $topic->ID);
         if (bbp_is_topic_published($topic->ID)) {
             $actions['unapproved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Unapprove this topic', 'bbpress') . '">' . _x('Unapprove', 'Unapprove Topic', 'bbpress') . '</a>';
         } elseif (!bbp_is_topic_private($topic->ID)) {
             $actions['approved'] = '<a href="' . esc_url($approve_uri) . '" title="' . esc_attr__('Approve this topic', 'bbpress') . '">' . _x('Approve', 'Approve Topic', 'bbpress') . '</a>';
             $actions['view'] = '<a href="' . esc_url(bbp_get_topic_permalink($topic->ID)) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;', 'bbpress'), bbp_get_topic_title($topic->ID))) . '" rel="permalink">' . esc_html__('View', 'bbpress') . '</a>';
         }
         // Close
         // Show the 'close' and 'open' link on published and closed posts only
         if (in_array($topic->post_status, array(bbp_get_public_status_id(), bbp_get_closed_status_id()))) {
             $close_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_close'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'close-topic_' . $topic->ID);
             if (bbp_is_topic_open($topic->ID)) {
                 $actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Close this topic', 'bbpress') . '">' . _x('Close', 'Close a Topic', 'bbpress') . '</a>';
             } else {
                 $actions['closed'] = '<a href="' . esc_url($close_uri) . '" title="' . esc_attr__('Open this topic', 'bbpress') . '">' . _x('Open', 'Open a Topic', 'bbpress') . '</a>';
             }
         }
         // Sticky
         // Dont show sticky if topic links is spam, trash or pending
         if (!bbp_is_topic_spam($topic->ID) && !bbp_is_topic_trash($topic->ID) && !bbp_is_topic_pending($topic->ID)) {
             $stick_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'stick-topic_' . $topic->ID);
             if (bbp_is_topic_sticky($topic->ID)) {
                 $actions['stick'] = '<a href="' . esc_url($stick_uri) . '" title="' . esc_attr__('Unstick this topic', 'bbpress') . '">' . esc_html__('Unstick', 'bbpress') . '</a>';
             } else {
                 $super_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick', 'super' => '1'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'stick-topic_' . $topic->ID);
                 $actions['stick'] = '<a href="' . esc_url($stick_uri) . '" title="' . esc_attr__('Stick this topic to its forum', 'bbpress') . '">' . esc_html__('Stick', 'bbpress') . '</a> <a href="' . esc_url($super_uri) . '" title="' . esc_attr__('Stick this topic to front', 'bbpress') . '">' . esc_html__('(to front)', 'bbpress') . '</a>';
             }
         }
         // Spam
         $spam_uri = wp_nonce_url(add_query_arg(array('topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_spam'), remove_query_arg(array('bbp_topic_toggle_notice', 'topic_id', 'failed', 'super'))), 'spam-topic_' . $topic->ID);
         if (bbp_is_topic_spam($topic->ID)) {
             $actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark the topic as not spam', 'bbpress') . '">' . esc_html__('Not spam', 'bbpress') . '</a>';
         } else {
             $actions['spam'] = '<a href="' . esc_url($spam_uri) . '" title="' . esc_attr__('Mark this topic as spam', 'bbpress') . '">' . esc_html__('Spam', 'bbpress') . '</a>';
         }
     }
     // Do not show trash links for spam topics, or spam links for trashed topics
     if (current_user_can('delete_topic', $topic->ID)) {
         if (bbp_get_trash_status_id() === $topic->post_status) {
             $post_type_object = get_post_type_object(bbp_get_topic_post_type());
             $actions['untrash'] = "<a title='" . esc_attr__('Restore this item from the Trash', 'bbpress') . "' href='" . wp_nonce_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_topic_post_type()), admin_url('edit.php'))), admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $topic->ID))), 'untrash-' . $topic->post_type . '_' . $topic->ID) . "'>" . esc_html__('Restore', 'bbpress') . "</a>";
         } elseif (EMPTY_TRASH_DAYS) {
             $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__('Move this item to the Trash', 'bbpress') . "' href='" . esc_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_topic_post_type()), admin_url('edit.php'))), get_delete_post_link($topic->ID))) . "'>" . esc_html__('Trash', 'bbpress') . "</a>";
         }
         if (bbp_get_trash_status_id() === $topic->post_status || !EMPTY_TRASH_DAYS) {
             $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__('Delete this item permanently', 'bbpress') . "' href='" . esc_url(add_query_arg(array('_wp_http_referer' => add_query_arg(array('post_type' => bbp_get_topic_post_type()), admin_url('edit.php'))), get_delete_post_link($topic->ID, '', true))) . "'>" . esc_html__('Delete Permanently', 'bbpress') . "</a>";
         } elseif (bbp_get_spam_status_id() === $topic->post_status) {
             unset($actions['trash']);
         }
     }
     return $actions;
 }
开发者ID:joeyblake,项目名称:bbpress,代码行数:93,代码来源:topics.php

示例12: widget

    /**
     * Displays the output, the replies list
     *
     * @since bbPress (r2653)
     *
     * @param mixed $args
     * @param array $instance
     * @uses apply_filters() Calls 'bbp_reply_widget_title' with the title
     * @uses bbp_get_reply_author_link() To get the reply author link
     * @uses bbp_get_reply_id() To get the reply id
     * @uses bbp_get_reply_url() To get the reply url
     * @uses bbp_get_reply_excerpt() To get the reply excerpt
     * @uses bbp_get_reply_topic_title() To get the reply topic title
     * @uses get_the_date() To get the date of the reply
     * @uses get_the_time() To get the time of the reply
     */
    public function widget($args, $instance)
    {
        // Get widget settings
        $settings = $this->parse_settings($instance);
        // Typical WordPress filter
        $settings['title'] = apply_filters('widget_title', $settings['title'], $instance, $this->id_base);
        // bbPress filter
        $settings['title'] = apply_filters('bbp_replies_widget_title', $settings['title'], $instance, $this->id_base);
        // Note: private and hidden forums will be excluded via the
        // bbp_pre_get_posts_normalize_forum_visibility action and function.
        $widget_query = new WP_Query(array('post_type' => bbp_get_reply_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'posts_per_page' => (int) $settings['max_shown'], 'ignore_sticky_posts' => true, 'no_found_rows' => true));
        // Bail if no replies
        if (!$widget_query->have_posts()) {
            return;
        }
        echo $args['before_widget'];
        if (!empty($settings['title'])) {
            echo $args['before_title'] . $settings['title'] . $args['after_title'];
        }
        ?>

		<ul>

			<?php 
        while ($widget_query->have_posts()) {
            $widget_query->the_post();
            ?>

				<li>

					<?php 
            // Verify the reply ID
            $reply_id = bbp_get_reply_id($widget_query->post->ID);
            $reply_link = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($reply_id, 50)) . '">' . bbp_get_reply_topic_title($reply_id) . '</a>';
            // Only query user if showing them
            if (!empty($settings['show_user'])) {
                $author_link = bbp_get_reply_author_link(array('post_id' => $reply_id, 'type' => 'both', 'size' => 14));
            } else {
                $author_link = false;
            }
            // Reply author, link, and timestamp
            if (!empty($settings['show_date']) && !empty($author_link)) {
                // translators: 1: reply author, 2: reply link, 3: reply timestamp
                printf(_x('%1$s on %2$s %3$s', 'widgets', 'bbpress'), $author_link, $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                // Reply link and timestamp
            } elseif (!empty($settings['show_date'])) {
                // translators: 1: reply link, 2: reply timestamp
                printf(_x('%1$s %2$s', 'widgets', 'bbpress'), $reply_link, '<div>' . bbp_get_time_since(get_the_time('U')) . '</div>');
                // Reply author and title
            } elseif (!empty($author_link)) {
                // translators: 1: reply author, 2: reply link
                printf(_x('%1$s on %2$s', 'widgets', 'bbpress'), $author_link, $reply_link);
                // Only the reply title
            } else {
                // translators: 1: reply link
                printf(_x('%1$s', 'widgets', 'bbpress'), $reply_link);
            }
            ?>

				</li>

			<?php 
        }
        ?>

		</ul>

		<?php 
        echo $args['after_widget'];
        // Reset the $post global
        wp_reset_postdata();
    }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:88,代码来源:widgets.php

示例13: test_bbp_unspam_topic_replies

 /**
  * @covers ::bbp_unspam_topic_replies
  */
 public function test_bbp_unspam_topic_replies()
 {
     $f = $this->factory->forum->create();
     $now = time();
     $post_date_topic = date('Y-m-d H:i:s', $now - 60 * 60 * 100);
     $post_date_reply = date('Y-m-d H:i:s', $now - 60 * 60 * 80);
     $topic_time = '4 days, 4 hours ago';
     $reply_time = '3 days, 8 hours ago';
     $t = $this->factory->topic->create(array('post_parent' => $f, 'post_date' => $post_date_topic, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create_many(2, array('post_parent' => $t, 'post_date' => $post_date_reply, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     bbp_spam_topic_replies($t);
     bbp_unspam_topic_replies($t);
     $this->assertEquals('', get_post_meta($t, '_bbp_pre_spammed_replies', true));
     $this->assertEquals(array(), get_post_meta($t, '_bbp_pre_spammed_replies', false));
     foreach ($r as $reply) {
         $reply_status = get_post_status($reply);
         $this->assertSame(bbp_get_public_status_id(), $reply_status);
         $this->assertEquals('', get_post_meta($reply, '_wp_trash_meta_status', true));
         $this->assertEquals(array(), get_post_meta($reply, '_wp_trash_meta_status', false));
     }
     $count = bbp_get_forum_reply_count($f, false, true);
     $this->assertSame(2, $count);
     $last_reply_id = bbp_get_forum_last_reply_id($f);
     $this->assertSame($r[1], $last_reply_id);
     $last_active_id = bbp_get_forum_last_active_id($f);
     $this->assertSame($r[1], $last_active_id);
     $last_active_time = bbp_get_forum_last_active_time($f);
     $this->assertSame($reply_time, $last_active_time);
     $count = bbp_get_topic_reply_count($t, true, true);
     $this->assertSame(2, $count);
     $count = bbp_get_topic_reply_count_hidden($t, true, true);
     $this->assertSame(0, $count);
     $last_reply_id = bbp_get_topic_last_reply_id($t);
     $this->assertSame($r[1], $last_reply_id);
     $last_active_id = bbp_get_topic_last_active_id($t);
     $this->assertSame($r[1], $last_active_id);
     $last_active_time = bbp_get_topic_last_active_time($t);
     $this->assertSame($reply_time, $last_active_time);
 }
开发者ID:joeyblake,项目名称:bbpress,代码行数:42,代码来源:status.php

示例14: create_screen_save

 /**
  * Save the Group Forum data on create
  *
  * @since bbPress (r3465)
  */
 public function create_screen_save($group_id = 0)
 {
     // Nonce check
     if (!bbp_verify_nonce_request('groups_create_save_' . $this->slug)) {
         bbp_add_error('bbp_create_group_forum_screen_save', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress'));
         return;
     }
     // Check for possibly empty group_id
     if (empty($group_id)) {
         $group_id = bp_get_new_group_id();
     }
     $create_forum = !empty($_POST['bbp-create-group-forum']) ? true : false;
     $forum_id = 0;
     $forum_ids = bbp_get_group_forum_ids($group_id);
     if (!empty($forum_ids)) {
         $forum_id = (int) is_array($forum_ids) ? $forum_ids[0] : $forum_ids;
     }
     // Create a forum, or not
     switch ($create_forum) {
         case true:
             // Bail if initial content was already created
             if (!empty($forum_id)) {
                 return;
             }
             // Set the default forum status
             switch (bp_get_new_group_status()) {
                 case 'hidden':
                     $status = bbp_get_hidden_status_id();
                     break;
                 case 'private':
                     $status = bbp_get_private_status_id();
                     break;
                 case 'public':
                 default:
                     $status = bbp_get_public_status_id();
                     break;
             }
             // Create the initial forum
             $forum_id = bbp_insert_forum(array('post_parent' => bbp_get_group_forums_root_id(), 'post_title' => bp_get_new_group_name(), 'post_content' => bp_get_new_group_description(), 'post_status' => $status));
             // Run the BP-specific functions for new groups
             $this->new_forum(array('forum_id' => $forum_id));
             // Update forum active
             groups_update_groupmeta(bp_get_new_group_id(), '_bbp_forum_enabled_' . $forum_id, true);
             // Toggle forum on
             $this->toggle_group_forum(bp_get_new_group_id(), true);
             break;
         case false:
             // Forum was created but is now being undone
             if (!empty($forum_id)) {
                 // Delete the forum
                 wp_delete_post($forum_id, true);
                 // Delete meta values
                 groups_delete_groupmeta(bp_get_new_group_id(), 'forum_id');
                 groups_delete_groupmeta(bp_get_new_group_id(), '_bbp_forum_enabled_' . $forum_id);
                 // Toggle forum off
                 $this->toggle_group_forum(bp_get_new_group_id(), false);
             }
             break;
     }
 }
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:65,代码来源:groups.php

示例15: check_post

 /**
  * Converts topic/reply data into Akismet comment checking format
  *
  * @since bbPress (r3277)
  *
  * @param string $post_data
  *
  * @uses get_userdata() To get the user data
  * @uses bbp_filter_anonymous_user_data() To get anonymous user data
  * @uses bbp_get_topic_permalink() To get the permalink of the topic
  * @uses bbp_get_reply_url() To get the permalink of the reply
  * @uses bbp_current_author_ip() To get the IP address of the current user
  * @uses BBP_Akismet::maybe_spam() To check if post is spam
  * @uses akismet_get_user_roles() To get the role(s) of the current user
  * @uses do_action() To call the 'bbp_akismet_spam_caught' hook
  * @uses add_filter() To call the 'bbp_new_reply_pre_set_terms' hook
  *
  * @return array Array of post data
  */
 public function check_post($post_data)
 {
     // Define local variables
     $user_data = array();
     $post_permalink = '';
     // Post is not published
     if (bbp_get_public_status_id() != $post_data['post_status']) {
         return $post_data;
     }
     // Cast the post_author to 0 if it's empty
     if (empty($post_data['post_author'])) {
         $post_data['post_author'] = 0;
     }
     /** Author ************************************************************/
     // Get user data
     $userdata = get_userdata($post_data['post_author']);
     $anonymous_data = bbp_filter_anonymous_post_data();
     // Author is anonymous
     if (!empty($anonymous_data)) {
         $user_data['name'] = $anonymous_data['bbp_anonymous_name'];
         $user_data['email'] = $anonymous_data['bbp_anonymous_name'];
         $user_data['website'] = $anonymous_data['bbp_anonymous_name'];
         // Author is logged in
     } elseif (!empty($userdata)) {
         $user_data['name'] = $userdata->display_name;
         $user_data['email'] = $userdata->user_email;
         $user_data['website'] = $userdata->user_url;
         // Missing author data, so set some empty strings
     } else {
         $user_data['name'] = '';
         $user_data['email'] = '';
         $user_data['website'] = '';
     }
     /** Post **************************************************************/
     // Use post parent for permalink
     if (!empty($post_data['post_parent'])) {
         $post_permalink = get_permalink($post_data['post_parent']);
     }
     // Put post_data back into usable array
     $_post = array('comment_author' => $user_data['name'], 'comment_author_email' => $user_data['email'], 'comment_author_url' => $user_data['website'], 'comment_content' => $post_data['post_content'], 'comment_post_ID' => $post_data['post_parent'], 'comment_type' => $post_data['post_type'], 'permalink' => $post_permalink, 'referrer' => $_SERVER['HTTP_REFERER'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'user_ID' => $post_data['post_author'], 'user_ip' => bbp_current_author_ip(), 'user_role' => akismet_get_user_roles($post_data['post_author']));
     // Check the post_data
     $_post = $this->maybe_spam($_post);
     // Get the result
     $post_data['bbp_akismet_result'] = $_post['bbp_akismet_result'];
     unset($_post['bbp_akismet_result']);
     // Store the data as submitted
     $post_data['bbp_post_as_submitted'] = $_post;
     // Allow post_data to be manipulated
     do_action_ref_array('bbp_akismet_check_post', $post_data);
     // Spam
     if ('true' == $post_data['bbp_akismet_result']) {
         // Let plugins do their thing
         do_action('bbp_akismet_spam_caught');
         // This is spam
         $post_data['post_status'] = bbp_get_spam_status_id();
         // We don't want your spam tags here
         add_filter('bbp_new_reply_pre_set_terms', array($this, 'filter_post_terms'), 1, 3);
         // @todo Spam counter?
     }
     // @todo Topic/reply moderation? No true/false response - 'pending' or 'draft'
     // @todo Auto-delete old spam?
     // Log the last post
     $this->last_post = $post_data;
     // Pass the data back to the filter
     return $post_data;
 }
开发者ID:rmccue,项目名称:bbPress,代码行数:85,代码来源:bbp-extend-akismet.php


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