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


PHP bbp_add_view_all函数代码示例

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


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

示例1: bbp_toggle_topic_handler


//.........这里部分代码省略.........
    if (!in_array($action, $possible_actions)) {
        return;
    }
    $failure = '';
    // Empty failure string
    $view_all = false;
    // Assume not viewing all
    $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 = true === $is_open ? bbp_close_topic($topic_id) : bbp_open_topic($topic_id);
            $failure = true === $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 = false === $is_sticky && !empty($_GET['super']) && "1" === $_GET['super'] ? true : false;
            $success = true === $is_sticky ? bbp_unstick_topic($topic_id) : bbp_stick_topic($topic_id, $is_super);
            $failure = true === $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 = true === $is_spam ? bbp_unspam_topic($topic_id) : bbp_spam_topic($topic_id);
            $failure = true === $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
        case 'bbp_toggle_topic_trash':
            $sub_action = !empty($_GET['sub_action']) && in_array($_GET['sub_action'], array('trash', 'untrash', 'delete')) ? $_GET['sub_action'] : false;
            if (empty($sub_action)) {
                break;
            }
            switch ($sub_action) {
                case 'trash':
                    check_ajax_referer('trash-' . bbp_get_topic_post_type() . '_' . $topic_id);
                    $view_all = true;
                    $success = wp_trash_post($topic_id);
                    $failure = __('<strong>ERROR</strong>: There was a problem trashing the topic.', 'bbpress');
                    break;
                case 'untrash':
                    check_ajax_referer('untrash-' . bbp_get_topic_post_type() . '_' . $topic_id);
                    $success = wp_untrash_post($topic_id);
                    $failure = __('<strong>ERROR</strong>: There was a problem untrashing the topic.', 'bbpress');
                    break;
                case 'delete':
                    check_ajax_referer('delete-' . bbp_get_topic_post_type() . '_' . $topic_id);
                    $success = wp_delete_post($topic_id);
                    $failure = __('<strong>ERROR</strong>: There was a problem deleting the topic.', 'bbpress');
                    break;
            }
            break;
    }
    // Do additional topic toggle actions
    do_action('bbp_toggle_topic_handler', $success, $post_data, $action);
    // No errors
    if (false !== $success && !is_wp_error($success)) {
        // Redirect back to the topic's forum
        if (isset($sub_action) && 'delete' === $sub_action) {
            $redirect = bbp_get_forum_permalink($success->post_parent);
            // Redirect back to the topic
        } else {
            // Get the redirect detination
            $permalink = bbp_get_topic_permalink($topic_id);
            $redirect = bbp_add_view_all($permalink, $view_all);
        }
        wp_safe_redirect($redirect);
        // For good measure
        exit;
        // Handle errors
    } else {
        bbp_add_error('bbp_toggle_topic', $failure);
    }
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:101,代码来源:functions.php

示例2: bbp_get_topic_edit_url

/**
 * Return URL to the topic edit page
 *
 * @since 2.0.0 bbPress (r2753)
 *
 * @param int $topic_id Optional. Topic id
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_topic() To get the topic
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_get_topic_edit_url' with the edit
 *                        url and topic id
 * @return string Topic edit url
 */
