Changeset 13091
- Timestamp:
- 08/23/2021 02:03:02 AM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-notifications/actions/bulk-manage.php
r13034 r13091 1 1 <?php 2 2 /** 3 * Notifications: Bulk-manage action handler 3 * Notifications: Bulk-manage action handler. 4 4 * 5 5 * @package BuddyPress … … 28 28 29 29 // Bail if no action or no IDs. 30 if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ) ) ) || empty( $notifications ) || empty( $nonce ) ) {30 if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ), true ) ) || empty( $notifications ) || empty( $nonce ) ) { 31 31 return false; 32 32 } … … 42 42 // Delete, mark as read or unread depending on the user 'action'. 43 43 switch ( $action ) { 44 case 'delete' 44 case 'delete': 45 45 foreach ( $notifications as $notification ) { 46 46 bp_notifications_delete_notification( $notification ); 47 47 } 48 48 bp_core_add_message( __( 'Notifications deleted.', 'buddypress' ) ); 49 break;49 break; 50 50 51 case 'read' 51 case 'read': 52 52 foreach ( $notifications as $notification ) { 53 53 bp_notifications_mark_notification( $notification, false ); 54 54 } 55 55 bp_core_add_message( __( 'Notifications marked as read', 'buddypress' ) ); 56 break;56 break; 57 57 58 case 'unread' 58 case 'unread': 59 59 foreach ( $notifications as $notification ) { 60 60 bp_notifications_mark_notification( $notification, true ); 61 61 } 62 62 bp_core_add_message( __( 'Notifications marked as unread.', 'buddypress' ) ); 63 break;63 break; 64 64 } 65 65 -
trunk/src/bp-notifications/actions/delete.php
r13034 r13091 1 1 <?php 2 2 /** 3 * Notifications: Delete action handler 3 * Notifications: Delete action handler. 4 4 * 5 5 * @package BuddyPress … … 23 23 24 24 // Get the action. 25 $action = ! empty( $_GET['action'] ) ? $_GET['action'] : '';26 $nonce = ! empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : '';27 $id = ! empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : '';25 $action = ! empty( $_GET['action'] ) ? $_GET['action'] : ''; 26 $nonce = ! empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : ''; 27 $id = ! empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : ''; 28 28 29 29 // Bail if no action or no ID. … … 34 34 // Check the nonce and delete the notification. 35 35 if ( bp_verify_nonce_request( 'bp_notification_delete_' . $id ) && bp_notifications_delete_notification( $id ) ) { 36 bp_core_add_message( __( 'Notification successfully deleted.', 'buddypress' ));36 bp_core_add_message( __( 'Notification successfully deleted.', 'buddypress' ) ); 37 37 } else { 38 38 bp_core_add_message( __( 'There was a problem deleting that notification.', 'buddypress' ), 'error' ); -
trunk/src/bp-notifications/bp-notifications-adminbar.php
r12495 r13091 35 35 // Add the top-level Notifications button. 36 36 $wp_admin_bar->add_node( array( 37 'parent' 38 'id' 39 'title' 40 'href' 37 'parent' => 'top-secondary', 38 'id' => 'bp-notifications', 39 'title' => $menu_title, 40 'href' => $menu_link, 41 41 ) ); 42 42 … … 59 59 } 60 60 61 return ;61 return true; 62 62 } 63 63 add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 ); -
trunk/src/bp-notifications/bp-notifications-cache.php
r12518 r13091 31 31 'object_column' => 'notification_id', 32 32 'meta_table' => buddypress()->notifications->table_name_meta, 33 'cache_key_prefix' => 'bp_notifications_meta' 33 'cache_key_prefix' => 'bp_notifications_meta', 34 34 ) ); 35 35 } … … 53 53 * @since 2.0.0 54 54 * 55 * @param BP_Notifications_Notification $n Notification object.55 * @param BP_Notifications_Notification $notification Notification object. 56 56 */ 57 function bp_notifications_clear_all_for_user_cache_after_save( BP_Notifications_Notification $n ) {58 bp_notifications_clear_all_for_user_cache( $n ->user_id );57 function bp_notifications_clear_all_for_user_cache_after_save( $notification ) { 58 bp_notifications_clear_all_for_user_cache( $notification->user_id ); 59 59 } 60 60 add_action( 'bp_notification_after_save', 'bp_notifications_clear_all_for_user_cache_after_save' ); -
trunk/src/bp-notifications/bp-notifications-filters.php
r12670 r13091 7 7 * @since 4.0.0 8 8 */ 9 10 9 11 10 // Format numerical output. -
trunk/src/bp-notifications/bp-notifications-functions.php
r12605 r13091 30 30 * @type string $date_notified Timestamp for the notification. 31 31 * } 32 * @return int|bool ID of the newly created notification on success, false 33 * on failure. 32 * @return int|bool ID of the newly created notification on success, false on failure. 34 33 */ 35 34 function bp_notifications_add_notification( $args = array() ) { … … 96 95 * 97 96 * @param int $id ID of the notification to delete. 98 * @return false|int Trueon success, false on failure.97 * @return false|int Integer on success, false on failure. 99 98 */ 100 99 function bp_notifications_delete_notification( $id ) { … … 115 114 * @param int $id ID of the notification. 116 115 * @param int|bool $is_new 0 for read, 1 for unread. 117 * @return false|int Trueon success, false on failure.116 * @return false|int Number of rows updated on success, false on failure. 118 117 */ 119 118 function bp_notifications_mark_notification( $id, $is_new = false ) { … … 147 146 if ( false === $notifications ) { 148 147 $notifications = BP_Notifications_Notification::get( array( 149 'user_id' => $user_id 148 'user_id' => $user_id, 150 149 ) ); 151 150 wp_cache_set( 'all_for_user_' . $user_id, $notifications, 'bp_notifications' ); … … 483 482 return BP_Notifications_Notification::update( 484 483 array( 485 'is_new' => $is_new 484 'is_new' => $is_new, 486 485 ), 487 486 array( 488 487 'user_id' => $user_id, 489 488 'component_name' => $component_name, 490 'component_action' => $component_action 489 'component_action' => $component_action, 491 490 ) 492 491 ); … … 512 511 return BP_Notifications_Notification::update( 513 512 array( 514 'is_new' => $is_new 513 'is_new' => $is_new, 515 514 ), 516 515 array( … … 519 518 'secondary_item_id' => $secondary_item_id, 520 519 'component_name' => $component_name, 521 'component_action' => $component_action 520 'component_action' => $component_action, 522 521 ) 523 522 ); … … 541 540 return BP_Notifications_Notification::update( 542 541 array( 543 'is_new' => $is_new 542 'is_new' => $is_new, 544 543 ), 545 544 array( … … 547 546 'secondary_item_id' => $secondary_item_id, 548 547 'component_name' => $component_name, 549 'component_action' => $component_action 548 'component_action' => $component_action, 550 549 ) 551 550 ); … … 572 571 return BP_Notifications_Notification::update( 573 572 array( 574 'is_new' => $is_new 573 'is_new' => $is_new, 575 574 ), 576 575 array( 577 576 'item_id' => $user_id, 578 577 'component_name' => $component_name, 579 'component_action' => $component_action 578 'component_action' => $component_action, 580 579 ) 581 580 ); -
trunk/src/bp-notifications/bp-notifications-template.php
r13034 r13091 493 493 echo bp_get_the_notification_description(); 494 494 } 495 496 495 /** 497 496 * Get full-text description for a specific notification. … … 526 525 * @since 2.3.0 Added the `$notification` parameter. 527 526 * 528 * @param string $description Full-text description for a specific notification.529 * @param object$notification Notification object.527 * @param string $description Full-text description for a specific notification. 528 * @param BP_Notifications_Notification $notification Notification object. 530 529 */ 531 530 return apply_filters( 'bp_get_the_notification_description', $description, $notification ); … … 600 599 $args = array( 601 600 'action' => 'read', 602 'notification_id' => $id 601 'notification_id' => $id, 603 602 ); 604 603 … … 692 691 $args = array( 693 692 'action' => 'unread', 694 'notification_id' => $id 693 'notification_id' => $id, 695 694 ); 696 695 … … 835 834 $args = array( 836 835 'action' => 'delete', 837 'notification_id' => $id 836 'notification_id' => $id, 838 837 ); 839 838 -
trunk/src/bp-notifications/classes/class-bp-notifications-component.php
r12670 r13091 29 29 buddypress()->plugin_dir, 30 30 array( 31 'adminbar_myaccount_order' => 30 31 'adminbar_myaccount_order' => 30, 32 32 ) 33 33 ); … … 122 122 'search_string' => __( 'Search Notifications...', 'buddypress' ), 123 123 'global_tables' => $global_tables, 124 'meta_tables' => $meta_tables 124 'meta_tables' => $meta_tables, 125 125 ); 126 126 … … 250 250 'id' => 'my-account-' . $this->id, 251 251 'title' => $title, 252 'href' => $notifications_link 252 'href' => $notifications_link, 253 253 ); 254 254 … … 259 259 'title' => $unread, 260 260 'href' => $notifications_link, 261 'position' => 10 261 'position' => 10, 262 262 ); 263 263 … … 268 268 'title' => _x( 'Read', 'My Account Notification sub nav', 'buddypress' ), 269 269 'href' => trailingslashit( $notifications_link . 'read' ), 270 'position' => 20 270 'position' => 20, 271 271 ); 272 272 } … … 289 289 $bp->bp_options_title = __( 'Notifications', 'buddypress' ); 290 290 } else { 291 $bp->bp_options_title = bp_get_displayed_user_fullname(); 291 292 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 292 293 'item_id' => bp_displayed_user_id(), … … 294 295 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() ) 295 296 ) ); 296 $bp->bp_options_title = bp_get_displayed_user_fullname();297 297 } 298 298 } -
trunk/src/bp-notifications/classes/class-bp-notifications-notification.php
r13069 r13091 42 42 * 43 43 * @since 1.9.0 44 * @var int|null 45 */ 46 public $secondary_item_id = null; 47 48 /** 49 * The ID of the user the notification is associated with. 50 * 51 * @since 1.9.0 44 52 * @var int 45 53 */ 46 public $secondary_item_id = null;47 48 /**49 * The ID of the user the notification is associated with.50 *51 * @since 1.9.052 * @var int53 */54 54 public $user_id; 55 55 … … 90 90 * 91 91 * @since 9.1.0 92 * @access public93 92 * @var array 94 93 */ … … 101 100 'component_action', 102 101 'date_notified', 103 'is_new' 102 'is_new', 104 103 ); 105 104 … … 220 219 * 221 220 * @since 1.9.0 221 * 222 * @global wpdb $wpdb WordPress database object. 223 * 224 * @see wpdb::insert() for further description of paramater formats. 222 225 * 223 226 * @param array $data { … … 245 248 * @since 1.9.0 246 249 * 250 * @global wpdb $wpdb WordPress database object. 251 * 247 252 * @see wpdb::update() for further description of paramater formats. 248 253 * … … 267 272 * @since 1.9.0 268 273 * 269 * @see wpdb::update() for further description of paramater formats. 274 * @global wpdb $wpdb WordPress database object. 275 * 276 * @see wpdb::delete() for further description of paramater formats. 270 277 * 271 278 * @param array $where Array of WHERE clauses to filter by, passed to … … 287 294 * 288 295 * @since 1.9.0 296 * 297 * @global wpdb $wpdb WordPress database object. 289 298 * 290 299 * @param array $args See {@link BP_Notifications_Notification::get()} … … 438 447 439 448 // Sort order direction. 440 if ( ! empty( $args['sort_order'] ) && in_array( $args['sort_order'], array( 'ASC', 'DESC' ) ) ) {449 if ( ! empty( $args['sort_order'] ) && in_array( $args['sort_order'], array( 'ASC', 'DESC' ), true ) ) { 441 450 $sort_order = $args['sort_order']; 442 451 $conditions['sort_order'] = "{$sort_order}"; … … 457 466 * 458 467 * @since 1.9.0 468 * 469 * @global wpdb $wpdb WordPress database object. 459 470 * 460 471 * @param array $args See {@link BP_Notifications_Notification::get()} … … 578 589 * @since 1.9.0 579 590 * 591 * @global BuddyPress $bp The one true BuddyPress instance. 592 * @global wpdb $wpdb WordPress database object. 593 * 580 594 * @param int $user_id ID of the user being checked. 581 595 * @param int $notification_id ID of the notification being checked. 582 * @return bool True if the notification belongs to the user, otherwise 583 * false. 596 * @return bool True if the notification belongs to the user, otherwise false. 584 597 */ 585 598 public static function check_access( $user_id = 0, $notification_id = 0 ) { … … 600 613 * @since 2.3.0 601 614 * 602 * @param mixed$args Args to parse.615 * @param array|string $args Args to parse. 603 616 * @return array 604 617 */ … … 619 632 'meta_query' => false, 620 633 'date_query' => false, 621 'update_meta_cache' => true 634 'update_meta_cache' => true, 622 635 ) ); 623 636 } … … 627 640 * 628 641 * @since 1.9.0 642 * 643 * @global BuddyPress $bp The one true BuddyPress instance. 644 * @global wpdb $wpdb WordPress database object. 629 645 * 630 646 * @param array $args { … … 737 753 * @since 1.9.0 738 754 * 739 * @see BP_Notifications_Notification::get() for a description of arguments. 740 * 741 * @param array $args See {@link BP_Notifications_Notification::get()}. 755 * @global BuddyPress $bp The one true BuddyPress instance. 756 * @global wpdb $wpdb WordPress database object. 757 * 758 * @param array|string $args See {@link BP_Notifications_Notification::get()}. 742 759 * @return int Count of located items. 743 760 */ … … 871 888 public static function update( $update_args = array(), $where_args = array() ) { 872 889 $update = self::get_query_clauses( $update_args ); 873 $where = self::get_query_clauses( $where_args 890 $where = self::get_query_clauses( $where_args ); 874 891 875 892 /** … … 1174 1191 * @since 3.0.0 1175 1192 * 1193 * @global BuddyPress $bp The one true BuddyPress instance. 1194 * @global wpdb $wpdb WordPress database object. 1195 * 1176 1196 * @param int $user_id ID of the user whose notifications are being fetched. 1177 1197 * @return array Notifications items for formatting into a list. -
trunk/src/bp-notifications/classes/class-bp-notifications-template.php
r10523 r13091 142 142 /** 143 143 * Constructor method. 144 *145 * @see bp_has_notifications() For information on the array format.146 144 * 147 145 * @since 1.9.0 … … 171 169 'max' => null, 172 170 'meta_query' => false, 173 'date_query' => false 171 'date_query' => false, 174 172 ) ); 175 173 176 174 // Sort order direction. 177 175 $orders = array( 'ASC', 'DESC' ); 178 if ( ! empty( $_GET['sort_order'] ) && in_array( $_GET['sort_order'], $orders ) ) {176 if ( ! empty( $_GET['sort_order'] ) && in_array( $_GET['sort_order'], $orders, true ) ) { 179 177 $r['sort_order'] = $_GET['sort_order']; 180 178 } else { … … 184 182 // Setup variables. 185 183 $this->pag_arg = sanitize_key( $r['page_arg'] ); 186 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] 187 $this->pag_num = bp_sanitize_pagination_arg( 'num', 184 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] ); 185 $this->pag_num = bp_sanitize_pagination_arg( 'num', $r['per_page'] ); 188 186 $this->user_id = $r['user_id']; 189 187 $this->is_new = $r['is_new']; … … 239 237 'current' => $this->pag_page, 240 238 'prev_text' => _x( '←', 'Notifications pagination previous text', 'buddypress' ), 241 'next_text' => _x( '→', 'Notifications pagination next text', 239 'next_text' => _x( '→', 'Notifications pagination next text', 'buddypress' ), 242 240 'mid_size' => 1, 243 241 'add_args' => $add_args, … … 256 254 */ 257 255 public function has_notifications() { 258 if ( $this->notification_count ) { 259 return true; 260 } 261 262 return false; 256 return ! empty( $this->notification_count ); 263 257 } 264 258 … … 268 262 * @since 1.9.0 269 263 * 270 * @return objectThe next notification to iterate over.264 * @return BP_Notifications_Notification The next notification to iterate over. 271 265 */ 272 266 public function next_notification() { … … 312 306 return true; 313 307 314 } elseif ( $this->current_notification + 1 == $this->notification_count ) {308 } elseif ( $this->current_notification + 1 === $this->notification_count ) { 315 309 316 310 /** … … 319 313 * @since 1.9.0 320 314 */ 321 do_action( 'notifications_loop_end' );315 do_action( 'notifications_loop_end' ); 322 316 323 317 $this->rewind_notifications(); -
trunk/src/bp-notifications/screens/read.php
r13034 r13091 1 1 <?php 2 2 /** 3 * Notifications: User's "Notifications > Read" screen handler 3 * Notifications: User's "Notifications > Read" screen handler. 4 4 * 5 5 * @package BuddyPress … … 58 58 // Check the nonce and mark the notification. 59 59 if ( bp_verify_nonce_request( 'bp_notification_mark_unread_' . $id ) && bp_notifications_mark_notification( $id, true ) ) { 60 bp_core_add_message( __( 'Notification successfully marked unread.', 'buddypress' ));60 bp_core_add_message( __( 'Notification successfully marked unread.', 'buddypress' ) ); 61 61 } else { 62 62 bp_core_add_message( __( 'There was a problem marking that notification.', 'buddypress' ), 'error' ); -
trunk/src/bp-notifications/screens/unread.php
r13034 r13091 1 1 <?php 2 2 /** 3 * Notifications: User's "Notifications" screen handler 3 * Notifications: User's "Notifications" screen handler. 4 4 * 5 5 * @package BuddyPress … … 58 58 // Check the nonce and mark the notification. 59 59 if ( bp_verify_nonce_request( 'bp_notification_mark_read_' . $id ) && bp_notifications_mark_notification( $id, false ) ) { 60 bp_core_add_message( __( 'Notification successfully marked read.', 'buddypress' ));60 bp_core_add_message( __( 'Notification successfully marked read.', 'buddypress' ) ); 61 61 } else { 62 62 bp_core_add_message( __( 'There was a problem marking that notification.', 'buddypress' ), 'error' ); -
trunk/src/bp-settings/classes/class-bp-settings-component.php
r13090 r13091 99 99 * @since 1.5.0 100 100 * 101 * @param array $args Array of arguments. 101 * @see BP_Component::setup_globals() for a description of arguments. 102 * 103 * @param array $args See BP_Component::setup_globals() for a description. 102 104 */ 103 105 public function setup_globals( $args = array() ) { … … 120 122 * @since 1.5.0 121 123 * 122 * @param array $main_nav Array of main nav items. 123 * @param array $sub_nav Array of sub nav items. 124 * @see BP_Component::setup_nav() for a description of arguments. 125 * 126 * @param array $main_nav Optional. See BP_Component::setup_nav() for 127 * description. 128 * @param array $sub_nav Optional. See BP_Component::setup_nav() for 129 * description. 124 130 */ 125 131 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { … … 145 151 'show_for_displayed_user' => $access, 146 152 'screen_function' => 'bp_settings_screen_general', 147 'default_subnav_slug' => 'general' 153 'default_subnav_slug' => 'general', 148 154 ); 149 155 … … 156 162 'screen_function' => 'bp_settings_screen_general', 157 163 'position' => 10, 158 'user_has_access' => $access 164 'user_has_access' => $access, 159 165 ); 160 166 … … 168 174 'screen_function' => 'bp_settings_screen_notification', 169 175 'position' => 20, 170 'user_has_access' => $access 176 'user_has_access' => $access, 171 177 ); 172 178 … … 180 186 'screen_function' => 'bp_settings_screen_capabilities', 181 187 'position' => 80, 182 'user_has_access' => ! bp_is_my_profile() 188 'user_has_access' => ! bp_is_my_profile(), 183 189 ); 184 190 } … … 223 229 224 230 /** 225 * Set up the Toolbar. 226 * 227 * @since 1.5.0 228 * 229 * @param array $wp_admin_nav Array of Admin Bar items. 231 * Set up the component entries in the WordPress Admin Bar. 232 * 233 * @since 1.5.0 234 * 235 * @see BP_Component::setup_nav() for a description of the $wp_admin_nav 236 * parameter array. 237 * 238 * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a 239 * description. 230 240 */ 231 241 public function setup_admin_bar( $wp_admin_nav = array() ) { … … 242 252 'id' => 'my-account-' . $this->id, 243 253 'title' => __( 'Settings', 'buddypress' ), 244 'href' => $settings_link 254 'href' => $settings_link, 245 255 ); 246 256 … … 251 261 'title' => __( 'General', 'buddypress' ), 252 262 'href' => $settings_link, 253 'position' => 10 263 'position' => 10, 254 264 ); 255 265 … … 261 271 'title' => __( 'Email', 'buddypress' ), 262 272 'href' => trailingslashit( $settings_link . 'notifications' ), 263 'position' => 20 273 'position' => 20, 264 274 ); 265 275 } … … 286 296 'title' => __( 'Delete Account', 'buddypress' ), 287 297 'href' => trailingslashit( $settings_link . 'delete-account' ), 288 'position' => 90 298 'position' => 90, 289 299 ); 290 300 }
Note: See TracChangeset
for help on using the changeset viewer.