Theme_Installer_Skin

Theme Installer Skin for the WordPress Theme Installer.

Defined (1)

The class is defined in the following location(s).

/wp-admin/includes/class-theme-installer-skin.php  
  1. class Theme_Installer_Skin extends WP_Upgrader_Skin { 
  2. public $api; 
  3. public $type; 
  4.  
  5. /** 
  6. * @param array $args 
  7. */ 
  8. public function __construct($args = array()) { 
  9. $defaults = array( 'type' => 'web', 'url' => '', 'theme' => '', 'nonce' => '', 'title' => '' ); 
  10. $args = wp_parse_args($args, $defaults); 
  11.  
  12. $this->type = $args['type']; 
  13. $this->api = isset($args['api']) ? $args['api'] : array(); 
  14.  
  15. parent::__construct($args); 
  16.  
  17. /** 
  18. * @access public 
  19. */ 
  20. public function before() { 
  21. if ( !empty($this->api) ) 
  22. $this->upgrader->strings['process_success'] = sprintf( $this->upgrader->strings['process_success_specific'], $this->api->name, $this->api->version); 
  23.  
  24. /** 
  25. * @access public 
  26. */ 
  27. public function after() { 
  28. if ( empty($this->upgrader->result['destination_name']) ) 
  29. return; 
  30.  
  31. $theme_info = $this->upgrader->theme_info(); 
  32. if ( empty( $theme_info ) ) 
  33. return; 
  34.  
  35. $name = $theme_info->display('Name'); 
  36. $stylesheet = $this->upgrader->result['destination_name']; 
  37. $template = $theme_info->get_template(); 
  38.  
  39. $activate_link = add_query_arg( array( 
  40. 'action' => 'activate',  
  41. 'template' => urlencode( $template ),  
  42. 'stylesheet' => urlencode( $stylesheet ),  
  43. ), admin_url('themes.php') ); 
  44. $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); 
  45.  
  46. $install_actions = array(); 
  47.  
  48. if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 
  49. $install_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>'; 
  50. $install_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>'; 
  51.  
  52. if ( is_network_admin() && current_user_can( 'manage_network_themes' ) ) 
  53. $install_actions['network_enable'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=enable&theme=' . urlencode( $stylesheet ), 'enable-theme_' . $stylesheet ) ) . '" target="_parent">' . __( 'Network Enable' ) . '</a>'; 
  54.  
  55. if ( $this->type == 'web' ) 
  56. $install_actions['themes_page'] = '<a href="' . self_admin_url( 'theme-install.php' ) . '" target="_parent">' . __( 'Return to Theme Installer' ) . '</a>'; 
  57. elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) 
  58. $install_actions['themes_page'] = '<a href="' . self_admin_url( 'themes.php' ) . '" target="_parent">' . __( 'Return to Themes page' ) . '</a>'; 
  59.  
  60. if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) 
  61. unset( $install_actions['activate'], $install_actions['preview'] ); 
  62.  
  63. /** 
  64. * Filters the list of action links available following a single theme installation. 
  65. * @since 2.8.0 
  66. * @param array $install_actions Array of theme action links. 
  67. * @param object $api Object containing WordPress.org API theme data. 
  68. * @param string $stylesheet Theme directory name. 
  69. * @param WP_Theme $theme_info Theme object. 
  70. */ 
  71. $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info ); 
  72. if ( ! empty($install_actions) ) 
  73. $this->feedback(implode(' | ', (array)$install_actions));