Changeset 4070 for branches/plugin/bbp-admin/bbp-replies.php
- Timestamp:
- 07/08/2012 08:55:34 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-admin/bbp-replies.php
r4054 r4070 39 39 * @uses BBP_Replies_Admin::setup_actions() Setup the help text 40 40 */ 41 function __construct() {41 public function __construct() { 42 42 $this->setup_globals(); 43 43 $this->setup_actions(); … … 56 56 * @uses bbp_get_reply_post_type() To get the reply post type 57 57 */ 58 function setup_actions() {58 private function setup_actions() { 59 59 60 60 // Add some general styling to the admin area … … 93 93 94 94 /** 95 * Should we bail out of this method? 96 * 97 * @since bbPress (r4067) 98 * @return boolean 99 */ 100 private function bail() { 101 if ( $this->post_type != get_current_screen()->post_type ) 102 return true; 103 104 return false; 105 } 106 107 /** 95 108 * Admin globals 96 109 * … … 98 111 * @access private 99 112 */ 100 function setup_globals() { 101 102 // Setup the post type for this admin component 113 private function setup_globals() { 103 114 $this->post_type = bbp_get_reply_post_type(); 104 115 } … … 113 124 */ 114 125 public function edit_help() { 126 127 if ( $this->bail() ) return; 115 128 116 129 // Overview … … 176 189 public function new_help() { 177 190 191 if ( $this->bail() ) return; 192 178 193 $customize_display = '<p>' . __( 'The title field and the big reply 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>'; 179 194 … … 243 258 * @uses do_action() Calls 'bbp_reply_attributes_metabox' 244 259 */ 245 function reply_attributes_metabox() { 260 public function reply_attributes_metabox() { 261 262 if ( $this->bail() ) return; 263 246 264 add_meta_box ( 247 265 'bbp_reply_attributes', … … 268 286 * @return int Parent id 269 287 */ 270 function reply_attributes_metabox_save( $reply_id ) { 288 public function reply_attributes_metabox_save( $reply_id ) { 289 290 if ( $this->bail() ) return $reply_id; 271 291 272 292 // Bail if doing an autosave … … 318 338 * id 319 339 */ 320 function author_metabox() { 340 public function author_metabox() { 341 342 if ( $this->bail() ) return; 321 343 322 344 // Bail if post_type is not a reply … … 353 375 * @return int Topic or reply id 354 376 */ 355 function author_metabox_save( $post_id ) { 377 public function author_metabox_save( $post_id ) { 378 379 if ( $this->bail() ) return $post_id; 356 380 357 381 // Bail if no post_id … … 393 417 * @uses do_action() Calls 'bbp_admin_head' 394 418 */ 395 function admin_head() { 419 public function admin_head() { 420 421 if ( $this->bail() ) return; 422 396 423 ?> 397 424 … … 464 491 * @uses wp_safe_redirect() Redirect the page to custom url 465 492 */ 466 function toggle_reply() { 493 public function toggle_reply() { 494 495 if ( $this->bail() ) return; 467 496 468 497 // Only proceed if GET is a reply toggle action … … 524 553 * message, reply id, notice and is it a failure 525 554 */ 526 function toggle_reply_notice() { 555 public function toggle_reply_notice() { 556 557 if ( $this->bail() ) return; 527 558 528 559 // Only proceed if GET is a reply toggle action … … 576 607 * @return array $columns bbPress reply columns 577 608 */ 578 function replies_column_headers( $columns ) { 609 public function replies_column_headers( $columns ) { 610 611 if ( $this->bail() ) return $columns; 612 579 613 $columns = array( 580 614 'cb' => '<input type="checkbox" />', … … 617 651 * column and reply id 618 652 */ 619 function replies_column_data( $column, $reply_id ) { 653 public function replies_column_data( $column, $reply_id ) { 654 655 if ( $this->bail() ) return; 620 656 621 657 // Get topic ID … … 727 763 * @return array $actions Actions 728 764 */ 729 function replies_row_actions( $actions, $reply ) {730 731 if ( bbp_get_reply_post_type() == $reply->post_type ) {732 unset( $actions['inline hide-if-no-js'] ); 733 734 // Reply view links to topic 735 $actions['view'] = '<a href="' . bbp_get_reply_url( $reply->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_reply_title( $reply->ID ) ) ) . '" rel="permalink">' . __( 'View', 'bbpress' ) . '</a>';736 737 // User cannot view replies in trash 738 if ( ( bbp_get_trash_status_id() == $reply->post_status ) && !current_user_can( 'view_trash' ) )739 unset( $actions['view'] );740 741 // Only show the actions if the user is capable of viewing them 742 if ( current_user_can( 'moderate', $reply->ID ) ) {743 if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_spam_status_id() )) ) {744 $spam_uri = esc_url( wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_spam' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'spam-reply_' . $reply->ID ) );745 if ( bbp_is_reply_spam( $reply->ID ) ) {746 $actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark the reply as not spam', 'bbpress' ) . '">' . __( 'Not spam', 'bbpress' ) . '</a>';747 } else {748 $actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark this reply as spam', 'bbpress' ) . '">' . __( 'Spam', 'bbpress' ) . '</a>';749 }765 public function replies_row_actions( $actions, $reply ) { 766 767 if ( $this->bail() ) return $actions; 768 769 unset( $actions['inline hide-if-no-js'] ); 770 771 // Reply view links to topic 772 $actions['view'] = '<a href="' . bbp_get_reply_url( $reply->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_reply_title( $reply->ID ) ) ) . '" rel="permalink">' . __( 'View', 'bbpress' ) . '</a>'; 773 774 // User cannot view replies in trash 775 if ( ( bbp_get_trash_status_id() == $reply->post_status ) && !current_user_can( 'view_trash' ) ) 776 unset( $actions['view'] ); 777 778 // Only show the actions if the user is capable of viewing them 779 if ( current_user_can( 'moderate', $reply->ID ) ) { 780 if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_spam_status_id() ) ) ) { 781 $spam_uri = esc_url( wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_spam' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'spam-reply_' . $reply->ID ) ); 782 if ( bbp_is_reply_spam( $reply->ID ) ) { 783 $actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark the reply as not spam', 'bbpress' ) . '">' . __( 'Not spam', 'bbpress' ) . '</a>'; 784 } else { 785 $actions['spam'] = '<a href="' . $spam_uri . '" title="' . esc_attr__( 'Mark this reply as spam', 'bbpress' ) . '">' . __( 'Spam', 'bbpress' ) . '</a>'; 750 786 } 751 787 } 752 753 // Trash 754 if ( current_user_can( 'delete_reply', $reply->ID ) ) {755 if ( bbp_get_trash_status_id() == $reply->post_status) {756 $post_type_object = get_post_type_object( bbp_get_reply_post_type() );757 $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ) ), wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . "'>" . __( 'Restore', 'bbpress' ) . "</a>";758 } elseif ( EMPTY_TRASH_DAYS ) {759 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $reply->ID ) ) . "'>" . __( 'Trash', 'bbpress' ) . "</a>";760 }761 762 if ( bbp_get_trash_status_id() == $reply->post_status || !EMPTY_TRASH_DAYS ) { 763 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $reply->ID, '', true ) ) . "'>" . __( 'Delete Permanently', 'bbpress' ) . "</a>";764 } elseif ( bbp_get_spam_status_id() == $reply->post_status ) {765 unset( $actions['trash'] );766 }788 } 789 790 // Trash 791 if ( current_user_can( 'delete_reply', $reply->ID ) ) { 792 if ( bbp_get_trash_status_id() == $reply->post_status ) { 793 $post_type_object = get_post_type_object( bbp_get_reply_post_type() ); 794 $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ) ), wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $reply->ID ) ), 'untrash-' . $reply->post_type . '_' . $reply->ID ) ) . "'>" . __( 'Restore', 'bbpress' ) . "</a>"; 795 } elseif ( EMPTY_TRASH_DAYS ) { 796 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $reply->ID ) ) . "'>" . __( 'Trash', 'bbpress' ) . "</a>"; 797 } 798 799 if ( bbp_get_trash_status_id() == $reply->post_status || !EMPTY_TRASH_DAYS ) { 800 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . add_query_arg( array( '_wp_http_referer' => add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) ) ), get_delete_post_link( $reply->ID, '', true ) ) . "'>" . __( 'Delete Permanently', 'bbpress' ) . "</a>"; 801 } elseif ( bbp_get_spam_status_id() == $reply->post_status ) { 802 unset( $actions['trash'] ); 767 803 } 768 804 } … … 781 817 * @return bool False. If post type is not topic or reply 782 818 */ 783 function filter_dropdown() { 819 public function filter_dropdown() { 820 821 if ( $this->bail() ) return; 784 822 785 823 // Add Empty Spam button … … 811 849 * @return array Processed Query Vars 812 850 */ 813 function filter_post_rows( $query_vars ) { 814 global $pagenow; 851 public function filter_post_rows( $query_vars ) { 852 853 if ( $this->bail() ) return $query_vars; 815 854 816 855 // Add post_parent query_var if one is present … … 839 878 * @return array 840 879 */ 841 function updated_messages( $messages ) {880 public function updated_messages( $messages ) { 842 881 global $post_ID; 882 883 if ( $this->bail() ) return $messages; 843 884 844 885 // URL for the current topic … … 906 947 */ 907 948 function bbp_admin_replies() { 908 global $typenow;909 910 if ( bbp_get_reply_post_type() != $typenow )911 return;912 913 949 bbpress()->admin->replies = new BBP_Replies_Admin(); 914 950 }
Note: See TracChangeset
for help on using the changeset viewer.