- Timestamp:
- 10/22/2015 06:02:55 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-notifications/bp-notifications-template.php
r10248 r10303 266 266 public function __construct( $args = array() ) { 267 267 268 // Parse arguments 268 // Parse arguments. 269 269 $r = wp_parse_args( $args, array( 270 270 'id' => false, … … 286 286 ) ); 287 287 288 // Overrides 289 290 // Sort order direction 288 // Sort order direction. 291 289 $orders = array( 'ASC', 'DESC' ); 292 290 if ( ! empty( $_GET['sort_order'] ) && in_array( $_GET['sort_order'], $orders ) ) { … … 296 294 } 297 295 298 // Setup variables 296 // Setup variables. 299 297 $this->pag_arg = sanitize_key( $r['page_arg'] ); 300 298 $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] ); … … 322 320 ); 323 321 324 // Setup the notifications to loop through 322 // Setup the notifications to loop through. 325 323 $this->notifications = BP_Notifications_Notification::get( $this->query_vars ); 326 324 $this->total_notification_count = BP_Notifications_Notification::get_total_count( $this->query_vars ); … … 457 455 $this->notification = $this->next_notification(); 458 456 459 // loop has just started457 // Loop has just started. 460 458 if ( 0 === $this->current_notification ) { 461 459 … … 492 490 * Default: 'npage'. 493 491 * } 494 *495 492 * @return bool 496 493 */ 497 494 function bp_has_notifications( $args = '' ) { 498 495 499 // Get the default is_new argument 496 // Get the default is_new argument. 500 497 if ( bp_is_current_action( 'unread' ) ) { 501 498 $is_new = 1; … … 503 500 $is_new = 0; 504 501 505 // not on a notifications page? default to fetch new notifications502 // Not on a notifications page? default to fetch new notifications. 506 503 } else { 507 504 $is_new = 1; 508 505 } 509 506 510 // Get the user ID 507 // Get the user ID. 511 508 if ( bp_displayed_user_id() ) { 512 509 $user_id = bp_displayed_user_id(); … … 515 512 } 516 513 517 // Parse the args 514 // Parse the args. 518 515 $r = bp_parse_args( $args, array( 519 516 'id' => false, … … 531 528 'per_page' => 25, 532 529 533 // these are additional arguments that are not available in534 // BP_Notifications_Notification::get() 530 // These are additional arguments that are not available in 531 // BP_Notifications_Notification::get(). 535 532 'max' => false, 536 533 'page_arg' => 'npage', 537 534 ), 'has_notifications' ); 538 535 539 // Get the notifications 536 // Get the notifications. 540 537 $query_loop = new BP_Notifications_Template( $r ); 541 538 542 // Setup the global query loop 539 // Setup the global query loop. 543 540 buddypress()->notifications->query_loop = $query_loop; 544 541 … … 757 754 function bp_get_the_notification_time_since() { 758 755 759 // Get the notified date 756 // Get the notified date. 760 757 $date_notified = bp_get_the_notification_date_notified(); 761 758 762 // Notified date has legitimate data 759 // Notified date has legitimate data. 763 760 if ( '0000-00-00 00:00:00' !== $date_notified ) { 764 761 $retval = bp_core_time_since( $date_notified ); 765 762 766 // Notified date is empty, so return a fun string 763 // Notified date is empty, so return a fun string. 767 764 } else { 768 765 $retval = __( 'Date not found', 'buddypress' ); … … 799 796 $notification = $bp->notifications->query_loop->notification; 800 797 801 // Callback function exists 798 // Callback function exists. 802 799 if ( isset( $bp->{ $notification->component_name }->notification_callback ) && is_callable( $bp->{ $notification->component_name }->notification_callback ) ) { 803 800 $description = call_user_func( $bp->{ $notification->component_name }->notification_callback, $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1 ); … … 807 804 $description = call_user_func( $bp->{ $notification->component_name }->format_notification_function, $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1 ); 808 805 809 // Allow non BuddyPress components to hook in 806 // Allow non BuddyPress components to hook in. 810 807 } else { 811 808 … … 843 840 function bp_get_the_notification_mark_read_link() { 844 841 845 // Start the output buffer 842 // Start the output buffer. 846 843 ob_start(); ?> 847 844 … … 874 871 /** 875 872 * Return the URL used for marking a single notification as read. 876 873 * 877 874 * @since 2.1.0 878 875 */ 879 876 function bp_get_the_notification_mark_read_url() { 880 877 881 // Get the notification ID 878 // Get the notification ID. 882 879 $id = bp_get_the_notification_id(); 883 880 884 // Get the args to add to the URL 881 // Get the args to add to the URL. 885 882 $args = array( 886 883 'action' => 'read', … … 888 885 ); 889 886 890 // Add the args to the URL 887 // Add the args to the URL. 891 888 $url = add_query_arg( $args, bp_get_notifications_unread_permalink() ); 892 889 893 // Add the nonce 890 // Add the nonce. 894 891 $url = wp_nonce_url( $url, 'bp_notification_mark_read_' . $id ); 895 892 … … 921 918 function bp_get_the_notification_mark_unread_link() { 922 919 923 // Start the output buffer 920 // Start the output buffer. 924 921 ob_start(); ?> 925 922 … … 952 949 /** 953 950 * Return the URL used for marking a single notification as unread. 954 951 * 955 952 * @since 2.1.0 956 953 */ 957 954 function bp_get_the_notification_mark_unread_url() { 958 955 959 // Get the notification ID 956 // Get the notification ID. 960 957 $id = bp_get_the_notification_id(); 961 958 962 // Get the args to add to the URL 959 // Get the args to add to the URL. 963 960 $args = array( 964 961 'action' => 'unread', … … 966 963 ); 967 964 968 // Add the args to the URL 965 // Add the args to the URL. 969 966 $url = add_query_arg( $args, bp_get_notifications_read_permalink() ); 970 967 971 // Add the nonce 968 // Add the nonce. 972 969 $url = wp_nonce_url( $url, 'bp_notification_mark_unread_' . $id ); 973 970 … … 1032 1029 function bp_get_the_notification_delete_link() { 1033 1030 1034 // Start the output buffer 1031 // Start the output buffer. 1035 1032 ob_start(); ?> 1036 1033 … … 1071 1068 function bp_get_the_notification_delete_url() { 1072 1069 1073 // URL to add nonce to 1070 // URL to add nonce to. 1074 1071 if ( bp_is_current_action( 'unread' ) ) { 1075 1072 $link = bp_get_notifications_unread_permalink(); … … 1078 1075 } 1079 1076 1080 // Get the ID 1077 // Get the ID. 1081 1078 $id = bp_get_the_notification_id(); 1082 1079 1083 // Get the args to add to the URL 1080 // Get the args to add to the URL. 1084 1081 $args = array( 1085 1082 'action' => 'delete', … … 1087 1084 ); 1088 1085 1089 // Add the args 1086 // Add the args. 1090 1087 $url = add_query_arg( $args, $link ); 1091 1088 1092 // Add the nonce 1089 // Add the nonce. 1093 1090 $url = wp_nonce_url( $url, 'bp_notification_delete_' . $id ); 1094 1091 … … 1106 1103 * Output the action links for the current notification. 1107 1104 * 1105 * @since 1.9.0 1106 * 1108 1107 * @param array|string $args Array of arguments. 1109 * @since 1.9.01110 1108 */ 1111 1109 function bp_the_notification_action_links( $args = '' ) { … … 1123 1121 * @type array $links Array of links to implode by 'sep'. 1124 1122 * } 1125 *1126 1123 * @return string HTML links for actions to take on single notifications. 1127 1124 */ 1128 1125 function bp_get_the_notification_action_links( $args = '' ) { 1129 1126 1130 // Parse 1127 // Parse. 1131 1128 $r = wp_parse_args( $args, array( 1132 1129 'before' => '', … … 1139 1136 ) ); 1140 1137 1141 // Build the links 1138 // Build the links. 1142 1139 $retval = $r['before'] . implode( $r['links'], $r['sep'] ) . $r['after']; 1143 1140 … … 1226 1223 function bp_notifications_sort_order_form() { 1227 1224 1228 // Setup local variables 1225 // Setup local variables. 1229 1226 $orders = array( 'DESC', 'ASC' ); 1230 1227 $selected = 'DESC'; 1231 1228 1232 // Check for a custom sort_order 1229 // Check for a custom sort_order. 1233 1230 if ( !empty( $_REQUEST['sort_order'] ) ) { 1234 1231 if ( in_array( $_REQUEST['sort_order'], $orders ) ) {
Note: See TracChangeset
for help on using the changeset viewer.