Changeset 5834 for trunk/src/includes/admin/forums.php
- Timestamp:
- 07/15/2015 03:59:23 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/forums.php
r5829 r5834 64 64 add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) ); 65 65 66 // Metabox actions67 add_action( 'add_meta_boxes', array( $this, 'attributes_metabox' ) );68 add_action( 'save_post', array( $this, 'attributes_metabox_save' ) );69 70 66 // Forum Column headers. 71 67 add_filter( 'manage_' . $this->post_type . '_posts_columns', array( $this, 'column_headers' ) ); … … 75 71 add_filter( 'page_row_actions', array( $this, 'row_actions' ), 10, 2 ); 76 72 73 // Metabox actions 74 add_action( 'add_meta_boxes', array( $this, 'attributes_metabox' ) ); 75 add_action( 'save_post', array( $this, 'attributes_metabox_save' ) ); 76 77 77 // Check if there are any bbp_toggle_forum_* requests on admin_init, also have a message displayed 78 78 add_action( 'load-edit.php', array( $this, 'toggle_forum' ) ); 79 79 add_action( 'admin_notices', array( $this, 'toggle_forum_notice' ) ); 80 81 // Forum moderators AJAX; run at -1 to preempt built-in tag search 82 add_action( 'wp_ajax_ajax-tag-search', array( $this, 'ajax_tag_search' ), -1 ); 80 83 81 84 // Contextual Help … … 260 263 261 264 do_action( 'bbp_forum_attributes_metabox' ); 265 } 266 267 /** 268 * Return user nicename suggestions instead of tag suggestions 269 * 270 * @since bbPress (r5834) 271 * 272 * @uses bbp_get_forum_mod_tax_id() To get the forum moderator taxonomy id 273 * @uses sanitize_key() To sanitize the taxonomy id 274 * @uses get_taxonomy() To get the forum moderator taxonomy 275 * @uses current_user_can() To check if the current user add/edit forum moderators 276 * @uses get_users() To get an array of users 277 * @uses user_nicename() To get the users nice name 278 * 279 * @return Return early if not a request for forum moderators tax 280 */ 281 public function ajax_tag_search() { 282 283 // Only do AJAX if this is a forum moderators tax search. 284 if ( ! isset( $_GET['tax'] ) || ( bbp_get_forum_mod_tax_id() !== $_GET['tax'] ) ) { 285 return; 286 } 287 288 $taxonomy = sanitize_key( $_GET['tax'] ); 289 $tax = get_taxonomy( $taxonomy ); 290 if ( empty( $tax ) ) { 291 wp_die( 0 ); 292 } 293 294 // Check permissions. 295 if ( ! current_user_can( $tax->cap->assign_terms ) ) { 296 wp_die( -1 ); 297 } 298 299 $s = stripslashes( $_GET['q'] ); 300 301 // Replace tag delimiter with a comma if needed. 302 $comma = _x( ',', 'tag delimiter', 'bbpress' ); 303 if ( ',' !== $comma ) { 304 $s = str_replace( $comma, ',', $s ); 305 } 306 307 if ( false !== strpos( $s, ',' ) ) { 308 $s = explode( ',', $s ); 309 $s = $s[ count( $s ) - 1 ]; 310 } 311 312 // Search on at least 2 characters. 313 $s = trim( $s ); 314 if ( strlen( $s ) < 2 ) { 315 wp_die(); // Require 2 chars for matching. 316 } 317 318 // Get users. 319 $results = array(); 320 $users = get_users( array( 321 'blog_id' => 0, // All users. 322 'fields' => array( 'user_nicename' ), 323 'search' => '*' . $s . '*', 324 'search_columns' => array( 'user_nicename' ), 325 'orderby' => 'user_nicename', 326 ) ); 327 328 // Format the users into a nice array. 329 if ( ! empty( $users ) ) { 330 foreach ( array_values( $users ) as $details ) { 331 $results[] = $details->user_nicename; 332 } 333 } 334 335 // Echo results for AJAX. 336 echo join( $results, "\n" ); 337 wp_die(); 262 338 } 263 339 … … 349 425 /*<![CDATA[*/ 350 426 351 #mi sc-publishing-actions,427 #minor-publishing, 352 428 #save-post { 353 429 display: none; … … 373 449 374 450 .column-author, 451 .column-bbp_forum_mods, 375 452 .column-bbp_reply_author, 376 453 .column-bbp_topic_author { … … 566 643 } 567 644 568 $columns = array ( 645 // Set list table column headers 646 $columns = array( 569 647 'cb' => '<input type="checkbox" />', 570 'title' => __( 'Forum', 'bbpress' ), 571 'bbp_forum_topic_count' => __( 'Topics', 'bbpress' ), 572 'bbp_forum_reply_count' => __( 'Replies', 'bbpress' ), 573 'author' => __( 'Creator', 'bbpress' ), 574 'bbp_forum_created' => __( 'Created' , 'bbpress' ), 575 'bbp_forum_freshness' => __( 'Freshness', 'bbpress' ) 648 'title' => __( 'Forum', 'bbpress' ), 649 'bbp_forum_topic_count' => __( 'Topics', 'bbpress' ), 650 'bbp_forum_reply_count' => __( 'Replies', 'bbpress' ), 651 'author' => __( 'Creator', 'bbpress' ), 652 'bbp_forum_mods' => __( 'Moderators', 'bbpress' ), 653 'bbp_forum_created' => __( 'Created' , 'bbpress' ), 654 'bbp_forum_freshness' => __( 'Freshness', 'bbpress' ) 576 655 ); 656 657 // Remove forum mods column if not enabled 658 if ( ! bbp_allow_forum_mods() ) { 659 unset( $columns['bbp_forum_mods'] ); 660 } 577 661 578 662 return apply_filters( 'bbp_admin_forums_column_headers', $columns ); … … 609 693 case 'bbp_forum_reply_count' : 610 694 bbp_forum_reply_count( $forum_id ); 695 break; 696 697 case 'bbp_forum_mods' : 698 $moderators = wp_get_object_terms( $forum_id, bbp_get_forum_mod_tax_id() ); 699 if ( empty( $moderators ) ) { 700 esc_html__( 'None', 'bbpress' ); 701 } else { 702 echo implode( ', ', wp_list_pluck( $moderators, 'name' ) ); 703 } 611 704 break; 612 705
Note: See TracChangeset
for help on using the changeset viewer.