105 ); |
105 ); |
106 } elseif ( 'press-this' === $from ) { |
106 } elseif ( 'press-this' === $from ) { |
107 $install_actions['activate_plugin'] = sprintf( |
107 $install_actions['activate_plugin'] = sprintf( |
108 '<a class="button button-primary" href="%s" target="_parent">%s</a>', |
108 '<a class="button button-primary" href="%s" target="_parent">%s</a>', |
109 wp_nonce_url( 'plugins.php?action=activate&from=press-this&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ), |
109 wp_nonce_url( 'plugins.php?action=activate&from=press-this&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ), |
110 __( 'Activate Plugin & Return to Press This' ) |
110 __( 'Activate Plugin & Go to Press This' ) |
111 ); |
111 ); |
112 } else { |
112 } else { |
113 $install_actions['activate_plugin'] = sprintf( |
113 $install_actions['activate_plugin'] = sprintf( |
114 '<a class="button button-primary" href="%s" target="_parent">%s</a>', |
114 '<a class="button button-primary" href="%s" target="_parent">%s</a>', |
115 wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ), |
115 wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ), |
128 |
128 |
129 if ( 'import' === $from ) { |
129 if ( 'import' === $from ) { |
130 $install_actions['importers_page'] = sprintf( |
130 $install_actions['importers_page'] = sprintf( |
131 '<a href="%s" target="_parent">%s</a>', |
131 '<a href="%s" target="_parent">%s</a>', |
132 admin_url( 'import.php' ), |
132 admin_url( 'import.php' ), |
133 __( 'Return to Importers' ) |
133 __( 'Go to Importers' ) |
134 ); |
134 ); |
135 } elseif ( 'web' === $this->type ) { |
135 } elseif ( 'web' === $this->type ) { |
136 $install_actions['plugins_page'] = sprintf( |
136 $install_actions['plugins_page'] = sprintf( |
137 '<a href="%s" target="_parent">%s</a>', |
137 '<a href="%s" target="_parent">%s</a>', |
138 self_admin_url( 'plugin-install.php' ), |
138 self_admin_url( 'plugin-install.php' ), |
139 __( 'Return to Plugin Installer' ) |
139 __( 'Go to Plugin Installer' ) |
140 ); |
140 ); |
141 } elseif ( 'upload' === $this->type && 'plugins' === $from ) { |
141 } elseif ( 'upload' === $this->type && 'plugins' === $from ) { |
142 $install_actions['plugins_page'] = sprintf( |
142 $install_actions['plugins_page'] = sprintf( |
143 '<a href="%s">%s</a>', |
143 '<a href="%s">%s</a>', |
144 self_admin_url( 'plugin-install.php' ), |
144 self_admin_url( 'plugin-install.php' ), |
145 __( 'Return to Plugin Installer' ) |
145 __( 'Go to Plugin Installer' ) |
146 ); |
146 ); |
147 } else { |
147 } else { |
148 $install_actions['plugins_page'] = sprintf( |
148 $install_actions['plugins_page'] = sprintf( |
149 '<a href="%s" target="_parent">%s</a>', |
149 '<a href="%s" target="_parent">%s</a>', |
150 self_admin_url( 'plugins.php' ), |
150 self_admin_url( 'plugins.php' ), |
151 __( 'Return to Plugins page' ) |
151 __( 'Go to Plugins page' ) |
152 ); |
152 ); |
153 } |
153 } |
154 |
154 |
155 if ( ! $this->result || is_wp_error( $this->result ) ) { |
155 if ( ! $this->result || is_wp_error( $this->result ) ) { |
156 unset( $install_actions['activate_plugin'], $install_actions['network_activate'] ); |
156 unset( $install_actions['activate_plugin'], $install_actions['network_activate'] ); |
206 |
206 |
207 if ( ! $current_plugin_data || ! $new_plugin_data ) { |
207 if ( ! $current_plugin_data || ! $new_plugin_data ) { |
208 return false; |
208 return false; |
209 } |
209 } |
210 |
210 |
211 echo '<h2 class="update-from-upload-heading">' . esc_html( __( 'This plugin is already installed.' ) ) . '</h2>'; |
211 echo '<h2 class="update-from-upload-heading">' . esc_html__( 'This plugin is already installed.' ) . '</h2>'; |
212 |
212 |
213 $this->is_downgrading = version_compare( $current_plugin_data['Version'], $new_plugin_data['Version'], '>' ); |
213 $this->is_downgrading = version_compare( $current_plugin_data['Version'], $new_plugin_data['Version'], '>' ); |
214 |
214 |
215 $rows = array( |
215 $rows = array( |
216 'Name' => __( 'Plugin name' ), |
216 'Name' => __( 'Plugin name' ), |
219 'RequiresWP' => __( 'Required WordPress version' ), |
219 'RequiresWP' => __( 'Required WordPress version' ), |
220 'RequiresPHP' => __( 'Required PHP version' ), |
220 'RequiresPHP' => __( 'Required PHP version' ), |
221 ); |
221 ); |
222 |
222 |
223 $table = '<table class="update-from-upload-comparison"><tbody>'; |
223 $table = '<table class="update-from-upload-comparison"><tbody>'; |
224 $table .= '<tr><th></th><th>' . esc_html( __( 'Current' ) ) . '</th>'; |
224 $table .= '<tr><th></th><th>' . esc_html_x( 'Current', 'plugin' ) . '</th>'; |
225 $table .= '<th>' . esc_html( __( 'Uploaded' ) ) . '</th></tr>'; |
225 $table .= '<th>' . esc_html_x( 'Uploaded', 'plugin' ) . '</th></tr>'; |
226 |
226 |
227 $is_same_plugin = true; // Let's consider only these rows. |
227 $is_same_plugin = true; // Let's consider only these rows. |
228 |
228 |
229 foreach ( $rows as $field => $label ) { |
229 foreach ( $rows as $field => $label ) { |
230 $old_value = ! empty( $current_plugin_data[ $field ] ) ? (string) $current_plugin_data[ $field ] : '-'; |
230 $old_value = ! empty( $current_plugin_data[ $field ] ) ? (string) $current_plugin_data[ $field ] : '-'; |
254 echo apply_filters( 'install_plugin_overwrite_comparison', $table, $current_plugin_data, $new_plugin_data ); |
254 echo apply_filters( 'install_plugin_overwrite_comparison', $table, $current_plugin_data, $new_plugin_data ); |
255 |
255 |
256 $install_actions = array(); |
256 $install_actions = array(); |
257 $can_update = true; |
257 $can_update = true; |
258 |
258 |
259 $blocked_message = '<p>' . esc_html( __( 'The plugin cannot be updated due to the following:' ) ) . '</p>'; |
259 $blocked_message = '<p>' . esc_html__( 'The plugin cannot be updated due to the following:' ) . '</p>'; |
260 $blocked_message .= '<ul class="ul-disc">'; |
260 $blocked_message .= '<ul class="ul-disc">'; |
261 |
261 |
262 $requires_php = isset( $new_plugin_data['RequiresPHP'] ) ? $new_plugin_data['RequiresPHP'] : null; |
262 $requires_php = isset( $new_plugin_data['RequiresPHP'] ) ? $new_plugin_data['RequiresPHP'] : null; |
263 $requires_wp = isset( $new_plugin_data['RequiresWP'] ) ? $new_plugin_data['RequiresWP'] : null; |
263 $requires_wp = isset( $new_plugin_data['RequiresWP'] ) ? $new_plugin_data['RequiresWP'] : null; |
264 |
264 |
308 $overwrite = $this->is_downgrading ? 'downgrade-plugin' : 'update-plugin'; |
308 $overwrite = $this->is_downgrading ? 'downgrade-plugin' : 'update-plugin'; |
309 |
309 |
310 $install_actions['overwrite_plugin'] = sprintf( |
310 $install_actions['overwrite_plugin'] = sprintf( |
311 '<a class="button button-primary update-from-upload-overwrite" href="%s" target="_parent">%s</a>', |
311 '<a class="button button-primary update-from-upload-overwrite" href="%s" target="_parent">%s</a>', |
312 wp_nonce_url( add_query_arg( 'overwrite', $overwrite, $this->url ), 'plugin-upload' ), |
312 wp_nonce_url( add_query_arg( 'overwrite', $overwrite, $this->url ), 'plugin-upload' ), |
313 __( 'Replace current with uploaded' ) |
313 _x( 'Replace current with uploaded', 'plugin' ) |
314 ); |
314 ); |
315 } else { |
315 } else { |
316 echo $blocked_message; |
316 echo $blocked_message; |
317 } |
317 } |
318 |
318 |
323 wp_nonce_url( $cancel_url, 'plugin-upload-cancel-overwrite' ), |
323 wp_nonce_url( $cancel_url, 'plugin-upload-cancel-overwrite' ), |
324 __( 'Cancel and go back' ) |
324 __( 'Cancel and go back' ) |
325 ); |
325 ); |
326 |
326 |
327 /** |
327 /** |
328 * Filters the list of action links available following a single plugin installation |
328 * Filters the list of action links available following a single plugin installation failure |
329 * failure when overwriting is allowed. |
329 * when overwriting is allowed. |
330 * |
330 * |
331 * @since 5.5.0 |
331 * @since 5.5.0 |
332 * |
332 * |
333 * @param string[] $install_actions Array of plugin action links. |
333 * @param string[] $install_actions Array of plugin action links. |
334 * @param object $api Object containing WordPress.org API plugin data. |
334 * @param object $api Object containing WordPress.org API plugin data. |