[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/includes/ -> class-theme-upgrader-skin.php (source)

   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       * @param array $args
  23       */
  24  	public function __construct( $args = array() ) {
  25          $defaults = array(
  26              'url'   => '',
  27              'theme' => '',
  28              'nonce' => '',
  29              'title' => __( 'Update Theme' ),
  30          );
  31          $args     = wp_parse_args( $args, $defaults );
  32  
  33          $this->theme = $args['theme'];
  34  
  35          parent::__construct( $args );
  36      }
  37  
  38      /**
  39       */
  40  	public function after() {
  41          $this->decrement_update_count( 'theme' );
  42  
  43          $update_actions = array();
  44          $theme_info     = $this->upgrader->theme_info();
  45          if ( $theme_info ) {
  46              $name       = $theme_info->display( 'Name' );
  47              $stylesheet = $this->upgrader->result['destination_name'];
  48              $template   = $theme_info->get_template();
  49  
  50              $activate_link = add_query_arg(
  51                  array(
  52                      'action'     => 'activate',
  53                      'template'   => urlencode( $template ),
  54                      'stylesheet' => urlencode( $stylesheet ),
  55                  ),
  56                  admin_url( 'themes.php' )
  57              );
  58              $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
  59  
  60              $customize_url = add_query_arg(
  61                  array(
  62                      'theme'  => urlencode( $stylesheet ),
  63                      'return' => urlencode( admin_url( 'themes.php' ) ),
  64                  ),
  65                  admin_url( 'customize.php' )
  66              );
  67  
  68              if ( get_stylesheet() == $stylesheet ) {
  69                  if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
  70                      $update_actions['preview'] = sprintf(
  71                          '<a href="%s" class="hide-if-no-customize load-customize">' .
  72                          '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
  73                          esc_url( $customize_url ),
  74                          __( 'Customize' ),
  75                          /* translators: %s: Theme name. */
  76                          sprintf( __( 'Customize &#8220;%s&#8221;' ), $name )
  77                      );
  78                  }
  79              } elseif ( current_user_can( 'switch_themes' ) ) {
  80                  if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
  81                      $update_actions['preview'] = sprintf(
  82                          '<a href="%s" class="hide-if-no-customize load-customize">' .
  83                          '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
  84                          esc_url( $customize_url ),
  85                          __( 'Live Preview' ),
  86                          /* translators: %s: Theme name. */
  87                          sprintf( __( 'Live Preview &#8220;%s&#8221;' ), $name )
  88                      );
  89                  }
  90  
  91                  $update_actions['activate'] = sprintf(
  92                      '<a href="%s" class="activatelink">' .
  93                      '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
  94                      esc_url( $activate_link ),
  95                      __( 'Activate' ),
  96                      /* translators: %s: Theme name. */
  97                      sprintf( __( 'Activate &#8220;%s&#8221;' ), $name )
  98                  );
  99              }
 100  
 101              if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) {
 102                  unset( $update_actions['preview'], $update_actions['activate'] );
 103              }
 104          }
 105  
 106          $update_actions['themes_page'] = sprintf(
 107              '<a href="%s" target="_parent">%s</a>',
 108              self_admin_url( 'themes.php' ),
 109              __( 'Return to Themes page' )
 110          );
 111  
 112          /**
 113           * Filters the list of action links available following a single theme update.
 114           *
 115           * @since 2.8.0
 116           *
 117           * @param string[] $update_actions Array of theme action links.
 118           * @param string   $theme          Theme directory name.
 119           */
 120          $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme );
 121  
 122          if ( ! empty( $update_actions ) ) {
 123              $this->feedback( implode( ' | ', (array) $update_actions ) );
 124          }
 125      }
 126  }


Generated: Sun Sep 22 01:00:03 2019 Cross-referenced by PHPXref 0.7.1