function bbp_get_topic_edit_url($topic_id = 0)
{
    $topic = bbp_get_topic($topic_id);
    if (empty($topic)) {
        return;
    }
    // Remove view=all link from edit
    $topic_link = bbp_remove_view_all(bbp_get_topic_permalink($topic_id));
    // Pretty permalinks
    if (bbp_use_pretty_urls()) {
        $url = trailingslashit($topic_link) . bbp_get_edit_rewrite_id();
        $url = user_trailingslashit($url);
        // Unpretty permalinks
    } else {
        $url = add_query_arg(array(bbp_get_topic_post_type() => $topic->post_name, bbp_get_edit_rewrite_id() => '1'), $topic_link);
    }
    // Maybe add view=all
    $url = bbp_add_view_all($url);
    return apply_filters('bbp_get_topic_edit_url', $url, $topic_id);
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:33,代码来源:template.php

示例3: bbp_get_reply_edit_url

/**
 * Return URL to the reply edit page
 *
 * @since bbPress (r2753)
 *
 * @param int $reply_id Optional. Reply id
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_reply() To get the reply
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_get_reply_edit_url' with the edit
 *                        url and reply id
 * @return string Reply edit url
 */
function bbp_get_reply_edit_url($reply_id = 0)
{
    global $wp_rewrite;
    $bbp = bbpress();
    $reply = bbp_get_reply(bbp_get_reply_id($reply_id));
    if (empty($reply)) {
        return;
    }
    $reply_link = bbp_remove_view_all(bbp_get_reply_permalink($reply_id));
    // Pretty permalinks
    if ($wp_rewrite->using_permalinks()) {
        $url = trailingslashit($reply_link) . $bbp->edit_id;
        $url = trailingslashit($url);
        // Unpretty permalinks
    } else {
        $url = add_query_arg(array(bbp_get_reply_post_type() => $reply->post_name, $bbp->edit_id => '1'), $reply_link);
    }
    // Maybe add view all
    $url = bbp_add_view_all($url);
    return apply_filters('bbp_get_reply_edit_url', $url, $reply_id);
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:35,代码来源:template.php

示例4: bbp_edit_forum_handler


//.........这里部分代码省略.........
        }
        // Forum is hidden and user cannot access
        if (bbp_is_forum_hidden($forum_parent_id) && !current_user_can('read_hidden_forums')) {
            bbp_add_error('bbp_edit_forum_forum_hidden', __('<strong>ERROR</strong>: This forum is hidden and you do not have the capability to read or create new forums in it.', 'bbpress'));
        }
    }
    /** Forum Title ***********************************************************/
    if (!empty($_POST['bbp_forum_title'])) {
        $forum_title = esc_attr(strip_tags($_POST['bbp_forum_title']));
    }
    // Filter and sanitize
    $forum_title = apply_filters('bbp_edit_forum_pre_title', $forum_title, $forum_id);
    // No forum title
    if (empty($forum_title)) {
        bbp_add_error('bbp_edit_forum_title', __('<strong>ERROR</strong>: Your forum needs a title.', 'bbpress'));
    }
    /** Forum Content *********************************************************/
    if (!empty($_POST['bbp_forum_content'])) {
        $forum_content = $_POST['bbp_forum_content'];
    }
    // Filter and sanitize
    $forum_content = apply_filters('bbp_edit_forum_pre_content', $forum_content, $forum_id);
    // No forum content
    if (empty($forum_content)) {
        bbp_add_error('bbp_edit_forum_content', __('<strong>ERROR</strong>: Your forum description cannot be empty.', 'bbpress'));
    }
    /** Forum Blacklist *******************************************************/
    if (!bbp_check_for_blacklist($anonymous_data, bbp_get_forum_author_id($forum_id), $forum_title, $forum_content)) {
        bbp_add_error('bbp_forum_blacklist', __('<strong>ERROR</strong>: Your forum cannot be edited at this time.', 'bbpress'));
    }
    /** Forum Moderation ******************************************************/
    $post_status = bbp_get_public_status_id();
    if (!bbp_check_for_moderation($anonymous_data, bbp_get_forum_author_id($forum_id), $forum_title, $forum_content)) {
        $post_status = bbp_get_pending_status_id();
    }
    /** Additional Actions (Before Save) **************************************/
    do_action('bbp_edit_forum_pre_extras', $forum_id);
    // Bail if errors
    if (bbp_has_errors()) {
        return;
    }
    /** No Errors *************************************************************/
    // Add the content of the form to $forum_data as an array
    // Just in time manipulation of forum data before being edited
    $forum_data = apply_filters('bbp_edit_forum_pre_insert', array('ID' => $forum_id, 'post_title' => $forum_title, 'post_content' => $forum_content, 'post_status' => $post_status, 'post_parent' => $forum_parent_id));
    // Insert forum
    $forum_id = wp_update_post($forum_data);
    /** Revisions *************************************************************/
    /**
    * @todo omitted for 2.1
    	// Revision Reason
    	if ( !empty( $_POST['bbp_forum_edit_reason'] ) )
    		$forum_edit_reason = esc_attr( strip_tags( $_POST['bbp_forum_edit_reason'] ) );
    
    	// Update revision log
    	if ( !empty( $_POST['bbp_log_forum_edit'] ) && ( "1" === $_POST['bbp_log_forum_edit'] ) && ( $revision_id = wp_save_post_revision( $forum_id ) ) ) {
    		bbp_update_forum_revision_log( array(
    			'forum_id'    => $forum_id,
    			'revision_id' => $revision_id,
    			'author_id'   => bbp_get_current_user_id(),
    			'reason'      => $forum_edit_reason
    		) );
    	}
    */
    /** No Errors *************************************************************/
    if (!empty($forum_id) && !is_wp_error($forum_id)) {
        // Update counts, etc...
        do_action('bbp_edit_forum', array('forum_id' => $forum_id, 'post_parent' => $forum_parent_id, 'forum_author' => $forum->post_author, 'last_topic_id' => 0, 'last_reply_id' => 0, 'last_active_id' => 0, 'last_active_time' => 0, 'last_active_status' => bbp_get_public_status_id()));
        // If the new forum parent id is not equal to the old forum parent
        // id, run the bbp_move_forum action and pass the forum's parent id
        // as the first arg and new forum parent id as the second.
        // @todo implement
        //if ( $forum_id !== $forum->post_parent )
        //	bbp_move_forum_handler( $forum_parent_id, $forum->post_parent, $forum_id );
        /** Additional Actions (After Save) ***********************************/
        do_action('bbp_edit_forum_post_extras', $forum_id);
        /** Redirect **********************************************************/
        // Redirect to
        $redirect_to = bbp_get_redirect_to();
        // View all?
        $view_all = bbp_get_view_all();
        // Get the forum URL
        $forum_url = bbp_get_forum_permalink($forum_id, $redirect_to);
        // Add view all?
        if (!empty($view_all)) {
            $forum_url = bbp_add_view_all($forum_url);
        }
        // Allow to be filtered
        $forum_url = apply_filters('bbp_edit_forum_redirect_to', $forum_url, $view_all, $redirect_to);
        /** Successful Edit ***************************************************/
        // Redirect back to new forum
        wp_safe_redirect($forum_url);
        // For good measure
        exit;
        /** Errors ****************************************************************/
    } else {
        $append_error = is_wp_error($forum_id) && $forum_id->get_error_message() ? $forum_id->get_error_message() . ' ' : '';
        bbp_add_error('bbp_forum_error', __('<strong>ERROR</strong>: The following problem(s) have been found with your forum:' . $append_error . 'Please try again.', 'bbpress'));
    }
}
开发者ID:jenia-buianov,项目名称:all_my_sites,代码行数:101,代码来源:functions.php

