Skip to content

Commit fec81ec

Browse files
committed
Lint fix
1 parent 301cfd2 commit fec81ec

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

src/Core_Command.php

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,16 @@ public function check_update( $args, $assoc_args ) {
9999
[ 'version', 'update_type', 'package_url' ]
100100
);
101101
$formatter->display_items( $updates );
102-
} else {
102+
} elseif ( $this->version_check_error ) {
103103
// If there was an HTTP error during version check, show a warning
104-
if ( $this->version_check_error ) {
105-
WP_CLI::warning(
106-
sprintf(
107-
'Failed to check for updates: %s',
108-
$this->version_check_error->get_error_message()
109-
)
110-
);
111-
} else {
112-
WP_CLI::success( 'WordPress is at the latest version.' );
113-
}
104+
WP_CLI::warning(
105+
sprintf(
106+
'Failed to check for updates: %s',
107+
$this->version_check_error->get_error_message()
108+
)
109+
);
110+
} else {
111+
WP_CLI::success( 'WordPress is at the latest version.' );
114112
}
115113
}
116114

@@ -1537,14 +1535,8 @@ private function get_updates( $assoc_args ) {
15371535
* @param array $_args HTTP request arguments (unused).
15381536
* @param string $url URL being requested.
15391537
*/
1540-
private function capture_version_check_error( $response, $context, $_class, $_args, $url ) {
1541-
// Only capture errors for the version check API using str_contains for PHP 8.0+
1542-
// or fallback to strpos for older versions
1543-
$is_version_check_url = function_exists( 'str_contains' )
1544-
? str_contains( $url, 'api.wordpress.org/core/version-check' )
1545-
: false !== strpos( $url, 'api.wordpress.org/core/version-check' );
1546-
1547-
if ( ! $is_version_check_url ) {
1538+
public function capture_version_check_error( $response, $context, $_class, $_args, $url ) {
1539+
if ( false !== strpos( $url, 'api.wordpress.org/core/version-check' ) ) {
15481540
return;
15491541
}
15501542

0 commit comments

Comments
 (0)