[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-admin/includes/ -> class-plugin-installer-skin.php (source)

   1  <?php
   2  /**
   3   * Upgrader API: Plugin_Installer_Skin class
   4   *
   5   * @package WordPress
   6   * @subpackage Upgrader
   7   * @since 4.6.0
   8   */
   9  
  10  /**
  11   * Plugin Installer Skin for WordPress Plugin Installer.
  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 Plugin_Installer_Skin extends WP_Upgrader_Skin {
  19      public $api;
  20      public $type;
  21  
  22      /**
  23       * @param array $args
  24       */
  25  	public function __construct( $args = array() ) {
  26          $defaults = array(
  27              'type'   => 'web',
  28              'url'    => '',
  29              'plugin' => '',
  30              'nonce'  => '',
  31              'title'  => '',
  32          );
  33          $args     = wp_parse_args( $args, $defaults );
  34  
  35          $this->type = $args['type'];
  36          $this->api  = isset( $args['api'] ) ? $args['api'] : array();
  37  
  38          parent::__construct( $args );
  39      }
  40  
  41      /**
  42       */
  43  	public function before() {
  44          if ( ! empty( $this->api ) ) {
  45              $this->upgrader->strings['process_success'] = sprintf(
  46                  /* translators: 1: Plugin name, 2: Plugin version. */
  47                  __( 'Successfully installed the plugin <strong>%1$s %2$s</strong>.' ),
  48                  $this->api->name,
  49                  $this->api->version
  50              );
  51          }
  52      }
  53  
  54      /**
  55       */
  56  	public function after() {
  57          $plugin_file = $this->upgrader->plugin_info();
  58  
  59          $install_actions = array();
  60  
  61          $from = isset( $_GET['from'] ) ? wp_unslash( $_GET['from'] ) : 'plugins';
  62  
  63          if ( 'import' == $from ) {
  64              $install_actions['activate_plugin'] = sprintf(
  65                  '<a class="button button-primary" href="%s" target="_parent">%s</a>',
  66                  wp_nonce_url( 'plugins.php?action=activate&amp;from=import&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
  67                  __( 'Activate Plugin &amp; Run Importer' )
  68              );
  69          } elseif ( 'press-this' == $from ) {
  70              $install_actions['activate_plugin'] = sprintf(
  71                  '<a class="button button-primary" href="%s" target="_parent">%s</a>',
  72                  wp_nonce_url( 'plugins.php?action=activate&amp;from=press-this&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
  73                  __( 'Activate Plugin &amp; Return to Press This' )
  74              );
  75          } else {
  76              $install_actions['activate_plugin'] = sprintf(
  77                  '<a class="button button-primary" href="%s" target="_parent">%s</a>',
  78                  wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
  79                  __( 'Activate Plugin' )
  80              );
  81          }
  82  
  83          if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
  84              $install_actions['network_activate'] = sprintf(
  85                  '<a class="button button-primary" href="%s" target="_parent">%s</a>',
  86                  wp_nonce_url( 'plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
  87                  __( 'Network Activate' )
  88              );
  89              unset( $install_actions['activate_plugin'] );
  90          }
  91  
  92          if ( 'import' == $from ) {
  93              $install_actions['importers_page'] = sprintf(
  94                  '<a href="%s" target="_parent">%s</a>',
  95                  admin_url( 'import.php' ),
  96                  __( 'Return to Importers' )
  97              );
  98          } elseif ( $this->type == 'web' ) {
  99              $install_actions['plugins_page'] = sprintf(
 100                  '<a href="%s" target="_parent">%s</a>',
 101                  self_admin_url( 'plugin-install.php' ),
 102                  __( 'Return to Plugin Installer' )
 103              );
 104          } elseif ( 'upload' == $this->type && 'plugins' == $from ) {
 105              $install_actions['plugins_page'] = sprintf(
 106                  '<a href="%s">%s</a>',
 107                  self_admin_url( 'plugin-install.php' ),
 108                  __( 'Return to Plugin Installer' )
 109              );
 110          } else {
 111              $install_actions['plugins_page'] = sprintf(
 112                  '<a href="%s" target="_parent">%s</a>',
 113                  self_admin_url( 'plugins.php' ),
 114                  __( 'Return to Plugins page' )
 115              );
 116          }
 117  
 118          if ( ! $this->result || is_wp_error( $this->result ) ) {
 119              unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
 120          } elseif ( ! current_user_can( 'activate_plugin', $plugin_file ) ) {
 121              unset( $install_actions['activate_plugin'] );
 122          }
 123  
 124          /**
 125           * Filters the list of action links available following a single plugin installation.
 126           *
 127           * @since 2.7.0
 128           *
 129           * @param string[] $install_actions Array of plugin action links.
 130           * @param object   $api             Object containing WordPress.org API plugin data. Empty
 131           *                                  for non-API installs, such as when a plugin is installed
 132           *                                  via upload.
 133           * @param string   $plugin_file     Path to the plugin file relative to the plugins directory.
 134           */
 135          $install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
 136  
 137          if ( ! empty( $install_actions ) ) {
 138              $this->feedback( implode( ' ', (array) $install_actions ) );
 139          }
 140      }
 141  }


Generated: Tue Oct 22 08:20:01 2019 Cross-referenced by PHPXref 0.7