- Timestamp:
- 02/05/2016 05:26:45 AM (9 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-notifications/classes/class-bp-notifications-template.php
r10515 r10523 1 1 <?php 2 2 /** 3 * BuddyPress Notifications Template Functions.3 * BuddyPress Notifications Template Loop Class. 4 4 * 5 5 * @package BuddyPress … … 10 10 // Exit if accessed directly. 11 11 defined( 'ABSPATH' ) || exit; 12 13 /**14 * Output the notifications component slug.15 *16 * @since 1.9.017 */18 function bp_notifications_slug() {19 echo bp_get_notifications_slug();20 }21 /**22 * Return the notifications component slug.23 *24 * @since 1.9.025 *26 * @return string Slug of the Notifications component.27 */28 function bp_get_notifications_slug() {29 30 /**31 * Filters the notifications component slug.32 *33 * @since 1.9.034 *35 * @param string $slug Notifications component slug.36 */37 return apply_filters( 'bp_get_notifications_slug', buddypress()->notifications->slug );38 }39 40 /**41 * Output the notifications permalink.42 *43 * @since 1.9.044 */45 function bp_notifications_permalink() {46 echo bp_get_notifications_permalink();47 }48 /**49 * Return the notifications permalink.50 *51 * @since 1.9.052 *53 * @return string Notifications permalink.54 */55 function bp_get_notifications_permalink() {56 $retval = trailingslashit( bp_loggedin_user_domain() . bp_get_notifications_slug() );57 58 /**59 * Filters the notifications permalink.60 *61 * @since 1.9.062 *63 * @param string $retval Permalink for the notifications.64 */65 return apply_filters( 'bp_get_notifications_permalink', $retval );66 }67 68 /**69 * Output the unread notifications permalink.70 *71 * @since 1.9.072 */73 function bp_notifications_unread_permalink() {74 echo bp_get_notifications_unread_permalink();75 }76 /**77 * Return the unread notifications permalink.78 *79 * @since 1.9.080 *81 * @return string Unread notifications permalink.82 */83 function bp_get_notifications_unread_permalink() {84 $retval = trailingslashit( bp_loggedin_user_domain() . bp_get_notifications_slug() . '/unread' );85 86 /**87 * Filters the unread notifications permalink.88 *89 * @since 1.9.090 *91 * @param string $retval Permalink for the unread notifications.92 */93 return apply_filters( 'bp_get_notifications_unread_permalink', $retval );94 }95 96 /**97 * Output the read notifications permalink.98 *99 * @since 1.9.0100 */101 function bp_notifications_read_permalink() {102 echo bp_get_notifications_read_permalink();103 }104 /**105 * Return the read notifications permalink.106 *107 * @since 1.9.0108 *109 * @return string Read notifications permalink.110 */111 function bp_get_notifications_read_permalink() {112 $retval = trailingslashit( bp_loggedin_user_domain() . bp_get_notifications_slug() . '/read' );113 114 /**115 * Filters the read notifications permalink.116 *117 * @since 1.9.0118 *119 * @param string $retval Permalink for the read notifications.120 */121 return apply_filters( 'bp_get_notifications_unread_permalink', $retval );122 }123 124 /** Main Loop *****************************************************************/125 12 126 13 /** … … 468 355 } 469 356 } 470 471 /** The Loop ******************************************************************/472 473 /**474 * Initialize the notifications loop.475 *476 * Based on the $args passed, bp_has_notifications() populates477 * buddypress()->notifications->query_loop global, enabling the use of BP478 * templates and template functions to display a list of notifications.479 *480 * @since 1.9.0481 *482 * @param array|string $args {483 * Arguments for limiting the contents of the notifications loop. Can be484 * passed as an associative array, or as a URL query string.485 *486 * See {@link BP_Notifications_Notification::get()} for detailed487 * information on the arguments. In addition, also supports:488 *489 * @type int $max Optional. Max items to display. Default: false.490 * @type string $page_arg URL argument to use for pagination.491 * Default: 'npage'.492 * }493 * @return bool494 */495 function bp_has_notifications( $args = '' ) {496 497 // Get the default is_new argument.498 if ( bp_is_current_action( 'unread' ) ) {499 $is_new = 1;500 } elseif ( bp_is_current_action( 'read' ) ) {501 $is_new = 0;502 503 // Not on a notifications page? default to fetch new notifications.504 } else {505 $is_new = 1;506 }507 508 // Get the user ID.509 if ( bp_displayed_user_id() ) {510 $user_id = bp_displayed_user_id();511 } else {512 $user_id = bp_loggedin_user_id();513 }514 515 // Parse the args.516 $r = bp_parse_args( $args, array(517 'id' => false,518 'user_id' => $user_id,519 'secondary_item_id' => false,520 'component_name' => bp_notifications_get_registered_components(),521 'component_action' => false,522 'is_new' => $is_new,523 'search_terms' => isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '',524 'order_by' => 'date_notified',525 'sort_order' => 'DESC',526 'meta_query' => false,527 'date_query' => false,528 'page' => 1,529 'per_page' => 25,530 531 // These are additional arguments that are not available in532 // BP_Notifications_Notification::get().533 'max' => false,534 'page_arg' => 'npage',535 ), 'has_notifications' );536 537 // Get the notifications.538 $query_loop = new BP_Notifications_Template( $r );539 540 // Setup the global query loop.541 buddypress()->notifications->query_loop = $query_loop;542 543 /**544 * Filters whether or not the user has notifications to display.545 *546 * @since 1.9.0547 *548 * @param bool $value Whether or not there are notifications to display.549 * @param BP_Notifications_Template $query_loop BP_Notifications_Template object instance.550 */551 return apply_filters( 'bp_has_notifications', $query_loop->has_notifications(), $query_loop );552 }553 554 /**555 * Get the notifications returned by the template loop.556 *557 * @since 1.9.0558 *559 * @return array List of notifications.560 */561 function bp_the_notifications() {562 return buddypress()->notifications->query_loop->notifications();563 }564 565 /**566 * Get the current notification object in the loop.567 *568 * @since 1.9.0569 *570 * @return object The current notification within the loop.571 */572 function bp_the_notification() {573 return buddypress()->notifications->query_loop->the_notification();574 }575 576 /** Loop Output ***************************************************************/577 578 /**579 * Output the ID of the notification currently being iterated on.580 *581 * @since 1.9.0582 */583 function bp_the_notification_id() {584 echo bp_get_the_notification_id();585 }586 /**587 * Return the ID of the notification currently being iterated on.588 *589 * @since 1.9.0590 *591 * @return int ID of the current notification.592 */593 function bp_get_the_notification_id() {594 595 /**596 * Filters the ID of the notification currently being iterated on.597 *598 * @since 1.9.0599 *600 * @param int $id ID of the notification being iterated on.601 */602 return apply_filters( 'bp_get_the_notification_id', buddypress()->notifications->query_loop->notification->id );603 }604 605 /**606 * Output the associated item ID of the notification currently being iterated on.607 *608 * @since 1.9.0609 */610 function bp_the_notification_item_id() {611 echo bp_get_the_notification_item_id();612 }613 /**614 * Return the associated item ID of the notification currently being iterated on.615 *616 * @since 1.9.0617 *618 * @return int ID of the item associated with the current notification.619 */620 function bp_get_the_notification_item_id() {621 622 /**623 * Filters the associated item ID of the notification currently being iterated on.624 *625 * @since 1.9.0626 *627 * @param int $item_id ID of the associated item.628 */629 return apply_filters( 'bp_get_the_notification_item_id', buddypress()->notifications->query_loop->notification->item_id );630 }631 632 /**633 * Output the secondary associated item ID of the notification currently being iterated on.634 *635 * @since 1.9.0636 */637 function bp_the_notification_secondary_item_id() {638 echo bp_get_the_notification_secondary_item_id();639 }640 /**641 * Return the secondary associated item ID of the notification currently being iterated on.642 *643 * @since 1.9.0644 *645 * @return int ID of the secondary item associated with the current notification.646 */647 function bp_get_the_notification_secondary_item_id() {648 649 /**650 * Filters the secondary associated item ID of the notification currently being iterated on.651 *652 * @since 1.9.0653 *654 * @param int $secondary_item_id ID of the secondary associated item.655 */656 return apply_filters( 'bp_get_the_notification_secondary_item_id', buddypress()->notifications->query_loop->notification->secondary_item_id );657 }658 659 /**660 * Output the name of the component associated with the notification currently being iterated on.661 *662 * @since 1.9.0663 */664 function bp_the_notification_component_name() {665 echo bp_get_the_notification_component_name();666 }667 /**668 * Return the name of the component associated with the notification currently being iterated on.669 *670 * @since 1.9.0671 *672 * @return int Name of the component associated with the current notification.673 */674 function bp_get_the_notification_component_name() {675 676 /**677 * Filters the name of the component associated with the notification currently being iterated on.678 *679 * @since 1.9.0680 *681 * @param int $component_name Name of the component associated with the current notification.682 */683 return apply_filters( 'bp_get_the_notification_component_name', buddypress()->notifications->query_loop->notification->component_name );684 }685 686 /**687 * Output the name of the action associated with the notification currently being iterated on.688 *689 * @since 1.9.0690 */691 function bp_the_notification_component_action() {692 echo bp_get_the_notification_component_action();693 }694 /**695 * Return the name of the action associated with the notification currently being iterated on.696 *697 * @since 1.9.0698 *699 * @return int Name of the action associated with the current notification.700 */701 function bp_get_the_notification_component_action() {702 703 /**704 * Filters the name of the action associated with the notification currently being iterated on.705 *706 * @since 1.9.0707 *708 * @param int $component_action Name of the action associated with the current notification.709 */710 return apply_filters( 'bp_get_the_notification_component_action', buddypress()->notifications->query_loop->notification->component_action );711 }712 713 /**714 * Output the timestamp of the current notification.715 *716 * @since 1.9.0717 */718 function bp_the_notification_date_notified() {719 echo bp_get_the_notification_date_notified();720 }721 /**722 * Return the timestamp of the current notification.723 *724 * @since 1.9.0725 *726 * @return string Timestamp of the current notification.727 */728 function bp_get_the_notification_date_notified() {729 730 /**731 * Filters the timestamp of the current notification.732 *733 * @since 1.9.0734 *735 * @param string $date_notified Timestamp of the current notification.736 */737 return apply_filters( 'bp_get_the_notification_date_notified', buddypress()->notifications->query_loop->notification->date_notified );738 }739 740 /**741 * Output the timestamp of the current notification.742 *743 * @since 1.9.0744 */745 function bp_the_notification_time_since() {746 echo bp_get_the_notification_time_since();747 }748 /**749 * Return the timestamp of the current notification.750 *751 * @since 1.9.0752 *753 * @return string Timestamp of the current notification.754 */755 function bp_get_the_notification_time_since() {756 757 // Get the notified date.758 $date_notified = bp_get_the_notification_date_notified();759 760 // Notified date has legitimate data.761 if ( '0000-00-00 00:00:00' !== $date_notified ) {762 $retval = bp_core_time_since( $date_notified );763 764 // Notified date is empty, so return a fun string.765 } else {766 $retval = __( 'Date not found', 'buddypress' );767 }768 769 /**770 * Filters the time since value of the current notification.771 *772 * @since 1.9.0773 *774 * @param string $retval Time since value for current notification.775 */776 return apply_filters( 'bp_get_the_notification_time_since', $retval );777 }778 779 /**780 * Output full-text description for a specific notification.781 *782 * @since 1.9.0783 */784 function bp_the_notification_description() {785 echo bp_get_the_notification_description();786 }787 788 /**789 * Get full-text description for a specific notification.790 *791 * @since 1.9.0792 *793 * @return string794 */795 function bp_get_the_notification_description() {796 $bp = buddypress();797 $notification = $bp->notifications->query_loop->notification;798 799 // Callback function exists.800 if ( isset( $bp->{ $notification->component_name }->notification_callback ) && is_callable( $bp->{ $notification->component_name }->notification_callback ) ) {801 $description = call_user_func( $bp->{ $notification->component_name }->notification_callback, $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1 );802 803 // @deprecated format_notification_function - 1.5804 } elseif ( isset( $bp->{ $notification->component_name }->format_notification_function ) && function_exists( $bp->{ $notification->component_name }->format_notification_function ) ) {805 $description = call_user_func( $bp->{ $notification->component_name }->format_notification_function, $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1 );806 807 // Allow non BuddyPress components to hook in.808 } else {809 810 /** This filter is documented in bp-notifications/bp-notifications-functions.php */811 $description = apply_filters_ref_array( 'bp_notifications_get_notifications_for_user', array( $notification->component_action, $notification->item_id, $notification->secondary_item_id, 1 ) );812 }813 814 /**815 * Filters the full-text description for a specific notification.816 *817 * @since 1.9.0818 * @since 2.3.0 Added the `$notification` parameter.819 *820 * @param string $description Full-text description for a specific notification.821 * @param object $notification Notification object.822 */823 return apply_filters( 'bp_get_the_notification_description', $description, $notification );824 }825 826 /**827 * Output the mark read link for the current notification.828 *829 * @since 1.9.0830 *831 * @uses bp_get_the_notification_mark_read_link()832 */833 function bp_the_notification_mark_read_link() {834 echo bp_get_the_notification_mark_read_link();835 }836 /**837 * Return the mark read link for the current notification.838 *839 * @since 1.9.0840 *841 * @return string842 */843 function bp_get_the_notification_mark_read_link() {844 845 // Start the output buffer.846 ob_start(); ?>847 848 <a href="<?php bp_the_notification_mark_read_url(); ?>" class="mark-read primary"><?php _e( 'Read', 'buddypress' ); ?></a>849 850 <?php $retval = ob_get_clean();851 852 /**853 * Filters the mark read link for the current notification.854 *855 * @since 1.9.0856 *857 * @param string $retval HTML for the mark read link for the current notification.858 */859 return apply_filters( 'bp_get_the_notification_mark_read_link', $retval );860 }861 862 /**863 * Output the URL used for marking a single notification as read.864 *865 * Since this function directly outputs a URL, it is escaped.866 *867 * @since 2.1.0868 *869 * @uses bp_get_the_notification_mark_read_url()870 */871 function bp_the_notification_mark_read_url() {872 echo esc_url( bp_get_the_notification_mark_read_url() );873 }874 /**875 * Return the URL used for marking a single notification as read.876 *877 * @since 2.1.0878 *879 * @return string880 */881 function bp_get_the_notification_mark_read_url() {882 883 // Get the notification ID.884 $id = bp_get_the_notification_id();885 886 // Get the args to add to the URL.887 $args = array(888 'action' => 'read',889 'notification_id' => $id890 );891 892 // Add the args to the URL.893 $url = add_query_arg( $args, bp_get_notifications_unread_permalink() );894 895 // Add the nonce.896 $url = wp_nonce_url( $url, 'bp_notification_mark_read_' . $id );897 898 /**899 * Filters the URL used for marking a single notification as read.900 *901 * @since 2.1.0902 *903 * @param string $url URL to use for marking the single notification as read.904 */905 return apply_filters( 'bp_get_the_notification_mark_read_url', $url );906 }907 908 /**909 * Output the mark unread link for the current notification.910 *911 * @since 1.9.0912 *913 * @uses bp_get_the_notification_mark_unread_link()914 */915 function bp_the_notification_mark_unread_link() {916 echo bp_get_the_notification_mark_unread_link();917 }918 /**919 * Return the mark unread link for the current notification.920 *921 * @since 1.9.0922 *923 * @return string924 */925 function bp_get_the_notification_mark_unread_link() {926 927 // Start the output buffer.928 ob_start(); ?>929 930 <a href="<?php bp_the_notification_mark_unread_url(); ?>" class="mark-unread primary"><?php _ex( 'Unread', 'Notification screen action', 'buddypress' ); ?></a>931 932 <?php $retval = ob_get_clean();933 934 /**935 * Filters the link used for marking a single notification as unread.936 *937 * @since 1.9.0938 *939 * @param string $retval HTML for the mark unread link for the current notification.940 */941 return apply_filters( 'bp_get_the_notification_mark_unread_link', $retval );942 }943 944 /**945 * Output the URL used for marking a single notification as unread.946 *947 * Since this function directly outputs a URL, it is escaped.948 *949 * @since 2.1.0950 *951 * @uses bp_get_the_notification_mark_unread_url()952 */953 function bp_the_notification_mark_unread_url() {954 echo esc_url( bp_get_the_notification_mark_unread_url() );955 }956 /**957 * Return the URL used for marking a single notification as unread.958 *959 * @since 2.1.0960 *961 * @return string962 */963 function bp_get_the_notification_mark_unread_url() {964 965 // Get the notification ID.966 $id = bp_get_the_notification_id();967 968 // Get the args to add to the URL.969 $args = array(970 'action' => 'unread',971 'notification_id' => $id972 );973 974 // Add the args to the URL.975 $url = add_query_arg( $args, bp_get_notifications_read_permalink() );976 977 // Add the nonce.978 $url = wp_nonce_url( $url, 'bp_notification_mark_unread_' . $id );979 980 /**981 * Filters the URL used for marking a single notification as unread.982 *983 * @since 2.1.0984 *985 * @param string $url URL to use for marking the single notification as unread.986 */987 return apply_filters( 'bp_get_the_notification_mark_unread_url', $url );988 }989 990 /**991 * Output the mark link for the current notification.992 *993 * @since 1.9.0994 *995 * @uses bp_get_the_notification_mark_unread_link()996 */997 function bp_the_notification_mark_link() {998 echo bp_get_the_notification_mark_link();999 }1000 /**1001 * Return the mark link for the current notification.1002 *1003 * @since 1.9.01004 *1005 * @return string1006 */1007 function bp_get_the_notification_mark_link() {1008 1009 if ( bp_is_current_action( 'read' ) ) {1010 $retval = bp_get_the_notification_mark_unread_link();1011 } else {1012 $retval = bp_get_the_notification_mark_read_link();1013 }1014 1015 /**1016 * Filters the mark link for the current notification.1017 *1018 * @since 1.9.01019 *1020 * @param string $retval The mark link for the current notification.1021 */1022 return apply_filters( 'bp_get_the_notification_mark_link', $retval );1023 }1024 1025 /**1026 * Output the delete link for the current notification.1027 *1028 * @since 1.9.01029 *1030 * @uses bp_get_the_notification_delete_link()1031 */1032 function bp_the_notification_delete_link() {1033 echo bp_get_the_notification_delete_link();1034 }1035 /**1036 * Return the delete link for the current notification.1037 *1038 * @since 1.9.01039 *1040 * @return string1041 */1042 function bp_get_the_notification_delete_link() {1043 1044 // Start the output buffer.1045 ob_start(); ?>1046 1047 <a href="<?php bp_the_notification_delete_url(); ?>" class="delete secondary confirm"><?php _e( 'Delete', 'buddypress' ); ?></a>1048 1049 <?php $retval = ob_get_clean();1050 1051 /**1052 * Filters the delete link for the current notification.1053 *1054 * @since 1.9.01055 *1056 * @param string $retval HTML for the delete link for the current notification.1057 */1058 return apply_filters( 'bp_get_the_notification_delete_link', $retval );1059 }1060 1061 /**1062 * Output the URL used for deleting a single notification.1063 *1064 * Since this function directly outputs a URL, it is escaped.1065 *1066 * @since 2.1.01067 *1068 * @uses esc_url()1069 * @uses bp_get_the_notification_delete_url()1070 */1071 function bp_the_notification_delete_url() {1072 echo esc_url( bp_get_the_notification_delete_url() );1073 }1074 /**1075 * Return the URL used for deleting a single notification.1076 *1077 * @since 2.1.01078 *1079 * @return string1080 */1081 function bp_get_the_notification_delete_url() {1082 1083 // URL to add nonce to.1084 if ( bp_is_current_action( 'unread' ) ) {1085 $link = bp_get_notifications_unread_permalink();1086 } elseif ( bp_is_current_action( 'read' ) ) {1087 $link = bp_get_notifications_read_permalink();1088 }1089 1090 // Get the ID.1091 $id = bp_get_the_notification_id();1092 1093 // Get the args to add to the URL.1094 $args = array(1095 'action' => 'delete',1096 'notification_id' => $id1097 );1098 1099 // Add the args.1100 $url = add_query_arg( $args, $link );1101 1102 // Add the nonce.1103 $url = wp_nonce_url( $url, 'bp_notification_delete_' . $id );1104 1105 /**1106 * Filters the URL used for deleting a single notification.1107 *1108 * @since 2.1.01109 *1110 * @param string $url URL used for deleting a single notification.1111 */1112 return apply_filters( 'bp_get_the_notification_delete_url', $url );1113 }1114 1115 /**1116 * Output the action links for the current notification.1117 *1118 * @since 1.9.01119 *1120 * @param array|string $args Array of arguments.1121 */1122 function bp_the_notification_action_links( $args = '' ) {1123 echo bp_get_the_notification_action_links( $args );1124 }1125 /**1126 * Return the action links for the current notification.1127 *1128 * @since 1.9.01129 *1130 * @param array|string $args {1131 * @type string $before HTML before the links.1132 * @type string $after HTML after the links.1133 * @type string $sep HTML between the links.1134 * @type array $links Array of links to implode by 'sep'.1135 * }1136 * @return string HTML links for actions to take on single notifications.1137 */1138 function bp_get_the_notification_action_links( $args = '' ) {1139 1140 // Parse.1141 $r = wp_parse_args( $args, array(1142 'before' => '',1143 'after' => '',1144 'sep' => ' | ',1145 'links' => array(1146 bp_get_the_notification_mark_link(),1147 bp_get_the_notification_delete_link()1148 )1149 ) );1150 1151 // Build the links.1152 $retval = $r['before'] . implode( $r['links'], $r['sep'] ) . $r['after'];1153 1154 /**1155 * Filters the action links for the current notification.1156 *1157 * @since 1.9.01158 *1159 * @param string $retval HTML links for actions to take on single notifications.1160 */1161 return apply_filters( 'bp_get_the_notification_action_links', $retval );1162 }1163 1164 /**1165 * Output the pagination count for the current notification loop.1166 *1167 * @since 1.9.01168 */1169 function bp_notifications_pagination_count() {1170 echo bp_get_notifications_pagination_count();1171 }1172 /**1173 * Return the pagination count for the current notification loop.1174 *1175 * @since 1.9.01176 *1177 * @return string HTML for the pagination count.1178 */1179 function bp_get_notifications_pagination_count() {1180 $query_loop = buddypress()->notifications->query_loop;1181 $start_num = intval( ( $query_loop->pag_page - 1 ) * $query_loop->pag_num ) + 1;1182 $from_num = bp_core_number_format( $start_num );1183 $to_num = bp_core_number_format( ( $start_num + ( $query_loop->pag_num - 1 ) > $query_loop->total_notification_count ) ? $query_loop->total_notification_count : $start_num + ( $query_loop->pag_num - 1 ) );1184 $total = bp_core_number_format( $query_loop->total_notification_count );1185 1186 if ( 1 == $query_loop->total_notification_count ) {1187 $pag = __( 'Viewing 1 notification', 'buddypress' );1188 } else {1189 $pag = sprintf( _n( 'Viewing %1$s - %2$s of %3$s notification', 'Viewing %1$s - %2$s of %3$s notifications', $query_loop->total_notification_count, 'buddypress' ), $from_num, $to_num, $total );1190 }1191 1192 /**1193 * Filters the pagination count for the current notification loop.1194 *1195 * @since 1.9.01196 *1197 * @param string $pag HTML for the pagination count.1198 */1199 return apply_filters( 'bp_notifications_pagination_count', $pag );1200 }1201 1202 /**1203 * Output the pagination links for the current notification loop.1204 *1205 * @since 1.9.01206 */1207 function bp_notifications_pagination_links() {1208 echo bp_get_notifications_pagination_links();1209 }1210 /**1211 * Return the pagination links for the current notification loop.1212 *1213 * @since 1.9.01214 *1215 * @return string HTML for the pagination links.1216 */1217 function bp_get_notifications_pagination_links() {1218 1219 /**1220 * Filters the pagination links for the current notification loop.1221 *1222 * @since 1.9.01223 *1224 * @param string $pag_links HTML for the pagination links.1225 */1226 return apply_filters( 'bp_get_notifications_pagination_links', buddypress()->notifications->query_loop->pag_links );1227 }1228 1229 /** Form Helpers **************************************************************/1230 1231 /**1232 * Output the form for changing the sort order of notifications.1233 *1234 * @since 1.9.01235 */1236 function bp_notifications_sort_order_form() {1237 1238 // Setup local variables.1239 $orders = array( 'DESC', 'ASC' );1240 $selected = 'DESC';1241 1242 // Check for a custom sort_order.1243 if ( !empty( $_REQUEST['sort_order'] ) ) {1244 if ( in_array( $_REQUEST['sort_order'], $orders ) ) {1245 $selected = $_REQUEST['sort_order'];1246 }1247 } ?>1248 1249 <form action="" method="get" id="notifications-sort-order">1250 <label for="notifications-sort-order-list"><?php esc_html_e( 'Order By:', 'buddypress' ); ?></label>1251 1252 <select id="notifications-sort-order-list" name="sort_order" onchange="this.form.submit();">1253 <option value="DESC" <?php selected( $selected, 'DESC' ); ?>><?php _e( 'Newest First', 'buddypress' ); ?></option>1254 <option value="ASC" <?php selected( $selected, 'ASC' ); ?>><?php _e( 'Oldest First', 'buddypress' ); ?></option>1255 </select>1256 1257 <noscript>1258 <input id="submit" type="submit" name="form-submit" class="submit" value="<?php esc_attr_e( 'Go', 'buddypress' ); ?>" />1259 </noscript>1260 </form>1261 1262 <?php1263 }1264 1265 /**1266 * Output the dropdown for bulk management of notifications.1267 *1268 * @since 2.2.01269 */1270 function bp_notifications_bulk_management_dropdown() {1271 ?>1272 <label class="bp-screen-reader-text" for="notification-select"><?php _e( 'Select Bulk Action', 'buddypress' ); ?></label>1273 <select name="notification_bulk_action" id="notification-select">1274 <option value="" selected="selected"><?php _e( 'Bulk Actions', 'buddypress' ); ?></option>1275 1276 <?php if ( bp_is_current_action( 'unread' ) ) : ?>1277 <option value="read"><?php _e( 'Mark read', 'buddypress' ); ?></option>1278 <?php elseif ( bp_is_current_action( 'read' ) ) : ?>1279 <option value="unread"><?php _e( 'Mark unread', 'buddypress' ); ?></option>1280 <?php endif; ?>1281 <option value="delete"><?php _e( 'Delete', 'buddypress' ); ?></option>1282 </select>1283 <input type="submit" id="notification-bulk-manage" class="button action" value="<?php esc_attr_e( 'Apply', 'buddypress' ); ?>">1284 <?php1285 }
Note: See TracChangeset
for help on using the changeset viewer.