Skip to:
Content

BuddyPress.org

Changeset 13138


Ignore:
Timestamp:
11/06/2021 04:46:47 PM (4 years ago)
Author:
imath
Message:

BP Admin Tabs: improve the Pages settings screen display

This commit also makes sure the BP Admin Tabs are well displayed in Multisite configs when BuddyPress is network activated.

Props oztaser

Fixes #8588

Location:
trunk/src/bp-core
Files:
2 edited

Legend:

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

    r13137 r13138  
    180180    $static_pages = bp_core_admin_get_static_pages();
    181181
    182     if ( !empty( $static_pages ) ) : ?>
     182    if ( ! empty( $static_pages ) ) : ?>
    183183
    184184        <h3><?php esc_html_e( 'Registration', 'buddypress' ); ?></h3>
     
    189189                <?php esc_html_e( 'These pages will only be reachable by users who are not logged in.', 'buddypress' ); ?>
    190190            </p>
     191
     192            <table class="form-table">
     193                <tbody>
     194
     195                    <?php foreach ( $static_pages as $name => $label ) : ?>
     196
     197                        <tr valign="top">
     198                            <th scope="row">
     199                                <label for="bp_pages[<?php echo esc_attr( $name ) ?>]"><?php echo esc_html( $label ) ?></label>
     200                            </th>
     201
     202                            <td>
     203
     204                                <?php if ( ! bp_is_root_blog() ) switch_to_blog( bp_get_root_blog_id() ); ?>
     205
     206                                <?php echo wp_dropdown_pages( array(
     207                                    'name'             => 'bp_pages[' . esc_attr( $name ) . ']',
     208                                    'echo'             => false,
     209                                    'show_option_none' => __( '- None -', 'buddypress' ),
     210                                    'selected'         => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false
     211                                ) ) ?>
     212
     213                                <?php if ( ! bp_is_root_blog() ) restore_current_blog(); ?>
     214
     215                            </td>
     216                        </tr>
     217
     218                    <?php endforeach; ?>
     219
     220                    <?php
     221
     222                    /**
     223                     * Fires after the display of default static pages for BuddyPress setup.
     224                     *
     225                     * @since 1.5.0
     226                     */
     227                    do_action( 'bp_active_external_pages' ); ?>
     228
     229                </tbody>
     230            </table>
    191231        <?php else : ?>
    192232            <?php if ( is_multisite() ) : ?>
     
    219259                </p>
    220260            <?php endif; ?>
    221         <?php endif; ?>
    222 
    223         <table class="form-table">
    224             <tbody>
    225 
    226                 <?php if ( bp_allow_access_to_registration_pages() ) : foreach ( $static_pages as $name => $label ) : ?>
    227 
    228                     <tr valign="top">
    229                         <th scope="row">
    230                             <label for="bp_pages[<?php echo esc_attr( $name ) ?>]"><?php echo esc_html( $label ) ?></label>
    231                         </th>
    232 
    233                         <td>
    234 
    235                             <?php if ( ! bp_is_root_blog() ) switch_to_blog( bp_get_root_blog_id() ); ?>
    236 
    237                             <?php echo wp_dropdown_pages( array(
    238                                 'name'             => 'bp_pages[' . esc_attr( $name ) . ']',
    239                                 'echo'             => false,
    240                                 'show_option_none' => __( '- None -', 'buddypress' ),
    241                                 'selected'         => !empty( $existing_pages[$name] ) ? $existing_pages[$name] : false
    242                             ) ) ?>
    243 
    244                             <?php if ( ! bp_is_root_blog() ) restore_current_blog(); ?>
    245 
    246                         </td>
    247                     </tr>
    248 
    249                 <?php endforeach; endif; ?>
    250 
    251                 <?php
    252 
    253                 /**
    254                  * Fires after the display of default static pages for BuddyPress setup.
    255                  *
    256                  * @since 1.5.0
    257                  */
    258                 do_action( 'bp_active_external_pages' ); ?>
    259 
    260             </tbody>
    261         </table>
    262 
    263         <?php
     261        <?php endif;
    264262    endif;
    265263}
  • trunk/src/bp-core/classes/class-bp-admin.php

    r13137 r13138  
    12881288     */
    12891289    public function add_inline_styles() {
    1290         $screen                  = get_current_screen();
    1291         $current_settings_tab_id = array_search( $screen->id, $this->submenu_pages['settings'], true );
    1292         $current_tools_tab_id    = array_search( $screen->id, $this->submenu_pages['tools'], true );
     1290        $screen = get_current_screen();
     1291
     1292        if ( ! isset( $screen->id ) ) {
     1293            return;
     1294        }
     1295
     1296        // We might need to edit this id, see below code.
     1297        $screen_id = $screen->id;
     1298
     1299        // Multisite configs adds a '-network' suffix to page hooknames inside the Network Admin screens.
     1300        if ( is_multisite() && is_network_admin() && bp_is_network_activated() ) {
     1301            $screen_id = str_replace( '-network', '', $screen_id );
     1302        }
     1303
     1304        $current_settings_tab_id = array_search( $screen_id, $this->submenu_pages['settings'], true );
     1305        $current_tools_tab_id    = array_search( $screen_id, $this->submenu_pages['tools'], true );
    12931306        $current_tab_id          = '';
    12941307        $tabs                    = array();
Note: See TracChangeset for help on using the changeset viewer.