2016-05-10 07:11:30 -04:00
|
|
|
<?php
|
|
|
|
/**
|
2016-05-10 07:31:28 -04:00
|
|
|
* Upgrader API: Plugin_Upgrader_Skin class
|
2016-05-10 07:11:30 -04:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Upgrader
|
2016-05-10 07:31:28 -04:00
|
|
|
* @since 4.6.0
|
2016-05-10 07:11:30 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plugin Upgrader Skin for WordPress Plugin Upgrades.
|
|
|
|
*
|
|
|
|
* @since 2.8.0
|
2016-05-13 16:59:27 -04:00
|
|
|
* @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php.
|
2016-07-09 09:45:33 -04:00
|
|
|
*
|
|
|
|
* @see WP_Upgrader_Skin
|
2016-05-10 07:11:30 -04:00
|
|
|
*/
|
|
|
|
class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
|
2017-11-30 18:11:00 -05:00
|
|
|
public $plugin = '';
|
|
|
|
public $plugin_active = false;
|
2016-05-10 07:11:30 -04:00
|
|
|
public $plugin_network_active = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $args
|
|
|
|
*/
|
|
|
|
public function __construct( $args = array() ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
$defaults = array(
|
|
|
|
'url' => '',
|
|
|
|
'plugin' => '',
|
|
|
|
'nonce' => '',
|
|
|
|
'title' => __( 'Update Plugin' ),
|
|
|
|
);
|
|
|
|
$args = wp_parse_args( $args, $defaults );
|
2016-05-10 07:11:30 -04:00
|
|
|
|
|
|
|
$this->plugin = $args['plugin'];
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$this->plugin_active = is_plugin_active( $this->plugin );
|
2016-05-10 07:11:30 -04:00
|
|
|
$this->plugin_network_active = is_plugin_active_for_network( $this->plugin );
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
parent::__construct( $args );
|
2016-05-10 07:11:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
public function after() {
|
|
|
|
$this->plugin = $this->upgrader->plugin_info();
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! empty( $this->plugin ) && ! is_wp_error( $this->result ) && $this->plugin_active ) {
|
2016-05-10 07:11:30 -04:00
|
|
|
// Currently used only when JS is off for a single plugin update?
|
|
|
|
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>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->decrement_update_count( 'plugin' );
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$update_actions = array(
|
|
|
|
'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>',
|
|
|
|
'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>',
|
2016-05-10 07:11:30 -04:00
|
|
|
);
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugin', $this->plugin ) ) {
|
2016-05-10 07:11:30 -04:00
|
|
|
unset( $update_actions['activate_plugin'] );
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2016-05-10 07:11:30 -04:00
|
|
|
|
|
|
|
/**
|
2016-05-22 14:01:30 -04:00
|
|
|
* Filters the list of action links available following a single plugin update.
|
2016-05-10 07:11:30 -04:00
|
|
|
*
|
|
|
|
* @since 2.7.0
|
|
|
|
*
|
|
|
|
* @param array $update_actions Array of plugin action links.
|
|
|
|
* @param string $plugin Path to the plugin file.
|
|
|
|
*/
|
|
|
|
$update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! empty( $update_actions ) ) {
|
|
|
|
$this->feedback( implode( ' | ', (array) $update_actions ) );
|
|
|
|
}
|
2016-05-10 07:11:30 -04:00
|
|
|
}
|
|
|
|
}
|