<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][11931] trunk: Friends: Conditionally load action and screen functions.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/11931">11931</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/11931","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>r-a-y</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2018-04-02 16:43:02 +0000 (Mon, 02 Apr 2018)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Friends: Conditionally load action and screen functions.

This commit conditionally loads action and screen function code for the
Friends component, utilizing the `'bp_late_include'` hook introduced in
<a href="http://buddypress.trac.wordpress.org/changeset/11884">r11884</a>.

Previously, we loaded these functions at all times, which is unnecessary
when a user is not on a BuddyPress friends page. Now, we only load this
code when needed.

See <a href="http://buddypress.trac.wordpress.org/ticket/7218">#7218</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpfriendsclassesclassbpfriendscomponentphp">trunk/src/bp-friends/classes/class-bp-friends-component.php</a></li>
<li><a href="#trunktestsphpunitincludesloaderphp">trunk/tests/phpunit/includes/loader.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/src/bp-friends/actions/</li>
<li><a href="#trunksrcbpfriendsactionsaddfriendphp">trunk/src/bp-friends/actions/add-friend.php</a></li>
<li><a href="#trunksrcbpfriendsactionsremovefriendphp">trunk/src/bp-friends/actions/remove-friend.php</a></li>
<li>trunk/src/bp-friends/screens/</li>
<li><a href="#trunksrcbpfriendsscreensmyfriendsphp">trunk/src/bp-friends/screens/my-friends.php</a></li>
<li><a href="#trunksrcbpfriendsscreensrequestsphp">trunk/src/bp-friends/screens/requests.php</a></li>
<li><a href="#trunksrcbpfriendsscreenssettingsemailphp">trunk/src/bp-friends/screens/settings-email.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunksrcbpfriendsbpfriendsactionsphp">trunk/src/bp-friends/bp-friends-actions.php</a></li>
<li><a href="#trunksrcbpfriendsbpfriendsscreensphp">trunk/src/bp-friends/bp-friends-screens.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpfriendsactionsaddfriendphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-friends/actions/add-friend.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-friends/actions/add-friend.php                               (rev 0)
+++ trunk/src/bp-friends/actions/add-friend.php 2018-04-02 16:43:02 UTC (rev 11931)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,48 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Friends: Add action
+ *
+ * @package BuddyPress
+ * @subpackage FriendsActions
+ * @since 3.0.0
+ */
+
+/**
+ * Catch and process friendship requests.
+ *
+ * @since 1.0.1
+ */
+function friends_action_add_friend() {
+       if ( !bp_is_friends_component() || !bp_is_current_action( 'add-friend' ) )
+               return false;
+
+       if ( !$potential_friend_id = (int)bp_action_variable( 0 ) )
+               return false;
+
+       if ( $potential_friend_id == bp_loggedin_user_id() )
+               return false;
+
+       $friendship_status = BP_Friends_Friendship::check_is_friend( bp_loggedin_user_id(), $potential_friend_id );
+
+       if ( 'not_friends' == $friendship_status ) {
+
+               if ( !check_admin_referer( 'friends_add_friend' ) )
+                       return false;
+
+               if ( !friends_add_friend( bp_loggedin_user_id(), $potential_friend_id ) ) {
+                       bp_core_add_message( __( 'Friendship could not be requested.', 'buddypress' ), 'error' );
+               } else {
+                       bp_core_add_message( __( 'Friendship requested', 'buddypress' ) );
+               }
+
+       } elseif ( 'is_friend' == $friendship_status ) {
+               bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' );
+       } else {
+               bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' );
+       }
+
+       bp_core_redirect( wp_get_referer() );
+
+       return false;
+}
+add_action( 'bp_actions', 'friends_action_add_friend' );
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcbpfriendsactionsremovefriendphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-friends/actions/remove-friend.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-friends/actions/remove-friend.php                            (rev 0)
+++ trunk/src/bp-friends/actions/remove-friend.php      2018-04-02 16:43:02 UTC (rev 11931)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,48 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Friends: Remove action
+ *
+ * @package BuddyPress
+ * @subpackage FriendsActions
+ * @since 3.0.0
+ */
+
+/**
+ * Catch and process Remove Friendship requests.
+ *
+ * @since 1.0.1
+ */
+function friends_action_remove_friend() {
+       if ( !bp_is_friends_component() || !bp_is_current_action( 'remove-friend' ) )
+               return false;
+
+       if ( !$potential_friend_id = (int)bp_action_variable( 0 ) )
+               return false;
+
+       if ( $potential_friend_id == bp_loggedin_user_id() )
+               return false;
+
+       $friendship_status = BP_Friends_Friendship::check_is_friend( bp_loggedin_user_id(), $potential_friend_id );
+
+       if ( 'is_friend' == $friendship_status ) {
+
+               if ( !check_admin_referer( 'friends_remove_friend' ) )
+                       return false;
+
+               if ( !friends_remove_friend( bp_loggedin_user_id(), $potential_friend_id ) ) {
+                       bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' );
+               } else {
+                       bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) );
+               }
+
+       } elseif ( 'not_friends' == $friendship_status ) {
+               bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );
+       } else {
+               bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' );
+       }
+
+       bp_core_redirect( wp_get_referer() );
+
+       return false;
+}
+add_action( 'bp_actions', 'friends_action_remove_friend' );
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcbpfriendsbpfriendsactionsphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/src/bp-friends/bp-friends-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-friends/bp-friends-actions.php       2018-04-02 10:12:19 UTC (rev 11930)
+++ trunk/src/bp-friends/bp-friends-actions.php 2018-04-02 16:43:02 UTC (rev 11931)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,95 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * BuddyPress Friends Actions.
- *
- * Action functions are exactly the same as screen functions, however they do
- * not have a template screen associated with them. Usually they will send the
- * user back to the default screen after execution.
- *
- * @package BuddyPress
- * @subpackage FriendsActions
- * @since 1.5.0
- */
-
-// Exit if accessed directly.
-defined( 'ABSPATH' ) || exit;
-
-/**
- * Catch and process friendship requests.
- *
- * @since 1.0.1
- */
-function friends_action_add_friend() {
-       if ( !bp_is_friends_component() || !bp_is_current_action( 'add-friend' ) )
-               return false;
-
-       if ( !$potential_friend_id = (int)bp_action_variable( 0 ) )
-               return false;
-
-       if ( $potential_friend_id == bp_loggedin_user_id() )
-               return false;
-
-       $friendship_status = BP_Friends_Friendship::check_is_friend( bp_loggedin_user_id(), $potential_friend_id );
-
-       if ( 'not_friends' == $friendship_status ) {
-
-               if ( !check_admin_referer( 'friends_add_friend' ) )
-                       return false;
-
-               if ( !friends_add_friend( bp_loggedin_user_id(), $potential_friend_id ) ) {
-                       bp_core_add_message( __( 'Friendship could not be requested.', 'buddypress' ), 'error' );
-               } else {
-                       bp_core_add_message( __( 'Friendship requested', 'buddypress' ) );
-               }
-
-       } elseif ( 'is_friend' == $friendship_status ) {
-               bp_core_add_message( __( 'You are already friends with this user', 'buddypress' ), 'error' );
-       } else {
-               bp_core_add_message( __( 'You already have a pending friendship request with this user', 'buddypress' ), 'error' );
-       }
-
-       bp_core_redirect( wp_get_referer() );
-
-       return false;
-}
-add_action( 'bp_actions', 'friends_action_add_friend' );
-
-/**
- * Catch and process Remove Friendship requests.
- *
- * @since 1.0.1
- */
-function friends_action_remove_friend() {
-       if ( !bp_is_friends_component() || !bp_is_current_action( 'remove-friend' ) )
-               return false;
-
-       if ( !$potential_friend_id = (int)bp_action_variable( 0 ) )
-               return false;
-
-       if ( $potential_friend_id == bp_loggedin_user_id() )
-               return false;
-
-       $friendship_status = BP_Friends_Friendship::check_is_friend( bp_loggedin_user_id(), $potential_friend_id );
-
-       if ( 'is_friend' == $friendship_status ) {
-
-               if ( !check_admin_referer( 'friends_remove_friend' ) )
-                       return false;
-
-               if ( !friends_remove_friend( bp_loggedin_user_id(), $potential_friend_id ) ) {
-                       bp_core_add_message( __( 'Friendship could not be canceled.', 'buddypress' ), 'error' );
-               } else {
-                       bp_core_add_message( __( 'Friendship canceled', 'buddypress' ) );
-               }
-
-       } elseif ( 'not_friends' == $friendship_status ) {
-               bp_core_add_message( __( 'You are not yet friends with this user', 'buddypress' ), 'error' );
-       } else {
-               bp_core_add_message( __( 'You have a pending friendship request with this user', 'buddypress' ), 'error' );
-       }
-
-       bp_core_redirect( wp_get_referer() );
-
-       return false;
-}
-add_action( 'bp_actions', 'friends_action_remove_friend' );
</del></span></pre></div>
<a id="trunksrcbpfriendsbpfriendsscreensphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/src/bp-friends/bp-friends-screens.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-friends/bp-friends-screens.php       2018-04-02 10:12:19 UTC (rev 11930)
+++ trunk/src/bp-friends/bp-friends-screens.php 2018-04-02 16:43:02 UTC (rev 11931)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,161 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * BuddyPress Friends Screen Functions.
- *
- * Screen functions are the controllers of BuddyPress. They will execute when
- * their specific URL is caught. They will first save or manipulate data using
- * business functions, then pass on the user to a template file.
- *
- * @package BuddyPress
- * @subpackage FriendsScreens
- * @since 1.5.0
- */
-
-// Exit if accessed directly.
-defined( 'ABSPATH' ) || exit;
-
-/**
- * Catch and process the My Friends page.
- *
- * @since 1.0.0
- */
-function friends_screen_my_friends() {
-
-       /**
-        * Fires before the loading of template for the My Friends page.
-        *
-        * @since 1.0.0
-        */
-       do_action( 'friends_screen_my_friends' );
-
-       /**
-        * Filters the template used to display the My Friends page.
-        *
-        * @since 1.0.0
-        *
-        * @param string $template Path to the my friends template to load.
-        */
-       bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) );
-}
-
-/**
- * Catch and process the Requests page.
- *
- * @since 1.0.0
- */
-function friends_screen_requests() {
-       if ( bp_is_action_variable( 'accept', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
-               // Check the nonce.
-               check_admin_referer( 'friends_accept_friendship' );
-
-               if ( friends_accept_friendship( bp_action_variable( 1 ) ) )
-                       bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
-               else
-                       bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' );
-
-               bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
-
-       } elseif ( bp_is_action_variable( 'reject', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
-               // Check the nonce.
-               check_admin_referer( 'friends_reject_friendship' );
-
-               if ( friends_reject_friendship( bp_action_variable( 1 ) ) )
-                       bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
-               else
-                       bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
-
-               bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
-
-       } elseif ( bp_is_action_variable( 'cancel', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
-               // Check the nonce.
-               check_admin_referer( 'friends_withdraw_friendship' );
-
-               if ( friends_withdraw_friendship( bp_loggedin_user_id(), bp_action_variable( 1 ) ) )
-                       bp_core_add_message( __( 'Friendship request withdrawn', 'buddypress' ) );
-               else
-                       bp_core_add_message( __( 'Friendship request could not be withdrawn', 'buddypress' ), 'error' );
-
-               bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
-       }
-
-       /**
-        * Fires before the loading of template for the friends requests page.
-        *
-        * @since 1.0.0
-        */
-       do_action( 'friends_screen_requests' );
-
-       /**
-        * Filters the template used to display the My Friends page.
-        *
-        * @since 1.0.0
-        *
-        * @param string $template Path to the friends request template to load.
-        */
-       bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
-}
-
-/**
- * Add Friends-related settings to the Settings > Notifications page.
- *
- * @since 1.0.0
- */
-function friends_screen_notification_settings() {
-
-       if ( !$send_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_request', true ) )
-               $send_requests   = 'yes';
-
-       if ( !$accept_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_accepted', true ) )
-               $accept_requests = 'yes'; ?>
-
-       <table class="notification-settings" id="friends-notification-settings">
-               <thead>
-                       <tr>
-                               <th class="icon"></th>
-                               <th class="title"><?php _ex( 'Friends', 'Friend settings on notification settings page', 'buddypress' ) ?></th>
-                               <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
-                               <th class="no"><?php _e( 'No', 'buddypress' )?></th>
-                       </tr>
-               </thead>
-
-               <tbody>
-                       <tr id="friends-notification-settings-request">
-                               <td></td>
-                               <td><?php _ex( 'A member sends you a friendship request', 'Friend settings on notification settings page', 'buddypress' ) ?></td>
-                               <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
-                                       /* translators: accessibility text */
-                                       _e( 'Yes, send email', 'buddypress' );
-                               ?></label></td>
-                               <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
-                                       /* translators: accessibility text */
-                                       _e( 'No, do not send email', 'buddypress' );
-                               ?></label></td>
-                       </tr>
-                       <tr id="friends-notification-settings-accepted">
-                               <td></td>
-                               <td><?php _ex( 'A member accepts your friendship request', 'Friend settings on notification settings page', 'buddypress' ) ?></td>
-                               <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
-                                       /* translators: accessibility text */
-                                       _e( 'Yes, send email', 'buddypress' );
-                               ?></label></td>
-                               <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
-                                       /* translators: accessibility text */
-                                       _e( 'No, do not send email', 'buddypress' );
-                               ?></label></td>
-                       </tr>
-
-                       <?php
-
-                       /**
-                        * Fires after the last table row on the friends notification screen.
-                        *
-                        * @since 1.0.0
-                        */
-                       do_action( 'friends_screen_notification_settings' ); ?>
-
-               </tbody>
-       </table>
-
-<?php
-}
-add_action( 'bp_notification_settings', 'friends_screen_notification_settings' );
</del></span></pre></div>
<a id="trunksrcbpfriendsclassesclassbpfriendscomponentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-friends/classes/class-bp-friends-component.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-friends/classes/class-bp-friends-component.php       2018-04-02 10:12:19 UTC (rev 11930)
+++ trunk/src/bp-friends/classes/class-bp-friends-component.php 2018-04-02 16:43:02 UTC (rev 11931)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -47,8 +47,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function includes( $includes = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $includes = array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'cache',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        'actions',
-                       'screens',
</del><span class="cx" style="display: block; padding: 0 10px">                         'filters',
</span><span class="cx" style="display: block; padding: 0 10px">                        'activity',
</span><span class="cx" style="display: block; padding: 0 10px">                        'template',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -65,6 +63,41 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Late includes method.
+        *
+        * Only load up certain code when on specific pages.
+        *
+        * @since 3.0.0
+        */
+       public function late_includes() {
+               // Bail if PHPUnit is running.
+               if ( defined( 'BP_TESTS_DIR' ) ) {
+                       return;
+               }
+
+               // Friends.
+               if ( bp_is_user_friends() ) {
+                       // Authenticated actions.
+                       if ( is_user_logged_in() &&
+                               in_array( bp_current_action(), array( 'add-friend', 'remove-friend' ), true )
+                       ) {
+                               require $this->path . 'bp-friends/actions/' . bp_current_action() . '.php';
+                       }
+
+                       // User nav.
+                       require $this->path . 'bp-friends/screens/my-friends.php';
+                       if ( is_user_logged_in() && bp_is_user_friend_requests() ) {
+                               require $this->path . 'bp-friends/screens/requests.php';
+                       }
+               }
+
+               // Settings.
+               if ( bp_is_user_settings_notifications() ) {
+                       require $this->path . 'bp-friends/screens/settings-email.php';
+               }
+       }
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Set up bp-friends global settings.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * The BP_FRIENDS_SLUG constant is deprecated, and only used here for
</span></span></pre></div>
<a id="trunksrcbpfriendsscreensmyfriendsphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-friends/screens/my-friends.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-friends/screens/my-friends.php                               (rev 0)
+++ trunk/src/bp-friends/screens/my-friends.php 2018-04-02 16:43:02 UTC (rev 11931)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,32 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Friends: User's "Friends" screen handler
+ *
+ * @package BuddyPress
+ * @subpackage FriendsScreens
+ * @since 3.0.0
+ */
+
+/**
+ * Catch and process the My Friends page.
+ *
+ * @since 1.0.0
+ */
+function friends_screen_my_friends() {
+
+       /**
+        * Fires before the loading of template for the My Friends page.
+        *
+        * @since 1.0.0
+        */
+       do_action( 'friends_screen_my_friends' );
+
+       /**
+        * Filters the template used to display the My Friends page.
+        *
+        * @since 1.0.0
+        *
+        * @param string $template Path to the my friends template to load.
+        */
+       bp_core_load_template( apply_filters( 'friends_template_my_friends', 'members/single/home' ) );
+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcbpfriendsscreensrequestsphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-friends/screens/requests.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-friends/screens/requests.php                         (rev 0)
+++ trunk/src/bp-friends/screens/requests.php   2018-04-02 16:43:02 UTC (rev 11931)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,65 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Friends: User's "Friends > Requests" screen handler
+ *
+ * @package BuddyPress
+ * @subpackage FriendsScreens
+ * @since 3.0.0
+ */
+
+/**
+ * Catch and process the Requests page.
+ *
+ * @since 1.0.0
+ */
+function friends_screen_requests() {
+       if ( bp_is_action_variable( 'accept', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
+               // Check the nonce.
+               check_admin_referer( 'friends_accept_friendship' );
+
+               if ( friends_accept_friendship( bp_action_variable( 1 ) ) )
+                       bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
+               else
+                       bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' );
+
+               bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
+
+       } elseif ( bp_is_action_variable( 'reject', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
+               // Check the nonce.
+               check_admin_referer( 'friends_reject_friendship' );
+
+               if ( friends_reject_friendship( bp_action_variable( 1 ) ) )
+                       bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
+               else
+                       bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
+
+               bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
+
+       } elseif ( bp_is_action_variable( 'cancel', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
+               // Check the nonce.
+               check_admin_referer( 'friends_withdraw_friendship' );
+
+               if ( friends_withdraw_friendship( bp_loggedin_user_id(), bp_action_variable( 1 ) ) )
+                       bp_core_add_message( __( 'Friendship request withdrawn', 'buddypress' ) );
+               else
+                       bp_core_add_message( __( 'Friendship request could not be withdrawn', 'buddypress' ), 'error' );
+
+               bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
+       }
+
+       /**
+        * Fires before the loading of template for the friends requests page.
+        *
+        * @since 1.0.0
+        */
+       do_action( 'friends_screen_requests' );
+
+       /**
+        * Filters the template used to display the My Friends page.
+        *
+        * @since 1.0.0
+        *
+        * @param string $template Path to the friends request template to load.
+        */
+       bp_core_load_template( apply_filters( 'friends_template_requests', 'members/single/home' ) );
+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcbpfriendsscreenssettingsemailphpfromrev11930trunksrcbpfriendsbpfriendsscreensphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/src/bp-friends/screens/settings-email.php (from rev 11930, trunk/src/bp-friends/bp-friends-screens.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-friends/screens/settings-email.php                           (rev 0)
+++ trunk/src/bp-friends/screens/settings-email.php     2018-04-02 16:43:02 UTC (rev 11931)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,73 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Friends: Integration into user's "Settings > Email" screen
+ *
+ * @package BuddyPress
+ * @subpackage FriendsScreens
+ * @since 3.0.0
+ */
+
+/**
+ * Add Friends-related settings to the Settings > Notifications page.
+ *
+ * @since 1.0.0
+ */
+function friends_screen_notification_settings() {
+
+       if ( !$send_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_request', true ) )
+               $send_requests   = 'yes';
+
+       if ( !$accept_requests = bp_get_user_meta( bp_displayed_user_id(), 'notification_friends_friendship_accepted', true ) )
+               $accept_requests = 'yes'; ?>
+
+       <table class="notification-settings" id="friends-notification-settings">
+               <thead>
+                       <tr>
+                               <th class="icon"></th>
+                               <th class="title"><?php _ex( 'Friends', 'Friend settings on notification settings page', 'buddypress' ) ?></th>
+                               <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
+                               <th class="no"><?php _e( 'No', 'buddypress' )?></th>
+                       </tr>
+               </thead>
+
+               <tbody>
+                       <tr id="friends-notification-settings-request">
+                               <td></td>
+                               <td><?php _ex( 'A member sends you a friendship request', 'Friend settings on notification settings page', 'buddypress' ) ?></td>
+                               <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
+                                       /* translators: accessibility text */
+                                       _e( 'Yes, send email', 'buddypress' );
+                               ?></label></td>
+                               <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
+                                       /* translators: accessibility text */
+                                       _e( 'No, do not send email', 'buddypress' );
+                               ?></label></td>
+                       </tr>
+                       <tr id="friends-notification-settings-accepted">
+                               <td></td>
+                               <td><?php _ex( 'A member accepts your friendship request', 'Friend settings on notification settings page', 'buddypress' ) ?></td>
+                               <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
+                                       /* translators: accessibility text */
+                                       _e( 'Yes, send email', 'buddypress' );
+                               ?></label></td>
+                               <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
+                                       /* translators: accessibility text */
+                                       _e( 'No, do not send email', 'buddypress' );
+                               ?></label></td>
+                       </tr>
+
+                       <?php
+
+                       /**
+                        * Fires after the last table row on the friends notification screen.
+                        *
+                        * @since 1.0.0
+                        */
+                       do_action( 'friends_screen_notification_settings' ); ?>
+
+               </tbody>
+       </table>
+
+<?php
+}
+add_action( 'bp_notification_settings', 'friends_screen_notification_settings' );
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunktestsphpunitincludesloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/includes/loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/includes/loader.php   2018-04-02 10:12:19 UTC (rev 11930)
+++ trunk/tests/phpunit/includes/loader.php     2018-04-02 16:43:02 UTC (rev 11931)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -23,7 +23,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * In BuddyPress, this is loaded conditionally, but PHPUnit needs all files
</span><span class="cx" style="display: block; padding: 0 10px">  * loaded at the same time to prevent weird load order issues.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-$components = array( 'activity', 'groups', 'members', 'messages', 'settings', 'xprofile' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+$components = array( 'activity', 'friends', 'groups', 'members', 'messages', 'settings', 'xprofile' );
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $components as $component ) {
</span><span class="cx" style="display: block; padding: 0 10px">        add_action( "bp_{$component}_includes", function() use ( $component ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $dirs = array(
</span></span></pre>
</div>
</div>

</body>
</html>