<!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][6584] trunk/bp-core/admin/bp-core-functions.php: First pass at contextual help pages.</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/6584">6584</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2012-12-10 09:02:49 +0000 (Mon, 10 Dec 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>First pass at contextual help pages. Props modemlooper. Fixes <a href="http://buddypress.trac.wordpress.org/ticket/4613">#4613</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcoreadminbpcorefunctionsphp">trunk/bp-core/admin/bp-core-functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcoreadminbpcorefunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/admin/bp-core-functions.php (6583 => 6584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/admin/bp-core-functions.php        2012-12-10 08:47:07 UTC (rev 6583)
+++ trunk/bp-core/admin/bp-core-functions.php        2012-12-10 09:02:49 UTC (rev 6584)
</span><span class="lines">@@ -88,14 +88,14 @@
</span><span class="cx">         $settings_url = add_query_arg( 'page', 'bp-components', $url ); ?&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;div class=&quot;wrap&quot;&gt;
</span><del>-                &lt;?php screen_icon( 'buddypress'); ?&gt;
</del><ins>+                &lt;?php screen_icon( 'buddypress' ); ?&gt;
</ins><span class="cx">                 &lt;h2&gt;&lt;?php _e( 'Why have all my BuddyPress menus disappeared?', 'buddypress' ); ?&gt;&lt;/h2&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;p&gt;&lt;?php _e( &quot;Don't worry! We've moved the BuddyPress options into more convenient and easier to find locations. You're seeing this page because you are running a legacy BuddyPress plugin which has not been updated.&quot;, 'buddypress' ); ?&gt;&lt;/p&gt;
</span><span class="cx">                 &lt;p&gt;&lt;?php printf( __( 'Components, Pages, Settings, and Forums, have been moved to &lt;a href=&quot;%s&quot;&gt;Settings &amp;gt; BuddyPress&lt;/a&gt;. Profile Fields has been moved into the &lt;a href=&quot;%s&quot;&gt;Users&lt;/a&gt; menu.', 'buddypress' ), esc_url( $settings_url ), bp_get_admin_url( 'users.php?page=bp-profile-setup' ) ); ?&gt;&lt;/p&gt;
</span><span class="cx">         &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;?php
</del><ins>+        &lt;?php
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /** Notices *******************************************************************/
</span><span class="lines">@@ -126,13 +126,13 @@
</span><span class="cx"> 
</span><span class="cx">         // Show the messages
</span><span class="cx">         if ( !empty( $bp-&gt;admin-&gt;notices ) ) {
</span><del>-        ?&gt;
</del><ins>+                ?&gt;
</ins><span class="cx">                 &lt;div id=&quot;message&quot; class=&quot;updated fade&quot;&gt;
</span><del>-                        &lt;?php foreach( $bp-&gt;admin-&gt;notices as $notice ) : ?&gt;
</del><ins>+                &lt;?php foreach ( $bp-&gt;admin-&gt;notices as $notice ) : ?&gt;
</ins><span class="cx">                                 &lt;p&gt;&lt;?php echo $notice ?&gt;&lt;/p&gt;
</span><del>-                        &lt;?php endforeach ?&gt;
</del><ins>+                &lt;?php endforeach ?&gt;
</ins><span class="cx">                 &lt;/div&gt;
</span><del>-        &lt;?php
</del><ins>+                &lt;?php
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> add_action( 'admin_notices',         'bp_core_print_admin_notices' );
</span><span class="lines">@@ -179,7 +179,7 @@
</span><span class="cx"> function bp_do_activation_redirect() {
</span><span class="cx"> 
</span><span class="cx">         // Bail if no activation redirect
</span><del>-    if ( ! get_transient( '_bp_activation_redirect' ) )
</del><ins>+        if ( ! get_transient( '_bp_activation_redirect' ) )
</ins><span class="cx">                 return;
</span><span class="cx"> 
</span><span class="cx">         // Delete the redirect transient
</span><span class="lines">@@ -211,7 +211,7 @@
</span><span class="cx">         // Setup core admin tabs
</span><span class="cx">         $tabs = array(
</span><span class="cx">                 '0' =&gt; array(
</span><del>-                        'href' =&gt; bp_get_admin_url( add_query_arg( array( 'page' =&gt; 'bp-components'    ), 'admin.php' ) ),
</del><ins>+                        'href' =&gt; bp_get_admin_url( add_query_arg( array( 'page' =&gt; 'bp-components' ), 'admin.php' ) ),
</ins><span class="cx">                         'name' =&gt; __( 'Components', 'buddypress' )
</span><span class="cx">                 ),
</span><span class="cx">                 '1' =&gt; array(
</span><span class="lines">@@ -219,13 +219,13 @@
</span><span class="cx">                         'name' =&gt; __( 'Pages', 'buddypress' )
</span><span class="cx">                 ),
</span><span class="cx">                 '2' =&gt; array(
</span><del>-                        'href' =&gt; bp_get_admin_url( add_query_arg( array( 'page' =&gt; 'bp-settings'      ), 'admin.php' ) ),
-                        'name' =&gt; __( 'Settings',   'buddypress' )
</del><ins>+                        'href' =&gt; bp_get_admin_url( add_query_arg( array( 'page' =&gt; 'bp-settings' ), 'admin.php' ) ),
+                        'name' =&gt; __( 'Settings', 'buddypress' )
</ins><span class="cx">                 )
</span><span class="cx">         );
</span><span class="cx"> 
</span><span class="cx">         // Loop through tabs and build navigation
</span><del>-        foreach( array_values( $tabs ) as $tab_data ) {
</del><ins>+        foreach ( array_values( $tabs ) as $tab_data ) {
</ins><span class="cx">                 $is_current = (bool) ( $tab_data['name'] == $active_tab );
</span><span class="cx">                 $tab_class  = $is_current ? $active_class : $idle_class;
</span><span class="cx">                 $tabs_html .= '&lt;a href=&quot;' . $tab_data['href'] . '&quot; class=&quot;' . $tab_class . '&quot;&gt;' . $tab_data['name'] . '&lt;/a&gt;';
</span><span class="lines">@@ -237,3 +237,125 @@
</span><span class="cx">         // Do other fun things
</span><span class="cx">         do_action( 'bp_admin_tabs' );
</span><span class="cx"> }
</span><ins>+
+/** Help **********************************************************************/
+
+/**
+ * adds contextual help to BuddyPress admin pages
+ *
+ * @since BuddyPress (1.7)
+ * @todo Make this part of the BP_Component class and split into each component
+ */
+function bp_core_add_contextual_help( $screen = '' ) {
+
+        $screen = get_current_screen();
+
+        switch ( $screen-&gt;id ) {
+
+                // Compontent page
+                case 'settings_page_bp-components' :
+
+                        // help tabs
+                        $screen-&gt;add_help_tab( array(
+                                'id'      =&gt; 'bp-comp-overview',
+                                'title'   =&gt; __( 'Overview' ),
+                                'content' =&gt; bp_core_add_contextual_help_content( 'bp-comp-overview' ),
+                        ) );
+
+                        // help panel - sidebar links
+                        $screen-&gt;set_help_sidebar(
+                                '&lt;p&gt;&lt;strong&gt;' . __( 'For more information:', 'buddypress' ) . '&lt;/strong&gt;&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( '&lt;a href=&quot;http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-components&quot;&gt;Managing Components&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( '&lt;a href=&quot;http://buddypress.org/support/&quot;&gt;Support Forums&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;'
+                        );
+                        break;
+
+                // Pages page
+                case 'settings_page_bp-page-settings' :
+
+                        // Help tabs
+                        $screen-&gt;add_help_tab( array(
+                                'id' =&gt; 'bp-page-overview',
+                                'title' =&gt; __( 'Overview' ),
+                                'content' =&gt; bp_core_add_contextual_help_content( 'bp-page-overview' ),
+                        ) );
+
+                        // Help panel - sidebar links
+                        $screen-&gt;set_help_sidebar(
+                                '&lt;p&gt;&lt;strong&gt;' . __( 'For more information:', 'buddypress' ) . '&lt;/strong&gt;&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( '&lt;a href=&quot;http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-pages&quot;&gt;Managing Pages&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( '&lt;a href=&quot;http://buddypress.org/support/&quot;&gt;Support Forums&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;'
+                        );
+
+                        break;
+
+                // Settings page
+                case 'settings_page_bp-settings' :
+
+                        // Help tabs
+                        $screen-&gt;add_help_tab( array(
+                                'id'      =&gt; 'bp-settings-overview',
+                                'title'   =&gt; __( 'Overview' ),
+                                'content' =&gt; bp_core_add_contextual_help_content( 'bp-settings-overview' ),
+                        ) );
+
+                        // Help panel - sidebar links
+                        $screen-&gt;set_help_sidebar(
+                                '&lt;p&gt;&lt;strong&gt;' . __( 'For more information:', 'buddypress' ) . '&lt;/strong&gt;&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( '&lt;a href=&quot;http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-settings&quot;&gt;Managing Settings&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( '&lt;a href=&quot;http://buddypress.org/support/&quot;&gt;Support Forums&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;'
+                        );
+
+                        break;
+
+                // Profile fields page
+                case 'users_page_bp-profile-overview' :
+
+                        // Help tabs
+                        $screen-&gt;add_help_tab( array(
+                                'id'      =&gt; 'bp-profile-overview',
+                                'title'   =&gt; __( 'Overview' ),
+                                'content' =&gt; bp_core_add_contextual_help_content( 'bp-profile-overview' ),
+                        ) );
+
+                        // Help panel - sidebar links
+                        $screen-&gt;set_help_sidebar(
+                                '&lt;p&gt;&lt;strong&gt;' . __( 'For more information:', 'buddypress' ) . '&lt;/strong&gt;&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( '&lt;a href=&quot;http://codex.buddypress.org/getting-started/configure-buddypress-components/#users-profile-fields&quot;&gt;Managing Profile Fields&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;' .
+                                '&lt;p&gt;' . __( '&lt;a href=&quot;http://buddypress.org/support/&quot;&gt;Support Forums&lt;/a&gt;', 'buddypress' ) . '&lt;/p&gt;'
+                        );
+
+                        break;
+        }
+}
+add_action( 'contextual_help', 'bp_core_add_contextual_help' );
+
+/**
+ * renders contextual help content to contextual help tabs
+ *
+ * @since BuddyPress (1.7)
+ */
+function bp_core_add_contextual_help_content( $tab = '' ) {
+
+        switch ( $tab ) {
+                case 'bp-comp-overview' :
+                        return '&lt;p&gt;' . __( 'By default, all BuddyPress components are enabled. You can selectively disable any of the components by using the form. Your BuddyPress installation will continue to function. However, the features of the disabled components will no longer be accessible to anyone using the site.', 'buddypress' ) . '&lt;/p&gt;';
+                        break;
+
+                case'bp-page-overview' :
+                        return '&lt;p&gt;' . __( 'BuddyPress Components use WordPress Pages for their root directory/archive pages. Here you can change the page associations for each active component.', 'buddypress' ) . '&lt;/p&gt;';
+                        break;
+
+                case 'bp-settings-overview' :
+                        return '&lt;p&gt;' . __( 'Extra configuration settings.', 'buddypress' ) . '&lt;/p&gt;';
+                        break;
+
+                case 'bp-profile-overview' :
+                        return '&lt;p&gt;' . __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.&lt;/br&gt;&lt;/br&gt;Note: Any fields in the first group will appear on the signup page.', 'buddypress' ) . '&lt;/p&gt;';
+                        break;
+
+                default:
+                        return false;
+                        break;
+        }
+}
</ins></span></pre>
</div>
</div>

</body>
</html>