[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress messages admin site-wide notices list table class. 4 * 5 * @package BuddyPress 6 * @subpackage MessagesClasses 7 * @since 3.0.0 8 */ 9 10 // Exit if accessed directly. 11 defined( 'ABSPATH' ) || exit; 12 13 // Include WP's list table class. 14 if ( ! class_exists( 'WP_List_Table' ) ) { 15 require( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); 16 } 17 18 /** 19 * BuddyPress Notices List Table class. 20 */ 21 class BP_Messages_Notices_List_Table extends WP_List_Table { 22 23 /** 24 * Constructor 25 * 26 * @since 3.0.0 27 * 28 * @param array $args Arguments passed to the WP_List_Table::constructor. 29 */ 30 public function __construct( $args = array() ) { 31 parent::__construct( 32 array( 33 'plural' => 'notices', 34 'singular' => 'notice', 35 'ajax' => true, 36 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 37 ) 38 ); 39 } 40 41 /** 42 * Checks the current user's permissions 43 * 44 * @since 3.0.0 45 */ 46 public function ajax_user_can() { 47 return bp_current_user_can( 'bp_moderate' ); 48 } 49 50 /** 51 * Set up items for display in the list table. 52 * 53 * Handles filtering of data, sorting, pagination, and any other data 54 * manipulation required prior to rendering. 55 * 56 * @since 3.0.0 57 */ 58 public function prepare_items() { 59 $page = $this->get_pagenum(); 60 $per_page = $this->get_items_per_page( 'bp_notices_per_page' ); 61 62 $this->items = BP_Messages_Notice::get_notices( array( 63 'pag_num' => $per_page, 64 'pag_page' => $page 65 ) ); 66 67 $this->set_pagination_args( array( 68 'total_items' => BP_Messages_Notice::get_total_notice_count(), 69 'per_page' => $per_page, 70 ) ); 71 } 72 73 /** 74 * Get a list of columns. The format is: 75 * 'internal-name' => 'Title' 76 * 77 * @since 3.0.0 78 * 79 * @return array 80 */ 81 public function get_columns() { 82 return apply_filters( 'bp_notices_list_table_get_columns', array( 83 'subject' => _x( 'Subject', 'Admin Notices column header', 'buddypress' ), 84 'message' => _x( 'Content', 'Admin Notices column header', 'buddypress' ), 85 'date_sent' => _x( 'Created', 'Admin Notices column header', 'buddypress' ), 86 ) ); 87 } 88 89 /** 90 * Generates content for a single row of the table 91 * 92 * @since 3.0.0 93 * 94 * @param object $item The current item 95 */ 96 public function single_row( $item ) { 97 $class = ''; 98 99 if ( ! empty( $item->is_active ) ) { 100 $class = ' class="notice-active"'; 101 } 102 103 echo "<tr{$class}>"; 104 $this->single_row_columns( $item ); 105 echo '</tr>'; 106 } 107 108 /** 109 * Generates content for the "subject" column. 110 * 111 * @since 3.0.0 112 * 113 * @param object $item The current item 114 */ 115 public function column_subject( $item ) { 116 $actions = array( 117 'activate_deactivate' => sprintf( '<a href="%s" data-bp-notice-id="%d" data-bp-action="activate">%s</a>', 118 esc_url( wp_nonce_url( add_query_arg( array( 119 'page' => 'bp-notices', 120 'notice_action' => 'activate', 121 'notice_id' => $item->id 122 ), bp_get_admin_url( 'users.php' ) ), 'messages-activate-notice-' . $item->id ) ), 123 (int) $item->id, 124 esc_html__( 'Activate Notice', 'buddypress' ) ), 125 'delete' => sprintf( '<a href="%s" data-bp-notice-id="%d" data-bp-action="delete">%s</a>', 126 esc_url( wp_nonce_url( add_query_arg( array( 127 'page' => 'bp-notices', 128 'notice_action' => 'delete', 129 'notice_id' => $item->id 130 ), bp_get_admin_url( 'users.php' ) ), 'messages-delete-notice-' . $item->id ) ), 131 (int) $item->id, 132 esc_html__( 'Delete Notice', 'buddypress' ) ) 133 ); 134 135 if ( ! empty( $item->is_active ) ) { 136 /* translators: %s: notice subject */ 137 $item->subject = sprintf( _x( 'Active: %s', 'Tag prepended to active site-wide notice titles on WP Admin notices list table', 'buddypress' ), $item->subject ); 138 $actions['activate_deactivate'] = sprintf( '<a href="%s" data-bp-notice-id="%d" data-bp-action="deactivate">%s</a>', 139 esc_url( wp_nonce_url( add_query_arg( array( 140 'page' => 'bp-notices', 141 'notice_action' => 'deactivate', 142 'notice_id' => $item->id 143 ), bp_get_admin_url( 'users.php' ) ), 'messages-deactivate-notice-' . $item->id ) ), 144 (int) $item->id, 145 esc_html__( 'Deactivate Notice', 'buddypress' ) ); 146 } 147 148 echo '<strong>' . apply_filters( 'bp_get_message_notice_subject', $item->subject ) . '</strong> ' . $this->row_actions( $actions ); 149 } 150 151 /** 152 * Generates content for the "message" column. 153 * 154 * @since 3.0.0 155 * 156 * @param object $item The current item 157 */ 158 public function column_message( $item ) { 159 echo apply_filters( 'bp_get_message_notice_text', $item->message ); 160 } 161 162 /** 163 * Generates content for the "date_sent" column. 164 * 165 * @since 3.0.0 166 * 167 * @param object $item The current item 168 */ 169 public function column_date_sent( $item ) { 170 echo apply_filters( 'bp_get_message_notice_post_date', bp_format_time( strtotime( $item->date_sent ) ) ); 171 } 172 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:54 2024 | Cross-referenced by PHPXref 0.7.1 |