3 * Themes administration panel.
6 * @subpackage Administration
9 /** WordPress Administration Bootstrap */
10 require_once( dirname( __FILE__ ) . '/admin.php' );
12 if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') )
13 wp_die( __( 'Cheatin’ uh?' ) );
15 $wp_list_table = _get_list_table('WP_Themes_List_Table');
17 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 's', 'features', '_ajax_fetch_list_nonce', '_wp_http_referer', 'paged' ), $_SERVER['REQUEST_URI'] );
19 if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
20 if ( 'activate' == $_GET['action'] ) {
21 check_admin_referer('switch-theme_' . $_GET['stylesheet']);
22 $theme = wp_get_theme( $_GET['stylesheet'] );
23 if ( ! $theme->exists() || ! $theme->is_allowed() )
24 wp_die( __( 'Cheatin’ uh?' ) );
25 switch_theme( $theme->get_stylesheet() );
26 wp_redirect( admin_url('themes.php?activated=true') );
28 } elseif ( 'delete' == $_GET['action'] ) {
29 check_admin_referer('delete-theme_' . $_GET['stylesheet']);
30 $theme = wp_get_theme( $_GET['stylesheet'] );
31 if ( !current_user_can('delete_themes') || ! $theme->exists() )
32 wp_die( __( 'Cheatin’ uh?' ) );
33 delete_theme($_GET['stylesheet']);
34 wp_redirect( admin_url('themes.php?deleted=true') );
39 $wp_list_table->prepare_items();
41 $title = __('Manage Themes');
42 $parent_file = 'themes.php';
44 if ( current_user_can( 'switch_themes' ) ) :
46 $help_manage = '<p>' . __('Aside from the default theme included with your WordPress installation, themes are designed and developed by third parties.') . '</p>' .
47 '<p>' . __('You can see your active theme at the top of the screen. Below are the other themes you have installed that are not currently in use. You can see what your site would look like with one of these themes by clicking the Live Preview link (see "Previewing and Customizing" help tab). To change themes, click the Activate link.') . '</p>';
49 get_current_screen()->add_help_tab( array(
51 'title' => __('Overview'),
52 'content' => $help_manage
55 if ( current_user_can( 'install_themes' ) ) {
56 if ( is_multisite() ) {
57 $help_install = '<p>' . __('Installing themes on Multisite can only be done from the Network Admin section.') . '</p>';
59 $help_install = '<p>' . sprintf( __('If you would like to see more themes to choose from, click on the “Install Themes” tab and you will be able to browse or search for additional themes from the <a href="%s" target="_blank">WordPress.org Theme Directory</a>. Themes in the WordPress.org Theme Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they’re free!'), 'http://wordpress.org/themes/' ) . '</p>';
62 get_current_screen()->add_help_tab( array(
63 'id' => 'adding-themes',
64 'title' => __('Adding Themes'),
65 'content' => $help_install
71 endif; // switch_themes
73 if ( current_user_can( 'edit_theme_options' ) ) {
75 '<p>' . __('Click on the "Live Preview" link under any theme to preview that theme and change theme options in a separate, full-screen view. Any installed theme can be previewed and customized in this way.') . '</p>'.
76 '<p>' . __('The theme being previewed is fully interactive — navigate to different pages to see how the theme handles posts, archives, and other page templates.') . '</p>' .
77 '<p>' . __('In the left-hand pane you can edit the theme settings. The settings will differ, depending on what theme features the theme being previewed supports. To accept the new settings and activate the theme all in one step, click the "Save & Activate" button at the top of the left-hand pane.') . '</p>' .
78 '<p>' . __('When previewing on smaller monitors, you can use the "Collapse" icon at the bottom of the left-hand pane. This will hide the pane, giving you more room to preview your site in the new theme. To bring the pane back, click on the Collapse icon again.') . '</p>';
80 get_current_screen()->add_help_tab( array(
81 'id' => 'customize-preview-themes',
82 'title' => __('Previewing and Customizing'),
83 'content' => $help_customize
87 get_current_screen()->set_help_sidebar(
88 '<p><strong>' . __('For more information:') . '</strong></p>' .
89 '<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>' .
90 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
93 wp_enqueue_script( 'theme' );
94 wp_enqueue_script( 'customize-loader' );
96 require_once( ABSPATH . 'wp-admin/admin-header.php' );
99 <div class="wrap"><?php
101 if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
102 <h2 class="nav-tab-wrapper">
103 <a href="themes.php" class="nav-tab nav-tab-active"><?php echo esc_html( $title ); ?></a><a href="<?php echo admin_url( 'theme-install.php'); ?>" class="nav-tab"><?php echo esc_html_x('Install Themes', 'theme'); ?></a>
105 <h2><?php echo esc_html( $title ); ?>
109 if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : ?>
110 <div id="message1" class="updated"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
111 <?php elseif ( isset($_GET['activated']) ) :
112 if ( isset( $_GET['previewed'] ) ) { ?>
113 <div id="message2" class="updated"><p><?php printf( __( 'Settings saved and theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div>
115 <div id="message2" class="updated"><p><?php printf( __( 'New theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div><?php
117 elseif ( isset($_GET['deleted']) ) : ?>
118 <div id="message3" class="updated"><p><?php _e('Theme deleted.') ?></p></div>
122 $ct = wp_get_theme();
123 $screenshot = $ct->get_screenshot();
124 $class = $screenshot ? 'has-screenshot' : '';
126 $customize_title = sprintf( __( 'Customize “%s”' ), $ct->display('Name') );
129 <div id="current-theme" class="<?php echo esc_attr( $class ); ?>">
130 <?php if ( $screenshot ) : ?>
131 <?php if ( current_user_can( 'edit_theme_options' ) ) : ?>
132 <a href="<?php echo wp_customize_url(); ?>" class="load-customize hide-if-no-customize" title="<?php echo esc_attr( $customize_title ); ?>">
133 <img src="<?php echo esc_url( $screenshot ); ?>" alt="<?php esc_attr_e( 'Current theme preview' ); ?>" />
136 <img class="hide-if-customize" src="<?php echo esc_url( $screenshot ); ?>" alt="<?php esc_attr_e( 'Current theme preview' ); ?>" />
139 <h3><?php _e('Current Theme'); ?></h3>
141 <?php echo $ct->display('Name'); ?>
145 if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
146 echo '<p class="error-message">' . sprintf( __( 'ERROR: %s' ), $ct->errors()->get_error_message() ) . '</p>';
149 // Certain error codes are less fatal than others. We can still display theme information in most cases.
150 if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() )
151 && in_array( $ct->errors()->get_error_code(), array( 'theme_no_parent', 'theme_parent_invalid', 'theme_no_index' ) ) ) ) : ?>
154 <ul class="theme-info">
155 <li><?php printf( __('By %s'), $ct->display('Author') ); ?></li>
156 <li><?php printf( __('Version %s'), $ct->display('Version') ); ?></li>
158 <p class="theme-description"><?php echo $ct->display('Description'); ?></p>
159 <?php if ( $ct->parent() ) {
160 printf( ' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>',
161 __( 'http://codex.wordpress.org/Child_Themes' ),
162 $ct->parent()->display( 'Name' ) );
164 <?php theme_update_available( $ct ); ?>
168 // Pretend you didn't see this.
170 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
171 foreach ( (array) $submenu['themes.php'] as $item) {
173 if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 'customize.php' == $item[2] )
175 // 0 = name, 1 = capability, 2 = file
176 if ( ( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file)) )
177 $class = ' class="current"';
178 if ( !empty($submenu[$item[2]]) ) {
179 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
180 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
181 if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
182 $options[] = "<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
184 $options[] = "<a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>";
185 } else if ( current_user_can($item[1]) ) {
186 $menu_file = $item[2];
187 if ( false !== ( $pos = strpos( $menu_file, '?' ) ) )
188 $menu_file = substr( $menu_file, 0, $pos );
189 if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) {
190 $options[] = "<a href='{$item[2]}'$class>{$item[0]}</a>";
192 $options[] = "<a href='themes.php?page={$item[2]}'$class>{$item[0]}</a>";
198 if ( $options || current_user_can( 'edit_theme_options' ) ) :
200 <div class="theme-options">
201 <?php if ( current_user_can( 'edit_theme_options' ) ) : ?>
202 <a id="customize-current-theme-link" href="<?php echo wp_customize_url(); ?>" class="load-customize hide-if-no-customize" title="<?php echo esc_attr( $customize_title ); ?>"><?php _e( 'Customize' ); ?></a>
204 endif; // edit_theme_options
207 <span><?php _e( 'Options:' )?></span>
209 <?php foreach ( $options as $option ) : ?>
210 <li><?php echo $option; ?></li>
218 endif; // options || edit_theme_options
221 <?php endif; // theme errors ?>
227 if ( ! current_user_can( 'switch_themes' ) ) {
229 require( ABSPATH . 'wp-admin/admin-footer.php' );
234 <form class="search-form filter-form" action="" method="get">
236 <h3 class="available-themes"><?php _e('Available Themes'); ?></h3>
238 <?php if ( !empty( $_REQUEST['s'] ) || !empty( $_REQUEST['features'] ) || $wp_list_table->has_items() ) : ?>
240 <p class="search-box">
241 <label class="screen-reader-text" for="theme-search-input"><?php _e('Search Installed Themes'); ?>:</label>
242 <input type="search" id="theme-search-input" name="s" value="<?php _admin_search_query(); ?>" />
243 <?php submit_button( __( 'Search Installed Themes' ), 'button', false, false, array( 'id' => 'search-submit' ) ); ?>
244 <a id="filter-click" href="?filter=1"><?php _e( 'Feature Filter' ); ?></a>
247 <div id="filter-box" style="<?php if ( empty($_REQUEST['filter']) ) echo 'display: none;'; ?>">
248 <?php $feature_list = get_theme_feature_list(); ?>
249 <div class="feature-filter">
250 <p class="install-help"><?php _e('Theme filters') ?></p>
251 <?php if ( !empty( $_REQUEST['filter'] ) ) : ?>
252 <input type="hidden" name="filter" value="1" />
254 <?php foreach ( $feature_list as $feature_name => $features ) :
255 $feature_name = esc_html( $feature_name ); ?>
257 <div class="feature-container">
258 <div class="feature-name"><?php echo $feature_name ?></div>
260 <ol class="feature-group">
261 <?php foreach ( $features as $key => $feature ) :
262 $feature_name = $feature;
263 $feature_name = esc_html( $feature_name );
264 $feature = esc_attr( $feature );
267 <input type="checkbox" name="features[]" id="feature-id-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( in_array( $key, $wp_list_table->features ) ); ?>/>
268 <label for="feature-id-<?php echo $key; ?>"><?php echo $feature_name; ?></label>
275 <div class="feature-container">
276 <?php submit_button( __( 'Apply Filters' ), 'button-secondary submitter', false, false, array( 'id' => 'filter-submit' ) ); ?>
278 <a id="mini-filter-click" href="<?php echo esc_url( remove_query_arg( array('filter', 'features', 'submit') ) ); ?>"><?php _e( 'Close filters' )?></a>
289 <?php $wp_list_table->display(); ?>
295 // List broken themes, if any.
296 if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) {
299 <h3><?php _e('Broken Themes'); ?></h3>
300 <p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p>
302 <table id="broken-themes">
304 <th><?php _ex('Name', 'theme name'); ?></th>
305 <th><?php _e('Description'); ?></th>
308 foreach ( $broken_themes as $broken_theme ) {
311 <td>" . $broken_theme->get('Name') ."</td>
312 <td>" . $broken_theme->errors()->get_error_message() . "</td>
322 <?php require( ABSPATH . 'wp-admin/admin-footer.php' ); ?>