Skip to:
Content

Changeset 11593


Ignore:
Timestamp:
06/21/2017 09:36:35 AM (12 months ago)
Author:
djpaul
Message:

Core: add template pack option to BuddyPress > Settings.

Location:
trunk/src
Files:
3 edited

Legend:

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

    r10825 r11593  
    4646
    4747<?php
     48}
     49
     50/**
     51 * Form element to change the active template pack.
     52 */
     53function bp_admin_setting_callback_theme_package_id() {
     54    $options = '';
     55
     56    /*
     57     * Note: This should never be empty. /bp-templates/ is the
     58     * canonical backup if no other packages exist. If there's an error here,
     59     * something else is wrong.
     60     *
     61     * See BuddyPress::register_theme_packages()
     62     */
     63    foreach ( (array) buddypress()->theme_compat->packages as $id => $theme ) {
     64        $options .= sprintf(
     65            '<option value="%1$s" %2$s>%3$s</option>',
     66            esc_attr( $id ),
     67            selected( $theme->id, bp_get_theme_package_id(), false ),
     68            esc_html( $theme->name )
     69        );
     70    }
     71
     72    if ( $options ) : ?>
     73        <select name="_bp_theme_package_id" id="_bp_theme_package_id"><?php echo $options; ?></select>
     74        <p class="description"><label for="_bp_theme_package_id"><?php esc_html_e( 'The selected Template Pack will serve all BuddyPress templates.', 'buddypress' ); ?></label></p>
     75
     76    <?php else : ?>
     77        <p><?php esc_html_e( 'No template packages available.', 'buddypress' ); ?></p>
     78
     79    <?php endif;
    4880}
    4981
  • trunk/src/bp-core/classes/class-bp-admin.php

    r11442 r11593  
    395395        add_settings_field( 'bp-disable-account-deletion', __( 'Account Deletion', 'buddypress' ), 'bp_admin_setting_callback_account_deletion', 'buddypress', 'bp_main' );
    396396        register_setting( 'buddypress', 'bp-disable-account-deletion', 'intval' );
     397
     398        // Template pack picker.
     399        add_settings_field( '_bp_theme_package_id', __( 'Template Pack', 'buddypress' ), 'bp_admin_setting_callback_theme_package_id', 'buddypress', 'bp_main' );
     400        register_setting( 'buddypress', '_bp_theme_package_id', 'sanitize_text_field' );
    397401
    398402        /* XProfile Section **************************************************/
  • trunk/src/class-buddypress.php

    r11447 r11593  
    705705        bp_register_theme_package( array(
    706706            'id'      => 'legacy',
    707             'name'    => __( 'BuddyPress Default', 'buddypress' ),
     707            'name'    => __( 'BuddyPress Legacy', 'buddypress' ),
    708708            'version' => bp_get_version(),
    709709            'dir'     => trailingslashit( $this->themes_dir . '/bp-legacy' ),
Note: See TracChangeset for help on using the changeset viewer.