[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BuddyPress Friends Screen Functions. 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 FriendsScreens 11 * @since 1.5.0 12 */ 13 14 // Exit if accessed directly. 15 defined( 'ABSPATH' ) || exit; 16 17 /** 18 * Catch and process the My Friends page. 19 * 20 * @since 1.0.0 21 */ 22 function friends_screen_my_friends() { 23 24 /** 25 * Fires before the loading of template for the My Friends page. 26 * 27 * @since 1.0.0 28 */ 29 do_action( 'friends_screen_my_friends' ); 30 31 /** 32 * Filters the template used to display the My Friends page. 33 * 34 * @since 1.0.0 35 * 36 * @param string $template Path to the my friends template to load. 37 */ 38 bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) ); 39 } 40 41 /** 42 * Catch and process the Requests page. 43 * 44 * @since 1.0.0 45 */ 46 function friends_screen_requests() { 47 if ( bp_is_action_variable( 'accept', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) { 48 // Check the nonce. 49 check_admin_referer( 'friends_accept_friendship' ); 50 51 if ( friends_accept_friendship( bp_action_variable( 1 ) ) ) 52 bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) ); 53 else 54 bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' ); 55 56 bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) ); 57 58 } elseif ( bp_is_action_variable( 'reject', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) { 59 // Check the nonce. 60 check_admin_referer( 'friends_reject_friendship' ); 61 62 if ( friends_reject_friendship( bp_action_variable( 1 ) ) ) 63 bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) ); 64 else 65 bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' ); 66 67 bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) ); 68 69 } elseif ( bp_is_action_variable( 'cancel', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) { 70 // Check the nonce. 71 check_admin_referer( 'friends_withdraw_friendship' ); 72 73 if ( friends_withdraw_friendship( bp_loggedin_user_id(), bp_action_variable( 1 ) ) ) 74 bp_core_add_message( __( 'Friendship request withdrawn', 'buddypress' ) ); 75 else 76 bp_core_add_message( __( 'Friendship request could not be withdrawn', 'buddypress' ), 'error' ); 77 78 bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) ); 79 } 80 81 /** 82 * Fires before the loading of template for the friends requests page. 83 * 84 * @since 1.0.0 85 */ 86 do_action( 'friends_screen_requests' ); 87 88 /** 89 * Filters the template used to display the My Friends page. 90 * 91 * @since 1.0.0 92 * 93 * @param string $template Path to the friends request template to load. 94 */ 95 bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) ); 96 } 97 98 /** 99 * Add Friends-related settings to the Settings > Notifications page. 100 * 101 * @since 1.0.0 102 */ 103 function friends_screen_notification_settings() { 104 105 if ( !$send_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_request', true ) ) 106 $send_requests = 'yes'; 107 108 if ( !$accept_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_accepted', true ) ) 109 $accept_requests = 'yes'; ?> 110 111 <table class="notification-settings" id="friends-notification-settings"> 112 <thead> 113 <tr> 114 <th class="icon"></th> 115 <th class="title"><?php _ex( 'Friends', 'Friend settings on notification settings page', 'buddypress' ) ?></th> 116 <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th> 117 <th class="no"><?php _e( 'No', 'buddypress' )?></th> 118 </tr> 119 </thead> 120 121 <tbody> 122 <tr id="friends-notification-settings-request"> 123 <td></td> 124 <td><?php _ex( 'A member sends you a friendship request', 'Friend settings on notification settings page', 'buddypress' ) ?></td> 125 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_request]" id="notification-friends-friendship-request-yes" value="yes" <?php checked( $send_requests, 'yes', true ) ?>/><label for="notification-friends-friendship-request-yes" class="bp-screen-reader-text"><?php 126 /* translators: accessibility text */ 127 _e( 'Yes, send email', 'buddypress' ); 128 ?></label></td> 129 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_request]" id="notification-friends-friendship-request-no" value="no" <?php checked( $send_requests, 'no', true ) ?>/><label for="notification-friends-friendship-request-no" class="bp-screen-reader-text"><?php 130 /* translators: accessibility text */ 131 _e( 'No, do not send email', 'buddypress' ); 132 ?></label></td> 133 </tr> 134 <tr id="friends-notification-settings-accepted"> 135 <td></td> 136 <td><?php _ex( 'A member accepts your friendship request', 'Friend settings on notification settings page', 'buddypress' ) ?></td> 137 <td class="yes"><input type="radio" name="notifications[notification_friends_friendship_accepted]" id="notification-friends-friendship-accepted-yes" value="yes" <?php checked( $accept_requests, 'yes', true ) ?>/><label for="notification-friends-friendship-accepted-yes" class="bp-screen-reader-text"><?php 138 /* translators: accessibility text */ 139 _e( 'Yes, send email', 'buddypress' ); 140 ?></label></td> 141 <td class="no"><input type="radio" name="notifications[notification_friends_friendship_accepted]" id="notification-friends-friendship-accepted-no" value="no" <?php checked( $accept_requests, 'no', true ) ?>/><label for="notification-friends-friendship-accepted-no" class="bp-screen-reader-text"><?php 142 /* translators: accessibility text */ 143 _e( 'No, do not send email', 'buddypress' ); 144 ?></label></td> 145 </tr> 146 147 <?php 148 149 /** 150 * Fires after the last table row on the friends notification screen. 151 * 152 * @since 1.0.0 153 */ 154 do_action( 'friends_screen_notification_settings' ); ?> 155 156 </tbody> 157 </table> 158 159 <?php 160 } 161 add_action( 'bp_notification_settings', 'friends_screen_notification_settings' );
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 |