Changeset 42343 for trunk/src/wp-admin/themes.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/themes.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/themes.php
r42217 r42343 18 18 } 19 19 20 if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) {20 if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) { 21 21 if ( 'activate' == $_GET['action'] ) { 22 check_admin_referer( 'switch-theme_' . $_GET['stylesheet']);22 check_admin_referer( 'switch-theme_' . $_GET['stylesheet'] ); 23 23 $theme = wp_get_theme( $_GET['stylesheet'] ); 24 24 … … 32 32 33 33 switch_theme( $theme->get_stylesheet() ); 34 wp_redirect( admin_url( 'themes.php?activated=true') );34 wp_redirect( admin_url( 'themes.php?activated=true' ) ); 35 35 exit; 36 36 } elseif ( 'delete' == $_GET['action'] ) { 37 check_admin_referer( 'delete-theme_' . $_GET['stylesheet']);37 check_admin_referer( 'delete-theme_' . $_GET['stylesheet'] ); 38 38 $theme = wp_get_theme( $_GET['stylesheet'] ); 39 39 … … 65 65 } 66 66 67 $title = __('Manage Themes');67 $title = __( 'Manage Themes' ); 68 68 $parent_file = 'themes.php'; 69 69 70 70 // Help tab: Overview 71 71 if ( current_user_can( 'switch_themes' ) ) { 72 $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>' .72 $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>' . 73 73 '<p>' . __( 'From this screen you can:' ) . '</p>' . 74 74 '<ul><li>' . __( 'Hover or tap to see Activate and Live Preview buttons' ) . '</li>' . … … 78 78 '<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>'; 79 79 80 get_current_screen()->add_help_tab( array( 81 'id' => 'overview', 82 'title' => __( 'Overview' ), 83 'content' => $help_overview 84 ) ); 80 get_current_screen()->add_help_tab( 81 array( 82 'id' => 'overview', 83 'title' => __( 'Overview' ), 84 'content' => $help_overview, 85 ) 86 ); 85 87 } // switch_themes 86 88 … … 88 90 if ( current_user_can( 'install_themes' ) ) { 89 91 if ( is_multisite() ) { 90 $help_install = '<p>' . __( 'Installing themes on Multisite can only be done from the Network Admin section.') . '</p>';92 $help_install = '<p>' . __( 'Installing themes on Multisite can only be done from the Network Admin section.' ) . '</p>'; 91 93 } else { 92 $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">WordPress Theme Directory</a>. Themes in the WordPress 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>';94 $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">WordPress Theme Directory</a>. Themes in the WordPress 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>'; 93 95 } 94 96 95 get_current_screen()->add_help_tab( array( 96 'id' => 'adding-themes', 97 'title' => __('Adding Themes'), 98 'content' => $help_install 99 ) ); 97 get_current_screen()->add_help_tab( 98 array( 99 'id' => 'adding-themes', 100 'title' => __( 'Adding Themes' ), 101 'content' => $help_install, 102 ) 103 ); 100 104 } // install_themes 101 105 … … 103 107 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 104 108 $help_customize = 105 '<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>' .109 '<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>' . 106 110 '<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 Publish & Activate button above the menu.' ) . '</p>' . 107 111 '<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>'; 108 112 109 get_current_screen()->add_help_tab( array( 110 'id' => 'customize-preview-themes', 111 'title' => __( 'Previewing and Customizing' ), 112 'content' => $help_customize 113 ) ); 113 get_current_screen()->add_help_tab( 114 array( 115 'id' => 'customize-preview-themes', 116 'title' => __( 'Previewing and Customizing' ), 117 'content' => $help_customize, 118 ) 119 ); 114 120 } // edit_theme_options && customize 115 121 … … 127 133 wp_reset_vars( array( 'theme', 'search' ) ); 128 134 129 wp_localize_script( 'theme', '_wpThemeSettings', array( 130 'themes' => $themes, 131 'settings' => array( 132 'canInstall' => ( ! is_multisite() && current_user_can( 'install_themes' ) ), 133 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null, 134 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ), 135 'adminUrl' => parse_url( admin_url(), PHP_URL_PATH ), 136 ), 137 'l10n' => array( 138 'addNew' => __( 'Add New Theme' ), 139 'search' => __( 'Search Installed Themes' ), 140 'searchPlaceholder' => __( 'Search installed themes...' ), // placeholder (no ellipsis) 141 'themesFound' => __( 'Number of Themes found: %d' ), 142 'noThemesFound' => __( 'No themes found. Try a different search.' ), 143 ), 144 ) ); 135 wp_localize_script( 136 'theme', '_wpThemeSettings', array( 137 'themes' => $themes, 138 'settings' => array( 139 'canInstall' => ( ! is_multisite() && current_user_can( 'install_themes' ) ), 140 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null, 141 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ), 142 'adminUrl' => parse_url( admin_url(), PHP_URL_PATH ), 143 ), 144 'l10n' => array( 145 'addNew' => __( 'Add New Theme' ), 146 'search' => __( 'Search Installed Themes' ), 147 'searchPlaceholder' => __( 'Search installed themes...' ), // placeholder (no ellipsis) 148 'themesFound' => __( 'Number of Themes found: %d' ), 149 'noThemesFound' => __( 'No themes found. Try a different search.' ), 150 ), 151 ) 152 ); 145 153 146 154 add_thickbox(); … … 164 172 <hr class="wp-header-end"> 165 173 <?php 166 if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : ?> 167 <div id="message1" class="updated notice is-dismissible"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> 168 <?php elseif ( isset($_GET['activated']) ) : 169 if ( isset( $_GET['previewed'] ) ) { ?> 174 if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : 175 ?> 176 <div id="message1" class="updated notice is-dismissible"><p><?php _e( 'The active theme is broken. Reverting to the default theme.' ); ?></p></div> 177 <?php 178 elseif ( isset( $_GET['activated'] ) ) : 179 if ( isset( $_GET['previewed'] ) ) { 180 ?> 170 181 <div id="message2" class="updated notice is-dismissible"><p><?php _e( 'Settings saved and theme activated.' ); ?> <a href="<?php echo home_url( '/' ); ?>"><?php _e( 'Visit site' ); ?></a></p></div> 171 182 <?php } else { ?> 172 <div id="message2" class="updated notice is-dismissible"><p><?php _e( 'New theme activated.' ); ?> <a href="<?php echo home_url( '/' ); ?>"><?php _e( 'Visit site' ); ?></a></p></div><?php 173 } 174 elseif ( isset($_GET['deleted']) ) : ?> 175 <div id="message3" class="updated notice is-dismissible"><p><?php _e('Theme deleted.') ?></p></div> 183 <div id="message2" class="updated notice is-dismissible"><p><?php _e( 'New theme activated.' ); ?> <a href="<?php echo home_url( '/' ); ?>"><?php _e( 'Visit site' ); ?></a></p></div> 184 <?php 185 } 186 elseif ( isset( $_GET['deleted'] ) ) : 187 ?> 188 <div id="message3" class="updated notice is-dismissible"><p><?php _e( 'Theme deleted.' ); ?></p></div> 176 189 <?php elseif ( isset( $_GET['delete-active-child'] ) ) : ?> 177 190 <div id="message4" class="error"><p><?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?></p></div> … … 193 206 // Pretend you didn't see this. 194 207 $current_theme_actions = array(); 195 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) { 196 foreach ( (array) $submenu['themes.php'] as $item) { 197 $class = ''; 198 if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) 199 continue; 200 // 0 = name, 1 = capability, 2 = file 201 if ( ( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file)) ) 202 $class = ' current'; 203 if ( !empty($submenu[$item[2]]) ) { 204 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 205 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); 206 if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) 207 $current_theme_actions[] = "<a class='button$class' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>"; 208 else 209 $current_theme_actions[] = "<a class='button$class' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>"; 210 } elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) { 211 $menu_file = $item[2]; 212 213 if ( current_user_can( 'customize' ) ) { 214 if ( 'custom-header' === $menu_file ) { 215 $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>"; 216 } elseif ( 'custom-background' === $menu_file ) { 217 $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>"; 218 } 219 } 220 221 if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) { 222 $menu_file = substr( $menu_file, 0, $pos ); 223 } 224 225 if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) { 226 $current_theme_actions[] = "<a class='button$class' href='{$item[2]}'>{$item[0]}</a>"; 227 } else { 228 $current_theme_actions[] = "<a class='button$class' href='themes.php?page={$item[2]}'>{$item[0]}</a>"; 208 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) { 209 foreach ( (array) $submenu['themes.php'] as $item ) { 210 $class = ''; 211 if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) { 212 continue; 213 } 214 // 0 = name, 1 = capability, 2 = file 215 if ( ( strcmp( $self, $item[2] ) == 0 && empty( $parent_file ) ) || ( $parent_file && ( $item[2] == $parent_file ) ) ) { 216 $class = ' current'; 217 } 218 if ( ! empty( $submenu[ $item[2] ] ) ) { 219 $submenu[ $item[2] ] = array_values( $submenu[ $item[2] ] ); // Re-index. 220 $menu_hook = get_plugin_page_hook( $submenu[ $item[2] ][0][2], $item[2] ); 221 if ( file_exists( WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}" ) || ! empty( $menu_hook ) ) { 222 $current_theme_actions[] = "<a class='button$class' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>"; 223 } else { 224 $current_theme_actions[] = "<a class='button$class' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>"; 225 } 226 } elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) { 227 $menu_file = $item[2]; 228 229 if ( current_user_can( 'customize' ) ) { 230 if ( 'custom-header' === $menu_file ) { 231 $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>"; 232 } elseif ( 'custom-background' === $menu_file ) { 233 $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>"; 229 234 } 230 235 } 236 237 if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) { 238 $menu_file = substr( $menu_file, 0, $pos ); 239 } 240 241 if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) { 242 $current_theme_actions[] = "<a class='button$class' href='{$item[2]}'>{$item[0]}</a>"; 243 } else { 244 $current_theme_actions[] = "<a class='button$class' href='themes.php?page={$item[2]}'>{$item[0]}</a>"; 245 } 231 246 } 232 247 } 248 } 233 249 234 250 ?> … … 319 335 <?php 320 336 // List broken themes, if any. 321 if ( ! is_multisite() && current_user_can( 'edit_themes') && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) {337 if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) { 322 338 ?> 323 339 324 340 <div class="broken-themes"> 325 <h3><?php _e( 'Broken Themes'); ?></h3>341 <h3><?php _e( 'Broken Themes' ); ?></h3> 326 342 <p><?php _e( 'The following themes are installed but incomplete.' ); ?></p> 327 343 328 344 <?php 329 $can_delete = current_user_can( 'delete_themes' );345 $can_delete = current_user_can( 'delete_themes' ); 330 346 $can_install = current_user_can( 'install_themes' ); 331 347 ?> 332 348 <table> 333 349 <tr> 334 <th><?php _ex( 'Name', 'theme name'); ?></th>335 <th><?php _e( 'Description'); ?></th>350 <th><?php _ex( 'Name', 'theme name' ); ?></th> 351 <th><?php _e( 'Description' ); ?></th> 336 352 <?php if ( $can_delete ) { ?> 337 353 <td></td> … … 348 364 if ( $can_delete ) { 349 365 $stylesheet = $broken_theme->get_stylesheet(); 350 $delete_url = add_query_arg( array( 351 'action' => 'delete', 352 'stylesheet' => urlencode( $stylesheet ), 353 ), admin_url( 'themes.php' ) ); 366 $delete_url = add_query_arg( 367 array( 368 'action' => 'delete', 369 'stylesheet' => urlencode( $stylesheet ), 370 ), admin_url( 'themes.php' ) 371 ); 354 372 $delete_url = wp_nonce_url( $delete_url, 'delete-theme_' . $stylesheet ); 355 373 ?> … … 360 378 if ( $can_install && 'theme_no_parent' === $broken_theme->errors()->get_error_code() ) { 361 379 $parent_theme_name = $broken_theme->get( 'Template' ); 362 $parent_theme = themes_api( 'theme_information', array( 'slug' => urlencode( $parent_theme_name ) ) );380 $parent_theme = themes_api( 'theme_information', array( 'slug' => urlencode( $parent_theme_name ) ) ); 363 381 364 382 if ( ! is_wp_error( $parent_theme ) ) { 365 $install_url = add_query_arg( array( 366 'action' => 'install-theme', 367 'theme' => urlencode( $parent_theme_name ), 368 ), admin_url( 'update.php' ) ); 383 $install_url = add_query_arg( 384 array( 385 'action' => 'install-theme', 386 'theme' => urlencode( $parent_theme_name ), 387 ), admin_url( 'update.php' ) 388 ); 369 389 $install_url = wp_nonce_url( $install_url, 'install-theme_' . $parent_theme_name ); 370 390 ?> … … 513 533 wp_print_update_row_templates(); 514 534 515 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( 516 'totals' => wp_get_update_data(), 517 ) ); 535 wp_localize_script( 536 'updates', '_wpUpdatesItemCounts', array( 537 'totals' => wp_get_update_data(), 538 ) 539 ); 518 540 519 541 require( ABSPATH . 'wp-admin/admin-footer.php' );
Note: See TracChangeset
for help on using the changeset viewer.