Skip to content

Commit a0b542a

Browse files
Coding Standards: Use more meaningful variable names in Plugin Upgrader.
Per the [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions Naming Conventions]: > Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting. This commit includes renaming of the following variables: * `$r` to `$upgrade_data`. * `$res` to `$connected`. * `$pluginfiles` to `$plugin_files` — Per naming conventions, separate words via underscores. * `$info` to `$new_plugin_data`. Follow-up to [6779], [8550], [9141], [11005], [12157], [18618], [56525]. Props costdev, mukesh27. See #63168. git-svn-id: https://develop.svn.wordpress.org/trunk@60997 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 7e980dd commit a0b542a

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/wp-admin/includes/class-plugin-upgrader.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function upgrade( $plugin, $args = array() ) {
206206
}
207207

208208
// Get the URL to the zip file.
209-
$r = $current->response[ $plugin ];
209+
$upgrade_data = $current->response[ $plugin ];
210210

211211
add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 );
212212
add_filter( 'upgrader_pre_install', array( $this, 'active_before' ), 10, 2 );
@@ -223,7 +223,7 @@ public function upgrade( $plugin, $args = array() ) {
223223

224224
$this->run(
225225
array(
226-
'package' => $r->package,
226+
'package' => $upgrade_data->package,
227227
'destination' => WP_PLUGIN_DIR,
228228
'clear_destination' => true,
229229
'clear_working' => true,
@@ -301,8 +301,8 @@ public function bulk_upgrade( $plugins, $args = array() ) {
301301
$this->skin->header();
302302

303303
// Connect to the filesystem first.
304-
$res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
305-
if ( ! $res ) {
304+
$connected = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
305+
if ( ! $connected ) {
306306
$this->skin->footer();
307307
return false;
308308
}
@@ -341,32 +341,32 @@ public function bulk_upgrade( $plugins, $args = array() ) {
341341
}
342342

343343
// Get the URL to the zip file.
344-
$r = $current->response[ $plugin ];
344+
$upgrade_data = $current->response[ $plugin ];
345345

346346
$this->skin->plugin_active = is_plugin_active( $plugin );
347347

348-
if ( isset( $r->requires ) && ! is_wp_version_compatible( $r->requires ) ) {
348+
if ( isset( $upgrade_data->requires ) && ! is_wp_version_compatible( $upgrade_data->requires ) ) {
349349
$result = new WP_Error(
350350
'incompatible_wp_required_version',
351351
sprintf(
352352
/* translators: 1: Current WordPress version, 2: WordPress version required by the new plugin version. */
353353
__( 'Your WordPress version is %1$s, however the new plugin version requires %2$s.' ),
354354
$wp_version,
355-
$r->requires
355+
$upgrade_data->requires
356356
)
357357
);
358358

359359
$this->skin->before( $result );
360360
$this->skin->error( $result );
361361
$this->skin->after();
362-
} elseif ( isset( $r->requires_php ) && ! is_php_version_compatible( $r->requires_php ) ) {
362+
} elseif ( isset( $upgrade_data->requires_php ) && ! is_php_version_compatible( $upgrade_data->requires_php ) ) {
363363
$result = new WP_Error(
364364
'incompatible_php_required_version',
365365
sprintf(
366366
/* translators: 1: Current PHP version, 2: PHP version required by the new plugin version. */
367367
__( 'The PHP version on your server is %1$s, however the new plugin version requires %2$s.' ),
368368
PHP_VERSION,
369-
$r->requires_php
369+
$upgrade_data->requires_php
370370
)
371371
);
372372

@@ -377,7 +377,7 @@ public function bulk_upgrade( $plugins, $args = array() ) {
377377
add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
378378
$result = $this->run(
379379
array(
380-
'package' => $r->package,
380+
'package' => $upgrade_data->package,
381381
'destination' => WP_PLUGIN_DIR,
382382
'clear_destination' => true,
383383
'clear_working' => true,
@@ -478,9 +478,9 @@ public function check_package( $source ) {
478478
$files = glob( $working_directory . '*.php' );
479479
if ( $files ) {
480480
foreach ( $files as $file ) {
481-
$info = get_plugin_data( $file, false, false );
482-
if ( ! empty( $info['Name'] ) ) {
483-
$this->new_plugin_data = $info;
481+
$new_plugin_data = get_plugin_data( $file, false, false );
482+
if ( ! empty( $new_plugin_data['Name'] ) ) {
483+
$this->new_plugin_data = $new_plugin_data;
484484
break;
485485
}
486486
}
@@ -490,8 +490,8 @@ public function check_package( $source ) {
490490
return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) );
491491
}
492492

493-
$requires_php = isset( $info['RequiresPHP'] ) ? $info['RequiresPHP'] : null;
494-
$requires_wp = isset( $info['RequiresWP'] ) ? $info['RequiresWP'] : null;
493+
$requires_php = isset( $new_plugin_data['RequiresPHP'] ) ? $new_plugin_data['RequiresPHP'] : null;
494+
$requires_wp = isset( $new_plugin_data['RequiresWP'] ) ? $new_plugin_data['RequiresWP'] : null;
495495

496496
if ( ! is_php_version_compatible( $requires_php ) ) {
497497
$error = sprintf(
@@ -542,9 +542,9 @@ public function plugin_info() {
542542
}
543543

544544
// Assume the requested plugin is the first in the list.
545-
$pluginfiles = array_keys( $plugin );
545+
$plugin_files = array_keys( $plugin );
546546

547-
return $this->result['destination_name'] . '/' . $pluginfiles[0];
547+
return $this->result['destination_name'] . '/' . $plugin_files[0];
548548
}
549549

550550
/**

0 commit comments

Comments
 (0)