diff --git wp-admin/includes/theme.php wp-admin/includes/theme.php
index 822fb5b..0e738c4 100644
|
|
|
function wp_prepare_themes_for_js( $themes = null ) { |
| 564 | 564 | |
| 565 | 565 | $parents = array(); |
| 566 | 566 | |
| | 567 | /** @var WP_Theme $theme */ |
| 567 | 568 | foreach ( $themes as $theme ) { |
| 568 | 569 | $slug = $theme->get_stylesheet(); |
| 569 | 570 | $encoded_slug = urlencode( $slug ); |
| … |
… |
function wp_prepare_themes_for_js( $themes = null ) { |
| 602 | 603 | 'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null, |
| 603 | 604 | 'customize' => $customize_action, |
| 604 | 605 | 'delete' => current_user_can( 'delete_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=delete&stylesheet=' . $encoded_slug ), 'delete-theme_' . $slug ) : null, |
| | 606 | 'network_activate' => ( current_user_can( 'manage_network_themes' ) && ! $theme->is_allowed() ) ? wp_nonce_url( admin_url( 'themes.php?action=network_activate&stylesheet=' . $encoded_slug ), 'network-activate_' . $slug ) : null, |
| 605 | 607 | ), |
| 606 | 608 | ); |
| 607 | 609 | } |
diff --git wp-admin/themes.php wp-admin/themes.php
index c02c17a..ced36f9 100644
|
|
|
if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_op |
| 17 | 17 | ); |
| 18 | 18 | } |
| 19 | 19 | |
| | 20 | if ( current_user_can( 'manage_network_themes' ) && isset($_GET['action'] ) ) { |
| | 21 | if ( 'network_activate' === $_GET['action'] ) { |
| | 22 | check_admin_referer( 'network-activate_' . $_GET['stylesheet'] ); |
| | 23 | WP_Theme::network_enable_theme( $_GET['stylesheet'] ); |
| | 24 | wp_redirect( admin_url('themes.php?network_activated=true') ); |
| | 25 | exit; |
| | 26 | } |
| | 27 | } |
| | 28 | |
| 20 | 29 | if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) { |
| 21 | 30 | if ( 'activate' == $_GET['action'] ) { |
| 22 | 31 | check_admin_referer('switch-theme_' . $_GET['stylesheet']); |
| … |
… |
get_current_screen()->set_help_sidebar( |
| 119 | 128 | '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' |
| 120 | 129 | ); |
| 121 | 130 | |
| 122 | | if ( current_user_can( 'switch_themes' ) ) { |
| | 131 | if ( current_user_can( 'manage_network_themes' ) ) { |
| | 132 | // Display all themes to allow network administrator who can manage themes to network activate it |
| | 133 | $themes = wp_prepare_themes_for_js( wp_get_themes() ); |
| | 134 | } else if ( current_user_can( 'switch_themes' ) ) { |
| | 135 | // Display only allowed themes |
| 123 | 136 | $themes = wp_prepare_themes_for_js(); |
| 124 | 137 | } else { |
| 125 | 138 | $themes = wp_prepare_themes_for_js( array( wp_get_theme() ) ); |
| … |
… |
require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
| 165 | 178 | <hr class="wp-header-end"> |
| 166 | 179 | <?php |
| 167 | 180 | if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : ?> |
| 168 | | <div id="message1" class="updated notice is-dismissible"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> |
| | 181 | <div id="message1" class="updated notice is-dismissible"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> |
| 169 | 182 | <?php elseif ( isset($_GET['activated']) ) : |
| 170 | | if ( isset( $_GET['previewed'] ) ) { ?> |
| | 183 | if ( isset( $_GET['previewed'] ) ) : ?> |
| 171 | 184 | <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> |
| 172 | | <?php } else { ?> |
| 173 | | <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 |
| 174 | | } |
| 175 | | elseif ( isset($_GET['deleted']) ) : ?> |
| 176 | | <div id="message3" class="updated notice is-dismissible"><p><?php _e('Theme deleted.') ?></p></div> |
| | 185 | <?php else : ?> |
| | 186 | <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> |
| | 187 | <?php endif; |
| | 188 | elseif ( isset( $_GET['deleted'] ) ) : ?> |
| | 189 | <div id="message3" class="updated notice is-dismissible"><p><?php _e('Theme deleted.') ?></p></div> |
| 177 | 190 | <?php elseif ( isset( $_GET['delete-active-child'] ) ) : ?> |
| 178 | 191 | <div id="message4" class="error"><p><?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?></p></div> |
| 179 | | <?php |
| 180 | | endif; |
| | 192 | <?php elseif ( isset( $_GET['network_activated'] ) ) : ?> |
| | 193 | <div id="message5" class="updated notice is-dismissible"><p><?php _e( 'New theme activated on the network, you can now active it on your site.' ); ?></p></div> |
| | 194 | <?php endif; |
| 181 | 195 | |
| 182 | 196 | $ct = wp_get_theme(); |
| 183 | 197 | |
| … |
… |
foreach ( $themes as $theme ) : |
| 281 | 295 | |
| 282 | 296 | <div class="theme-actions"> |
| 283 | 297 | |
| 284 | | <?php if ( $theme['active'] ) { ?> |
| | 298 | <?php if ( $theme['active'] ) : ?> |
| 285 | 299 | <?php if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?> |
| 286 | 300 | <a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a> |
| 287 | 301 | <?php } ?> |
| 288 | | <?php } else { ?> |
| | 302 | <?php else : ?> |
| 289 | 303 | <?php |
| 290 | | /* translators: %s: Theme name */ |
| 291 | | $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); |
| 292 | | ?> |
| 293 | | <a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> |
| 294 | | <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?> |
| 295 | | <a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a> |
| 296 | | <?php } ?> |
| 297 | | <?php } ?> |
| | 304 | if ( $theme['actions']['network_activate'] ) : |
| | 305 | /* translators: %s: Theme name */ |
| | 306 | $aria_label = sprintf( _x( 'Network Activate %s', 'theme' ), '{{ data.name }}' ); |
| | 307 | ?> |
| | 308 | <a class="button activate" href="<?php echo $theme['actions']['network_activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Network Activate' ); ?></a> |
| | 309 | <?php else : |
| | 310 | /* translators: %s: Theme name */ |
| | 311 | $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); |
| | 312 | ?> |
| | 313 | <a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> |
| | 314 | <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?> |
| | 315 | <a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a> |
| | 316 | <?php } ?> |
| | 317 | <?php endif; ?> |
| | 318 | <?php endif; ?> |
| 298 | 319 | |
| 299 | 320 | </div> |
| 300 | 321 | </div> |
| … |
… |
$can_install = current_user_can( 'install_themes' ); |
| 419 | 440 | <a class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a> |
| 420 | 441 | <# } #> |
| 421 | 442 | <# } else { #> |
| 422 | | <?php |
| 423 | | /* translators: %s: Theme name */ |
| 424 | | $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); |
| 425 | | ?> |
| 426 | | <a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a> |
| 427 | | <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a> |
| | 443 | <# if ( data.actions.network_activate ) { #> |
| | 444 | <?php |
| | 445 | /* translators: %s: Theme name */ |
| | 446 | $aria_label = sprintf( _x( 'Network Activate %s', 'theme' ), '{{ data.name }}' ); |
| | 447 | ?> |
| | 448 | <a class="button activate" href="{{{ data.actions.network_activate }}}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Network Activate' ); ?></a> |
| | 449 | <# } else { #> |
| | 450 | <?php |
| | 451 | /* translators: %s: Theme name */ |
| | 452 | $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); |
| | 453 | ?> |
| | 454 | <a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a> |
| | 455 | <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a> |
| | 456 | <# } #> |
| 428 | 457 | <# } #> |
| 429 | 458 | </div> |
| 430 | 459 | </script> |