WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/24/2015 08:30:22 PM (6 years ago)
Author:
markjaquith
Message:

Add theme browsing and theme switching to the Customizer

  • Brings into core the Customizer Theme Switcher feature plugin
  • You can now browse, preview, and activate themes right from the Customizer

fixes #31303.
props celloexpressions, afercia, westonruter, folletto, designsimply

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r31421 r31533  
    11111111        $this->register_control_type( 'WP_Customize_Image_Control' );
    11121112        $this->register_control_type( 'WP_Customize_Background_Image_Control' );
     1113        $this->register_control_type( 'WP_Customize_Theme_Control' );
     1114
     1115        /* Themes */
     1116
     1117        $this->add_section( new WP_Customize_Themes_Section( $this, 'themes', array(
     1118            'title' => sprintf( __( 'Theme: %s' ), $this->theme()->display('Name') ),
     1119            'capability' => 'switch_themes',
     1120            'priority' => 0,
     1121        ) ) );
     1122
     1123        // Themes Setting (unused - the theme is considerably more fundamental to the Customizer experience).
     1124        $this->add_setting( new WP_Customize_Filter_Setting( $this, 'active_theme', array(
     1125            'capability' => 'switch_themes',
     1126        ) ) );
     1127
     1128        require_once( ABSPATH . 'wp-admin/includes/theme.php' );
     1129
     1130        // Theme Controls.
     1131        $themes = wp_prepare_themes_for_js();
     1132        foreach ( $themes as $theme ) {
     1133            $theme_id = 'theme_' . $theme['id'];
     1134            $this->add_control( new WP_Customize_Theme_Control( $this, $theme_id, array(
     1135                'theme' => $theme,
     1136                'section' => 'themes',
     1137                'settings' => 'active_theme',
     1138            ) ) );
     1139        }
     1140
     1141        $this->add_control( new WP_Customize_New_Theme_Control( $this, 'add_theme', array(
     1142            'section' => 'themes',
     1143            'settings' => 'active_theme',
     1144        ) ) );
    11131145
    11141146        /* Site Title & Tagline */
Note: See TracChangeset for help on using the changeset viewer.