| @@ -1,7 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); | |
| 3 | - | |
| 4 | 2 | /** |
| 5 | 3 | * Class to check if the current WordPress and PHP versions meet our requirements. |
| 6 | 4 | * |
| 7 | 5 | * @since 1.9 |
| @@ -99,9 +97,9 @@ | ||
| 99 | 97 | * @type string $php_version Required PHP version. |
| 100 | 98 | * } |
| 101 | 99 | */ |
| 102 | 100 | public function __construct( $args ) { |
| 103 | - foreach ( array( 'plugin_name', 'plugin_file', 'plugin_version', 'wp_last_version', 'php_last_version', 'wp_version', 'php_version' ) as $setting ) { | |
| 101 | + foreach ( [ 'plugin_name', 'plugin_file', 'plugin_version', 'wp_last_version', 'php_last_version', 'wp_version', 'php_version' ] as $setting ) { | |
| 104 | 102 | if ( isset( $args[ $setting ] ) ) { |
| 105 | 103 | $this->$setting = $args[ $setting ]; |
| 106 | 104 | } |
| 107 | 105 | } |
| @@ -125,10 +123,10 @@ | ||
| 125 | 123 | * @return bool |
| 126 | 124 | */ |
| 127 | 125 | public function check() { |
| 128 | 126 | if ( ! $this->php_passes() || ! $this->wp_passes() ) { |
| 129 | - add_action( 'admin_notices', array( $this, 'print_notice' ) ); | |
| 130 | - add_action( 'admin_post_imagify_rollback', array( $this, 'rollback' ) ); | |
| 127 | + add_action( 'admin_notices', [ $this, 'print_notice' ] ); | |
| 128 | + add_action( 'admin_post_imagify_rollback', [ $this, 'rollback' ] ); | |
| 131 | 129 | |
| 132 | 130 | return false; |
| 133 | 131 | } |
| 134 | 132 | |
| @@ -198,9 +196,9 @@ | ||
| 198 | 196 | private function current_user_can() { |
| 199 | 197 | $describer = 'manage'; |
| 200 | 198 | $capacity = $this->is_active_for_network() ? 'manage_network_options' : 'manage_options'; |
| 201 | 199 | // This filter is documented in classes/Context/AbstractContext.php. |
| 202 | - $capacity = (string) apply_filters( 'imagify_capacity', $capacity, $describer, 'wp' ); | |
| 200 | + $capacity = (string) apply_filters( 'imagify_capacity', $capacity, $describer, 'wp' ); | |
| 203 | 201 | |
| 204 | 202 | $user_can = current_user_can( $capacity ); |
| 205 | 203 | // This filter is documented in classes/Context/AbstractContext.php. |
| 206 | 204 | $user_can = (bool) apply_filters( 'imagify_current_user_can', $user_can, $capacity, $describer, null, 'wp' ); |
| @@ -231,11 +229,9 @@ | ||
| 231 | 229 | |
| 232 | 230 | /** |
| 233 | 231 | * Warn if PHP version is less than 5.4 and offers to rollback. |
| 234 | 232 | * |
| 235 | - * @since 1.9 | |
| 236 | - * @access public | |
| 237 | - * @author Grégory Viguier | |
| 233 | + * @since 1.9 | |
| 238 | 234 | */ |
| 239 | 235 | public function print_notice() { |
| 240 | 236 | if ( ! $this->current_user_can() ) { |
| 241 | 237 | return; |
| @@ -240,12 +236,10 @@ | ||
| 240 | 236 | if ( ! $this->current_user_can() ) { |
| 241 | 237 | return; |
| 242 | 238 | } |
| 243 | 239 | |
| 244 | - imagify_load_translations(); | |
| 245 | - | |
| 246 | - $message = array(); | |
| 247 | - $required = array(); | |
| 240 | + $message = []; | |
| 241 | + $required = []; | |
| 248 | 242 | $rollback_url = wp_nonce_url( admin_url( 'admin-post.php?action=imagify_rollback' ), 'imagify_rollback' ); |
| 249 | 243 | |
| 250 | 244 | if ( ! $this->php_passes() ) { |
| 251 | 245 | /* translators: %1$s = Plugin name, %2$s = PHP version required. */ |
| @@ -268,17 +262,15 @@ | ||
| 268 | 262 | $message .= '<p>' . esc_html__( 'If you are not able to upgrade, you can rollback to the previous version by using the button below.', 'imagify' ) . "</p>\n"; |
| 269 | 263 | /* translators: %s = Previous plugin version. */ |
| 270 | 264 | $message .= '<p class="submit"><a href="' . esc_url( $rollback_url ) . '" class="button">' . sprintf( __( 'Re-install version %s', 'imagify' ), $this->get_last_version() ) . '</a></p>'; |
| 271 | 265 | |
| 272 | - echo '<div class="notice notice-error">' . $message . '</div>'; | |
| 266 | + echo '<div class="notice notice-error">' . $message . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 273 | 267 | } |
| 274 | 268 | |
| 275 | 269 | /** |
| 276 | 270 | * Do the rollback. |
| 277 | 271 | * |
| 278 | - * @since 1.9 | |
| 279 | - * @access public | |
| 280 | - * @author Grégory Viguier | |
| 272 | + * @since 1.9 | |
| 281 | 273 | */ |
| 282 | 274 | public function rollback() { |
| 283 | 275 | check_ajax_referer( 'imagify_rollback' ); |
| 284 | 276 | |
| @@ -285,10 +277,8 @@ | ||
| 285 | 277 | if ( ! $this->current_user_can() ) { |
| 286 | 278 | wp_die(); |
| 287 | 279 | } |
| 288 | 280 | |
| 289 | - imagify_load_translations(); | |
| 290 | - | |
| 291 | 281 | $plugin_transient = get_site_transient( 'update_plugins' ); |
| 292 | 282 | $plugin_basename = plugin_basename( $this->plugin_file ); |
| 293 | 283 | $plugin_folder = dirname( $plugin_basename ); |
| 294 | 284 | $last_version = $this->get_last_version(); |
| @@ -300,9 +290,9 @@ | ||
| 300 | 290 | $tmp_obj = $plugin_transient->response[ $plugin_basename ]; |
| 301 | 291 | } elseif ( ! empty( $plugin_transient->no_update[ $plugin_basename ] ) ) { |
| 302 | 292 | $tmp_obj = $plugin_transient->no_update[ $plugin_basename ]; |
| 303 | 293 | } else { |
| 304 | - $tmp_obj = (object) array( | |
| 294 | + $tmp_obj = (object) [ | |
| 305 | 295 | 'id' => 'w.org/plugins/' . $plugin_folder, |
| 306 | 296 | 'slug' => $plugin_folder, |
| 307 | 297 | 'plugin' => $plugin_basename, |
| 308 | 298 | 'new_version' => $last_version, |
| @@ -307,12 +297,12 @@ | ||
| 307 | 297 | 'plugin' => $plugin_basename, |
| 308 | 298 | 'new_version' => $last_version, |
| 309 | 299 | 'url' => 'https://wordpress.org/plugins/' . $plugin_folder . '/', |
| 310 | 300 | 'package' => 'https://downloads.wordpress.org/plugin/' . $package_filename, |
| 311 | - 'icons' => array(), | |
| 312 | - 'banners' => array(), | |
| 313 | - 'banners_rtl' => array(), | |
| 314 | - ); | |
| 301 | + 'icons' => [], | |
| 302 | + 'banners' => [], | |
| 303 | + 'banners_rtl' => [], | |
| 304 | + ]; | |
| 315 | 305 | } |
| 316 | 306 | |
| 317 | 307 | $tmp_obj->new_version = $last_version; |
| 318 | 308 | $tmp_obj->package = preg_replace( '@/[^/]+$@', '/' . $package_filename, $tmp_obj->package ); |
| @@ -334,10 +324,10 @@ | ||
| 334 | 324 | $upgrader->upgrade( $plugin_basename ); |
| 335 | 325 | |
| 336 | 326 | wp_die( |
| 337 | 327 | '', |
| 338 | - /* translators: %s is the plugin name. */ | |
| 339 | - sprintf( __( '%s Update Rollback', 'imagify' ), $this->plugin_name ), | |
| 340 | - array( 'response' => 200 ) | |
| 328 | + // translators: %s is the plugin name. | |
| 329 | + sprintf( esc_html__( '%s Update Rollback', 'imagify' ), esc_html( $this->plugin_name ) ), | |
| 330 | + [ 'response' => 200 ] | |
| 341 | 331 | ); |
| 342 | 332 | } |
| 343 | 333 | } |