Changeset 11868
- Timestamp:
- 02/28/2018 07:25:21 PM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 2 added
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/classes/class-bp-messages-component.php
r11578 r11868 73 73 if ( bp_is_active( $this->id, 'star' ) ) { 74 74 $includes[] = 'star'; 75 } 76 if ( is_admin() ) { 77 $includes[] = 'admin'; 75 78 } 76 79 -
trunk/src/bp-messages/classes/class-bp-messages-notices-admin.php
r11867 r11868 1 1 <?php 2 2 /** 3 * Mesages classes3 * BuddyPress messages component Site-wide Notices admin screen. 4 4 * 5 * @since 1.0.0 5 * 6 * @package BuddyPress 7 * @subpackage Messages 8 * @since 3.0.0 6 9 */ 7 10 … … 9 12 defined( 'ABSPATH' ) || exit; 10 13 11 if ( is_admin() && current_user_can( 'activate_plugins' ) ) : 12 13 class BP_Nouveau_Notices_List_Table extends WP_List_Table { 14 public function __construct( $args = array() ) { 15 parent::__construct( 16 array( 17 'plural' => 'notices', 18 'singular' => 'notice', 19 'ajax' => true, 20 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 21 ) 22 ); 23 } 24 25 public function ajax_user_can() { 26 return bp_current_user_can( 'bp_moderate' ); 27 } 28 29 public function prepare_items() { 30 $page = $this->get_pagenum(); 31 $per_page = $this->get_items_per_page( 'bp_nouveau_notices_per_page' ); 32 33 $this->items = BP_Messages_Notice::get_notices( array( 34 'pag_num' => $per_page, 35 'pag_page' => $page 36 ) ); 37 38 $this->set_pagination_args( array( 39 'total_items' => BP_Messages_Notice::get_total_notice_count(), 40 'per_page' => $per_page, 41 ) ); 42 } 43 44 public function get_columns() { 45 return apply_filters( 'bp_nouveau_notices_list_table_get_columns', array( 46 'subject' => _x( 'Subject', 'Admin Notices column header', 'buddypress' ), 47 'message' => _x( 'Content', 'Admin Notices column header', 'buddypress' ), 48 'date_sent' => _x( 'Created', 'Admin Notices column header', 'buddypress' ), 49 ) ); 50 } 51 52 public function single_row( $item ) { 53 $class = ''; 54 55 if ( ! empty( $item->is_active ) ) { 56 $class = ' class="notice-active"'; 57 } 58 59 echo "<tr{$class}>"; 60 $this->single_row_columns( $item ); 61 echo '</tr>'; 62 } 63 64 public function column_subject( $item ) { 65 $actions = array( 66 'activate_deactivate' => '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 67 'page' => 'bp-notices', 68 'activate' => $item->id 69 ), bp_get_admin_url( 'users.php' ) ) ), 'messages_activate_notice' ) . '" data-bp-notice-id="' . $item->id . '" data-bp-action="activate">' . esc_html__( 'Activate Notice', 'buddypress' ) . '</a>', 70 'delete' => '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 71 'page' => 'bp-notices', 72 'delete' => $item->id 73 ), bp_get_admin_url( 'users.php' ) ) ), 'messages_delete_thread' ) . '" data-bp-notice-id="' . $item->id . '" data-bp-action="delete">' . esc_html__( 'Delete Notice', 'buddypress' ) . '</a>', 74 ); 75 76 if ( ! empty( $item->is_active ) ) { 77 $actions['activate_deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 78 'page' => 'bp-notices', 79 'deactivate' => $item->id 80 ), bp_get_admin_url( 'users.php' ) ) ), 'messages_deactivate_notice' ) . '" data-bp-notice-id="' . $item->id . '" data-bp-action="deactivate">' . esc_html__( 'Deactivate Notice', 'buddypress' ) . '</a>'; 81 } 82 83 echo '<strong>' . apply_filters( 'bp_get_message_notice_subject', $item->subject ) . '</strong> ' . $this->row_actions( $actions ); 84 } 85 86 public function column_message( $item ) { 87 echo apply_filters( 'bp_get_message_notice_text', $item->message ); 88 } 89 90 public function column_date_sent( $item ) { 91 echo apply_filters( 'bp_get_message_notice_post_date', bp_format_time( strtotime( $item->date_sent ) ) ); 92 } 93 } 94 endif; 95 96 97 class BP_Nouveau_Admin_Notices { 98 14 class BP_Messages_Notices_Admin { 15 16 /** 17 * The ID returned by `add_users_page()`. 18 * 19 * @since 3.0.0 20 * @var string 21 */ 22 public $screen_id = ''; 23 24 /** 25 * The URL of the admin screen. 26 * 27 * @since 3.0.0 28 * @var string 29 */ 30 public $url = ''; 31 32 /** 33 * The current instance of the BP_Messages_Notices_List_Table class. 34 * 35 * @since 3.0.0 36 * @var object 37 */ 38 public $list_table = ''; 39 40 41 /** 42 * Create a new instance or access the current instance of this class. 43 * 44 * @since 3.0.0 45 */ 99 46 public static function register_notices_admin() { 100 if ( ! is_admin() || ! bp_is_active( 'messages' ) ) { 47 48 if ( ! is_admin() || ! bp_is_active( 'messages' ) || ! bp_current_user_can( 'bp_moderate' ) ) { 101 49 return; 102 50 } … … 114 62 * Constructor method. 115 63 * 116 * @since 2.0.064 * @since 3.0.0 117 65 */ 118 66 public function __construct() { … … 121 69 } 122 70 71 /** 72 * Populate the classs variables. 73 * 74 * @since 3.0.0 75 */ 123 76 protected function setup_globals() { 124 $this->screen_id = ''; 125 $this->url = add_query_arg( array( 'page' => 'bp-notices' ), bp_get_admin_url( 'users.php' ) ); 126 } 127 77 $this->url = add_query_arg( array( 'page' => 'bp-notices' ), bp_get_admin_url( 'users.php' ) ); 78 } 79 80 /** 81 * Add action hooks. 82 * 83 * @since 3.0.0 84 */ 128 85 protected function setup_actions() { 129 86 add_action( bp_core_admin_hook(), array( $this, 'admin_menu' ) ); 130 87 } 131 88 89 /** 90 * Add the 'All Member Notices' admin menu item. 91 * 92 * @since 3.0.0 93 */ 132 94 public function admin_menu() { 133 95 // Bail if current user cannot moderate community. … … 147 109 } 148 110 111 /** 112 * Catch save/update requests or load the screen. 113 * 114 * @since 3.0.0 115 */ 149 116 public function admin_load() { 150 117 if ( ! empty( $_POST['bp_notice']['send'] ) ) { … … 166 133 } 167 134 168 $this->list_table = new BP_Nouveau_Notices_List_Table( array( 'screen' => get_current_screen()->id ) ); 169 } 170 135 $this->list_table = new BP_Messages_Notices_List_Table( array( 'screen' => get_current_screen()->id ) ); 136 } 137 138 /** 139 * Generate content for the bp-notices admin screen. 140 * 141 * @since 3.0.0 142 */ 171 143 public function admin_index() { 172 144 $this->list_table->prepare_items(); … … 234 206 } 235 207 } 236 add_action( 'bp_init', array( 'BP_Nouveau_Admin_Notices', 'register_notices_admin' ) ); -
trunk/src/bp-templates/bp-nouveau/includes/messages/loader.php
r11855 r11868 42 42 */ 43 43 protected function includes() { 44 require $this->dir . 'classes.php';45 44 require $this->dir . 'functions.php'; 46 45 require $this->dir . 'template-tags.php';
Note: See TracChangeset
for help on using the changeset viewer.