153 |
153 |
154 if ( 'web' === $this->type ) { |
154 if ( 'web' === $this->type ) { |
155 $install_actions['themes_page'] = sprintf( |
155 $install_actions['themes_page'] = sprintf( |
156 '<a href="%s" target="_parent">%s</a>', |
156 '<a href="%s" target="_parent">%s</a>', |
157 self_admin_url( 'theme-install.php' ), |
157 self_admin_url( 'theme-install.php' ), |
158 __( 'Return to Theme Installer' ) |
158 __( 'Go to Theme Installer' ) |
159 ); |
159 ); |
160 } elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) { |
160 } elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) ) { |
161 $install_actions['themes_page'] = sprintf( |
161 $install_actions['themes_page'] = sprintf( |
162 '<a href="%s" target="_parent">%s</a>', |
162 '<a href="%s" target="_parent">%s</a>', |
163 self_admin_url( 'themes.php' ), |
163 self_admin_url( 'themes.php' ), |
164 __( 'Return to Themes page' ) |
164 __( 'Go to Themes page' ) |
165 ); |
165 ); |
166 } |
166 } |
167 |
167 |
168 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) { |
168 if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() || ! current_user_can( 'switch_themes' ) ) { |
169 unset( $install_actions['activate'], $install_actions['preview'] ); |
169 unset( $install_actions['activate'], $install_actions['preview'] ); |
219 |
219 |
220 if ( ! $current_theme_data || ! $new_theme_data ) { |
220 if ( ! $current_theme_data || ! $new_theme_data ) { |
221 return false; |
221 return false; |
222 } |
222 } |
223 |
223 |
224 echo '<h2 class="update-from-upload-heading">' . esc_html( __( 'This theme is already installed.' ) ) . '</h2>'; |
224 echo '<h2 class="update-from-upload-heading">' . esc_html__( 'This theme is already installed.' ) . '</h2>'; |
225 |
225 |
226 // Check errors for current theme. |
226 // Check errors for current theme. |
227 if ( is_wp_error( $current_theme_data->errors() ) ) { |
227 if ( is_wp_error( $current_theme_data->errors() ) ) { |
228 $this->feedback( 'current_theme_has_errors', $current_theme_data->errors()->get_error_message() ); |
228 $this->feedback( 'current_theme_has_errors', $current_theme_data->errors()->get_error_message() ); |
229 } |
229 } |
243 'RequiresPHP' => __( 'Required PHP version' ), |
243 'RequiresPHP' => __( 'Required PHP version' ), |
244 'Template' => __( 'Parent theme' ), |
244 'Template' => __( 'Parent theme' ), |
245 ); |
245 ); |
246 |
246 |
247 $table = '<table class="update-from-upload-comparison"><tbody>'; |
247 $table = '<table class="update-from-upload-comparison"><tbody>'; |
248 $table .= '<tr><th></th><th>' . esc_html( __( 'Current' ) ) . '</th><th>' . esc_html( __( 'Uploaded' ) ) . '</th></tr>'; |
248 $table .= '<tr><th></th><th>' . esc_html_x( 'Current', 'theme' ) . '</th><th>' . esc_html_x( 'Uploaded', 'theme' ) . '</th></tr>'; |
249 |
249 |
250 $is_same_theme = true; // Let's consider only these rows. |
250 $is_same_theme = true; // Let's consider only these rows. |
251 |
251 |
252 foreach ( $rows as $field => $label ) { |
252 foreach ( $rows as $field => $label ) { |
253 $old_value = $current_theme_data->display( $field, false ); |
253 $old_value = $current_theme_data->display( $field, false ); |
289 echo apply_filters( 'install_theme_overwrite_comparison', $table, $current_theme_data, $new_theme_data ); |
289 echo apply_filters( 'install_theme_overwrite_comparison', $table, $current_theme_data, $new_theme_data ); |
290 |
290 |
291 $install_actions = array(); |
291 $install_actions = array(); |
292 $can_update = true; |
292 $can_update = true; |
293 |
293 |
294 $blocked_message = '<p>' . esc_html( __( 'The theme cannot be updated due to the following:' ) ) . '</p>'; |
294 $blocked_message = '<p>' . esc_html__( 'The theme cannot be updated due to the following:' ) . '</p>'; |
295 $blocked_message .= '<ul class="ul-disc">'; |
295 $blocked_message .= '<ul class="ul-disc">'; |
296 |
296 |
297 $requires_php = isset( $new_theme_data['RequiresPHP'] ) ? $new_theme_data['RequiresPHP'] : null; |
297 $requires_php = isset( $new_theme_data['RequiresPHP'] ) ? $new_theme_data['RequiresPHP'] : null; |
298 $requires_wp = isset( $new_theme_data['RequiresWP'] ) ? $new_theme_data['RequiresWP'] : null; |
298 $requires_wp = isset( $new_theme_data['RequiresWP'] ) ? $new_theme_data['RequiresWP'] : null; |
299 |
299 |
343 $overwrite = $this->is_downgrading ? 'downgrade-theme' : 'update-theme'; |
343 $overwrite = $this->is_downgrading ? 'downgrade-theme' : 'update-theme'; |
344 |
344 |
345 $install_actions['overwrite_theme'] = sprintf( |
345 $install_actions['overwrite_theme'] = sprintf( |
346 '<a class="button button-primary update-from-upload-overwrite" href="%s" target="_parent">%s</a>', |
346 '<a class="button button-primary update-from-upload-overwrite" href="%s" target="_parent">%s</a>', |
347 wp_nonce_url( add_query_arg( 'overwrite', $overwrite, $this->url ), 'theme-upload' ), |
347 wp_nonce_url( add_query_arg( 'overwrite', $overwrite, $this->url ), 'theme-upload' ), |
348 __( 'Replace current with uploaded' ) |
348 _x( 'Replace current with uploaded', 'theme' ) |
349 ); |
349 ); |
350 } else { |
350 } else { |
351 echo $blocked_message; |
351 echo $blocked_message; |
352 } |
352 } |
353 |
353 |
358 wp_nonce_url( $cancel_url, 'theme-upload-cancel-overwrite' ), |
358 wp_nonce_url( $cancel_url, 'theme-upload-cancel-overwrite' ), |
359 __( 'Cancel and go back' ) |
359 __( 'Cancel and go back' ) |
360 ); |
360 ); |
361 |
361 |
362 /** |
362 /** |
363 * Filters the list of action links available following a single theme installation |
363 * Filters the list of action links available following a single theme installation failure |
364 * failure when overwriting is allowed. |
364 * when overwriting is allowed. |
365 * |
365 * |
366 * @since 5.5.0 |
366 * @since 5.5.0 |
367 * |
367 * |
368 * @param string[] $install_actions Array of theme action links. |
368 * @param string[] $install_actions Array of theme action links. |
369 * @param object $api Object containing WordPress.org API theme data. |
369 * @param object $api Object containing WordPress.org API theme data. |