<!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][11933] trunk: Notifications: 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/11933">11933</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/11933","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 17:35:08 +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'>Notifications: Conditionally load action and screen functions.
This commit conditionally loads action and screen function code for the
Notifications 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 notifications page. Now, we only load
this code when needed.
This commit also moves over the unused `bp_notifications_screen_settings()`
function from `bp-notifications-screens.php` to
`bp-notifications-functions.php`. This function is a candidate for future
deprecation.
See <a href="http://buddypress.trac.wordpress.org/ticket/7218">#7218</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpnotificationsbpnotificationsfunctionsphp">trunk/src/bp-notifications/bp-notifications-functions.php</a></li>
<li><a href="#trunksrcbpnotificationsclassesclassbpnotificationscomponentphp">trunk/src/bp-notifications/classes/class-bp-notifications-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-notifications/actions/</li>
<li><a href="#trunksrcbpnotificationsactionsbulkmanagephp">trunk/src/bp-notifications/actions/bulk-manage.php</a></li>
<li><a href="#trunksrcbpnotificationsactionsdeletephp">trunk/src/bp-notifications/actions/delete.php</a></li>
<li>trunk/src/bp-notifications/screens/</li>
<li><a href="#trunksrcbpnotificationsscreensreadphp">trunk/src/bp-notifications/screens/read.php</a></li>
<li><a href="#trunksrcbpnotificationsscreensunreadphp">trunk/src/bp-notifications/screens/unread.php</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunksrcbpnotificationsbpnotificationsactionsphp">trunk/src/bp-notifications/bp-notifications-actions.php</a></li>
<li><a href="#trunksrcbpnotificationsbpnotificationsscreensphp">trunk/src/bp-notifications/bp-notifications-screens.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpnotificationsactionsbulkmanagephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-notifications/actions/bulk-manage.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-notifications/actions/bulk-manage.php (rev 0)
+++ trunk/src/bp-notifications/actions/bulk-manage.php 2018-04-02 17:35:08 UTC (rev 11933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,69 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Notifications: Bulk-manage action handler
+ *
+ * @package BuddyPress
+ * @subpackage NotificationsActions
+ * @since 3.0.0
+ */
+
+/**
+ * Handles bulk management (mark as read/unread, delete) of notifications.
+ *
+ * @since 2.2.0
+ *
+ * @return bool
+ */
+function bp_notifications_action_bulk_manage() {
+
+ // Bail if not the read or unread screen.
+ if ( ! bp_is_notifications_component() || ! ( bp_is_current_action( 'read' ) || bp_is_current_action( 'unread' ) ) ) {
+ return false;
+ }
+
+ // Get the action.
+ $action = !empty( $_POST['notification_bulk_action'] ) ? $_POST['notification_bulk_action'] : '';
+ $nonce = !empty( $_POST['notifications_bulk_nonce'] ) ? $_POST['notifications_bulk_nonce'] : '';
+ $notifications = !empty( $_POST['notifications'] ) ? $_POST['notifications'] : '';
+
+ // Bail if no action or no IDs.
+ if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ) ) ) || empty( $notifications ) || empty( $nonce ) ) {
+ return false;
+ }
+
+ // Check the nonce.
+ if ( ! wp_verify_nonce( $nonce, 'notifications_bulk_nonce' ) ) {
+ bp_core_add_message( __( 'There was a problem managing your notifications.', 'buddypress' ), 'error' );
+ return false;
+ }
+
+ $notifications = wp_parse_id_list( $notifications );
+
+ // Delete, mark as read or unread depending on the user 'action'.
+ switch ( $action ) {
+ case 'delete' :
+ foreach ( $notifications as $notification ) {
+ bp_notifications_delete_notification( $notification );
+ }
+ bp_core_add_message( __( 'Notifications deleted.', 'buddypress' ) );
+ break;
+
+ case 'read' :
+ foreach ( $notifications as $notification ) {
+ bp_notifications_mark_notification( $notification, false );
+ }
+ bp_core_add_message( __( 'Notifications marked as read', 'buddypress' ) );
+ break;
+
+ case 'unread' :
+ foreach ( $notifications as $notification ) {
+ bp_notifications_mark_notification( $notification, true );
+ }
+ bp_core_add_message( __( 'Notifications marked as unread.', 'buddypress' ) );
+ break;
+ }
+
+ // Redirect.
+ bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/' . bp_current_action() . '/' );
+}
+add_action( 'bp_actions', 'bp_notifications_action_bulk_manage' );
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcbpnotificationsactionsdeletephp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-notifications/actions/delete.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-notifications/actions/delete.php (rev 0)
+++ trunk/src/bp-notifications/actions/delete.php 2018-04-02 17:35:08 UTC (rev 11933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,44 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Notifications: Delete action handler
+ *
+ * @package BuddyPress
+ * @subpackage NotificationsActions
+ * @since 3.0.0
+ */
+
+/**
+ * Handle deleting single notifications.
+ *
+ * @since 1.9.0
+ *
+ * @return bool
+ */
+function bp_notifications_action_delete() {
+
+ // Bail if not the read or unread screen.
+ if ( ! bp_is_notifications_component() || ! ( bp_is_current_action( 'read' ) || bp_is_current_action( 'unread' ) ) ) {
+ return false;
+ }
+
+ // Get the action.
+ $action = !empty( $_GET['action'] ) ? $_GET['action'] : '';
+ $nonce = !empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : '';
+ $id = !empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : '';
+
+ // Bail if no action or no ID.
+ if ( ( 'delete' !== $action ) || empty( $id ) || empty( $nonce ) ) {
+ return false;
+ }
+
+ // Check the nonce and delete the notification.
+ if ( bp_verify_nonce_request( 'bp_notification_delete_' . $id ) && bp_notifications_delete_notification( $id ) ) {
+ bp_core_add_message( __( 'Notification successfully deleted.', 'buddypress' ) );
+ } else {
+ bp_core_add_message( __( 'There was a problem deleting that notification.', 'buddypress' ), 'error' );
+ }
+
+ // Redirect.
+ bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/' . bp_current_action() . '/' );
+}
+add_action( 'bp_actions', 'bp_notifications_action_delete' );
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcbpnotificationsbpnotificationsactionsphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/src/bp-notifications/bp-notifications-actions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-notifications/bp-notifications-actions.php 2018-04-02 16:46:29 UTC (rev 11932)
+++ trunk/src/bp-notifications/bp-notifications-actions.php 2018-04-02 17:35:08 UTC (rev 11933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,184 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * BuddyPress Notifications 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 NotificationsActions
- * @since 1.9.0
- */
-
-// Exit if accessed directly.
-defined( 'ABSPATH' ) || exit;
-
-/**
- * Handle marking single notifications as read.
- *
- * @since 1.9.0
- *
- * @return bool
- */
-function bp_notifications_action_mark_read() {
-
- // Bail if not the unread screen.
- if ( ! bp_is_notifications_component() || ! bp_is_current_action( 'unread' ) ) {
- return false;
- }
-
- // Get the action.
- $action = !empty( $_GET['action'] ) ? $_GET['action'] : '';
- $nonce = !empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : '';
- $id = !empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : '';
-
- // Bail if no action or no ID.
- if ( ( 'read' !== $action ) || empty( $id ) || empty( $nonce ) ) {
- return false;
- }
-
- // Check the nonce and mark the notification.
- if ( bp_verify_nonce_request( 'bp_notification_mark_read_' . $id ) && bp_notifications_mark_notification( $id, false ) ) {
- bp_core_add_message( __( 'Notification successfully marked read.', 'buddypress' ) );
- } else {
- bp_core_add_message( __( 'There was a problem marking that notification.', 'buddypress' ), 'error' );
- }
-
- // Redirect.
- bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/unread/' );
-}
-add_action( 'bp_actions', 'bp_notifications_action_mark_read' );
-
-/**
- * Handle marking single notifications as unread.
- *
- * @since 1.9.0
- *
- * @return bool
- */
-function bp_notifications_action_mark_unread() {
-
- // Bail if not the read screen.
- if ( ! bp_is_notifications_component() || ! bp_is_current_action( 'read' ) ) {
- return false;
- }
-
- // Get the action.
- $action = !empty( $_GET['action'] ) ? $_GET['action'] : '';
- $nonce = !empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : '';
- $id = !empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : '';
-
- // Bail if no action or no ID.
- if ( ( 'unread' !== $action ) || empty( $id ) || empty( $nonce ) ) {
- return false;
- }
-
- // Check the nonce and mark the notification.
- if ( bp_verify_nonce_request( 'bp_notification_mark_unread_' . $id ) && bp_notifications_mark_notification( $id, true ) ) {
- bp_core_add_message( __( 'Notification successfully marked unread.', 'buddypress' ) );
- } else {
- bp_core_add_message( __( 'There was a problem marking that notification.', 'buddypress' ), 'error' );
- }
-
- // Redirect.
- bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/read/' );
-}
-add_action( 'bp_actions', 'bp_notifications_action_mark_unread' );
-
-/**
- * Handle deleting single notifications.
- *
- * @since 1.9.0
- *
- * @return bool
- */
-function bp_notifications_action_delete() {
-
- // Bail if not the read or unread screen.
- if ( ! bp_is_notifications_component() || ! ( bp_is_current_action( 'read' ) || bp_is_current_action( 'unread' ) ) ) {
- return false;
- }
-
- // Get the action.
- $action = !empty( $_GET['action'] ) ? $_GET['action'] : '';
- $nonce = !empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : '';
- $id = !empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : '';
-
- // Bail if no action or no ID.
- if ( ( 'delete' !== $action ) || empty( $id ) || empty( $nonce ) ) {
- return false;
- }
-
- // Check the nonce and delete the notification.
- if ( bp_verify_nonce_request( 'bp_notification_delete_' . $id ) && bp_notifications_delete_notification( $id ) ) {
- bp_core_add_message( __( 'Notification successfully deleted.', 'buddypress' ) );
- } else {
- bp_core_add_message( __( 'There was a problem deleting that notification.', 'buddypress' ), 'error' );
- }
-
- // Redirect.
- bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/' . bp_current_action() . '/' );
-}
-add_action( 'bp_actions', 'bp_notifications_action_delete' );
-
-/**
- * Handles bulk management (mark as read/unread, delete) of notifications.
- *
- * @since 2.2.0
- *
- * @return bool
- */
-function bp_notifications_action_bulk_manage() {
-
- // Bail if not the read or unread screen.
- if ( ! bp_is_notifications_component() || ! ( bp_is_current_action( 'read' ) || bp_is_current_action( 'unread' ) ) ) {
- return false;
- }
-
- // Get the action.
- $action = !empty( $_POST['notification_bulk_action'] ) ? $_POST['notification_bulk_action'] : '';
- $nonce = !empty( $_POST['notifications_bulk_nonce'] ) ? $_POST['notifications_bulk_nonce'] : '';
- $notifications = !empty( $_POST['notifications'] ) ? $_POST['notifications'] : '';
-
- // Bail if no action or no IDs.
- if ( ( ! in_array( $action, array( 'delete', 'read', 'unread' ) ) ) || empty( $notifications ) || empty( $nonce ) ) {
- return false;
- }
-
- // Check the nonce.
- if ( ! wp_verify_nonce( $nonce, 'notifications_bulk_nonce' ) ) {
- bp_core_add_message( __( 'There was a problem managing your notifications.', 'buddypress' ), 'error' );
- return false;
- }
-
- $notifications = wp_parse_id_list( $notifications );
-
- // Delete, mark as read or unread depending on the user 'action'.
- switch ( $action ) {
- case 'delete' :
- foreach ( $notifications as $notification ) {
- bp_notifications_delete_notification( $notification );
- }
- bp_core_add_message( __( 'Notifications deleted.', 'buddypress' ) );
- break;
-
- case 'read' :
- foreach ( $notifications as $notification ) {
- bp_notifications_mark_notification( $notification, false );
- }
- bp_core_add_message( __( 'Notifications marked as read', 'buddypress' ) );
- break;
-
- case 'unread' :
- foreach ( $notifications as $notification ) {
- bp_notifications_mark_notification( $notification, true );
- }
- bp_core_add_message( __( 'Notifications marked as unread.', 'buddypress' ) );
- break;
- }
-
- // Redirect.
- bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/' . bp_current_action() . '/' );
-}
-add_action( 'bp_actions', 'bp_notifications_action_bulk_manage' );
</del></span></pre></div>
<a id="trunksrcbpnotificationsbpnotificationsfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-notifications/bp-notifications-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-notifications/bp-notifications-functions.php 2018-04-02 16:46:29 UTC (rev 11932)
+++ trunk/src/bp-notifications/bp-notifications-functions.php 2018-04-02 17:35:08 UTC (rev 11933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -661,6 +661,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return apply_filters( 'bp_notifications_get_registered_components', $component_names, $active_components );
</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">+/**
+ * Catch and route the 'settings' notifications screen.
+ *
+ * This is currently unused.
+ *
+ * @since 1.9.0
+ */
+function bp_notifications_screen_settings() {}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /** Meta **********************************************************************/
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcbpnotificationsbpnotificationsscreensphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/src/bp-notifications/bp-notifications-screens.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-notifications/bp-notifications-screens.php 2018-04-02 16:46:29 UTC (rev 11932)
+++ trunk/src/bp-notifications/bp-notifications-screens.php 2018-04-02 17:35:08 UTC (rev 11933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,72 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * BuddyPress Notifications 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 NotificationsScreens
- * @since 1.9.0
- */
-
-// Exit if accessed directly.
-defined( 'ABSPATH' ) || exit;
-
-/**
- * Catch and route the 'unread' notifications screen.
- *
- * @since 1.9.0
- */
-function bp_notifications_screen_unread() {
-
- /**
- * Fires right before the loading of the notifications unread screen template file.
- *
- * @since 1.9.0
- */
- do_action( 'bp_notifications_screen_unread' );
-
- /**
- * Filters the template to load for the notifications unread screen.
- *
- * @since 1.9.0
- *
- * @param string $template Path to the notifications unread template to load.
- */
- bp_core_load_template( apply_filters( 'bp_notifications_template_unread', 'members/single/home' ) );
-}
-
-/**
- * Catch and route the 'read' notifications screen.
- *
- * @since 1.9.0
- */
-function bp_notifications_screen_read() {
-
- /**
- * Fires right before the loading of the notifications read screen template file.
- *
- * @since 1.9.0
- */
- do_action( 'bp_notifications_screen_read' );
-
- /**
- * Filters the template to load for the notifications read screen.
- *
- * @since 1.9.0
- *
- * @param string $template Path to the notifications read template to load.
- */
- bp_core_load_template( apply_filters( 'bp_notifications_template_read', 'members/single/home' ) );
-}
-
-/**
- * Catch and route the 'settings' notifications screen.
- *
- * @since 1.9.0
- */
-function bp_notifications_screen_settings() {
-
-}
</del></span></pre></div>
<a id="trunksrcbpnotificationsclassesclassbpnotificationscomponentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-notifications/classes/class-bp-notifications-component.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-notifications/classes/class-bp-notifications-component.php 2018-04-02 16:46:29 UTC (rev 11932)
+++ trunk/src/bp-notifications/classes/class-bp-notifications-component.php 2018-04-02 17:35:08 UTC (rev 11933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,8 +44,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</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><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"> 'adminbar',
</span><span class="cx" style="display: block; padding: 0 10px"> 'template',
</span><span class="cx" style="display: block; padding: 0 10px"> 'functions',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -56,6 +54,38 @@
</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;
+ }
+
+ // Bail if not on a notifications page or logged in.
+ if ( ! bp_is_user_notifications() || ! is_user_logged_in() ) {
+ return;
+ }
+
+ // Actions.
+ if ( bp_is_post_request() ) {
+ require $this->path . 'bp-notifications/actions/bulk-manage.php';
+ } elseif ( bp_is_get_request() ) {
+ require $this->path . 'bp-notifications/actions/delete.php';
+ }
+
+ // Screens.
+ require $this->path . 'bp-notifications/screens/unread.php';
+ if ( bp_is_current_action( 'read' ) ) {
+ require $this->path . 'bp-notifications/screens/read.php';
+ }
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Set up component global data.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.9.0
</span></span></pre></div>
<a id="trunksrcbpnotificationsscreensreadphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-notifications/screens/read.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-notifications/screens/read.php (rev 0)
+++ trunk/src/bp-notifications/screens/read.php 2018-04-02 17:35:08 UTC (rev 11933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,68 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Notifications: User's "Notifications > Read" screen handler
+ *
+ * @package BuddyPress
+ * @subpackage NotificationsScreens
+ * @since 3.0.0
+ */
+
+/**
+ * Catch and route the 'read' notifications screen.
+ *
+ * @since 1.9.0
+ */
+function bp_notifications_screen_read() {
+
+ /**
+ * Fires right before the loading of the notifications read screen template file.
+ *
+ * @since 1.9.0
+ */
+ do_action( 'bp_notifications_screen_read' );
+
+ /**
+ * Filters the template to load for the notifications read screen.
+ *
+ * @since 1.9.0
+ *
+ * @param string $template Path to the notifications read template to load.
+ */
+ bp_core_load_template( apply_filters( 'bp_notifications_template_read', 'members/single/home' ) );
+}
+
+/**
+ * Handle marking single notifications as unread.
+ *
+ * @since 1.9.0
+ *
+ * @return bool
+ */
+function bp_notifications_action_mark_unread() {
+
+ // Bail if not the read screen.
+ if ( ! bp_is_notifications_component() || ! bp_is_current_action( 'read' ) ) {
+ return false;
+ }
+
+ // Get the action.
+ $action = !empty( $_GET['action'] ) ? $_GET['action'] : '';
+ $nonce = !empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : '';
+ $id = !empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : '';
+
+ // Bail if no action or no ID.
+ if ( ( 'unread' !== $action ) || empty( $id ) || empty( $nonce ) ) {
+ return false;
+ }
+
+ // Check the nonce and mark the notification.
+ if ( bp_verify_nonce_request( 'bp_notification_mark_unread_' . $id ) && bp_notifications_mark_notification( $id, true ) ) {
+ bp_core_add_message( __( 'Notification successfully marked unread.', 'buddypress' ) );
+ } else {
+ bp_core_add_message( __( 'There was a problem marking that notification.', 'buddypress' ), 'error' );
+ }
+
+ // Redirect.
+ bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/read/' );
+}
+add_action( 'bp_actions', 'bp_notifications_action_mark_unread' );
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcbpnotificationsscreensunreadphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-notifications/screens/unread.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-notifications/screens/unread.php (rev 0)
+++ trunk/src/bp-notifications/screens/unread.php 2018-04-02 17:35:08 UTC (rev 11933)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,68 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Notifications: User's "Notifications" screen handler
+ *
+ * @package BuddyPress
+ * @subpackage NotificationsScreens
+ * @since 3.0.0
+ */
+
+/**
+ * Catch and route the 'unread' notifications screen.
+ *
+ * @since 1.9.0
+ */
+function bp_notifications_screen_unread() {
+
+ /**
+ * Fires right before the loading of the notifications unread screen template file.
+ *
+ * @since 1.9.0
+ */
+ do_action( 'bp_notifications_screen_unread' );
+
+ /**
+ * Filters the template to load for the notifications unread screen.
+ *
+ * @since 1.9.0
+ *
+ * @param string $template Path to the notifications unread template to load.
+ */
+ bp_core_load_template( apply_filters( 'bp_notifications_template_unread', 'members/single/home' ) );
+}
+
+/**
+ * Handle marking single notifications as read.
+ *
+ * @since 1.9.0
+ *
+ * @return bool
+ */
+function bp_notifications_action_mark_read() {
+
+ // Bail if not the unread screen.
+ if ( ! bp_is_notifications_component() || ! bp_is_current_action( 'unread' ) ) {
+ return false;
+ }
+
+ // Get the action.
+ $action = !empty( $_GET['action'] ) ? $_GET['action'] : '';
+ $nonce = !empty( $_GET['_wpnonce'] ) ? $_GET['_wpnonce'] : '';
+ $id = !empty( $_GET['notification_id'] ) ? $_GET['notification_id'] : '';
+
+ // Bail if no action or no ID.
+ if ( ( 'read' !== $action ) || empty( $id ) || empty( $nonce ) ) {
+ return false;
+ }
+
+ // Check the nonce and mark the notification.
+ if ( bp_verify_nonce_request( 'bp_notification_mark_read_' . $id ) && bp_notifications_mark_notification( $id, false ) ) {
+ bp_core_add_message( __( 'Notification successfully marked read.', 'buddypress' ) );
+ } else {
+ bp_core_add_message( __( 'There was a problem marking that notification.', 'buddypress' ), 'error' );
+ }
+
+ // Redirect.
+ bp_core_redirect( bp_displayed_user_domain() . bp_get_notifications_slug() . '/unread/' );
+}
+add_action( 'bp_actions', 'bp_notifications_action_mark_read' );
</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 16:46:29 UTC (rev 11932)
+++ trunk/tests/phpunit/includes/loader.php 2018-04-02 17:35:08 UTC (rev 11933)
</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', 'friends', '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', 'notifications', '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>