Changeset 6186 for trunk/src/includes/admin/forums.php
- Timestamp:
- 12/27/2016 10:45:16 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/admin/forums.php (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/forums.php
r6178 r6186 28 28 private $post_type = ''; 29 29 30 /**31 * @var WP_Screen The current screen object32 */33 private $screen;34 35 30 /** Functions *************************************************************/ 36 31 … … 80 75 add_action( 'add_meta_boxes', array( $this, 'attributes_metabox' ) ); 81 76 add_action( 'add_meta_boxes', array( $this, 'moderators_metabox' ) ); 77 add_action( 'add_meta_boxes', array( $this, 'comments_metabox' ) ); 82 78 add_action( 'save_post', array( $this, 'save_meta_boxes' ) ); 83 79 … … 93 89 94 90 /** 95 * Should we bail out of this method?96 *97 * @since 2.1.0 bbPress (r4067)98 *99 * @return boolean100 */101 private function bail() {102 103 // Not for a post type104 if ( empty( $this->screen->post_type ) ) {105 return true;106 }107 108 // Not this post type109 if ( $this->post_type != $this->screen->post_type ) {110 return true;111 }112 113 return false;114 }115 116 /**117 91 * Admin globals 118 92 * … … 123 97 private function setup_globals() { 124 98 $this->post_type = bbp_get_forum_post_type(); 125 $this->screen = get_current_screen();126 99 } 127 100 … … 137 110 public function edit_help() { 138 111 139 if ( $this->bail() ) {140 return;141 }142 143 112 // Overview 144 $this->screen->add_help_tab( array(113 get_current_screen()->add_help_tab( array( 145 114 'id' => 'overview', 146 115 'title' => __( 'Overview', 'bbpress' ), … … 150 119 151 120 // Screen Content 152 $this->screen->add_help_tab( array(121 get_current_screen()->add_help_tab( array( 153 122 'id' => 'screen-content', 154 123 'title' => __( 'Screen Content', 'bbpress' ), … … 163 132 164 133 // Available Actions 165 $this->screen->add_help_tab( array(134 get_current_screen()->add_help_tab( array( 166 135 'id' => 'action-links', 167 136 'title' => __( 'Available Actions', 'bbpress' ), … … 176 145 177 146 // Bulk Actions 178 $this->screen->add_help_tab( array(147 get_current_screen()->add_help_tab( array( 179 148 'id' => 'bulk-actions', 180 149 'title' => __( 'Bulk Actions', 'bbpress' ), … … 185 154 186 155 // Help Sidebar 187 $this->screen->set_help_sidebar(156 get_current_screen()->set_help_sidebar( 188 157 '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' . 189 158 '<p>' . __( '<a href="https://codex.bbpress.org" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' . … … 197 166 * @since 2.0.0 bbPress (r3119) 198 167 * 199 * @uses $this->screen168 * @uses get_current_screen() 200 169 */ 201 170 public function new_help() { 202 171 203 if ( $this->bail() ) {204 return;205 }206 207 172 $customize_display = '<p>' . __( 'The title field and the big forum editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.', 'bbpress' ) . '</p>'; 208 173 209 $this->screen->add_help_tab( array(174 get_current_screen()->add_help_tab( array( 210 175 'id' => 'customize-display', 211 176 'title' => __( 'Customizing This Display', 'bbpress' ), … … 213 178 ) ); 214 179 215 $this->screen->add_help_tab( array(180 get_current_screen()->add_help_tab( array( 216 181 'id' => 'title-forum-editor', 217 182 'title' => __( 'Title and Forum Editor', 'bbpress' ), … … 227 192 } 228 193 229 $this->screen->add_help_tab( array(194 get_current_screen()->add_help_tab( array( 230 195 'id' => 'forum-attributes', 231 196 'title' => __( 'Forum Attributes', 'bbpress' ), … … 241 206 ) ); 242 207 243 $this->screen->add_help_tab( array(208 get_current_screen()->add_help_tab( array( 244 209 'id' => 'publish-box', 245 210 'title' => __( 'Publish Box', 'bbpress' ), … … 247 212 ) ); 248 213 249 $this->screen->set_help_sidebar(214 get_current_screen()->set_help_sidebar( 250 215 '<p><strong>' . __( 'For more information:', 'bbpress' ) . '</strong></p>' . 251 216 '<p>' . __( '<a href="https://codex.bbpress.org" target="_blank">bbPress Documentation</a>', 'bbpress' ) . '</p>' . … … 264 229 */ 265 230 public function attributes_metabox() { 266 267 if ( $this->bail() ) {268 return;269 }270 231 271 232 // Meta data … … 293 254 public function moderators_metabox() { 294 255 295 if ( $this->bail() ) {296 return;297 }298 299 256 // Bail if feature not active or user cannot assign moderators 300 257 if ( ! bbp_allow_forum_mods() || ! current_user_can( 'assign_moderators' ) ) { … … 313 270 314 271 do_action( 'bbp_forum_moderators_metabox' ); 272 } 273 274 /** 275 * Remove comments & discussion metaboxes if comments are not supported 276 * 277 * @since 2.6.0 bbPress 278 */ 279 public function comments_metabox() { 280 if ( ! post_type_supports( $this->post_type, 'comments' ) ) { 281 remove_meta_box( 'commentstatusdiv', $this->post_type, 'normal' ); 282 remove_meta_box( 'commentsdiv', $this->post_type, 'normal' ); 283 } 315 284 } 316 285 … … 339 308 public function save_meta_boxes( $forum_id ) { 340 309 341 if ( $this->bail() ) {342 return $forum_id;343 }344 345 310 // Bail if doing an autosave 346 311 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { … … 396 361 */ 397 362 public function admin_head() { 398 399 if ( $this->bail() ) { 400 return; 401 } ?> 363 ?> 402 364 403 365 <style type="text/css" media="screen"> … … 492 454 public function toggle_forum() { 493 455 494 if ( $this->bail() ) {495 return;496 }497 498 456 // Only proceed if GET is a forum toggle action 499 457 if ( bbp_is_get_request() && ! empty( $_GET['forum_id'] ) && ! empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_forum_close' ) ) ) { … … 560 518 public function toggle_forum_notice() { 561 519 562 if ( $this->bail() ) {563 return;564 }565 566 520 // Only proceed if GET is a forum toggle action 567 521 if ( bbp_is_get_request() && ! empty( $_GET['bbp_forum_toggle_notice'] ) && in_array( $_GET['bbp_forum_toggle_notice'], array( 'opened', 'closed' ) ) && ! empty( $_GET['forum_id'] ) ) { … … 621 575 */ 622 576 public function column_headers( $columns ) { 623 624 if ( $this->bail() ) {625 return $columns;626 }627 577 628 578 // Set list table column headers … … 665 615 public function column_data( $column, $forum_id ) { 666 616 667 if ( $this->bail() ) {668 return;669 }670 671 617 switch ( $column ) { 672 618 case 'bbp_forum_topic_count' : … … 731 677 public function row_actions( $actions, $forum ) { 732 678 733 if ( $this->bail() ) {734 return $actions;735 }736 737 679 unset( $actions['inline hide-if-no-js'] ); 738 680 … … 774 716 public function updated_messages( $messages ) { 775 717 global $post_ID; 776 777 if ( $this->bail() ) {778 return $messages;779 }780 718 781 719 // URL for the current forum … … 867 805 * @uses BBP_Forums_Admin 868 806 */ 869 function bbp_admin_forums() { 807 function bbp_admin_forums( $current_screen ) { 808 809 // Bail if not a forum screen 810 if ( empty( $current_screen->post_type ) || ( bbp_get_forum_post_type() !== $current_screen->post_type ) ) { 811 return; 812 } 813 814 // Init the forums admin 870 815 bbpress()->admin->forums = new BBP_Forums_Admin(); 871 816 }
Note: See TracChangeset
for help on using the changeset viewer.