| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Upgrader API: Theme_Upgrader_Skin class 4 * 5 * @package WordPress 6 * @subpackage Upgrader 7 * @since 4.6.0 8 */ 9 10 /** 11 * Theme Upgrader Skin for WordPress Theme Upgrades. 12 * 13 * @since 2.8.0 14 * @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php. 15 * 16 * @see WP_Upgrader_Skin 17 */ 18 class Theme_Upgrader_Skin extends WP_Upgrader_Skin { 19 20 /** 21 * The upgrader instance. 22 * 23 * @since 2.8.0 24 * @var Theme_Upgrader 25 */ 26 public $upgrader; 27 28 /** 29 * Holds the theme slug in the Theme Directory. 30 * 31 * @since 2.8.0 32 * 33 * @var string 34 */ 35 public $theme = ''; 36 37 /** 38 * Constructor. 39 * 40 * Sets up the theme upgrader skin. 41 * 42 * @since 2.8.0 43 * 44 * @param array $args Optional. The theme upgrader skin arguments to 45 * override default options. Default empty array. 46 */ 47 public function __construct( $args = array() ) { 48 $defaults = array( 49 'url' => '', 50 'theme' => '', 51 'nonce' => '', 52 'title' => __( 'Update Theme' ), 53 ); 54 $args = wp_parse_args( $args, $defaults ); 55 56 $this->theme = $args['theme']; 57 58 parent::__construct( $args ); 59 } 60 61 /** 62 * Performs an action following a single theme update. 63 * 64 * @since 2.8.0 65 */ 66 public function after() { 67 $this->decrement_update_count( 'theme' ); 68 69 $update_actions = array(); 70 $theme_info = $this->upgrader->theme_info(); 71 if ( $theme_info ) { 72 $name = $theme_info->display( 'Name' ); 73 $stylesheet = $this->upgrader->result['destination_name']; 74 $template = $theme_info->get_template(); 75 76 $activate_link = add_query_arg( 77 array( 78 'action' => 'activate', 79 'template' => urlencode( $template ), 80 'stylesheet' => urlencode( $stylesheet ), 81 ), 82 admin_url( 'themes.php' ) 83 ); 84 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); 85 86 $customize_url = add_query_arg( 87 array( 88 'theme' => urlencode( $stylesheet ), 89 'return' => urlencode( admin_url( 'themes.php' ) ), 90 ), 91 admin_url( 'customize.php' ) 92 ); 93 94 if ( get_stylesheet() === $stylesheet ) { 95 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 96 $update_actions['preview'] = sprintf( 97 '<a href="%s" class="hide-if-no-customize load-customize">' . 98 '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', 99 esc_url( $customize_url ), 100 __( 'Customize' ), 101 /* translators: Hidden accessibility text. %s: Theme name. */ 102 sprintf( __( 'Customize “%s”' ), $name ) 103 ); 104 } 105 } elseif ( current_user_can( 'switch_themes' ) ) { 106 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 107 $update_actions['preview'] = sprintf( 108 '<a href="%s" class="hide-if-no-customize load-customize">' . 109 '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', 110 esc_url( $customize_url ), 111 __( 'Live Preview' ), 112 /* translators: Hidden accessibility text. %s: Theme name. */ 113 sprintf( __( 'Live Preview “%s”' ), $name ) 114 ); 115 } 116 117 $update_actions['activate'] = sprintf( 118 '<a href="%s" class="activatelink">' . 119 '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', 120 esc_url( $activate_link ), 121 _x( 'Activate', 'theme' ), 122 /* translators: Hidden accessibility text. %s: Theme name. */ 123 sprintf( _x( 'Activate “%s”', 'theme' ), $name ) 124 ); 125 } 126 127 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) { 128 unset( $update_actions['preview'], $update_actions['activate'] ); 129 } 130 } 131 132 $update_actions['themes_page'] = sprintf( 133 '<a href="%s" target="_parent">%s</a>', 134 self_admin_url( 'themes.php' ), 135 __( 'Go to Themes page' ) 136 ); 137 138 /** 139 * Filters the list of action links available following a single theme update. 140 * 141 * @since 2.8.0 142 * 143 * @param string[] $update_actions Array of theme action links. 144 * @param string $theme Theme directory name. 145 */ 146 $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme ); 147 148 if ( ! empty( $update_actions ) ) { 149 $this->feedback( implode( ' | ', (array) $update_actions ) ); 150 } 151 } 152 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Sat Sep 12 08:20:32 2026 | Cross-referenced by PHPXref |