<!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][5487] trunk/bp-activity/bp-activity-admin.php: Add a bunch of actions and filters for plugin authors to the Activity Admin screen.</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 { 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, #logmsg > ol { margin-left: 0; 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">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/5487">5487</a></dd>
<dt>Author</dt> <dd>djpaul</dd>
<dt>Date</dt> <dd>2011-12-10 19:24:05 +0000 (Sat, 10 Dec 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add a bunch of actions and filters for plugin authors to the Activity Admin screen. See <a href="http://buddypress.trac.wordpress.org/ticket/3660">#3660</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityadminphp">trunk/bp-activity/bp-activity-admin.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivityadminphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-admin.php (5486 => 5487)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-admin.php        2011-12-10 18:31:17 UTC (rev 5486)
+++ trunk/bp-activity/bp-activity-admin.php        2011-12-10 19:24:05 UTC (rev 5487)
</span><span class="lines">@@ -151,7 +151,6 @@
</span><span class="cx"> }
</span><span class="cx"> add_filter( 'default_hidden_meta_boxes', 'bp_activity_admin_edit_hidden_metaboxes', 10, 2 );
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> /**
</span><span class="cx">  * Set up the admin page before any output is sent. Register contextual help and screen options for this admin page.
</span><span class="cx">  *
</span><span class="lines">@@ -168,6 +167,9 @@
</span><span class="cx">         // Decide whether to load the index or edit screen
</span><span class="cx">         $doaction = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
</span><span class="cx"> 
</span><ins>+        // Call an action for plugins to hook in early
+        do_action( 'bp_activity_admin_load', $doaction );
+
</ins><span class="cx">         // Edit screen
</span><span class="cx">         if ( 'edit' == $doaction &amp;&amp; ! empty( $_GET['aid'] ) ) {
</span><span class="cx">                 // columns screen option
</span><span class="lines">@@ -261,6 +263,9 @@
</span><span class="cx">                 // Get activity IDs
</span><span class="cx">                 $activity_ids = array_map( 'absint', (array) $_REQUEST['aid'] );
</span><span class="cx"> 
</span><ins>+                // Call a filter for plugins to modify the requested activities to load
+                $activity_ids = apply_filters( 'bp_activity_admin_action_activity_ids', $activity_ids );
+
</ins><span class="cx">                 // Is this a bulk request?
</span><span class="cx">                 if ( 'bulk_' == substr( $doaction, 0, 5 ) &amp;&amp; ! empty( $_REQUEST['aid'] ) ) {
</span><span class="cx">                         // Check this is a valid form submission
</span><span class="lines">@@ -341,6 +346,9 @@
</span><span class="cx">                         unset( $activity );
</span><span class="cx">                 }
</span><span class="cx"> 
</span><ins>+                // Call actions for plugins to do something before we redirect
+                do_action( 'bp_activity_admin_action_after', array( $spammed, $unspammed, $deleted, $error ), $redirect_to, $activity_ids );
+
</ins><span class="cx">                 // Add arguments to the redirect URL so that on page reload, we can easily display what we've just done.
</span><span class="cx">                 if ( $spammed )
</span><span class="cx">                         $redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to );
</span><span class="lines">@@ -356,7 +364,7 @@
</span><span class="cx">                         $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );
</span><span class="cx"> 
</span><span class="cx">                 // Redirect
</span><del>-                wp_redirect( $redirect_to );
</del><ins>+                wp_redirect( apply_filters( 'bp_activity_admin_action_redirect', $redirect_to ) );
</ins><span class="cx">                 exit;
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -476,6 +484,9 @@
</span><span class="cx">                 if ( false === $result )
</span><span class="cx">                         $error = $activity-&gt;id;
</span><span class="cx"> 
</span><ins>+                // Call actions for plugins to do something before we redirect
+                do_action_ref_array( 'bp_activity_admin_edit_after', array( &amp;$activity, $error ) );
+
</ins><span class="cx">                 // If an error occured, pass back the activity ID that failed
</span><span class="cx">                 if ( $error )
</span><span class="cx">                         $redirect_to = add_query_arg( 'error', (int) $error, $redirect_to );
</span><span class="lines">@@ -483,7 +494,7 @@
</span><span class="cx">                         $redirect_to = add_query_arg( 'updated', (int) $activity-&gt;id, $redirect_to );
</span><span class="cx"> 
</span><span class="cx">                 // Redirect
</span><del>-                wp_redirect( $redirect_to );
</del><ins>+                wp_redirect( apply_filters( 'bp_activity_admin_edit_redirect', $redirect_to ) );
</ins><span class="cx">                 exit;
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -547,6 +558,9 @@
</span><span class="cx">         // Construct URL for form
</span><span class="cx">         $form_url = remove_query_arg( array( 'action', 'deleted', 'error', 'spammed', 'unspammed', ), $_SERVER['REQUEST_URI'] );
</span><span class="cx">         $form_url = add_query_arg( 'action', 'save', $form_url );
</span><ins>+
+        // Call an action for plugins to modify the activity before we display the edit form
+        do_action_ref_array( 'bp_activity_admin_edit', array( &amp;$activity ) );
</ins><span class="cx"> ?&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;div class=&quot;wrap&quot;&gt;
</span><span class="lines">@@ -770,6 +784,9 @@
</span><span class="cx"> 
</span><span class="cx">         // Prepare the activity items for display
</span><span class="cx">         $bp_activity_list_table-&gt;prepare_items();
</span><ins>+
+        // Call an action for plugins to modify the activity before we display the edit form
+        do_action( 'bp_activity_admin_index', $messages );
</ins><span class="cx"> ?&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;div class=&quot;wrap&quot;&gt;
</span><span class="lines">@@ -791,6 +808,7 @@
</span><span class="cx">                         &lt;div id=&quot;moderated&quot; class=&quot;&lt;?php echo ( ! empty( $_REQUEST['error'] ) ) ? 'error' : 'updated'; ?&gt;&quot;&gt;&lt;p&gt;&lt;?php echo implode( &quot;&lt;br/&gt;\n&quot;, $messages ); ?&gt;&lt;/p&gt;&lt;/div&gt;
</span><span class="cx">                 &lt;?php endif; ?&gt;
</span><span class="cx"> 
</span><ins>+                &lt;?php // Display each activity on its own row ?&gt;
</ins><span class="cx">                 &lt;?php $bp_activity_list_table-&gt;views(); ?&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;form id=&quot;bp-activities-form&quot; action=&quot;&quot; method=&quot;get&quot;&gt;
</span><span class="lines">@@ -799,6 +817,7 @@
</span><span class="cx">                         &lt;?php $bp_activity_list_table-&gt;display(); ?&gt;
</span><span class="cx">                 &lt;/form&gt;
</span><span class="cx"> 
</span><ins>+                &lt;?php // This markup is used for the reply form ?&gt;
</ins><span class="cx">                 &lt;table style=&quot;display: none;&quot;&gt;
</span><span class="cx">                         &lt;tr id=&quot;bp-activities-container&quot; style=&quot;display: none;&quot;&gt;
</span><span class="cx">                                 &lt;td colspan=&quot;4&quot;&gt;
</span><span class="lines">@@ -1057,6 +1076,8 @@
</span><span class="cx">                 &lt;ul class=&quot;subsubsub&quot;&gt;
</span><span class="cx">                         &lt;li class=&quot;all&quot;&gt;&lt;a href=&quot;&lt;?php echo esc_attr( esc_url( $redirect_to ) ); ?&gt;&quot; class=&quot;&lt;?php if ( 'spam' != $this-&gt;view ) echo 'current'; ?&gt;&quot;&gt;&lt;?php _e( 'All', 'buddypress' ); ?&gt;&lt;/a&gt; |&lt;/li&gt;
</span><span class="cx">                         &lt;li class=&quot;spam&quot;&gt;&lt;a href=&quot;&lt;?php echo esc_attr( esc_url( add_query_arg( 'activity_status', 'spam', $redirect_to ) ) ); ?&gt;&quot; class=&quot;&lt;?php if ( 'spam' == $this-&gt;view ) echo 'current'; ?&gt;&quot;&gt;&lt;?php printf( __( 'Spam &lt;span class=&quot;count&quot;&gt;(%s)&lt;/span&gt;', 'buddypress' ), number_format_i18n( $this-&gt;spam_count ) ); ?&gt;&lt;/a&gt;&lt;/li&gt;
</span><ins>+
+                        &lt;?php do_action( 'bp_activity_list_table_get_views', $redirect_to, $this-&gt;view ); ?&gt;
</ins><span class="cx">                 &lt;/ul&gt;
</span><span class="cx">         &lt;?php
</span><span class="cx">         }
</span><span class="lines">@@ -1073,7 +1094,7 @@
</span><span class="cx">                 $actions['bulk_ham']    = __( 'Not Spam', 'buddypress' );
</span><span class="cx">                 $actions['bulk_delete'] = __( 'Delete Permanently', 'buddypress' );
</span><span class="cx"> 
</span><del>-                return $actions;
</del><ins>+                return apply_filters( 'bp_activity_list_table_get_bulk_actions', $actions );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span></span></pre>
</div>
</div>

</body>
</html>