示例5: bbp_get_forum_topics_link

/**
 * Return the topics link of the forum
 *
 * @since bbPress (r2883)
 *
 * @param int $forum_id Optional. Topic id
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_forum() To get the forum
 * @uses bbp_get_forum_topic_count() To get the forum topic count
 * @uses bbp_get_forum_permalink() To get the forum permalink
 * @uses remove_query_arg() To remove args from the url
 * @uses bbp_get_forum_topic_count_hidden() To get the forum hidden
 *                                           topic count
 * @uses current_user_can() To check if the current user can edit others
 *                           topics
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_get_forum_topics_link' with the
 *                        topics link and forum id
 */
function bbp_get_forum_topics_link($forum_id = 0)
{
    $forum = bbp_get_forum($forum_id);
    $forum_id = $forum->ID;
    $topics = bbp_get_forum_topic_count($forum_id);
    $topics = sprintf(_n('%s topic', '%s topics', $topics, 'bbpress'), $topics);
    $retval = '';
    // First link never has view=all
    if (bbp_get_view_all('edit_others_topics')) {
        $retval .= "<a href='" . esc_url(bbp_remove_view_all(bbp_get_forum_permalink($forum_id))) . "'>{$topics}</a>";
    } else {
        $retval .= $topics;
    }
    // Get deleted topics
    $deleted = bbp_get_forum_topic_count_hidden($forum_id);
    // This forum has hidden topics
    if (!empty($deleted) && current_user_can('edit_others_topics')) {
        // Extra text
        $extra = sprintf(__(' (+ %d hidden)', 'bbpress'), $deleted);
        // No link
        if (bbp_get_view_all()) {
            $retval .= " {$extra}";
            // Link
        } else {
            $retval .= " <a href='" . esc_url(bbp_add_view_all(bbp_get_forum_permalink($forum_id), true)) . "'>{$extra}</a>";
        }
    }
    return apply_filters('bbp_get_forum_topics_link', $retval, $forum_id);
}
开发者ID:hscale,项目名称:webento,代码行数:48,代码来源:bbp-forum-template.php

