mirror of
https://ghproxy.net/https://github.com/fairpm/fair-plugin.git
synced 2025-09-04 10:32:01 +08:00
Replace strpos()
with newer str_*()
functions. (#166)
Signed-off-by: costdev <79332690+costdev@users.noreply.github.com>
This commit is contained in:
parent
b64e97776d
commit
6b5d9b772c
6 changed files with 10 additions and 10 deletions
|
@ -30,7 +30,7 @@ function bootstrap() {
|
||||||
* @return bool|array|WP_Error Replaced value, false to proceed, or WP_Error on failure.
|
* @return bool|array|WP_Error Replaced value, false to proceed, or WP_Error on failure.
|
||||||
*/
|
*/
|
||||||
function replace_credits_api( $response, array $parsed_args, string $url ) {
|
function replace_credits_api( $response, array $parsed_args, string $url ) {
|
||||||
if ( strpos( $url, 'api.wordpress.org/core/credits/' ) === false ) {
|
if ( ! str_contains( $url, 'api.wordpress.org/core/credits/' ) ) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ function replace_credits_api( $response, array $parsed_args, string $url ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Credits API 1.0 returns a serialized value rather than JSON.
|
// Credits API 1.0 returns a serialized value rather than JSON.
|
||||||
if ( strpos( $url, 'credits/1.0' ) !== false ) {
|
if ( str_contains( $url, 'credits/1.0' ) ) {
|
||||||
$credits = serialize( json_decode( $credits, true ) );
|
$credits = serialize( json_decode( $credits, true ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ function replace_repo_api_urls( $status, $args, $url ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
strpos( $url, 'api.wordpress.org/plugins/' ) === false
|
! str_contains( $url, 'api.wordpress.org/plugins/' )
|
||||||
&& strpos( $url, 'api.wordpress.org/themes/' ) === false
|
&& ! str_contains( $url, 'api.wordpress.org/themes/' )
|
||||||
&& strpos( $url, 'api.wordpress.org/core/version-check/' ) === false
|
&& ! str_contains( $url, 'api.wordpress.org/core/version-check/' )
|
||||||
) {
|
) {
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ function bootstrap() {
|
||||||
* @return bool Replaced value, or false to proceed.
|
* @return bool Replaced value, or false to proceed.
|
||||||
*/
|
*/
|
||||||
function replace_popular_importers_api( $response, $parsed_args, $url ) {
|
function replace_popular_importers_api( $response, $parsed_args, $url ) {
|
||||||
if ( strpos( $url, 'api.wordpress.org/core/importers' ) !== false ) {
|
if ( str_contains( $url, 'api.wordpress.org/core/importers' ) ) {
|
||||||
$query = parse_url( $url, PHP_URL_QUERY );
|
$query = parse_url( $url, PHP_URL_QUERY );
|
||||||
parse_str( $query, $params );
|
parse_str( $query, $params );
|
||||||
return get_popular_importers_response( $params['version'] );
|
return get_popular_importers_response( $params['version'] );
|
||||||
|
|
|
@ -55,7 +55,7 @@ function bootstrap() {
|
||||||
function register_class_path( string $prefix, string $path ) : void {
|
function register_class_path( string $prefix, string $path ) : void {
|
||||||
$prefix_length = strlen( $prefix );
|
$prefix_length = strlen( $prefix );
|
||||||
spl_autoload_register( function ( $class ) use ( $prefix, $prefix_length, $path ) {
|
spl_autoload_register( function ( $class ) use ( $prefix, $prefix_length, $path ) {
|
||||||
if ( strpos( $class, $prefix . NS_SEPARATOR ) !== 0 ) {
|
if ( ! str_starts_with( $class, $prefix . NS_SEPARATOR ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ function bootstrap() {
|
||||||
* @return bool|array Replaced value, or false to proceed.
|
* @return bool|array Replaced value, or false to proceed.
|
||||||
*/
|
*/
|
||||||
function replace_salt_generation_via_api( $value, $args, $url ) {
|
function replace_salt_generation_via_api( $value, $args, $url ) {
|
||||||
if ( strpos( $url, 'api.wordpress.org/secret-key/1.1/salt' ) !== false ) {
|
if ( str_contains( $url, 'api.wordpress.org/secret-key/1.1/salt' ) ) {
|
||||||
return get_salt_generation_response();
|
return get_salt_generation_response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,11 +66,11 @@ function bootstrap() {
|
||||||
* @return bool|array Replaced value, or false to proceed.
|
* @return bool|array Replaced value, or false to proceed.
|
||||||
*/
|
*/
|
||||||
function replace_browser_version_check( $value, $args, $url ) {
|
function replace_browser_version_check( $value, $args, $url ) {
|
||||||
if ( strpos( $url, 'api.wordpress.org/core/browse-happy' ) !== false ) {
|
if ( str_contains( $url, 'api.wordpress.org/core/browse-happy' ) ) {
|
||||||
$agent = $args['body']['useragent'];
|
$agent = $args['body']['useragent'];
|
||||||
return get_browser_check_response( $agent );
|
return get_browser_check_response( $agent );
|
||||||
}
|
}
|
||||||
if ( strpos( $url, 'api.wordpress.org/core/serve-happy' ) !== false ) {
|
if ( str_contains( $url, 'api.wordpress.org/core/serve-happy' ) ) {
|
||||||
$query = parse_url( $url, PHP_URL_QUERY );
|
$query = parse_url( $url, PHP_URL_QUERY );
|
||||||
$url_args = wp_parse_args( $query );
|
$url_args = wp_parse_args( $query );
|
||||||
return get_server_check_response( $url_args['php_version'] ?? PHP_VERSION );
|
return get_server_check_response( $url_args['php_version'] ?? PHP_VERSION );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue