3 * Upgrader API: Theme_Upgrader_Skin class
11 * Theme Upgrader Skin for WordPress Theme Upgrades.
14 * @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php.
16 * @see WP_Upgrader_Skin
18 class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
25 public function __construct($args = array()) {
26 $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') );
27 $args = wp_parse_args($args, $defaults);
29 $this->theme = $args['theme'];
31 parent::__construct($args);
37 public function after() {
38 $this->decrement_update_count( 'theme' );
40 $update_actions = array();
41 if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
42 $name = $theme_info->display('Name');
43 $stylesheet = $this->upgrader->result['destination_name'];
44 $template = $theme_info->get_template();
46 $activate_link = add_query_arg( array(
47 'action' => 'activate',
48 'template' => urlencode( $template ),
49 'stylesheet' => urlencode( $stylesheet ),
50 ), admin_url('themes.php') );
51 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
53 if ( get_stylesheet() == $stylesheet ) {
54 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
55 $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Customize' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Customize “%s”' ), $name ) . '</span></a>';
57 } elseif ( current_user_can( 'switch_themes' ) ) {
58 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
59 $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>';
61 $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>';
64 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() )
65 unset( $update_actions['preview'], $update_actions['activate'] );
68 $update_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>';
71 * Filters the list of action links available following a single theme update.
75 * @param array $update_actions Array of theme action links.
76 * @param string $theme Theme directory name.
78 $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme );
80 if ( ! empty($update_actions) )
81 $this->feedback(implode(' | ', (array)$update_actions));