bbPress::register_post_statuses()
Register the post statuses used by bbPress
Description Description
We do some manipulation of the ‘trash’ status so trashed topics and replies can be viewed from within the theme.
Source Source
File: bbpress.php
public static function register_post_statuses() { // Closed register_post_status( bbp_get_closed_status_id(), apply_filters( 'bbp_register_closed_post_status', array( 'label' => _x( 'Closed', 'post', 'bbpress' ), 'label_count' => _nx_noop( 'Closed <span class="count">(%s)</span>', 'Closed <span class="count">(%s)</span>', 'post', 'bbpress' ), 'public' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => true, 'source' => 'bbpress' ) ) ); // Spam register_post_status( bbp_get_spam_status_id(), apply_filters( 'bbp_register_spam_post_status', array( 'label' => _x( 'Spam', 'post', 'bbpress' ), 'label_count' => _nx_noop( 'Spam <span class="count">(%s)</span>', 'Spam <span class="count">(%s)</span>', 'post', 'bbpress' ), 'protected' => true, 'exclude_from_search' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => false, 'source' => 'bbpress' ) ) ); // Orphan register_post_status( bbp_get_orphan_status_id(), apply_filters( 'bbp_register_orphan_post_status', array( 'label' => _x( 'Orphan', 'post', 'bbpress' ), 'label_count' => _nx_noop( 'Orphan <span class="count">(%s)</span>', 'Orphans <span class="count">(%s)</span>', 'post', 'bbpress' ), 'protected' => true, 'exclude_from_search' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => false, 'source' => 'bbpress' ) ) ); // Hidden register_post_status( bbp_get_hidden_status_id(), apply_filters( 'bbp_register_hidden_post_status', array( 'label' => _x( 'Hidden', 'post', 'bbpress' ), 'label_count' => _nx_noop( 'Hidden <span class="count">(%s)</span>', 'Hidden <span class="count">(%s)</span>', 'post', 'bbpress' ), 'private' => true, 'exclude_from_search' => true, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => true, 'source' => 'bbpress' ) ) ); /** * Trash fix * * We need to remove the internal arg and change that to * protected so that the users with 'view_trash' cap can view * single trashed topics/replies in the front-end as wp_query * doesn't allow any hack for the trashed topics to be viewed. */ global $wp_post_statuses; if ( ! empty( $wp_post_statuses['trash'] ) ) { // User can view trash so set internal to false if ( current_user_can( 'view_trash' ) ) { $wp_post_statuses['trash']->internal = false; $wp_post_statuses['trash']->protected = true; // User cannot view trash so set internal to true } else { $wp_post_statuses['trash']->internal = true; } } }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |