Пример #1
0
 /**
  * Setup the admin hooks, actions and filters
  *
  * @since 2.0.0 bbPress (r2646)
  * @since 2.6.0 bbPress (r6101) Added bulk actions
  *
  * @access private
  *
  * @uses add_action() To add various actions
  * @uses add_filter() To add various filters
  * @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
  */
 private function setup_actions()
 {
     // Add some general styling to the admin area
     add_action('bbp_admin_head', array($this, 'admin_head'));
     // Messages
     add_filter('post_updated_messages', array($this, 'updated_messages'));
     // Reply bulk actions, added in WordPress 4.7, see #WP16031
     if (bbp_get_major_wp_version() >= 4.7) {
         add_filter('bulk_actions-edit-reply', array($this, 'bulk_actions'));
         add_filter('handle_bulk_actions-edit-reply', array($this, 'handle_bulk_actions'), 10, 3);
         add_filter('bulk_post_updated_messages', array($this, 'bulk_post_updated_messages'), 10, 2);
     }
     // Reply column headers.
     add_filter('manage_' . $this->post_type . '_posts_columns', array($this, 'column_headers'));
     // Reply columns (in post row)
     add_action('manage_' . $this->post_type . '_posts_custom_column', array($this, 'column_data'), 10, 2);
     add_filter('post_row_actions', array($this, 'row_actions'), 10, 2);
     // Reply metabox actions
     add_action('add_meta_boxes', array($this, 'attributes_metabox'));
     add_action('add_meta_boxes', array($this, 'author_metabox'));
     add_action('save_post', array($this, 'save_meta_boxes'));
     // Check if there are any bbp_toggle_reply_* requests on admin_init, also have a message displayed
     add_action('load-edit.php', array($this, 'toggle_reply'));
     add_action('admin_notices', array($this, 'toggle_reply_notice'));
     // Add ability to filter topics and replies per forum
     add_filter('restrict_manage_posts', array($this, 'filter_dropdown'));
     add_filter('bbp_request', array($this, 'filter_post_rows'));
     // Contextual Help
     add_action('load-edit.php', array($this, 'edit_help'));
     add_action('load-post.php', array($this, 'new_help'));
     add_action('load-post-new.php', array($this, 'new_help'));
 }
Пример #2
0
 /**
  * @covers ::bbp_forum_post_type
  * @covers ::bbp_get_forum_post_type
  */
 public function test_bbp_get_forum_post_type()
 {
     $f = $this->factory->forum->create();
     $fobj = get_post_type_object('forum');
     // WordPress 4.6 introduced `WP_Post_Type` class
     if (bbp_get_major_wp_version() < 4.6) {
         $this->assertInstanceOf('stdClass', $fobj);
     } else {
         $this->assertInstanceOf('WP_Post_Type', $fobj);
     }
     $this->assertEquals('forum', $fobj->name);
     // Test some defaults
     $this->assertTrue(is_post_type_hierarchical('forum'));
     $forum_type = bbp_forum_post_type($f);
     $this->expectOutputString('forum', $forum_type);
     $forum_type = bbp_get_forum_post_type($f);
     $this->assertSame('forum', $forum_type);
 }
Пример #3
0
 /**
  * @covers ::bbp_reply_post_type
  * @covers ::bbp_get_reply_post_type
  */
 public function test_bbp_reply_post_type()
 {
     $t = $this->factory->topic->create();
     $r = $this->factory->reply->create(array('post_parent' => $t, 'reply_meta' => array('topic_id' => $t)));
     $robj = get_post_type_object('reply');
     // WordPress 4.6 introduced `WP_Post_Type` class
     if (bbp_get_major_wp_version() < 4.6) {
         $this->assertInstanceOf('stdClass', $robj);
     } else {
         $this->assertInstanceOf('WP_Post_Type', $robj);
     }
     $this->assertEquals('reply', $robj->name);
     // Test some defaults
     $this->assertFalse(is_post_type_hierarchical('topic'));
     $reply_type = bbp_reply_post_type($r);
     $this->expectOutputString('reply', $reply_type);
     $reply_type = bbp_get_reply_post_type($r);
     $this->assertSame('reply', $reply_type);
 }
Пример #4
0
        /**
         * Add bulk forums role dropdown to the WordPress users table
         *
         * @since 2.2.0 bbPress (r4360)
         * @since 2.6.0 bbPress (r6055) Introduced the `$which` parameter.
         *
         * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
         */
        public static function user_role_bulk_dropdown($which)
        {
            // Remove the bottom list table "change forum role" dropdown from WordPress < 4.6.
            // See https://bbpress.trac.wordpress.org/ticket/2906.
            if (bbp_get_major_wp_version() < 4.6) {
                remove_action('restrict_manage_users', array(__CLASS__, 'user_role_bulk_dropdown'));
            }
            // Bail if current user cannot promote users
            if (!current_user_can('promote_users')) {
                return;
            }
            // Get the roles
            $dynamic_roles = bbp_get_dynamic_roles();
            // Only keymasters can set other keymasters
            if (!bbp_is_user_keymaster()) {
                unset($dynamic_roles[bbp_get_keymaster_role()]);
            }
            $select_id = 'bottom' === $which ? 'bbp-new-role2' : 'bbp-new-role';
            $button_id = 'bottom' === $which ? 'bbp-change-role2' : 'bbp-change-role';
            ?>

		<label class="screen-reader-text" for="<?php 
            echo $select_id;
            ?>
"><?php 
            esc_html_e('Change forum role to&hellip;', 'bbpress');
            ?>
</label>
		<select name="<?php 
            echo $select_id;
            ?>
" id="<?php 
            echo $select_id;
            ?>
" style="display:inline-block; float:none;">
			<option value=''><?php 
            esc_html_e('Change forum role to&hellip;', 'bbpress');
            ?>
</option>
			<?php 
            foreach ($dynamic_roles as $role => $details) {
                ?>
				<option value="<?php 
                echo esc_attr($role);
                ?>
"><?php 
                echo bbp_translate_user_role($details['name']);
                ?>
</option>
			<?php 
            }
            ?>
		</select><?php 
            submit_button(__('Change', 'bbpress'), 'secondary', $button_id, false);
            wp_nonce_field('bbp-bulk-users', 'bbp-bulk-users-nonce');
        }