[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress Messages Screens. 4 * 5 * Screen functions are the controllers of BuddyPress. They will execute when 6 * their specific URL is caught. They will first save or manipulate data using 7 * business functions, then pass on the user to a template file. 8 * 9 * @package BuddyPress 10 * @subpackage MessagesScreens 11 * @since 1.5.0 12 */ 13 14 // Exit if accessed directly. 15 defined( 'ABSPATH' ) || exit; 16 17 /** 18 * Load the Messages > Inbox screen. 19 * 20 * @since 1.0.0 21 */ 22 function messages_screen_inbox() { 23 24 if ( bp_action_variables() ) { 25 bp_do_404(); 26 return; 27 } 28 29 /** 30 * Fires right before the loading of the Messages inbox screen template file. 31 * 32 * @since 1.0.0 33 */ 34 do_action( 'messages_screen_inbox' ); 35 36 /** 37 * Filters the template to load for the Messages inbox screen. 38 * 39 * @since 1.0.0 40 * 41 * @param string $template Path to the messages template to load. 42 */ 43 bp_core_load_template( apply_filters( 'messages_template_inbox', 'members/single/home' ) ); 44 } 45 46 /** 47 * Load the Messages > Sent screen. 48 * 49 * @since 1.0.0 50 */ 51 function messages_screen_sentbox() { 52 53 if ( bp_action_variables() ) { 54 bp_do_404(); 55 return; 56 } 57 58 /** 59 * Fires right before the loading of the Messages sentbox screen template file. 60 * 61 * @since 1.0.0 62 */ 63 do_action( 'messages_screen_sentbox' ); 64 65 /** 66 * Filters the template to load for the Messages sentbox screen. 67 * 68 * @since 1.0.0 69 * 70 * @param string $template Path to the messages template to load. 71 */ 72 bp_core_load_template( apply_filters( 'messages_template_sentbox', 'members/single/home' ) ); 73 } 74 75 /** 76 * Load the Messages > Compose screen. 77 * 78 * @since 1.0.0 79 */ 80 function messages_screen_compose() { 81 82 if ( bp_action_variables() ) { 83 bp_do_404(); 84 return; 85 } 86 87 // Remove any saved message data from a previous session. 88 messages_remove_callback_values(); 89 90 /** 91 * Fires right before the loading of the Messages compose screen template file. 92 * 93 * @since 1.0.0 94 */ 95 do_action( 'messages_screen_compose' ); 96 97 /** 98 * Filters the template to load for the Messages compose screen. 99 * 100 * @since 1.0.0 101 * 102 * @param string $template Path to the messages template to load. 103 */ 104 bp_core_load_template( apply_filters( 'messages_template_compose', 'members/single/home' ) ); 105 } 106 107 /** 108 * Load an individual conversation screen. 109 * 110 * @since 1.0.0 111 * 112 * @return false|null False on failure. 113 */ 114 function messages_screen_conversation() { 115 116 // Bail if not viewing a single message. 117 if ( ! bp_is_messages_component() || ! bp_is_current_action( 'view' ) ) { 118 return false; 119 } 120 121 $thread_id = (int) bp_action_variable( 0 ); 122 123 if ( empty( $thread_id ) || ! messages_is_valid_thread( $thread_id ) ) { 124 if ( is_user_logged_in() ) { 125 bp_core_add_message( __( 'The conversation you tried to access is no longer available', 'buddypress' ), 'error' ); 126 } 127 128 bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() ) ); 129 } 130 131 // No access. 132 if ( ( ! messages_check_thread_access( $thread_id ) || ! bp_is_my_profile() ) && ! bp_current_user_can( 'bp_moderate' ) ) { 133 // If not logged in, prompt for login. 134 if ( ! is_user_logged_in() ) { 135 bp_core_no_access(); 136 return; 137 138 // Redirect away. 139 } else { 140 bp_core_add_message( __( 'You do not have access to that conversation.', 'buddypress' ), 'error' ); 141 bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() ) ); 142 } 143 } 144 145 // Load up BuddyPress one time. 146 $bp = buddypress(); 147 148 // Decrease the unread count in the nav before it's rendered. 149 $count = bp_get_total_unread_messages_count(); 150 $class = ( 0 === $count ) ? 'no-count' : 'count'; 151 $nav_name = sprintf( __( 'Messages <span class="%s">%s</span>', 'buddypress' ), esc_attr( $class ), bp_core_number_format( $count ) ); 152 153 // Edit the Navigation name. 154 $bp->members->nav->edit_nav( array( 155 'name' => $nav_name, 156 ), $bp->messages->slug ); 157 158 /** 159 * Fires right before the loading of the Messages view screen template file. 160 * 161 * @since 1.7.0 162 */ 163 do_action( 'messages_screen_conversation' ); 164 165 /** 166 * Filters the template to load for the Messages view screen. 167 * 168 * @since 1.0.0 169 * 170 * @param string $template Path to the messages template to load. 171 */ 172 bp_core_load_template( apply_filters( 'messages_template_view_message', 'members/single/home' ) ); 173 } 174 add_action( 'bp_screens', 'messages_screen_conversation' ); 175 176 /** 177 * Load the Messages > Notices screen. 178 * 179 * @since 1.0.0 180 * 181 * @return false|null False on failure. 182 */ 183 function messages_screen_notices() { 184 185 if ( bp_action_variables() ) { 186 bp_do_404(); 187 return; 188 } 189 190 /** 191 * Fires right before the loading of the Messages notices screen template file. 192 * 193 * @since 1.0.0 194 */ 195 do_action( 'messages_screen_notices' ); 196 197 /** 198 * Filters the template to load for the Messages notices screen. 199 * 200 * @since 1.0.0 201 * 202 * @param string $template Path to the messages template to load. 203 */ 204 bp_core_load_template( apply_filters( 'messages_template_notices', 'members/single/home' ) ); 205 } 206 207 /** 208 * Render the markup for the Messages section of Settings > Notifications. 209 * 210 * @since 1.0.0 211 */ 212 function messages_screen_notification_settings() { 213 214 if ( bp_action_variables() ) { 215 bp_do_404(); 216 return; 217 } 218 219 if ( !$new_messages = bp_get_user_meta( bp_displayed_user_id(), 'notification_messages_new_message', true ) ) { 220 $new_messages = 'yes'; 221 } ?> 222 223 <table class="notification-settings" id="messages-notification-settings"> 224 <thead> 225 <tr> 226 <th class="icon"></th> 227 <th class="title"><?php _e( 'Messages', 'buddypress' ) ?></th> 228 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 229 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 230 </tr> 231 </thead> 232 233 <tbody> 234 <tr id="messages-notification-settings-new-message"> 235 <td></td> 236 <td><?php _e( 'A member sends you a new message', 'buddypress' ) ?></td> 237 <td class="yes"><input type="radio" name="notifications[notification_messages_new_message]" id="notification-messages-new-messages-yes" value="yes" <?php checked( $new_messages, 'yes', true ) ?>/><label for="notification-messages-new-messages-yes" class="bp-screen-reader-text"><?php 238 /* translators: accessibility text */ 239 _e( 'Yes, send email', 'buddypress' ); 240 ?></label></td> 241 <td class="no"><input type="radio" name="notifications[notification_messages_new_message]" id="notification-messages-new-messages-no" value="no" <?php checked( $new_messages, 'no', true ) ?>/><label for="notification-messages-new-messages-no" class="bp-screen-reader-text"><?php 242 /* translators: accessibility text */ 243 _e( 'No, do not send email', 'buddypress' ); 244 ?></label></td> 245 </tr> 246 247 <?php 248 249 /** 250 * Fires inside the closing </tbody> tag for messages screen notification settings. 251 * 252 * @since 1.0.0 253 */ 254 do_action( 'messages_screen_notification_settings' ); ?> 255 </tbody> 256 </table> 257 258 <?php 259 } 260 add_action( 'bp_notification_settings', 'messages_screen_notification_settings', 2 );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Apr 2 01:00:57 2018 | Cross-referenced by PHPXref 0.7.1 |