Skip to:
Content

BuddyPress.org

Changeset 9429


Ignore:
Timestamp:
02/04/2015 02:38:10 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Ensure both "About" admin screens always have the same descriptive text and navigation.

Introduces static and helper methods for:

  • Determining is_new_install
  • Getting user-friendly version number
  • Outputting welcome text
  • Outputting tab navigation

Fixes #6182.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-admin.php

    r9421 r9429  
    188188
    189189        // Bail if user cannot moderate
    190         if ( ! bp_current_user_can( 'manage_options' ) )
     190        if ( ! bp_current_user_can( 'manage_options' ) ) {
    191191            return;
     192        }
    192193
    193194        // About
     
    351352            add_settings_section( 'bp_groups',        __( 'Groups Settings',  'buddypress' ), 'bp_admin_setting_callback_groups_section',   'buddypress'              );
    352353
    353             if ( empty( $avatar_setting ) )
     354            if ( empty( $avatar_setting ) ) {
    354355                $avatar_setting = 'bp_groups';
     356            }
    355357
    356358            // Allow subscriptions setting
     
    432434
    433435        // Return normal links if not BuddyPress
    434         if ( plugin_basename( buddypress()->basename ) != $file )
     436        if ( plugin_basename( buddypress()->basename ) != $file ) {
    435437            return $links;
     438        }
    436439
    437440        // Add a few links to the existing links array
     
    487490     */
    488491    public function about_screen() {
    489         $is_new_install = ! empty( $_GET['is_new_install'] );
    490         $welcome_text   = ( $is_new_install )
    491             ? __( 'Thank you for installing BuddyPress! BuddyPress %s gives you the components you need to turn your WordPress powered site into a thriving membership community.', 'buddypress' )
    492             : __( 'BuddyPress %s comes with a bunch of great improvements we think you’re really going to like.', 'buddypress' );
    493 
    494         list( $display_version ) = explode( '-', bp_get_version() ); ?>
     492    ?>
    495493
    496494        <div class="wrap about-wrap">
    497             <h1><?php printf( __( 'Welcome to BuddyPress %s', 'buddypress' ), $display_version ); ?></h1>
    498             <div class="about-text">
    499                 <?php printf( $welcome_text, $display_version ); ?>
    500             </div>
    501 
    502             <div class="bp-badge"></div>
    503 
    504             <h2 class="nav-tab-wrapper">
    505                 <a class="nav-tab nav-tab-active" href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-about' ), 'index.php' ) ) ); ?>">
    506                     <?php _e( 'What&#8217;s New', 'buddypress' ); ?>
    507                 </a><a class="nav-tab" href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'index.php' ) ) ); ?>">
    508                     <?php _e( 'Credits', 'buddypress' ); ?>
    509                 </a>
    510             </h2>
    511 
    512             <?php if ( $is_new_install ) : ?>
     495
     496            <?php self::welcome_text(); ?>
     497
     498            <?php self::tab_navigation( __METHOD__ ); ?>
     499
     500            <?php if ( self::is_new_install() ) : ?>
    513501
    514502                <div id="welcome-panel" class="welcome-panel">
     
    644632     */
    645633    public function credits_screen() {
    646 
    647         $is_new_install = ! empty( $_GET['is_new_install'] );
    648 
    649         list( $display_version ) = explode( '-', bp_get_version() ); ?>
     634    ?>
    650635
    651636        <div class="wrap about-wrap">
    652             <h1><?php printf( __( 'Welcome to BuddyPress %s', 'buddypress' ), $display_version ); ?></h1>
    653             <div class="about-text">
    654                 <?php if ( $is_new_install ) : ?>
    655                     <?php printf( __( 'Thank you for installing BuddyPress! BuddyPress %s is our most streamlined and easy-to-use release to date, and we think you&#8217;re going to love it.', 'buddypress' ), $display_version ); ?>
    656                 <?php else : ?>
    657                     <?php printf( __( 'Howdy. BuddyPress %s is our most streamlined and easy-to-use release to date, and we think you&#8217;re going to love it.', 'buddypress' ), $display_version ); ?>
    658                 <?php endif; ?>
    659             </div>
    660 
    661             <div class="bp-badge"></div>
    662 
    663             <h2 class="nav-tab-wrapper">
    664                 <a class="nav-tab" href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-about' ), 'index.php' ) ) ); ?>">
    665                     <?php _e( 'What&#8217;s New', 'buddypress' ); ?>
    666                 </a><a class="nav-tab nav-tab-active" href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'index.php' ) ) ); ?>">
    667                     <?php _e( 'Credits', 'buddypress' ); ?>
    668                 </a>
    669             </h2>
    670 
    671             <p class="about-description"><?php _e( 'BuddyPress is created by a worldwide network of friendly folks.', 'buddypress' ); ?></p>
     637
     638            <?php self::welcome_text(); ?>
     639
     640            <?php self::tab_navigation( __METHOD__ ); ?>
     641
     642            <p class="about-description"><?php _e( 'BuddyPress is created by a worldwide network of friendly folks like these.', 'buddypress' ); ?></p>
    672643
    673644            <h4 class="wp-people-group"><?php _e( 'Project Leaders', 'buddypress' ); ?></h4>
     
    743714            </ul>
    744715
    745             <h4 class="wp-people-group"><?php printf( __( 'Contributors to BuddyPress %s', 'buddypress' ), $display_version ); ?></h4>
     716            <h4 class="wp-people-group"><?php printf( esc_html__( 'Contributors to BuddyPress %s', 'buddypress' ), self::display_version() ); ?></h4>
    746717            <p class="wp-credits-list">
    747718                <a href="https://profiles.wordpress.org/andemann/">andemann</a>,
     
    803774        <?php
    804775    }
     776
     777    /**
     778     * Output welcome text and badge for What's New and Credits pages
     779     *
     780     * @since BuddyPress (2.2.0)
     781     */
     782    public static function welcome_text() {
     783
     784        // Switch welcome text based on whether this is a new installation or not
     785        $welcome_text = ( self::is_new_install() )
     786            ? __( 'Thank you for installing BuddyPress! BuddyPress %s gives you the components you need to turn your WordPress powered site into a thriving membership community.', 'buddypress' )
     787            : __( 'BuddyPress %s comes with a bunch of great improvements we think you&#8217;re really going to like.', 'buddypress' );
     788
     789        ?>
     790
     791        <h1><?php printf( esc_html__( 'Welcome to BuddyPress %s', 'buddypress' ), self::display_version() ); ?></h1>
     792        <div class="about-text">
     793            <?php printf( $welcome_text, self::display_version() ); ?>
     794        </div>
     795
     796        <div class="bp-badge"></div>
     797
     798        <?php
     799    }
     800
     801    /**
     802     * Output tab navigation for `What's New` and `Credits` pages
     803     *
     804     * @since BuddyPress (2.2.0)
     805     * @param string $tab
     806     */
     807    public static function tab_navigation( $tab = 'whats_new' ) {
     808    ?>
     809
     810        <h2 class="nav-tab-wrapper">
     811            <a class="nav-tab <?php if ( 'BP_Admin::about_screen' === $tab ) : ?>nav-tab-active<?php endif; ?>" href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-about' ), 'index.php' ) ) ); ?>">
     812                <?php esc_html_e( 'What&#8217;s New', 'buddypress' ); ?>
     813            </a><a class="nav-tab <?php if ( 'BP_Admin::credits_screen' === $tab ) : ?>nav-tab-active<?php endif; ?>" href="<?php echo esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'index.php' ) ) ); ?>">
     814                <?php esc_html_e( 'Credits', 'buddypress' ); ?>
     815            </a>
     816        </h2>
     817
     818    <?php
     819    }
     820
     821    /** Helpers ***************************************************************/
     822
     823    /**
     824     * Return true/false based on whether a query argument is set
     825     *
     826     * @see bp_do_activation_redirect()
     827     *
     828     * @since BuddyPress (2.2.0)
     829     * @return bool
     830     */
     831    public static function is_new_install() {
     832        return (bool) isset( $_GET['is_new_install'] );
     833    }
     834
     835    /**
     836     * Return a user-friendly version-number string, for use in translations
     837     *
     838     * @since BuddyPress (2.2.0)
     839     * @return string
     840     */
     841    public static function display_version() {
     842
     843        // Use static variable to prevent recalculations
     844        static $display = '';
     845
     846        // Only calculate on first run
     847        if ( '' === $display ) {
     848
     849            // Get current version
     850            $version = bp_get_version();
     851
     852            // Check for prerelease hyphen
     853            $pre     = strpos( $version, '-' );
     854
     855            // Strip prerelease suffix
     856            $display = ( false !== $pre )
     857                ? substr( $version, 0, $pre )
     858                : $version;
     859        }
     860
     861        // Done!
     862        return $display;
     863    }
    805864}
    806865endif; // class_exists check
Note: See TracChangeset for help on using the changeset viewer.