wp/wp-admin/includes/class-plugin-upgrader-skin.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    14  * @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php.
    14  * @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php.
    15  *
    15  *
    16  * @see WP_Upgrader_Skin
    16  * @see WP_Upgrader_Skin
    17  */
    17  */
    18 class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
    18 class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
    19 	public $plugin = '';
    19 	public $plugin                = '';
    20 	public $plugin_active = false;
    20 	public $plugin_active         = false;
    21 	public $plugin_network_active = false;
    21 	public $plugin_network_active = false;
    22 
    22 
    23 	/**
    23 	/**
    24 	 *
       
    25 	 * @param array $args
    24 	 * @param array $args
    26 	 */
    25 	 */
    27 	public function __construct( $args = array() ) {
    26 	public function __construct( $args = array() ) {
    28 		$defaults = array( 'url' => '', 'plugin' => '', 'nonce' => '', 'title' => __('Update Plugin') );
    27 		$defaults = array(
    29 		$args = wp_parse_args($args, $defaults);
    28 			'url'    => '',
       
    29 			'plugin' => '',
       
    30 			'nonce'  => '',
       
    31 			'title'  => __( 'Update Plugin' ),
       
    32 		);
       
    33 		$args     = wp_parse_args( $args, $defaults );
    30 
    34 
    31 		$this->plugin = $args['plugin'];
    35 		$this->plugin = $args['plugin'];
    32 
    36 
    33 		$this->plugin_active = is_plugin_active( $this->plugin );
    37 		$this->plugin_active         = is_plugin_active( $this->plugin );
    34 		$this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
    38 		$this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
    35 
    39 
    36 		parent::__construct($args);
    40 		parent::__construct( $args );
    37 	}
    41 	}
    38 
    42 
    39 	/**
    43 	/**
    40 	 */
    44 	 */
    41 	public function after() {
    45 	public function after() {
    42 		$this->plugin = $this->upgrader->plugin_info();
    46 		$this->plugin = $this->upgrader->plugin_info();
    43 		if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
    47 		if ( ! empty( $this->plugin ) && ! is_wp_error( $this->result ) && $this->plugin_active ) {
    44 			// Currently used only when JS is off for a single plugin update?
    48 			// Currently used only when JS is off for a single plugin update?
    45 			echo '<iframe title="' . esc_attr__( 'Update progress' ) . '" style="border:0;overflow:hidden" width="100%" height="170" src="' . wp_nonce_url( 'update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) . '"></iframe>';
    49 			echo '<iframe title="' . esc_attr__( 'Update progress' ) . '" style="border:0;overflow:hidden" width="100%" height="170" src="' . wp_nonce_url( 'update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) . '"></iframe>';
    46 		}
    50 		}
    47 
    51 
    48 		$this->decrement_update_count( 'plugin' );
    52 		$this->decrement_update_count( 'plugin' );
    49 
    53 
    50 		$update_actions =  array(
    54 		$update_actions = array(
    51 			'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>',
    55 			'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>',
    52 			'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>'
    56 			'plugins_page'    => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>',
    53 		);
    57 		);
    54 		if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugin', $this->plugin ) )
    58 		if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugin', $this->plugin ) ) {
    55 			unset( $update_actions['activate_plugin'] );
    59 			unset( $update_actions['activate_plugin'] );
       
    60 		}
    56 
    61 
    57 		/**
    62 		/**
    58 		 * Filters the list of action links available following a single plugin update.
    63 		 * Filters the list of action links available following a single plugin update.
    59 		 *
    64 		 *
    60 		 * @since 2.7.0
    65 		 * @since 2.7.0
    61 		 *
    66 		 *
    62 		 * @param array  $update_actions Array of plugin action links.
    67 		 * @param string[] $update_actions Array of plugin action links.
    63 		 * @param string $plugin         Path to the plugin file.
    68 		 * @param string   $plugin         Path to the plugin file relative to the plugins directory.
    64 		 */
    69 		 */
    65 		$update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
    70 		$update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
    66 
    71 
    67 		if ( ! empty($update_actions) )
    72 		if ( ! empty( $update_actions ) ) {
    68 			$this->feedback(implode(' | ', (array)$update_actions));
    73 			$this->feedback( implode( ' | ', (array) $update_actions ) );
       
    74 		}
    69 	}
    75 	}
    70 }
    76 }