示例6: bbp_toggle_reply_handler


//.........这里部分代码省略.........
 * @uses wp_trash_post() To trash the reply
 * @uses wp_untrash_post() To untrash the reply
 * @uses wp_delete_post() To delete the reply
 * @uses do_action() Calls 'bbp_toggle_reply_handler' with success, post data
 *                    and action
 * @uses bbp_get_reply_url() To get the reply url
 * @uses wp_safe_redirect() To redirect to the reply
 * @uses bbPress::errors:add() To log the error messages
 */
function bbp_toggle_reply_handler($action = '')
{
    // Bail if required GET actions aren't passed
    if (empty($_GET['reply_id'])) {
        return;
    }
    // Setup possible get actions
    $possible_actions = array('bbp_toggle_reply_spam', 'bbp_toggle_reply_trash');
    // Bail if actions aren't meant for this function
    if (!in_array($action, $possible_actions)) {
        return;
    }
    $failure = '';
    // Empty failure string
    $view_all = false;
    // Assume not viewing all
    $reply_id = (int) $_GET['reply_id'];
    // What's the reply id?
    $success = false;
    // Flag
    $post_data = array('ID' => $reply_id);
    // Prelim array
    // Make sure reply exists
    $reply = bbp_get_reply($reply_id);
    if (empty($reply)) {
        return;
    }
    // What is the user doing here?
    if (!current_user_can('edit_reply', $reply->ID) || 'bbp_toggle_reply_trash' === $action && !current_user_can('delete_reply', $reply->ID)) {
        bbp_add_error('bbp_toggle_reply_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 spam
        case 'bbp_toggle_reply_spam':
            check_ajax_referer('spam-reply_' . $reply_id);
            $is_spam = bbp_is_reply_spam($reply_id);
            $success = $is_spam ? bbp_unspam_reply($reply_id) : bbp_spam_reply($reply_id);
            $failure = $is_spam ? __('<strong>ERROR</strong>: There was a problem unmarking the reply as spam!', 'bbpress') : __('<strong>ERROR</strong>: There was a problem marking the reply as spam!', 'bbpress');
            $view_all = !$is_spam;
            break;
            // Toggle trash
        // Toggle trash
        case 'bbp_toggle_reply_trash':
            $sub_action = in_array($_GET['sub_action'], array('trash', 'untrash', 'delete')) ? $_GET['sub_action'] : false;
            if (empty($sub_action)) {
                break;
            }
            switch ($sub_action) {
                case 'trash':
                    check_ajax_referer('trash-' . bbp_get_reply_post_type() . '_' . $reply_id);
                    $view_all = true;
                    $success = wp_trash_post($reply_id);
                    $failure = __('<strong>ERROR</strong>: There was a problem trashing the reply!', 'bbpress');
                    break;
                case 'untrash':
                    check_ajax_referer('untrash-' . bbp_get_reply_post_type() . '_' . $reply_id);
                    $success = wp_untrash_post($reply_id);
                    $failure = __('<strong>ERROR</strong>: There was a problem untrashing the reply!', 'bbpress');
                    break;
                case 'delete':
                    check_ajax_referer('delete-' . bbp_get_reply_post_type() . '_' . $reply_id);
                    $success = wp_delete_post($reply_id);
                    $failure = __('<strong>ERROR</strong>: There was a problem deleting the reply!', 'bbpress');
                    break;
            }
            break;
    }
    // Do additional reply toggle actions
    do_action('bbp_toggle_reply_handler', $success, $post_data, $action);
    // No errors
    if (false !== $success && !is_wp_error($success)) {
        /** Redirect **********************************************************/
        // Redirect to
        $redirect_to = bbp_get_redirect_to();
        // Get the reply URL
        $reply_url = bbp_get_reply_url($reply_id, $redirect_to);
        // Add view all if needed
        if (!empty($view_all)) {
            $reply_url = bbp_add_view_all($reply_url, true);
        }
        // Redirect back to reply
        wp_safe_redirect($reply_url);
        // For good measure
        exit;
        // Handle errors
    } else {
        bbp_add_error('bbp_toggle_reply', $failure);
    }
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:101,代码来源:functions.php

示例7: toggle_reply_handler

 /**
  * Handles the front end reporting/un-reporting of replies
  *
  * @since 1.0.0
  *
  * @param string $action The requested action to compare this function to
  */
 public function toggle_reply_handler($action = '')
 {
     // Bail if required GET actions aren't passed
     if (empty($_GET['reply_id'])) {
         return;
     }
     // Setup possible get actions
     $possible_actions = array('bbp_rc_toggle_reply_report');
     // Bail if actions aren't meant for this function
     if (!in_array($action, $possible_actions)) {
         return;
     }
     $failure = '';
     // Empty failure string
     $view_all = false;
     // Assume not viewing all
     $reply_id = (int) $_GET['reply_id'];
     // What's the reply id?
     $success = false;
     // Flag
     $post_data = array('ID' => $reply_id);
     // Prelim array
     $redirect = '';
     // Empty redirect URL
     // Make sure reply exists
     $reply = bbp_get_reply($reply_id);
     if (empty($reply)) {
         return;
     }
     // Bail if non-logged-in user
     if (!is_user_logged_in()) {
         return;
     }
     // What action are we trying to perform?
     switch ($action) {
         // Toggle reported
         case 'bbp_rc_toggle_reply_report':
             check_ajax_referer('report-reply_' . $reply_id);
             $is_reported = $this->is_reply_reported($reply_id);
             $success = true === $is_reported ? $this->unreport_reply($reply_id) : $this->report_reply($reply_id);
             $failure = true === $is_reported ? __('<strong>ERROR</strong>: There was a problem unmarking the reply as reported.', 'bbpress-report-content') : __('<strong>ERROR</strong>: There was a problem reporting the reply.', 'bbpress-report-content');
             // $view_all = !$is_reported; // Only need this if we want to hide it, like spam
             break;
     }
     // No errors
     if (false !== $success && !is_wp_error($success)) {
         /** Redirect **********************************************************/
         // Redirect to
         $redirect_to = bbp_get_redirect_to();
         // Get the reply URL
         $reply_url = bbp_get_reply_url($reply_id, $redirect_to);
         // Add view all if needed
         if (!empty($view_all)) {
             $reply_url = bbp_add_view_all($reply_url, true);
         }
         // Redirect back to reply
         wp_safe_redirect($reply_url);
         // For good measure
         exit;
         // Handle errors
     } else {
         bbp_add_error('bbp_rc_toggle_reply', $failure);
     }
 }
开发者ID:richrd,项目名称:bbpress-report-content,代码行数:71,代码来源:class-bbpress-report-content.php

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

示例9: bbp_toggle_topic

/**
 * Do the actual topic toggling
 *
 * This function is used by `bbp_toggle_topic_handler()` to do the actual heavy
 * lifting when it comes to toggling topic. It only really makes sense to call
 * within that context, so if you need to call this function directly, make sure
 * you're also doing what the handler does too.
 *
 * @since 2.6.0  bbPress (r6133)
 * @access private
 *
 * @param array $args
 */
function bbp_toggle_topic($args = array())
{
    // Parse the arguments
    $r = bbp_parse_args($args, array('id' => 0, 'action' => '', 'sub_action' => '', 'data' => array()));
    // Build the nonce suffix
    $nonce_suffix = bbp_get_topic_post_type() . '_' . (int) $r['id'];
    // Default return values
    $retval = array('status' => 0, 'message' => '', 'redirect_to' => bbp_get_topic_permalink($r['id'], bbp_get_redirect_to()), 'view_all' => false);
    // What action are we trying to perform?
    switch ($r['action']) {
        // Toggle approve/unapprove
        case 'bbp_toggle_topic_approve':
            check_ajax_referer("approve-{$nonce_suffix}");
            $is_pending = bbp_is_topic_pending($r['id']);
            $retval['view_all'] = !$is_pending;
            // Toggle
            $retval['status'] = true === $is_pending ? bbp_approve_topic($r['id']) : bbp_unapprove_topic($r['id']);
            // Feedback
            $retval['message'] = true === $is_pending ? __('<strong>ERROR</strong>: There was a problem approving the topic.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem unapproving the topic.', 'bbpress');
            break;
            // Toggle open/close
        // Toggle open/close
        case 'bbp_toggle_topic_close':
            check_ajax_referer("close-{$nonce_suffix}");
            $is_open = bbp_is_topic_open($r['id']);
            // Toggle
            $retval['status'] = true === $is_open ? bbp_close_topic($r['id']) : bbp_open_topic($r['id']);
            // Feedback
            $retval['message'] = true === $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-{$nonce_suffix}");
            $is_sticky = bbp_is_topic_sticky($r['id']);
            $is_super = false === $is_sticky && !empty($_GET['super']) && "1" === $_GET['super'] ? true : false;
            // Toggle
            $retval['status'] = true === $is_sticky ? bbp_unstick_topic($r['id']) : bbp_stick_topic($r['id'], $is_super);
            // Feedback
            $retval['message'] = true === $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-{$nonce_suffix}");
            $is_spam = bbp_is_topic_spam($r['id']);
            $retval['view_all'] = !$is_spam;
            // Toggle
            $retval['status'] = true === $is_spam ? bbp_unspam_topic($r['id']) : bbp_spam_topic($r['id']);
            // Feedback
            $retval['message'] = true === $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');
            break;
            // Toggle trash
        // Toggle trash
        case 'bbp_toggle_topic_trash':
            switch ($r['sub_action']) {
                case 'trash':
                    check_ajax_referer("trash-{$nonce_suffix}");
                    $retval['view_all'] = true;
                    $retval['status'] = wp_trash_post($r['id']);
                    $retval['message'] = __('<strong>ERROR</strong>: There was a problem trashing the topic.', 'bbpress');
                    break;
                case 'untrash':
                    check_ajax_referer("untrash-{$nonce_suffix}");
                    $retval['status'] = wp_untrash_post($r['id']);
                    $retval['message'] = __('<strong>ERROR</strong>: There was a problem untrashing the topic.', 'bbpress');
                    break;
                case 'delete':
                    check_ajax_referer("delete-{$nonce_suffix}");
                    $retval['status'] = wp_delete_post($r['id']);
                    $retval['message'] = __('<strong>ERROR</strong>: There was a problem deleting the topic.', 'bbpress');
                    break;
            }
            break;
    }
    // Maybe redirect back to the topic's forum
    if (isset($r['sub_action']) && 'delete' === $r['sub_action']) {
        $retval['redirect_to'] = bbp_get_forum_permalink($retval['status']->post_parent);
    }
    // Add view all if needed
    if (!empty($retval['view_all'])) {
        $retval['redirect_to'] = bbp_add_view_all($retval['redirect_to'], true);
    }
    // Filter & return
    return apply_filters('bbp_toggle_topic', $retval, $r, $args);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:99,代码来源:functions.php

示例10: bbp_toggle_reply

/**
 * Do the actual reply toggling
 *
 * This function is used by `bbp_toggle_reply_handler()` to do the actual heavy
 * lifting when it comes to toggling replies. It only really makes sense to call
 * within that context, so if you need to call this function directly, make sure
 * you're also doing what the handler does too.
 *
 * @since 2.6.0 bbPress (r6133)
 * @access private
 *
 * @param array $args
 */
function bbp_toggle_reply($args = array())
{
    // Parse the arguments
    $r = bbp_parse_args($args, array('id' => 0, 'action' => '', 'sub_action' => '', 'data' => array()));
    // Build the nonce suffix
    $nonce_suffix = bbp_get_reply_post_type() . '_' . (int) $r['id'];
    // Default return values
    $retval = array('status' => 0, 'message' => '', 'redirect_to' => bbp_get_reply_url($r['id'], bbp_get_redirect_to()), 'view_all' => false);
    // What action are we trying to perform?
    switch ($r['action']) {
        // Toggle approve
        case 'bbp_toggle_reply_approve':
            check_ajax_referer("approve-{$nonce_suffix}");
            $is_approve = bbp_is_reply_pending($r['id']);
            $retval['status'] = $is_approve ? bbp_approve_reply($r['id']) : bbp_unapprove_reply($r['id']);
            $retval['message'] = $is_approve ? __('<strong>ERROR</strong>: There was a problem approving the reply.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem unapproving the reply.', 'bbpress');
            $retval['view_all'] = !$is_approve;
            break;
            // Toggle spam
        // Toggle spam
        case 'bbp_toggle_reply_spam':
            check_ajax_referer("spam-{$nonce_suffix}");
            $is_spam = bbp_is_reply_spam($r['id']);
            $retval['status'] = $is_spam ? bbp_unspam_reply($r['id']) : bbp_spam_reply($r['id']);
            $retval['message'] = $is_spam ? __('<strong>ERROR</strong>: There was a problem unmarking the reply as spam.', 'bbpress') : __('<strong>ERROR</strong>: There was a problem marking the reply as spam.', 'bbpress');
            $retval['view_all'] = !$is_spam;
            break;
            // Toggle trash
        // Toggle trash
        case 'bbp_toggle_reply_trash':
            // Which subaction?
            switch ($r['sub_action']) {
                case 'trash':
                    check_ajax_referer("trash-{$nonce_suffix}");
                    $retval['view_all'] = true;
                    $retval['status'] = wp_trash_post($r['id']);
                    $retval['message'] = __('<strong>ERROR</strong>: There was a problem trashing the reply.', 'bbpress');
                    break;
                case 'untrash':
                    check_ajax_referer("untrash-{$nonce_suffix}");
                    $retval['status'] = wp_untrash_post($r['id']);
                    $retval['message'] = __('<strong>ERROR</strong>: There was a problem untrashing the reply.', 'bbpress');
                    break;
                case 'delete':
                    check_ajax_referer("delete-{$nonce_suffix}");
                    $retval['status'] = wp_delete_post($r['id']);
                    $retval['message'] = __('<strong>ERROR</strong>: There was a problem deleting the reply.', 'bbpress');
                    break;
            }
            break;
    }
    // Add view all if needed
    if (!empty($retval['view_all'])) {
        $retval['redirect_to'] = bbp_add_view_all($retval['redirect_to'], true);
    }
    // Filter & return
    return apply_filters('bbp_toggle_reply', $retval, $r, $args);
}
开发者ID:CompositeUK,项目名称:clone.bbPress,代码行数:71,代码来源:functions.php

示例11: bbp_get_reply_url

/**
 * Return the paginated url to the reply in the reply loop
 *
 * @since bbPress (r2679)
 *
 * @param int $reply_id Optional. Reply id
 * @param $string $redirect_to Optional. Pass a redirect value for use with
 *                              shortcodes and other fun things.
 * @uses bbp_get_reply_id() To get the reply id
 * @uses bbp_get_reply_topic_id() To get the reply topic id
 * @uses bbp_get_topic_permalink() To get the topic permalink
 * @uses bbp_get_reply_position() To get the reply position
 * @uses get_option() To get the replies per page option
 * @uses WP_Rewrite::using_permalinks() To check if the blog uses
 *                                       permalinks
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_get_reply_url' with the reply url,
 *                        reply id and bool count hidden
 * @return string Link to reply relative to paginated topic
 */
function bbp_get_reply_url($reply_id = 0, $redirect_to = '')
{
    // Set needed variables
    $reply_id = bbp_get_reply_id($reply_id);
    $topic_id = bbp_get_reply_topic_id($reply_id);
    $reply_page = ceil((int) bbp_get_reply_position($reply_id, $topic_id) / (int) bbp_get_replies_per_page());
    $reply_hash = '#post-' . $reply_id;
    $topic_link = bbp_get_topic_permalink($topic_id, $redirect_to);
    $topic_url = remove_query_arg('view', $topic_link);
    // Don't include pagination if on first page
    if (1 >= $reply_page) {
        $url = trailingslashit($topic_url) . $reply_hash;
        // Include pagination
    } else {
        global $wp_rewrite;
        // Pretty permalinks
        if ($wp_rewrite->using_permalinks()) {
            $url = trailingslashit($topic_url) . trailingslashit($wp_rewrite->pagination_base) . trailingslashit($reply_page) . $reply_hash;
            // Yucky links
        } else {
            $url = add_query_arg('paged', $reply_page, $topic_url) . $reply_hash;
        }
    }
    // Add topic view query arg back to end if it is set
    if (bbp_get_view_all()) {
        $url = bbp_add_view_all($url);
    }
    return apply_filters('bbp_get_reply_url', $url, $reply_id, $redirect_to);
}
开发者ID:hscale,项目名称:webento,代码行数:49,代码来源:bbp-reply-template.php


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