'notices', 'singular' => 'notice', 'ajax' => true, 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, ) ); } public function ajax_user_can() { return bp_current_user_can( 'bp_moderate' ); } public function prepare_items() { $page = $this->get_pagenum(); $per_page = $this->get_items_per_page( 'bp_nouveau_notices_per_page' ); $this->items = BP_Messages_Notice::get_notices( array( 'pag_num' => $per_page, 'pag_page' => $page ) ); $this->set_pagination_args( array( 'total_items' => BP_Messages_Notice::get_total_notice_count(), 'per_page' => $per_page, ) ); } public function get_columns() { return apply_filters( 'bp_nouveau_notices_list_table_get_columns', array( 'subject' => _x( 'Subject', 'Admin Notices column header', 'buddypress' ), 'message' => _x( 'Content', 'Admin Notices column header', 'buddypress' ), 'date_sent' => _x( 'Created', 'Admin Notices column header', 'buddypress' ), ) ); } public function single_row( $item ) { $class = ''; if ( ! empty( $item->is_active ) ) { $class = ' class="notice-active"'; } echo ""; $this->single_row_columns( $item ); echo ''; } public function column_subject( $item ) { $actions = array( 'activate_deactivate' => '' . esc_html__( 'Activate Notice', 'buddypress' ) . '', 'delete' => '' . esc_html__( 'Delete Notice', 'buddypress' ) . '', ); if ( ! empty( $item->is_active ) ) { $actions['activate_deactivate'] = '' . esc_html__( 'Deactivate Notice', 'buddypress' ) . ''; } echo '' . apply_filters( 'bp_get_message_notice_subject', $item->subject ) . ' ' . $this->row_actions( $actions ); } public function column_message( $item ) { echo apply_filters( 'bp_get_message_notice_text', $item->message ); } public function column_date_sent( $item ) { echo apply_filters( 'bp_get_message_notice_post_date', bp_format_time( strtotime( $item->date_sent ) ) ); } } endif; class BP_Nouveau_Admin_Notices { public static function register_notices_admin() { if ( ! is_admin() || ! bp_is_active( 'messages' ) ) { return; } $bp = buddypress(); if ( empty( $bp->messages->admin ) ) { $bp->messages->admin = new self; } return $bp->messages->admin; } /** * Constructor method. * * @since 2.0.0 */ public function __construct() { $this->setup_globals(); $this->setup_actions(); } protected function setup_globals() { $this->screen_id = ''; $this->url = add_query_arg( array( 'page' => 'bp-notices' ), bp_get_admin_url( 'users.php' ) ); } protected function setup_actions() { add_action( bp_core_admin_hook(), array( $this, 'admin_menu' ) ); } public function admin_menu() { // Bail if current user cannot moderate community. if ( ! bp_current_user_can( 'bp_moderate' ) || ! bp_is_active( 'messages' ) ) { return false; } $this->screen_id = add_users_page( _x( 'All Member Notices', 'Notices admin page title', 'buddypress' ), _x( 'All Member Notices', 'Admin Users menu', 'buddypress' ), 'manage_options', 'bp-notices', array( $this, 'admin_index' ) ); add_action( 'load-' . $this->screen_id, array( $this, 'admin_load' ) ); } public function admin_load() { if ( ! empty( $_POST['bp_notice']['send'] ) ) { $notice = wp_parse_args( $_POST['bp_notice'], array( 'subject' => '', 'content' => '' ) ); if ( messages_send_notice( $notice['subject'], $notice['content'] ) ) { $redirect_to = add_query_arg( 'success', 1, $this->url ); // Notice could not be sent. } else { $redirect_to = add_query_arg( 'error', 1, $this->url ); } wp_safe_redirect( $redirect_to ); exit(); } $this->list_table = new BP_Nouveau_Notices_List_Table( array( 'screen' => get_current_screen()->id ) ); } public function admin_index() { $this->list_table->prepare_items(); ?>
=' ) ) : ?>


url ); ?> method="post">
 

list_table->display(); ?>