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

PHP bbp_get_topic函数代码示例

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

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



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

示例1: test_bbp_insert_topic

 /**
  * @group canonical
  * @covers ::bbp_insert_topic
  */
 public function test_bbp_insert_topic()
 {
     $f = $this->factory->forum->create();
     $now = time();
     $post_date = date('Y-m-d H:i:s', $now - 60 * 60 * 100);
     $t = $this->factory->topic->create(array('post_title' => 'Topic 1', 'post_content' => 'Content for Topic 1', 'post_parent' => $f, 'post_date' => $post_date, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->reply->create(array('post_parent' => $t, 'post_date' => $post_date, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     // Get the topic.
     $topic = bbp_get_topic($t);
     remove_all_filters('bbp_get_topic_content');
     // Topic post.
     $this->assertSame('Topic 1', bbp_get_topic_title($t));
     $this->assertSame('Content for Topic 1', bbp_get_topic_content($t));
     $this->assertSame('publish', bbp_get_topic_status($t));
     $this->assertSame($f, wp_get_post_parent_id($t));
     $this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?topic=' . $topic->post_name, $topic->guid);
     // Topic meta.
     $this->assertSame($f, bbp_get_topic_forum_id($t));
     $this->assertSame(1, bbp_get_topic_reply_count($t, true));
     $this->assertSame(0, bbp_get_topic_reply_count_hidden($t, true));
     $this->assertSame(1, bbp_get_topic_voice_count($t, true));
     $this->assertSame($r, bbp_get_topic_last_reply_id($t));
     $this->assertSame($r, bbp_get_topic_last_active_id($t));
     $this->assertSame('4 days, 4 hours ago', bbp_get_topic_last_active_time($t));
 }
开发者ID:joeyblake,项目名称:bbpress,代码行数:29,代码来源:topic.php


示例2: widget


//.........这里部分代码省略.........
                                                    continue;
                                                }
                                            }
                                        }
                                        $title = trim(strip_tags($activity->content));
                                        $permalink = bp_activity_get_permalink($id);
                                    } else {
                                        if ('users' === $type) {
                                            $id = RatingWidgetPlugin::Urid2UserId($urid);
                                            if ($bpInstalled) {
                                                $title = trim(strip_tags(bp_core_get_user_displayname($id)));
                                                $permalink = bp_core_get_user_domain($id);
                                            } else {
                                                if ($bbInstalled) {
                                                    $title = trim(strip_tags(bbp_get_user_display_name($id)));
                                                    $permalink = bbp_get_user_profile_url($id);
                                                } else {
                                                    continue;
                                                }
                                            }
                                        } else {
                                            if ('forum_posts' === $type || 'forum_replies' === $type) {
                                                $id = RatingWidgetPlugin::Urid2ForumPostId($urid);
                                                if (function_exists('bp_forums_get_post')) {
                                                    $forum_post = @bp_forums_get_post($id);
                                                    if (!is_object($forum_post)) {
                                                        continue;
                                                    }
                                                    $title = trim(strip_tags($forum_post->post_text));
                                                    $page = bb_get_page_number($forum_post->post_position);
                                                    $permalink = get_topic_link($id, $page) . "#post-{$id}";
                                                } else {
                                                    if (function_exists('bbp_get_reply_id')) {
                                                        $forum_item = bbp_get_topic();
                                                        if (is_object($forum_item)) {
                                                            $is_topic = true;
                                                        } else {
                                                            $is_topic = false;
                                                            $forum_item = bbp_get_reply($id);
                                                            if (!is_object($forum_item)) {
                                                                if (RWLogger::IsOn()) {
                                                                    RWLogger::Log('BBP_FORUM_ITEM_NOT_EXIST', $id);
                                                                }
                                                                // Invalid id (no topic nor reply).
                                                                continue;
                                                            }
                                                            if (RWLogger::IsOn()) {
                                                                RWLogger::Log('BBP_IS_TOPIC_REPLY', $is_topic ? 'FALSE' : 'TRUE');
                                                            }
                                                        }
                                                        // Visible statueses: Public or Closed.
                                                        $visible_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id());
                                                        if (!in_array($forum_item->post_status, $visible_statuses)) {
                                                            if (RWLogger::IsOn()) {
                                                                RWLogger::Log('BBP_FORUM_ITEM_HIDDEN', $forum_item->post_status);
                                                            }
                                                            // Item is not public nor closed.
                                                            continue;
                                                        }
                                                        $is_reply = !$is_topic;
                                                        if ($is_reply) {
                                                            // Get parent topic.
                                                            $forum_topic = bbp_get_topic($forum_post->post_parent);
                                                            if (!in_array($forum_topic->post_status, $visible_statuses)) {
                                                                if (RWLogger::IsOn()) {
                                                                    RWLogger::Log('BBP_PARENT_FORUM_TOPIC_IS_HIDDEN', 'TRUE');
开发者ID:AlexOreshkevich,项目名称:velomode.by,代码行数:67,代码来源:rw-top-rated-widget.php


示例3: toggle_topic_notice_admin

    /**
     * Prints an admin notice when a topic has been (un)reported
     *
     * @since 1.0.0
     *
     * @return null
     */
    public function toggle_topic_notice_admin()
    {
        // Bail if we're not editing topics
        if (bbp_get_topic_post_type() != get_current_screen()->post_type) {
            return;
        }
        // Only proceed if GET is a topic toggle action
        if (bbp_is_get_request() && !empty($_GET['bbp_topic_toggle_notice']) && in_array($_GET['bbp_topic_toggle_notice'], array('unreported')) && !empty($_GET['topic_id'])) {
            $notice = $_GET['bbp_topic_toggle_notice'];
            // Which notice?
            $topic_id = (int) $_GET['topic_id'];
            // What's the topic id?
            $is_failure = !empty($_GET['failed']) ? true : false;
            // Was that a failure?
            // Bails if no topic_id or notice
            if (empty($notice) || empty($topic_id)) {
                return;
            }
            // Bail if topic is missing
            $topic = bbp_get_topic($topic_id);
            if (empty($topic)) {
                return;
            }
            $topic_title = bbp_get_topic_title($topic->ID);
            switch ($notice) {
                case 'unreported':
                    $message = $is_failure === true ? sprintf(__('There was a problem unreporting the topic "%1$s".', 'bbpress-report-content'), $topic_title) : sprintf(__('Topic "%1$s" successfully unreported.', 'bbpress-report-content'), $topic_title);
                    break;
            }
            ?>

			<div id="message" class="<?php 
            echo $is_failure === true ? 'error' : 'updated';
            ?>
 fade">
				<p style="line-height: 150%"><?php 
            echo esc_html($message);
            ?>
</p>
			</div>

			<?php 
        }
    }
开发者ID:richrd,项目名称:bbpress-report-content,代码行数:51,代码来源:class-bbpress-report-content.php


示例4: AddBBPressTopLeftOrRightRating

 /**
  * Add bbPress top left & right ratings.
  * Invoked on bbp_theme_before_reply_admin_links.
  */
 public function AddBBPressTopLeftOrRightRating()
 {
     if (RWLogger::IsOn()) {
         $params = func_get_args();
         RWLogger::LogEnterence('AddBBPressTopLeftOrRightRating', $params);
     }
     $forum_item = bbp_get_reply(bbp_get_reply_id());
     $is_reply = is_object($forum_item);
     if (!$is_reply) {
         $forum_item = bbp_get_topic(bbp_get_topic_id());
     }
     $class = $is_reply ? 'forum-reply' : 'forum-post';
     if (RWLogger::IsOn()) {
         RWLogger::Log('AddBBPressTopLeftOrRightRating', $class . ': ' . var_export($forum_item, true));
     }
     $ratingHtml = $this->EmbedRatingIfVisibleByPost($forum_item, $class, false, 'f' . $this->forum_post_align->hor, 'display: inline; margin-' . ('left' === $this->forum_post_align->hor ? 'right' : 'left') . ': 10px;');
     echo $ratingHtml;
 }
开发者ID:robertoAg,项目名称:wordpress_humor,代码行数:22,代码来源:rating-widget.php


示例5: process_topic_option

    /**
     * Process the user's bbPress topic selections when the post is saved
     */
    function process_topic_option($post_ID, $post)
    {
        /** Don't process on AJAX-based auto-drafts */
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
            return;
        }
        /** Don't process on initial page load auto drafts */
        if ($post->post_status == 'auto-draft') {
            return;
        }
        /** Only process for post types we specify */
        if (!in_array($post->post_type, apply_filters('bbppt_eligible_post_types', array('post', 'page')))) {
            return;
        }
        // TODO: combine existing topic and draft settings branches
        if (isset($_POST['bbpress_topic'])) {
            /**
             * Post was created through the full post editor form
             * Check the POST for settings
             */
            if (!empty($_POST['bbpress_topic']['enabled'])) {
                $bbppt_options = $_POST['bbpress_topic'];
                $create_topic = true;
                $use_defaults = isset($bbppt_options['use_defaults']);
                bbppt_debug('Processing a topic for regular post ' . $post_ID . ' with the following settings: ' . print_r($bbppt_options, true));
                bbppt_debug('Creating topic?: ' . $create_topic . '; using defaults?: ' . $use_defaults);
            } else {
                $create_topic = false;
                $bbppt_options = array();
                bbppt_debug('NOT creating a topic for regular post ' . $post_ID);
            }
        } else {
            if (get_post_meta($post_ID, 'bbpress_discussion_topic_id', true)) {
                /**
                 * If post has an existing topic, use its settings
                 */
                $bbppt_options = $this->get_topic_options_for_post($post_ID);
                $create_topic = !empty($bbppt_options['enabled']);
                $use_defaults = !empty($bbppt_options['use_defaults']);
                bbppt_debug('Processing topic for existing post ' . $post_ID . ' with the following settings: ' . print_r($bbppt_options, true));
                bbppt_debug('Creating topic?: ' . $create_topic . '; using defaults?: ' . $use_defaults);
            } else {
                if ($this->has_draft_settings($post)) {
                    /**
                     * If the post has draft settings saved, use draft settings
                     */
                    $bbppt_options = $this->get_draft_settings($post);
                    $create_topic = !empty($bbppt_options['enabled']);
                    $use_defaults = !empty($bbppt_options['use_defaults']);
                    bbppt_debug('Processing a topic for draft post ' . $post_ID . ' with the following settings: ' . print_r($bbppt_options, true));
                    bbppt_debug('Creating topic?: ' . $create_topic . '; using defaults?: ' . $use_defaults);
                } else {
                    /**
                     * Post was created through some other means (including XML-RPC) - use defaults
                     */
                    $bbppt_options = get_option('bbpress_discussion_defaults');
                    $create_topic = !empty($bbppt_options['enabled']);
                    $use_defaults = true;
                    $bbppt_options['use_defaults'] = $use_defaults;
                    bbppt_debug('Processing a topic for unattended post ' . $post_ID . ' with the following settings: ' . print_r($bbppt_options, true));
                    bbppt_debug('Creating topic?: ' . $create_topic . '; using defaults?: ' . $use_defaults);
                }
            }
        }
        /** If post is saved as a draft, store selected settings for publication later */
        if (in_array($post->post_status, apply_filters('bbppt_draft_post_status', array('draft', 'future')))) {
            $this->set_draft_settings($bbppt_options, $post);
            return;
        }
        /** Only process further when the post is published */
        if (!in_array($post->post_status, apply_filters('bbppt_eligible_post_status', array('publish', 'private')))) {
            return;
        }
        /**
         * The user requested to use a bbPress topic for discussion
         */
        if ($create_topic) {
            if (!function_exists('bbp_has_forums')) {
                ?>
<br /><p><?php 
                _e('bbPress Topics for Posts cannot process this request because it cannot detect your bbPress setup.', 'bbpress-post-topics');
                ?>
</p><?php 
                return;
            }
            $topic_slug = isset($bbppt_options['slug']) ? $bbppt_options['slug'] : '';
            $topic_forum = isset($bbppt_options['forum_id']) ? (int) $bbppt_options['forum_id'] : 0;
            if (!$use_defaults) {
                $topic_display = isset($bbppt_options['display']) ? $bbppt_options['display'] : 'topic';
                /** Store extra data for xreplies, as well as any custom display formats */
                $topic_display_extras = apply_filters('bbppt_store_display_extras', $bbppt_options['display-extras'], $post);
            }
            if (!empty($topic_slug)) {
                /** if user has selected an existing topic */
                if (is_numeric($topic_slug)) {
                    $topic = bbp_get_topic((int) $topic_slug);
                } else {
//.........这里部分代码省略.........
开发者ID:benklocek,项目名称:bbPress-Topics-for-Posts,代码行数:101,代码来源:index.php


示例6: bbp_unspam_topic

/**
 * Unspams a topic
 *
 * @since bbPress (r2740)
 *
 * @param int $topic_id Topic id
 * @uses bbp_get_topic() To get the topic
 * @uses do_action() Calls 'bbp_unspam_topic' with the topic id
 * @uses get_post_meta() To get the previous status
 * @uses delete_post_meta() To delete the previous status meta
 * @uses wp_update_post() To update the topic with the new status
 * @uses do_action() Calls 'bbp_unspammed_topic' with the topic id
 * @return mixed False or {@link WP_Error} on failure, topic id on success
 */
function bbp_unspam_topic($topic_id = 0)
{
    // Get the topic
    $topic = bbp_get_topic($topic_id);
    if (empty($topic)) {
        return $topic;
    }
    // Bail if already not spam
    if (bbp_get_spam_status_id() !== $topic->post_status) {
        return false;
    }
    // Execute pre unspam code
    do_action('bbp_unspam_topic', $topic_id);
    /** Untrash Replies *******************************************************/
    // Get the replies that were not previously trashed
    $pre_spammed_replies = get_post_meta($topic_id, '_bbp_pre_spammed_replies', true);
    // There are replies to untrash
    if (!empty($pre_spammed_replies)) {
        // Maybe reverse the trashed replies array
        if (is_array($pre_spammed_replies)) {
            $pre_spammed_replies = array_reverse($pre_spammed_replies);
        }
        // Loop through replies
        foreach ((array) $pre_spammed_replies as $reply) {
            wp_untrash_post($reply);
        }
    }
    /** Topic Tags ************************************************************/
    // Get pre-spam topic tags
    $terms = get_post_meta($topic_id, '_bbp_spam_topic_tags', true);
    // Topic had tags before it was spammed
    if (!empty($terms)) {
        // Set the tax_input of the topic
        $topic->tax_input = array(bbp_get_topic_tag_tax_id() => $terms);
        // Delete pre-spam topic tag meta
        delete_post_meta($topic_id, '_bbp_spam_topic_tags');
    }
    /** Topic Status **********************************************************/
    // Get pre spam status
    $topic_status = get_post_meta($topic_id, '_bbp_spam_meta_status', true);
    // If no previous status, default to publish
    if (empty($topic_status)) {
        $topic_status = bbp_get_public_status_id();
    }
    // Set post status to pre spam
    $topic->post_status = $topic_status;
    // Delete pre spam meta
    delete_post_meta($topic_id, '_bbp_spam_meta_status');
    // No revisions
    remove_action('pre_post_update', 'wp_save_post_revision');
    // Update the topic
    $topic_id = wp_update_post($topic);
    // Execute post unspam code
    do_action('bbp_unspammed_topic', $topic_id);
    // Return topic_id
    return $topic_id;
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:71,代码来源:functions.php


示例7: bbp_move_reply_handler

/**
 * Move reply handler
 *
 * Handles the front end move reply submission
 *
 * @since bbPress (r4521)
 *
 * @param string $action The requested action to compare this function to
 * @uses bbp_add_error() To add an error message
 * @uses bbp_get_reply() To get the reply
 * @uses bbp_get_topic() To get the topics
 * @uses bbp_verify_nonce_request() To verify the nonce and check the request
 * @uses current_user_can() To check if the current user can edit the reply and topics
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses is_wp_error() To check if the value retrieved is a {@link WP_Error}
 * @uses do_action() Calls 'bbp_pre_move_reply' with the from reply id, source
 *                    and destination topic ids
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses wpdb::prepare() To prepare our sql query
 * @uses wpdb::get_results() To execute the sql query and get results
 * @uses wp_update_post() To update the replies
 * @uses bbp_update_reply_topic_id() To update the reply topic id
 * @uses bbp_get_topic_forum_id() To get the topic forum id
 * @uses bbp_update_reply_forum_id() To update the reply forum id
 * @uses do_action() Calls 'bbp_split_topic_reply' with the reply id and
 *                    destination topic id
 * @uses bbp_update_topic_last_reply_id() To update the topic last reply id
 * @uses bbp_update_topic_last_active_time() To update the topic last active meta
 * @uses do_action() Calls 'bbp_post_split_topic' with the destination and
 *                    source topic ids and source topic's forum id
 * @uses bbp_get_topic_permalink() To get the topic permalink
 * @uses wp_safe_redirect() To redirect to the topic link
 */
function bbp_move_reply_handler($action = '')
{
    // Bail if action is not 'bbp-move-reply'
    if ('bbp-move-reply' !== $action) {
        return;
    }
    // Prevent debug notices
    $move_reply_id = $destination_topic_id = 0;
    $destination_topic_title = '';
    $destination_topic = $move_reply = $source_topic = '';
    /** Move Reply ***********************************************************/
    if (empty($_POST['bbp_reply_id'])) {
        bbp_add_error('bbp_move_reply_reply_id', __('<strong>ERROR</strong>: Reply ID to move not found!', 'bbpress'));
    } else {
        $move_reply_id = (int) $_POST['bbp_reply_id'];
    }
    $move_reply = bbp_get_reply($move_reply_id);
    // Reply exists
    if (empty($move_reply)) {
        bbp_add_error('bbp_mover_reply_r_not_found', __('<strong>ERROR</strong>: The reply you want to move was not found.', 'bbpress'));
    }
    /** Topic to Move From ***************************************************/
    // Get the reply's current topic
    $source_topic = bbp_get_topic($move_reply->post_parent);
    // No topic
    if (empty($source_topic)) {
        bbp_add_error('bbp_move_reply_source_not_found', __('<strong>ERROR</strong>: The topic you want to move from was not found.', 'bbpress'));
    }
    // Nonce check failed
    if (!bbp_verify_nonce_request('bbp-move-reply_' . $move_reply->ID)) {
        bbp_add_error('bbp_move_reply_nonce', __('<strong>ERROR</strong>: Are you sure you wanted to do that?', 'bbpress'));
        return;
    }
    // Use cannot edit topic
    if (!current_user_can('edit_topic', $source_topic->ID)) {
        bbp_add_error('bbp_move_reply_source_permission', __('<strong>ERROR</strong>: You do not have the permissions to edit the source topic.', 'bbpress'));
    }
    // How to move
    if (!empty($_POST['bbp_reply_move_option'])) {
        $move_option = (string) trim($_POST['bbp_reply_move_option']);
    }
    // Invalid move option
    if (empty($move_option) || !in_array($move_option, array('existing', 'topic'))) {
        bbp_add_error('bbp_move_reply_option', __('<strong>ERROR</strong>: You need to choose a valid move option.', 'bbpress'));
        // Valid move option
    } else {
        // What kind of move
        switch ($move_option) {
            // Into an existing topic
            case 'existing':
                // Get destination topic id
                if (empty($_POST['bbp_destination_topic'])) {
                    bbp_add_error('bbp_move_reply_destination_id', __('<strong>ERROR</strong>: Destination topic ID not found!', 'bbpress'));
                } else {
                    $destination_topic_id = (int) $_POST['bbp_destination_topic'];
                }
                // Get the destination topic
                $destination_topic = bbp_get_topic($destination_topic_id);
                // No destination topic
                if (empty($destination_topic)) {
                    bbp_add_error('bbp_move_reply_destination_not_found', __('<strong>ERROR</strong>: The topic you want to move to was not found!', 'bbpress'));
                }
                // User cannot edit the destination topic
                if (!current_user_can('edit_topic', $destination_topic->ID)) {
                    bbp_add_error('bbp_move_reply_destination_permission', __('<strong>ERROR</strong>: You do not have the permissions to edit the destination topic!', 'bbpress'));
                }
                // Bump the reply position
//.........这里部分代码省略.........
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:101,代码来源:functions.php


示例8: bbp_get_topic_spam_link

/**
 * Return the spam link of the topic
 *
 * @since bbPress (r2727)
 *
 * @param mixed $args This function supports these args:
 *  - id: Optional. Topic id
 *  - link_before: Before the link
 *  - link_after: After the link
 *  - spam_text: Spam text
 *  - unspam_text: Unspam text
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_topic() To get the topic
 * @uses current_user_can() To check if the current user can edit the topic
 * @uses bbp_is_topic_spam() To check if the topic is marked as spam
 * @uses add_query_arg() To add custom args to the url
 * @uses wp_nonce_url() To nonce the url
 * @uses esc_url() To escape the url
 * @uses apply_filters() Calls 'bbp_get_topic_spam_link' with the link
 *                        and args
 * @return string Topic spam link
 */
function bbp_get_topic_spam_link($args = '')
{
    $defaults = array('id' => 0, 'link_before' => '', 'link_after' => '', 'sep' => ' | ', 'spam_text' => __('Spam', 'bbpress'), 'unspam_text' => __('Unspam', 'bbpress'));
    $r = bbp_parse_args($args, $defaults, 'get_topic_spam_link');
    extract($r);
    $topic = bbp_get_topic(bbp_get_topic_id((int) $id));
    if (empty($topic) || !current_user_can('moderate', $topic->ID)) {
        return;
    }
    $display = bbp_is_topic_spam($topic->ID) ? $unspam_text : $spam_text;
    $uri = add_query_arg(array('action' => 'bbp_toggle_topic_spam', 'topic_id' => $topic->ID));
    $uri = esc_url(wp_nonce_url($uri, 'spam-topic_' . $topic->ID));
    $retval = $link_before . '<a href="' . $uri . '">' . $display . '</a>' . $link_after;
    return apply_filters('bbp_get_topic_spam_link', $retval, $args);
}
开发者ID:rmccue,项目名称:bbPress,代码行数:37,代码来源:bbp-topic-template.php


示例9: bbp_unapprove_topic

/**
 * Unapproves a topic
 *
 * @since 2.6.0 bbPress (r5503)
 *
 * @param int $topic_id Topic id
 * @uses bbp_get_topic() To get the topic
 * @uses bbp_get_pending_status_id() To get the pending status id
 * @uses do_action() Calls 'bbp_unapprove_topic' with the topic id
 * @uses remove_action() To remove the auto save post revision action
 * @uses wp_update_post() To update the topic with the new status
 * @uses do_action() Calls 'bbp_unapproved_topic' with the topic id
 * @return mixed False or {@link WP_Error} on failure, topic id on success
 */
function bbp_unapprove_topic($topic_id = 0)
{
    // Get topic
    $topic = bbp_get_topic($topic_id);
    if (empty($topic)) {
        return $topic;
    }
    // Bail if already pending
    if (bbp_get_pending_status_id() === $topic->post_status) {
        return false;
    }
    // Execute pre open code
    do_action('bbp_unapprove_topic', $topic_id);
    // Set pending status
    $topic->post_status = bbp_get_pending_status_id();
    // No revisions
    remove_action('pre_post_update', 'wp_save_post_revision');
    // Update topic
    $topic_id = wp_update_post($topic);
    // Execute post open code
    do_action('bbp_unapproved_topic', $topic_id);
    // Return topic_id
    return $topic_id;
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:38,代码来源:functions.php


示例10: likebtn_bbp_reply

function likebtn_bbp_reply($wrap = true, $position = LIKEBTN_POSITION_BOTH, $alignment = '', $content = '')
{
    // Reply to topic
    $entity = bbp_get_reply(bbp_get_reply_id());
    // Topic
    if (!is_object($entity)) {
        $entity = bbp_get_topic(bbp_get_topic_id());
    }
    if (!$entity) {
        return false;
    }
    return _likebtn_get_content_universal(LIKEBTN_ENTITY_BBP_POST, $entity->ID, $content, $wrap, $position, $alignment);
}
开发者ID:Omuze,项目名称:barakat,代码行数:13,代码来源:likebtn_like_button.php


示例11: bbp_add_user_topic_subscription

/**
 * Add a topic to user's subscriptions
 *
 * @since 2.0.0 bbPress (r2668)
 *
 * @param int $user_id Optional. User id
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_topic() To get the topic
 * @uses bbp_add_user_subscription() To add the subscription
 * @uses do_action() Calls 'bbp_add_user_subscription' with the user & topic id
 * @return bool Always true
 */
function bbp_add_user_topic_subscription($user_id = 0, $topic_id = 0)
{
    // Bail if not enough info
    if (empty($user_id) || empty($topic_id)) {
        return false;
    }
    // Bail if no topic
    $topic = bbp_get_topic($topic_id);
    if (empty($topic)) {
        return false;
    }
    // Bail if already subscribed
    if (bbp_is_user_subscribed_to_topic($user_id, $topic_id)) {
        return false;
    }
    // Bail if add fails
    if (!bbp_add_user_subscription($user_id, $topic_id)) {
        return false;
    }
    do_action('bbp_add_user_topic_subscription', $user_id, $topic_id);
    return true;
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:34,代码来源:functions.php


示例12: wi_bbp_send_pushover_notification_on_assignment

/**
 * Send a Pushover Notification when a moderator is assigned to a topic
 */
function wi_bbp_send_pushover_notification_on_assignment()
{
    if (isset($_POST['bbps_support_topic_assign'])) {
        if (!function_exists('ckpn_send_notification')) {
            return;
        }
        $user_id = absint($_POST['bbps_assign_list']);
        $topic = bbp_get_topic($_POST['bbps_topic_id']);
        if ($user_id > 0 && $user_id != get_current_user_id()) {
            $title = __('Easy Digital Downloads: A forum topic has been assigned to you', 'wi_bbp');
            $message = sprintf(__('You have been assigned to %1$s by another moderator', 'wi_bbp'), $topic->post_title);
            $user_push_key = get_user_meta($user_id, 'ckpn_user_key', true);
            if ($user_push_key) {
                $url = $topic->guid;
                $url_title = __('View Topic', 'wi_bbp');
                $args = array('title' => $title, 'message' => $message, 'user' => $user_push_key, 'url' => $url, 'url_title' => $url_title);
                ckpn_send_notification($args);
            }
        }
    }
}
开发者ID:WordImpress,项目名称:bbPress-Support,代码行数:24,代码来源:support-functions.php


示例13: Add_fb_link_reply

 static function Add_fb_link_reply($reply)
 {
     // Get data
     $topic_id = bbp_get_reply_topic_id($reply->ID);
     $topic = bbp_get_topic($topic_id);
     $link_id = get_post_meta($topic->ID, c_al2fb_meta_link_id, true);
     if (empty($link_id)) {
         return;
     }
     if (get_post_meta($topic->ID, c_al2fb_meta_nointegrate, true)) {
         return;
     }
     $user_ID = WPAL2Facebook::Get_user_ID($topic);
     if (!get_user_meta($user_ID, c_al2fb_meta_fb_comments_postback, true)) {
         return;
     }
     // Build message
     $message = bbp_get_reply_author($reply->ID) . ' ' . __('commented on', c_al2fb_text_domain) . ' ';
     $message .= html_entity_decode(get_bloginfo('title'), ENT_QUOTES, get_bloginfo('charset')) . ":\n\n";
     $message .= $reply->post_content;
     $message = apply_filters('al2fb_reply', $message, $reply_id);
     // Do not disturb WordPress
     try {
         $url = 'https://graph.facebook.com/v2.2/' . $link_id . '/comments';
         $url = apply_filters('al2fb_url', $url);
         $query_array = array('access_token' => WPAL2Int::Get_access_token_by_post($topic), 'message' => $message);
         // http://developers.facebook.com/docs/reference/api/Comment/
         $query = http_build_query($query_array, '', '&');
         // Execute request
         $response = WPAL2Int::Request($url, $query, 'POST');
         // Process response
         $fb_comment = json_decode($response);
         add_post_meta($topic->ID, c_al2fb_meta_fb_comment_id, $fb_comment->id);
         // Remove previous errors
         $error = get_post_meta($topic->ID, c_al2fb_meta_error, true);
         if (strpos($error, 'Add reply: ') !== false) {
             delete_post_meta($topic->ID, c_al2fb_meta_error, $error);
             delete_post_meta($topic->ID, c_al2fb_meta_error_time);
         }
     } catch (Exception $e) {
         update_post_meta($topic->ID, c_al2fb_meta_error, 'Add reply: ' . $e->getMessage());
         update_post_meta($topic->ID, c_al2fb_meta_error_time, date('c'));
     }
 }
开发者ID:kxt5258,项目名称:fullcircle,代码行数:44,代码来源:add-link-to-facebook-int.php


示例14: get_object_by_id

 public function get_object_by_id($topic_id)
 {
     return bbp_get_topic($topic_id);
 }
开发者ID:joeyblake,项目名称:bbpress,代码行数:4,代码来源:factory.php


示例15: ajax_subscription

 /**
  * AJAX handler to Subscribe/Unsubscribe a user from a topic
  *
  * @since bbPress (r3732)
  *
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
  * @uses bbp_is_user_logged_in() To check if user is logged in
  * @uses bbp_get_current_user_id() To get the current user id
  * @uses current_user_can() To check if the current user can edit the user
  * @uses bbp_get_topic() To get the topic
  * @uses wp_verify_nonce() To verify the nonce
  * @uses bbp_is_user_subscribed() To check if the topic is in user's subscriptions
  * @uses bbp_remove_user_subscriptions() To remove the topic from user's subscriptions
  * @uses bbp_add_user_subscriptions() To add the topic from user's subscriptions
  * @uses bbp_ajax_response() To return JSON
  */
 public function ajax_subscription()
 {
     // Bail if subscriptions are not active
     if (!bbp_is_subscriptions_active()) {
         bbp_ajax_response(false, __('Subscriptions are no longer active.', 'bbpress'), 300);
     }
     // Bail if user is not logged in
     if (!is_user_logged_in()) {
         bbp_ajax_response(false, __('Please login to subscribe to this topic.', 'bbpress'), 301);
     }
     // Get user and topic data
     $user_id = bbp_get_current_user_id();
     $id = intval($_POST['id']);
     // Bail if user cannot add favorites for this user
     if (!current_user_can('edit_user', $user_id)) {
         bbp_ajax_response(false, __('You do not have permission to do this.', 'bbpress'), 302);
     }
     // Get the topic
     $topic = bbp_get_topic($id);
     // Bail if topic cannot be found
     if (empty($topic)) {
         bbp_ajax_response(false, __('The topic could not be found.', 'bbpress'), 303);
     }
     // Bail if user did not take this action
     if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'toggle-subscription_' . $topic->ID)) {
         bbp_ajax_response(false, __('Are you sure you meant to do that?', 'bbpress'), 304);
     }
     // Take action
     $status = bbp_is_user_subscribed($user_id, $topic->ID) ? bbp_remove_user_subscription($user_id, $topic->ID) : bbp_add_user_subscription($user_id, $topic->ID);
     // Bail if action failed
     if (empty($status)) {
         bbp_ajax_response(false, __('The request was unsuccessful. Please try again.', 'bbpress'), 305);
     }
     // Put subscription attributes in convenient array
     $attrs = array('topic_id' => $topic->ID, 'user_id' => $user_id);
     // Action succeeded
     bbp_ajax_response(true, bbp_get_user_subscribe_link($attrs, $user_id, false), 200);
 }
开发者ID:danielcoats,项目名称:schoolpress,代码行数:54,代码来源:bbpress-functions.php


示例16: new_reply_redirect_to

 /**
  * Redirect to the group forum screen
  *
  * @since bbPress (r3653)
  */
 public function new_reply_redirect_to($redirect_url = '', $redirect_to = '', $reply_id = 0)
 {
     global $wp_rewrite;
     if (bp_is_group()) {
         $topic_id = bbp_get_reply_topic_id($reply_id);
         $topic = bbp_get_topic($topic_id);
         $reply_position = bbp_get_reply_position($reply_id, $topic_id);
         $reply_page = ceil((int) $reply_position / (int) bbp_get_replies_per_page());
         $reply_hash = '#post-' . $reply_id;
         $topic_url = trailingslashit(bp_get_group_permalink(groups_get_current_group())) . trailingslashit($this->slug) . trailingslashit($this->topic_slug) . trailingslashit($topic->post_name);
         // Don't include pagination if on first page
         if (1 >= $reply_page) {
             $redirect_url = trailingslashit($topic_url) . $reply_hash;
             // Include pagination
         } else {
             $redirect_url = trailingslashit($topic_url) . trailingslashit($wp_rewrite->pagination_base) . trailingslashit($reply_page) . $reply_hash;
         }
         // Add topic view query arg back to end if it is set
         if (bbp_get_view_all()) {
             $redirect_url = bbp_add_view_all($redirect_url);
         }
     }
     return $redirect_url;
 }
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:29,代码来源:groups.php


示例17: bbp_toggle_topic_handler

/**
 * Handles the front end opening/closing, spamming/unspamming,
 * sticking/unsticking and trashing/untrashing/deleting of topics
 *
 * @since bbPress (r2727)
 *
 * @uses bbp_get_topic() To get the topic
 * @uses current_user_can() To check if the user is capable of editing or
 *                           deleting the topic
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses check_ajax_referer() To verify the nonce and check the referer
 * @uses bbp_is_topic_open() To check if the topic is open
 * @uses bbp_close_topic() To close the topic
 * @uses bbp_open_topic() To open the topic
 * @uses bbp_is_topic_sticky() To check if the topic is a sticky
 * @uses bbp_unstick_topic() To unstick the topic
 * @uses bbp_stick_topic() To stick the topic
 * @uses bbp_is_topic_spam() To check if the topic is marked as spam
 * @uses bbp_spam_topic() To make the topic as spam
 * @uses bbp_unspam_topic() To unmark the topic as spam
 * @uses wp_trash_post() To trash the topic
 * @uses wp_untrash_post() To untrash the topic
 * @uses wp_delete_post() To delete the topic
 * @uses do_action() Calls 'bbp_toggle_topic_handler' with success, post data
 *                    and action
 * @uses bbp_get_forum_permalink() To get the forum link
 * @uses bbp_get_topic_permalink() To get the topic link
 * @uses add_query_arg() To add args to the url
 * @uses wp_safe_redirect() To redirect to the topic
 * @uses bbPress::errors:add() To log the error messages
 */
function bbp_toggle_topic_handler()
{
    // Bail if not a GET action
    if ('GET' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Bail if required GET actions aren't passed
    if (empty($_GET['topic_id']) || empty($_GET['action'])) {
        return;
    }
    // Setup possible get actions
    $possible_actions = array('bbp_toggle_topic_close', 'bbp_toggle_topic_stick', 'bbp_toggle_topic_spam', 'bbp_toggle_topic_trash');
    // Bail if actions aren't meant for this function
    if (!in_array($_GET['action'], $possible_actions)) {
        return;
    }
    $failure = '';
    // Empty failure string
    $view_all = false;
    // Assume not viewing all
    $action = $_GET['action'];
    // What action is taking place?
    $topic_id = (int) $_GET['topic_id'];
    // What's the topic id?
    $success = false;
    // Flag
    $post_data = array('ID' => $topic_id);
    // Prelim array
    $redirect = '';
    // Empty redirect URL
    // Make sure topic exists
    $topic = bbp_get_topic($topic_id);
    if (empty($topic)) {
        return;
    }
    // What is the user doing here?
    if (!current_user_can('edit_topic', $topic->ID) || 'bbp_toggle_topic_trash' == $action && !current_user_can('delete_topic', $topic->ID)) {
        bbp_add_error('bbp_toggle_topic_permission', __('<strong>ERROR:</strong> You do not have the permission to do that.', 'bbpress'));
        return;
    }
    // What action are we trying to perform?
    switch ($action) {
        // Toggle open/close
        case 'bbp_toggle_topic_close':
            check_ajax_referer('close-topic_' . $topic_id);
            $is_open = bbp_is_topic_open($topic_id);
            $success = $is_open ? bbp_close_topic($topic_id) : bbp_open_topic($topic_id);
            $failure = $is_open ? __('<strong>ERROR</strong>: There was a problem closing the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem opening the topic.', 'bbpress');
            break;
            // Toggle sticky/super-sticky/unstick
        // Toggle sticky/super-sticky/unstick
        case 'bbp_toggle_topic_stick':
            check_ajax_referer('stick-topic_' . $topic_id);
            $is_sticky = bbp_is_topic_sticky($topic_id);
            $is_super = empty($is_sticky) && !empty($_GET['super']) && 1 == (int) $_GET['super'] ? true : false;
            $success = $is_sticky ? bbp_unstick_topic($topic_id) : bbp_stick_topic($topic_id, $is_super);
            $failure = $is_sticky ? __('<strong>ERROR</strong>: There was a problem unsticking the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem sticking the topic.', 'bbpress');
            break;
            // Toggle spam
        // Toggle spam
        case 'bbp_toggle_topic_spam':
            check_ajax_referer('spam-topic_' . $topic_id);
            $is_spam = bbp_is_topic_spam($topic_id);
            $success = $is_spam ? bbp_unspam_topic($topic_id) : bbp_spam_topic($topic_id);
            $failure = $is_spam ? __('<strong>ERROR</strong>: There was a problem unmarking the topic as spam.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem marking the topic as spam.', 'bbpress');
            $view_all = !$is_spam;
            break;
            // Toggle trash
        // Toggle trash
//.........这里部分代码省略.........
开发者ID:vsalx,项目名称:rattieinfo,代码行数:101,代码来源:bbp-topic-functions.php


示例18: do_action

该文章已有0人参与评论

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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