8 |
8 |
9 /** WordPress Administration Bootstrap */ |
9 /** WordPress Administration Bootstrap */ |
10 require_once( dirname( __FILE__ ) . '/admin.php' ); |
10 require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 |
11 |
12 if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') ) |
12 if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') ) |
13 wp_die( __( 'Cheatin’ uh?' ) ); |
13 wp_die( __( 'Cheatin’ uh?' ), 403 ); |
14 |
|
15 $wp_list_table = _get_list_table('WP_Themes_List_Table'); |
|
16 |
|
17 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 's', 'features', '_ajax_fetch_list_nonce', '_wp_http_referer', 'paged' ), $_SERVER['REQUEST_URI'] ); |
|
18 |
14 |
19 if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) { |
15 if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) { |
20 if ( 'activate' == $_GET['action'] ) { |
16 if ( 'activate' == $_GET['action'] ) { |
21 check_admin_referer('switch-theme_' . $_GET['stylesheet']); |
17 check_admin_referer('switch-theme_' . $_GET['stylesheet']); |
22 $theme = wp_get_theme( $_GET['stylesheet'] ); |
18 $theme = wp_get_theme( $_GET['stylesheet'] ); |
23 if ( ! $theme->exists() || ! $theme->is_allowed() ) |
19 if ( ! $theme->exists() || ! $theme->is_allowed() ) |
24 wp_die( __( 'Cheatin’ uh?' ) ); |
20 wp_die( __( 'Cheatin’ uh?' ), 403 ); |
25 switch_theme( $theme->get_stylesheet() ); |
21 switch_theme( $theme->get_stylesheet() ); |
26 wp_redirect( admin_url('themes.php?activated=true') ); |
22 wp_redirect( admin_url('themes.php?activated=true') ); |
27 exit; |
23 exit; |
28 } elseif ( 'delete' == $_GET['action'] ) { |
24 } elseif ( 'delete' == $_GET['action'] ) { |
29 check_admin_referer('delete-theme_' . $_GET['stylesheet']); |
25 check_admin_referer('delete-theme_' . $_GET['stylesheet']); |
30 $theme = wp_get_theme( $_GET['stylesheet'] ); |
26 $theme = wp_get_theme( $_GET['stylesheet'] ); |
31 if ( !current_user_can('delete_themes') || ! $theme->exists() ) |
27 if ( !current_user_can('delete_themes') || ! $theme->exists() ) |
32 wp_die( __( 'Cheatin’ uh?' ) ); |
28 wp_die( __( 'Cheatin’ uh?' ), 403 ); |
33 delete_theme($_GET['stylesheet']); |
29 $active = wp_get_theme(); |
34 wp_redirect( admin_url('themes.php?deleted=true') ); |
30 if ( $active->get( 'Template' ) == $_GET['stylesheet'] ) { |
|
31 wp_redirect( admin_url( 'themes.php?delete-active-child=true' ) ); |
|
32 } else { |
|
33 delete_theme( $_GET['stylesheet'] ); |
|
34 wp_redirect( admin_url( 'themes.php?deleted=true' ) ); |
|
35 } |
35 exit; |
36 exit; |
36 } |
37 } |
37 } |
38 } |
38 |
39 |
39 $wp_list_table->prepare_items(); |
|
40 |
|
41 $title = __('Manage Themes'); |
40 $title = __('Manage Themes'); |
42 $parent_file = 'themes.php'; |
41 $parent_file = 'themes.php'; |
43 |
42 |
44 if ( current_user_can( 'switch_themes' ) ) : |
43 // Help tab: Overview |
45 |
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>' . |
45 $help_overview = '<p>' . __( 'This screen is used for managing your installed themes. Aside from the default theme(s) 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>'; |
46 '<p>' . __( 'From this screen you can:' ) . '</p>' . |
48 |
47 '<ul><li>' . __( 'Hover or tap to see Activate and Live Preview buttons' ) . '</li>' . |
49 get_current_screen()->add_help_tab( array( |
48 '<li>' . __( 'Click on the theme to see the theme name, version, author, description, tags, and the Delete link' ) . '</li>' . |
50 'id' => 'overview', |
49 '<li>' . __( 'Click Customize for the current theme or Live Preview for any other theme to see a live preview' ) . '</li></ul>' . |
51 'title' => __('Overview'), |
50 '<p>' . __( 'The current theme is displayed highlighted as the first theme.' ) . '</p>' . |
52 'content' => $help_manage |
51 '<p>' . __( 'The search for installed themes will search for terms in their name, description, author, or tag.' ) . ' <span id="live-search-desc">' . __( 'The search results will be updated as you type.' ) . '</span></p>'; |
53 ) ); |
52 |
54 |
53 get_current_screen()->add_help_tab( array( |
|
54 'id' => 'overview', |
|
55 'title' => __( 'Overview' ), |
|
56 'content' => $help_overview |
|
57 ) ); |
|
58 } // switch_themes |
|
59 |
|
60 // Help tab: Adding Themes |
55 if ( current_user_can( 'install_themes' ) ) { |
61 if ( current_user_can( 'install_themes' ) ) { |
56 if ( is_multisite() ) { |
62 if ( is_multisite() ) { |
57 $help_install = '<p>' . __('Installing themes on Multisite can only be done from the Network Admin section.') . '</p>'; |
63 $help_install = '<p>' . __('Installing themes on Multisite can only be done from the Network Admin section.') . '</p>'; |
58 } else { |
64 } else { |
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>'; |
65 $help_install = '<p>' . sprintf( __('If you would like to see more themes to choose from, click on the “Add New” button 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!'), 'https://wordpress.org/themes/' ) . '</p>'; |
60 } |
66 } |
61 |
67 |
62 get_current_screen()->add_help_tab( array( |
68 get_current_screen()->add_help_tab( array( |
63 'id' => 'adding-themes', |
69 'id' => 'adding-themes', |
64 'title' => __('Adding Themes'), |
70 'title' => __('Adding Themes'), |
65 'content' => $help_install |
71 'content' => $help_install |
66 ) ); |
72 ) ); |
67 } |
73 } // install_themes |
68 |
74 |
69 add_thickbox(); |
75 // Help tab: Previewing and Customizing |
70 |
76 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
71 endif; // switch_themes |
|
72 |
|
73 if ( current_user_can( 'edit_theme_options' ) ) { |
|
74 $help_customize = |
77 $help_customize = |
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>'. |
78 '<p>' . __( 'Tap or hover on any theme then click the Live Preview button to see a live preview of that theme and change theme options in a separate, full-screen view. You can also find a Live Preview button at the bottom of the theme details screen. 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>' . |
79 '<p>' . __( 'The theme being previewed is fully interactive — navigate to different pages to see how the theme handles posts, archives, and other page templates. The settings may 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 above the menu.' ) . '</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>' . |
80 '<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>'; |
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>'; |
|
79 |
81 |
80 get_current_screen()->add_help_tab( array( |
82 get_current_screen()->add_help_tab( array( |
81 'id' => 'customize-preview-themes', |
83 'id' => 'customize-preview-themes', |
82 'title' => __('Previewing and Customizing'), |
84 'title' => __( 'Previewing and Customizing' ), |
83 'content' => $help_customize |
85 'content' => $help_customize |
84 ) ); |
86 ) ); |
|
87 } // edit_theme_options && customize |
|
88 |
|
89 get_current_screen()->set_help_sidebar( |
|
90 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
91 '<p>' . __( '<a href="https://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>' ) . '</p>' . |
|
92 '<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' |
|
93 ); |
|
94 |
|
95 if ( current_user_can( 'switch_themes' ) ) { |
|
96 $themes = wp_prepare_themes_for_js(); |
|
97 } else { |
|
98 $themes = wp_prepare_themes_for_js( array( wp_get_theme() ) ); |
85 } |
99 } |
86 |
100 wp_reset_vars( array( 'theme', 'search' ) ); |
87 get_current_screen()->set_help_sidebar( |
101 |
88 '<p><strong>' . __('For more information:') . '</strong></p>' . |
102 wp_localize_script( 'theme', '_wpThemeSettings', array( |
89 '<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>' . |
103 'themes' => $themes, |
90 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
104 'settings' => array( |
91 ); |
105 'canInstall' => ( ! is_multisite() && current_user_can( 'install_themes' ) ), |
92 |
106 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null, |
|
107 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ), |
|
108 'adminUrl' => parse_url( admin_url(), PHP_URL_PATH ), |
|
109 ), |
|
110 'l10n' => array( |
|
111 'addNew' => __( 'Add New Theme' ), |
|
112 'search' => __( 'Search Installed Themes' ), |
|
113 'searchPlaceholder' => __( 'Search installed themes...' ), // placeholder (no ellipsis) |
|
114 'themesFound' => __( 'Number of Themes found: %d' ), |
|
115 'noThemesFound' => __( 'No themes found. Try a different search.' ), |
|
116 ), |
|
117 ) ); |
|
118 |
|
119 add_thickbox(); |
93 wp_enqueue_script( 'theme' ); |
120 wp_enqueue_script( 'theme' ); |
94 wp_enqueue_script( 'customize-loader' ); |
121 wp_enqueue_script( 'customize-loader' ); |
95 |
122 |
96 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
123 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
97 ?> |
124 ?> |
98 |
125 |
99 <div class="wrap"><?php |
126 <div class="wrap"> |
100 screen_icon(); |
127 <h2><?php esc_html_e( 'Themes' ); ?> |
101 if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?> |
128 <span class="title-count theme-count"><?php echo count( $themes ); ?></span> |
102 <h2 class="nav-tab-wrapper"> |
129 <?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?> |
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> |
130 <a href="<?php echo admin_url( 'theme-install.php' ); ?>" class="hide-if-no-js add-new-h2"><?php echo esc_html_x( 'Add New', 'Add new theme' ); ?></a> |
104 <?php else : ?> |
131 <?php endif; ?> |
105 <h2><?php echo esc_html( $title ); ?> |
132 </h2> |
106 <?php endif; ?> |
|
107 </h2> |
|
108 <?php |
133 <?php |
109 if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : ?> |
134 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> |
135 <div id="message1" class="updated notice is-dismissible"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> |
111 <?php elseif ( isset($_GET['activated']) ) : |
136 <?php elseif ( isset($_GET['activated']) ) : |
112 if ( isset( $_GET['previewed'] ) ) { ?> |
137 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> |
138 <div id="message2" class="updated notice is-dismissible"><p><?php printf( __( 'Settings saved and theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div> |
114 <?php } else { ?> |
139 <?php } else { ?> |
115 <div id="message2" class="updated"><p><?php printf( __( 'New theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div><?php |
140 <div id="message2" class="updated notice is-dismissible"><p><?php printf( __( 'New theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div><?php |
116 } |
141 } |
117 elseif ( isset($_GET['deleted']) ) : ?> |
142 elseif ( isset($_GET['deleted']) ) : ?> |
118 <div id="message3" class="updated"><p><?php _e('Theme deleted.') ?></p></div> |
143 <div id="message3" class="updated notice is-dismissible"><p><?php _e('Theme deleted.') ?></p></div> |
|
144 <?php elseif ( isset( $_GET['delete-active-child'] ) ) : ?> |
|
145 <div id="message4" class="error"><p><?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?></p></div> |
119 <?php |
146 <?php |
120 endif; |
147 endif; |
121 |
148 |
122 $ct = wp_get_theme(); |
149 $ct = wp_get_theme(); |
123 $screenshot = $ct->get_screenshot(); |
150 |
124 $class = $screenshot ? 'has-screenshot' : ''; |
|
125 |
|
126 $customize_title = sprintf( __( 'Customize “%s”' ), $ct->display('Name') ); |
|
127 |
|
128 ?> |
|
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' ); ?>" /> |
|
134 </a> |
|
135 <?php endif; ?> |
|
136 <img class="hide-if-customize" src="<?php echo esc_url( $screenshot ); ?>" alt="<?php esc_attr_e( 'Current theme preview' ); ?>" /> |
|
137 <?php endif; ?> |
|
138 |
|
139 <h3><?php _e('Current Theme'); ?></h3> |
|
140 <h4> |
|
141 <?php echo $ct->display('Name'); ?> |
|
142 </h4> |
|
143 |
|
144 <?php |
|
145 if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) { |
151 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>'; |
152 echo '<div class="error"><p>' . sprintf( __( 'ERROR: %s' ), $ct->errors()->get_error_message() ) . '</p></div>'; |
147 } |
153 } |
148 |
154 |
|
155 /* |
149 // Certain error codes are less fatal than others. We can still display theme information in most cases. |
156 // 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() ) |
157 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' ) ) ) ) : ?> |
158 && in_array( $ct->errors()->get_error_code(), array( 'theme_no_parent', 'theme_parent_invalid', 'theme_no_index' ) ) ) ) : ?> |
152 |
159 */ |
153 <div> |
160 |
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> |
|
157 </ul> |
|
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' ) ); |
|
163 } ?> |
|
164 <?php theme_update_available( $ct ); ?> |
|
165 </div> |
|
166 |
|
167 <?php |
|
168 // Pretend you didn't see this. |
161 // Pretend you didn't see this. |
169 $options = array(); |
162 $current_theme_actions = array(); |
170 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) { |
163 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) { |
171 foreach ( (array) $submenu['themes.php'] as $item) { |
164 foreach ( (array) $submenu['themes.php'] as $item) { |
172 $class = ''; |
165 $class = ''; |
173 if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 'customize.php' == $item[2] ) |
166 if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) |
174 continue; |
167 continue; |
175 // 0 = name, 1 = capability, 2 = file |
168 // 0 = name, 1 = capability, 2 = file |
176 if ( ( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file)) ) |
169 if ( ( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file)) ) |
177 $class = ' class="current"'; |
170 $class = ' current'; |
178 if ( !empty($submenu[$item[2]]) ) { |
171 if ( !empty($submenu[$item[2]]) ) { |
179 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. |
172 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. |
180 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); |
173 $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)) |
174 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>"; |
175 $current_theme_actions[] = "<a class='button button-secondary$class' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>"; |
183 else |
176 else |
184 $options[] = "<a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>"; |
177 $current_theme_actions[] = "<a class='button button-secondary$class' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>"; |
185 } else if ( current_user_can($item[1]) ) { |
178 } elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) { |
186 $menu_file = $item[2]; |
179 $menu_file = $item[2]; |
187 if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) |
180 |
|
181 if ( current_user_can( 'customize' ) ) { |
|
182 if ( 'custom-header' === $menu_file ) { |
|
183 $current_theme_actions[] = "<a class='button button-secondary hide-if-no-customize$class' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>"; |
|
184 } elseif ( 'custom-background' === $menu_file ) { |
|
185 $current_theme_actions[] = "<a class='button button-secondary hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>"; |
|
186 } |
|
187 } |
|
188 |
|
189 if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) { |
188 $menu_file = substr( $menu_file, 0, $pos ); |
190 $menu_file = substr( $menu_file, 0, $pos ); |
|
191 } |
|
192 |
189 if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) { |
193 if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) { |
190 $options[] = "<a href='{$item[2]}'$class>{$item[0]}</a>"; |
194 $current_theme_actions[] = "<a class='button button-secondary$class' href='{$item[2]}'>{$item[0]}</a>"; |
191 } else { |
195 } else { |
192 $options[] = "<a href='themes.php?page={$item[2]}'$class>{$item[0]}</a>"; |
196 $current_theme_actions[] = "<a class='button button-secondary$class' href='themes.php?page={$item[2]}'>{$item[0]}</a>"; |
193 } |
197 } |
194 } |
198 } |
195 } |
199 } |
196 } |
200 } |
197 |
201 |
198 if ( $options || current_user_can( 'edit_theme_options' ) ) : |
202 ?> |
|
203 |
|
204 <div class="theme-browser"> |
|
205 <div class="themes"> |
|
206 |
|
207 <?php |
|
208 /* |
|
209 * This PHP is synchronized with the tmpl-theme template below! |
|
210 */ |
|
211 |
|
212 foreach ( $themes as $theme ) : |
|
213 $aria_action = esc_attr( $theme['id'] . '-action' ); |
|
214 $aria_name = esc_attr( $theme['id'] . '-name' ); |
199 ?> |
215 ?> |
200 <div class="theme-options"> |
216 <div class="theme<?php if ( $theme['active'] ) echo ' active'; ?>" tabindex="0" aria-describedby="<?php echo $aria_action . ' ' . $aria_name; ?>"> |
201 <?php if ( current_user_can( 'edit_theme_options' ) ) : ?> |
217 <?php if ( ! empty( $theme['screenshot'][0] ) ) { ?> |
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> |
218 <div class="theme-screenshot"> |
203 <?php |
219 <img src="<?php echo $theme['screenshot'][0]; ?>" alt="" /> |
204 endif; // edit_theme_options |
220 </div> |
205 if ( $options ) : |
221 <?php } else { ?> |
206 ?> |
222 <div class="theme-screenshot blank"></div> |
207 <span><?php _e( 'Options:' )?></span> |
223 <?php } ?> |
208 <ul> |
224 <span class="more-details" id="<?php echo $aria_action; ?>"><?php _e( 'Theme Details' ); ?></span> |
209 <?php foreach ( $options as $option ) : ?> |
225 <div class="theme-author"><?php printf( __( 'By %s' ), $theme['author'] ); ?></div> |
210 <li><?php echo $option; ?></li> |
226 |
211 <?php endforeach; ?> |
227 <?php if ( $theme['active'] ) { ?> |
212 </ul> |
228 <h3 class="theme-name" id="<?php echo $aria_name; ?>"> |
213 <?php |
229 <?php |
214 endif; // options |
230 /* translators: %s: theme name */ |
215 ?> |
231 printf( __( '<span>Active:</span> %s' ), $theme['name'] ); |
|
232 ?> |
|
233 </h3> |
|
234 <?php } else { ?> |
|
235 <h3 class="theme-name" id="<?php echo $aria_name; ?>"><?php echo $theme['name']; ?></h3> |
|
236 <?php } ?> |
|
237 |
|
238 <div class="theme-actions"> |
|
239 |
|
240 <?php if ( $theme['active'] ) { ?> |
|
241 <?php if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?> |
|
242 <a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a> |
|
243 <?php } ?> |
|
244 <?php } else { ?> |
|
245 <a class="button button-secondary activate" href="<?php echo $theme['actions']['activate']; ?>"><?php _e( 'Activate' ); ?></a> |
|
246 <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?> |
|
247 <a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a> |
|
248 <a class="button button-secondary hide-if-customize" href="<?php echo $theme['actions']['preview']; ?>"><?php _e( 'Preview' ); ?></a> |
|
249 <?php } ?> |
|
250 <?php } ?> |
|
251 |
216 </div> |
252 </div> |
217 <?php |
253 |
218 endif; // options || edit_theme_options |
254 <?php if ( $theme['hasUpdate'] ) { ?> |
219 ?> |
255 <div class="theme-update"><?php _e( 'Update Available' ); ?></div> |
220 |
256 <?php } ?> |
221 <?php endif; // theme errors ?> |
|
222 |
|
223 </div> |
257 </div> |
224 |
258 <?php endforeach; ?> |
225 <br class="clear" /> |
259 <br class="clear" /> |
226 <?php |
|
227 if ( ! current_user_can( 'switch_themes' ) ) { |
|
228 echo '</div>'; |
|
229 require( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
230 exit; |
|
231 } |
|
232 ?> |
|
233 |
|
234 <form class="search-form filter-form" action="" method="get"> |
|
235 |
|
236 <h3 class="available-themes"><?php _e('Available Themes'); ?></h3> |
|
237 |
|
238 <?php if ( !empty( $_REQUEST['s'] ) || !empty( $_REQUEST['features'] ) || $wp_list_table->has_items() ) : ?> |
|
239 |
|
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> |
|
245 </p> |
|
246 |
|
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" /> |
|
253 <?php endif; ?> |
|
254 <?php foreach ( $feature_list as $feature_name => $features ) : |
|
255 $feature_name = esc_html( $feature_name ); ?> |
|
256 |
|
257 <div class="feature-container"> |
|
258 <div class="feature-name"><?php echo $feature_name ?></div> |
|
259 |
|
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 ); |
|
265 ?> |
|
266 <li> |
|
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> |
|
269 </li> |
|
270 <?php endforeach; ?> |
|
271 </ol> |
|
272 </div> |
|
273 <?php endforeach; ?> |
|
274 |
|
275 <div class="feature-container"> |
|
276 <?php submit_button( __( 'Apply Filters' ), 'button-secondary submitter', false, false, array( 'id' => 'filter-submit' ) ); ?> |
|
277 |
|
278 <a id="mini-filter-click" href="<?php echo esc_url( remove_query_arg( array('filter', 'features', 'submit') ) ); ?>"><?php _e( 'Close filters' )?></a> |
|
279 </div> |
260 </div> |
280 <br/> |
|
281 </div> |
|
282 <br class="clear"/> |
|
283 </div> |
261 </div> |
284 |
262 <div class="theme-overlay"></div> |
285 <?php endif; ?> |
263 |
286 |
264 <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p> |
287 <br class="clear" /> |
|
288 |
|
289 <?php $wp_list_table->display(); ?> |
|
290 |
|
291 </form> |
|
292 <br class="clear" /> |
|
293 |
265 |
294 <?php |
266 <?php |
295 // List broken themes, if any. |
267 // List broken themes, if any. |
296 if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) { |
268 if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) { |
297 ?> |
269 ?> |
298 |
270 |
|
271 <div class="broken-themes"> |
299 <h3><?php _e('Broken Themes'); ?></h3> |
272 <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> |
273 <p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p> |
301 |
274 |
302 <table id="broken-themes"> |
275 <?php |
|
276 $can_delete = current_user_can( 'delete_themes' ); |
|
277 ?> |
|
278 <table> |
303 <tr> |
279 <tr> |
304 <th><?php _ex('Name', 'theme name'); ?></th> |
280 <th><?php _ex('Name', 'theme name'); ?></th> |
305 <th><?php _e('Description'); ?></th> |
281 <th><?php _e('Description'); ?></th> |
|
282 <?php if ( $can_delete ) { ?> |
|
283 <th></th> |
|
284 <?php } ?> |
|
285 </tr> |
306 </tr> |
286 </tr> |
307 <?php |
287 <?php foreach ( $broken_themes as $broken_theme ) : ?> |
308 foreach ( $broken_themes as $broken_theme ) { |
|
309 echo " |
|
310 <tr> |
288 <tr> |
311 <td>" . $broken_theme->get('Name') ."</td> |
289 <td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?></td> |
312 <td>" . $broken_theme->errors()->get_error_message() . "</td> |
290 <td><?php echo $broken_theme->errors()->get_error_message(); ?></td> |
313 </tr>"; |
291 <?php |
314 } |
292 if ( $can_delete ) { |
315 ?> |
293 $stylesheet = $broken_theme->get_stylesheet(); |
|
294 $delete_url = add_query_arg( array( |
|
295 'action' => 'delete', |
|
296 'stylesheet' => urlencode( $stylesheet ), |
|
297 ), admin_url( 'themes.php' ) ); |
|
298 $delete_url = wp_nonce_url( $delete_url, 'delete-theme_' . $stylesheet ); |
|
299 ?> |
|
300 <td><a href="<?php echo esc_url( $delete_url ); ?>" class="button button-secondary delete-theme"><?php _e( 'Delete' ); ?></a></td> |
|
301 <?php |
|
302 } |
|
303 ?> |
|
304 </tr> |
|
305 <?php endforeach; ?> |
316 </table> |
306 </table> |
|
307 </div> |
|
308 |
317 <?php |
309 <?php |
318 } |
310 } |
319 ?> |
311 ?> |
320 </div> |
312 </div><!-- .wrap --> |
321 |
313 |
322 <?php require( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |
314 <?php |
|
315 /* |
|
316 * The tmpl-theme template is synchronized with PHP above! |
|
317 */ |
|
318 ?> |
|
319 <script id="tmpl-theme" type="text/template"> |
|
320 <# if ( data.screenshot[0] ) { #> |
|
321 <div class="theme-screenshot"> |
|
322 <img src="{{ data.screenshot[0] }}" alt="" /> |
|
323 </div> |
|
324 <# } else { #> |
|
325 <div class="theme-screenshot blank"></div> |
|
326 <# } #> |
|
327 <span class="more-details" id="{{ data.id }}-action"><?php _e( 'Theme Details' ); ?></span> |
|
328 <div class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.author }}}' ); ?></div> |
|
329 |
|
330 <# if ( data.active ) { #> |
|
331 <h3 class="theme-name" id="{{ data.id }}-name"> |
|
332 <?php |
|
333 /* translators: %s: theme name */ |
|
334 printf( __( '<span>Active:</span> %s' ), '{{ data.name }}' ); |
|
335 ?> |
|
336 </h3> |
|
337 <# } else { #> |
|
338 <h3 class="theme-name" id="{{ data.id }}-name">{{{ data.name }}}</h3> |
|
339 <# } #> |
|
340 |
|
341 <div class="theme-actions"> |
|
342 |
|
343 <# if ( data.active ) { #> |
|
344 <# if ( data.actions.customize ) { #> |
|
345 <a class="button button-primary customize load-customize hide-if-no-customize" href="{{ data.actions.customize }}"><?php _e( 'Customize' ); ?></a> |
|
346 <# } #> |
|
347 <# } else { #> |
|
348 <a class="button button-secondary activate" href="{{{ data.actions.activate }}}"><?php _e( 'Activate' ); ?></a> |
|
349 <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a> |
|
350 <a class="button button-secondary hide-if-customize" href="{{{ data.actions.preview }}}"><?php _e( 'Preview' ); ?></a> |
|
351 <# } #> |
|
352 |
|
353 </div> |
|
354 |
|
355 <# if ( data.hasUpdate ) { #> |
|
356 <div class="theme-update"><?php _e( 'Update Available' ); ?></div> |
|
357 <# } #> |
|
358 </script> |
|
359 |
|
360 <script id="tmpl-theme-single" type="text/template"> |
|
361 <div class="theme-backdrop"></div> |
|
362 <div class="theme-wrap"> |
|
363 <div class="theme-header"> |
|
364 <button class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme' ); ?></span></button> |
|
365 <button class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme' ); ?></span></button> |
|
366 <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close overlay' ); ?></span></button> |
|
367 </div> |
|
368 <div class="theme-about"> |
|
369 <div class="theme-screenshots"> |
|
370 <# if ( data.screenshot[0] ) { #> |
|
371 <div class="screenshot"><img src="{{ data.screenshot[0] }}" alt="" /></div> |
|
372 <# } else { #> |
|
373 <div class="screenshot blank"></div> |
|
374 <# } #> |
|
375 </div> |
|
376 |
|
377 <div class="theme-info"> |
|
378 <# if ( data.active ) { #> |
|
379 <span class="current-label"><?php _e( 'Current Theme' ); ?></span> |
|
380 <# } #> |
|
381 <h3 class="theme-name">{{{ data.name }}}<span class="theme-version"><?php printf( __( 'Version: %s' ), '{{ data.version }}' ); ?></span></h3> |
|
382 <h4 class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' ); ?></h4> |
|
383 |
|
384 <# if ( data.hasUpdate ) { #> |
|
385 <div class="theme-update-message"> |
|
386 <h4 class="theme-update"><?php _e( 'Update Available' ); ?></h4> |
|
387 {{{ data.update }}} |
|
388 </div> |
|
389 <# } #> |
|
390 <p class="theme-description">{{{ data.description }}}</p> |
|
391 |
|
392 <# if ( data.parent ) { #> |
|
393 <p class="parent-theme"><?php printf( __( 'This is a child theme of %s.' ), '<strong>{{{ data.parent }}}</strong>' ); ?></p> |
|
394 <# } #> |
|
395 |
|
396 <# if ( data.tags ) { #> |
|
397 <p class="theme-tags"><span><?php _e( 'Tags:' ); ?></span> {{{ data.tags }}}</p> |
|
398 <# } #> |
|
399 </div> |
|
400 </div> |
|
401 |
|
402 <div class="theme-actions"> |
|
403 <div class="active-theme"> |
|
404 <a href="{{{ data.actions.customize }}}" class="button button-primary customize load-customize hide-if-no-customize"><?php _e( 'Customize' ); ?></a> |
|
405 <?php echo implode( ' ', $current_theme_actions ); ?> |
|
406 </div> |
|
407 <div class="inactive-theme"> |
|
408 <# if ( data.actions.activate ) { #> |
|
409 <a href="{{{ data.actions.activate }}}" class="button button-secondary activate"><?php _e( 'Activate' ); ?></a> |
|
410 <# } #> |
|
411 <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a> |
|
412 <a href="{{{ data.actions.preview }}}" class="button button-secondary hide-if-customize"><?php _e( 'Preview' ); ?></a> |
|
413 </div> |
|
414 |
|
415 <# if ( ! data.active && data.actions['delete'] ) { #> |
|
416 <a href="{{{ data.actions['delete'] }}}" class="button button-secondary delete-theme"><?php _e( 'Delete' ); ?></a> |
|
417 <# } #> |
|
418 </div> |
|
419 </div> |
|
420 </script> |
|
421 |
|
422 <?php require( ABSPATH . 'wp-admin/admin-footer.php' ); |