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 |
20 public $plugin_active = false; |
20 /** |
|
21 * Holds the plugin slug in the Plugin Directory. |
|
22 * |
|
23 * @since 2.8.0 |
|
24 * |
|
25 * @var object |
|
26 */ |
|
27 public $plugin = ''; |
|
28 |
|
29 /** |
|
30 * Whether the plugin is active. |
|
31 * |
|
32 * @since 2.8.0 |
|
33 * |
|
34 * @var bool |
|
35 */ |
|
36 public $plugin_active = false; |
|
37 |
|
38 /** |
|
39 * Whether the plugin is active for the entire network. |
|
40 * |
|
41 * @since 2.8.0 |
|
42 * |
|
43 * @var bool |
|
44 */ |
21 public $plugin_network_active = false; |
45 public $plugin_network_active = false; |
22 |
46 |
23 /** |
47 /** |
24 * @param array $args |
48 * Constructor. |
|
49 * |
|
50 * Sets up the plugin upgrader skin. |
|
51 * |
|
52 * @since 2.8.0 |
|
53 * |
|
54 * @param array $args Optional. The plugin upgrader skin arguments to |
|
55 * override default options. Default empty array. |
25 */ |
56 */ |
26 public function __construct( $args = array() ) { |
57 public function __construct( $args = array() ) { |
27 $defaults = array( |
58 $defaults = array( |
28 'url' => '', |
59 'url' => '', |
29 'plugin' => '', |
60 'plugin' => '', |
39 |
70 |
40 parent::__construct( $args ); |
71 parent::__construct( $args ); |
41 } |
72 } |
42 |
73 |
43 /** |
74 /** |
|
75 * Action to perform following a single plugin update. |
|
76 * |
|
77 * @since 2.8.0 |
44 */ |
78 */ |
45 public function after() { |
79 public function after() { |
46 $this->plugin = $this->upgrader->plugin_info(); |
80 $this->plugin = $this->upgrader->plugin_info(); |
47 if ( ! empty( $this->plugin ) && ! is_wp_error( $this->result ) && $this->plugin_active ) { |
81 if ( ! empty( $this->plugin ) && ! is_wp_error( $this->result ) && $this->plugin_active ) { |
48 // Currently used only when JS is off for a single plugin update? |
82 // Currently used only when JS is off for a single plugin update? |
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>'; |
83 printf( |
|
84 '<iframe title="%s" style="border:0;overflow:hidden" width="100%%" height="170" src="%s"></iframe>', |
|
85 esc_attr__( 'Update progress' ), |
|
86 wp_nonce_url( 'update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) |
|
87 ); |
50 } |
88 } |
51 |
89 |
52 $this->decrement_update_count( 'plugin' ); |
90 $this->decrement_update_count( 'plugin' ); |
53 |
91 |
54 $update_actions = array( |
92 $update_actions = array( |
55 'activate_plugin' => '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ) . '" target="_parent">' . __( 'Activate Plugin' ) . '</a>', |
93 'activate_plugin' => sprintf( |
56 'plugins_page' => '<a href="' . self_admin_url( 'plugins.php' ) . '" target="_parent">' . __( 'Return to Plugins page' ) . '</a>', |
94 '<a href="%s" target="_parent">%s</a>', |
|
95 wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin ), |
|
96 __( 'Activate Plugin' ) |
|
97 ), |
|
98 'plugins_page' => sprintf( |
|
99 '<a href="%s" target="_parent">%s</a>', |
|
100 self_admin_url( 'plugins.php' ), |
|
101 __( 'Return to Plugins page' ) |
|
102 ), |
57 ); |
103 ); |
|
104 |
58 if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugin', $this->plugin ) ) { |
105 if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugin', $this->plugin ) ) { |
59 unset( $update_actions['activate_plugin'] ); |
106 unset( $update_actions['activate_plugin'] ); |
60 } |
107 } |
61 |
108 |
62 /** |
109 /** |