<!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 ); ?>
</span><span class="cx">
</span><span class="cx">         <div class="wrap">
</span><del>-                <?php screen_icon( 'buddypress'); ?>
</del><ins>+                <?php screen_icon( 'buddypress' ); ?>
</ins><span class="cx">                 <h2><?php _e( 'Why have all my BuddyPress menus disappeared?', 'buddypress' ); ?></h2>
</span><span class="cx">
</span><span class="cx">                 <p><?php _e( "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.", 'buddypress' ); ?></p>
</span><span class="cx">                 <p><?php printf( __( 'Components, Pages, Settings, and Forums, have been moved to <a href="%s">Settings &gt; BuddyPress</a>. Profile Fields has been moved into the <a href="%s">Users</a> menu.', 'buddypress' ), esc_url( $settings_url ), bp_get_admin_url( 'users.php?page=bp-profile-setup' ) ); ?></p>
</span><span class="cx">         </div>
</span><span class="cx">
</span><del>-<?php
</del><ins>+        <?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->admin->notices ) ) {
</span><del>-        ?>
</del><ins>+                ?>
</ins><span class="cx">                 <div id="message" class="updated fade">
</span><del>-                        <?php foreach( $bp->admin->notices as $notice ) : ?>
</del><ins>+                <?php foreach ( $bp->admin->notices as $notice ) : ?>
</ins><span class="cx">                                 <p><?php echo $notice ?></p>
</span><del>-                        <?php endforeach ?>
</del><ins>+                <?php endforeach ?>
</ins><span class="cx">                 </div>
</span><del>-        <?php
</del><ins>+                <?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' => array(
</span><del>-                        'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ),
</del><ins>+                        'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ),
</ins><span class="cx">                         'name' => __( 'Components', 'buddypress' )
</span><span class="cx">                 ),
</span><span class="cx">                 '1' => array(
</span><span class="lines">@@ -219,13 +219,13 @@
</span><span class="cx">                         'name' => __( 'Pages', 'buddypress' )
</span><span class="cx">                 ),
</span><span class="cx">                 '2' => array(
</span><del>-                        'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ),
-                        'name' => __( 'Settings', 'buddypress' )
</del><ins>+                        'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ),
+                        'name' => __( '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 .= '<a href="' . $tab_data['href'] . '" class="' . $tab_class . '">' . $tab_data['name'] . '</a>';
</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->id ) {
+
+                // Compontent page
+                case 'settings_page_bp-components' :
+
+                        // help tabs
+                        $screen->add_help_tab( array(
+                                'id' => 'bp-comp-overview',
+                                'title' => __( 'Overview' ),
+                                'content' => bp_core_add_contextual_help_content( 'bp-comp-overview' ),
+                        ) );
+
+                        // help panel - sidebar links
+                        $screen->set_help_sidebar(
+                                '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
+                                '<p>' . __( '<a href="http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-components">Managing Components</a>', 'buddypress' ) . '</p>' .
+                                '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
+                        );
+                        break;
+
+                // Pages page
+                case 'settings_page_bp-page-settings' :
+
+                        // Help tabs
+                        $screen->add_help_tab( array(
+                                'id' => 'bp-page-overview',
+                                'title' => __( 'Overview' ),
+                                'content' => bp_core_add_contextual_help_content( 'bp-page-overview' ),
+                        ) );
+
+                        // Help panel - sidebar links
+                        $screen->set_help_sidebar(
+                                '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
+                                '<p>' . __( '<a href="http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-pages">Managing Pages</a>', 'buddypress' ) . '</p>' .
+                                '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
+                        );
+
+                        break;
+
+                // Settings page
+                case 'settings_page_bp-settings' :
+
+                        // Help tabs
+                        $screen->add_help_tab( array(
+                                'id' => 'bp-settings-overview',
+                                'title' => __( 'Overview' ),
+                                'content' => bp_core_add_contextual_help_content( 'bp-settings-overview' ),
+                        ) );
+
+                        // Help panel - sidebar links
+                        $screen->set_help_sidebar(
+                                '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
+                                '<p>' . __( '<a href="http://codex.buddypress.org/getting-started/configure-buddypress-components/#settings-buddypress-settings">Managing Settings</a>', 'buddypress' ) . '</p>' .
+                                '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
+                        );
+
+                        break;
+
+                // Profile fields page
+                case 'users_page_bp-profile-overview' :
+
+                        // Help tabs
+                        $screen->add_help_tab( array(
+                                'id' => 'bp-profile-overview',
+                                'title' => __( 'Overview' ),
+                                'content' => bp_core_add_contextual_help_content( 'bp-profile-overview' ),
+                        ) );
+
+                        // Help panel - sidebar links
+                        $screen->set_help_sidebar(
+                                '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
+                                '<p>' . __( '<a href="http://codex.buddypress.org/getting-started/configure-buddypress-components/#users-profile-fields">Managing Profile Fields</a>', 'buddypress' ) . '</p>' .
+                                '<p>' . __( '<a href="http://buddypress.org/support/">Support Forums</a>', 'buddypress' ) . '</p>'
+                        );
+
+                        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 '<p>' . __( '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' ) . '</p>';
+                        break;
+
+                case'bp-page-overview' :
+                        return '<p>' . __( 'BuddyPress Components use WordPress Pages for their root directory/archive pages. Here you can change the page associations for each active component.', 'buddypress' ) . '</p>';
+                        break;
+
+                case 'bp-settings-overview' :
+                        return '<p>' . __( 'Extra configuration settings.', 'buddypress' ) . '</p>';
+                        break;
+
+                case 'bp-profile-overview' :
+                        return '<p>' . __( 'Your users will distinguish themselves through their profile page. Create relevant profile fields that will show on each users profile.</br></br>Note: Any fields in the first group will appear on the signup page.', 'buddypress' ) . '</p>';
+                        break;
+
+                default:
+                        return false;
+                        break;
+        }
+}
</ins></span></pre>
</div>
</div>
</body>
</html>