/wp-admin/includes/class-theme-upgrader-skin.php

  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. public $theme = ''; 
  20.  
  21. /** 
  22. * 
  23. * @param array $args 
  24. */ 
  25. public function __construct($args = array()) { 
  26. $defaults = array( 'url' => '', 'theme' => '', 'nonce' => '', 'title' => __('Update Theme') ); 
  27. $args = wp_parse_args($args, $defaults); 
  28.  
  29. $this->theme = $args['theme']; 
  30.  
  31. parent::__construct($args); 
  32.  
  33. /** 
  34. * @access public 
  35. */ 
  36. public function after() { 
  37. $this->decrement_update_count( 'theme' ); 
  38.  
  39. $update_actions = array(); 
  40. if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) { 
  41. $name = $theme_info->display('Name'); 
  42. $stylesheet = $this->upgrader->result['destination_name']; 
  43. $template = $theme_info->get_template(); 
  44.  
  45. $activate_link = add_query_arg( array( 
  46. 'action' => 'activate',  
  47. 'template' => urlencode( $template ),  
  48. 'stylesheet' => urlencode( $stylesheet ),  
  49. ), admin_url('themes.php') ); 
  50. $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); 
  51.  
  52. if ( get_stylesheet() == $stylesheet ) { 
  53. if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 
  54. $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>'; 
  55. } elseif ( current_user_can( 'switch_themes' ) ) { 
  56. if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 
  57. $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>'; 
  58. $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>'; 
  59.  
  60. if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) 
  61. unset( $update_actions['preview'], $update_actions['activate'] ); 
  62.  
  63. $update_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; 
  64.  
  65. /** 
  66. * Filters the list of action links available following a single theme update. 
  67. * 
  68. * @since 2.8.0 
  69. * 
  70. * @param array $update_actions Array of theme action links. 
  71. * @param string $theme Theme directory name. 
  72. */ 
  73. $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme ); 
  74.  
  75. if ( ! empty($update_actions) ) 
  76. $this->feedback(implode(' | ', (array)$update_actions)); 
.