mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Coding Standards: Use Yoda conditions where appropriate.
See #49222. git-svn-id: https://develop.svn.wordpress.org/trunk@47219 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -686,7 +686,7 @@ function is_serialized_string( $data ) {
|
||||
return false;
|
||||
} elseif ( ';' !== substr( $data, -1 ) ) {
|
||||
return false;
|
||||
} elseif ( $data[0] !== 's' ) {
|
||||
} elseif ( 's' !== $data[0] ) {
|
||||
return false;
|
||||
} elseif ( '"' !== substr( $data, -2, 1 ) ) {
|
||||
return false;
|
||||
@@ -1013,15 +1013,15 @@ function _http_build_query( $data, $prefix = null, $sep = null, $key = '', $urle
|
||||
if ( $urlencode ) {
|
||||
$k = urlencode( $k );
|
||||
}
|
||||
if ( is_int( $k ) && $prefix != null ) {
|
||||
if ( is_int( $k ) && null != $prefix ) {
|
||||
$k = $prefix . $k;
|
||||
}
|
||||
if ( ! empty( $key ) ) {
|
||||
$k = $key . '%5B' . $k . '%5D';
|
||||
}
|
||||
if ( $v === null ) {
|
||||
if ( null === $v ) {
|
||||
continue;
|
||||
} elseif ( $v === false ) {
|
||||
} elseif ( false === $v ) {
|
||||
$v = '0';
|
||||
}
|
||||
|
||||
@@ -1132,7 +1132,7 @@ function add_query_arg( ...$args ) {
|
||||
}
|
||||
|
||||
foreach ( $qs as $k => $v ) {
|
||||
if ( $v === false ) {
|
||||
if ( false === $v ) {
|
||||
unset( $qs[ $k ] );
|
||||
}
|
||||
}
|
||||
@@ -1539,7 +1539,7 @@ function do_feed() {
|
||||
// Remove the pad, if present.
|
||||
$feed = preg_replace( '/^_+/', '', $feed );
|
||||
|
||||
if ( $feed == '' || $feed == 'feed' ) {
|
||||
if ( '' == $feed || 'feed' === $feed ) {
|
||||
$feed = get_default_feed();
|
||||
}
|
||||
|
||||
@@ -1885,7 +1885,7 @@ function wp_get_referer() {
|
||||
|
||||
$ref = wp_get_raw_referer();
|
||||
|
||||
if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) && $ref !== home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) ) {
|
||||
if ( $ref && wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref && home_url() . wp_unslash( $_SERVER['REQUEST_URI'] ) !== $ref ) {
|
||||
return wp_validate_redirect( $ref, false );
|
||||
}
|
||||
|
||||
@@ -1947,7 +1947,7 @@ function wp_mkdir_p( $target ) {
|
||||
$target = str_replace( '//', '/', $target );
|
||||
|
||||
// Put the wrapper back on the target.
|
||||
if ( $wrapper !== null ) {
|
||||
if ( null !== $wrapper ) {
|
||||
$target = $wrapper . '://' . $target;
|
||||
}
|
||||
|
||||
@@ -1989,7 +1989,7 @@ function wp_mkdir_p( $target ) {
|
||||
* If a umask is set that modifies $dir_perms, we'll have to re-set
|
||||
* the $dir_perms correctly with chmod()
|
||||
*/
|
||||
if ( $dir_perms != ( $dir_perms & ~umask() ) ) {
|
||||
if ( ( $dir_perms & ~umask() ) != $dir_perms ) {
|
||||
$folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) );
|
||||
for ( $i = 1, $c = count( $folder_parts ); $i <= $c; $i++ ) {
|
||||
chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );
|
||||
@@ -2029,7 +2029,7 @@ function path_is_absolute( $path ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( strlen( $path ) == 0 || $path[0] == '.' ) {
|
||||
if ( strlen( $path ) == 0 || '.' === $path[0] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2039,7 +2039,7 @@ function path_is_absolute( $path ) {
|
||||
}
|
||||
|
||||
// A path starting with / or \ is absolute; anything else is relative.
|
||||
return ( $path[0] == '/' || $path[0] == '\\' );
|
||||
return ( '/' === $path[0] || '\\' === $path[0] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2185,7 +2185,7 @@ function wp_is_writable( $path ) {
|
||||
* @return bool Whether the path is writable.
|
||||
*/
|
||||
function win_is_writable( $path ) {
|
||||
if ( $path[ strlen( $path ) - 1 ] == '/' ) {
|
||||
if ( '/' === $path[ strlen( $path ) - 1 ] ) {
|
||||
// If it looks like a directory, check a random file within the directory.
|
||||
return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp' );
|
||||
} elseif ( is_dir( $path ) ) {
|
||||
@@ -2197,7 +2197,7 @@ function win_is_writable( $path ) {
|
||||
$should_delete_tmp_file = ! file_exists( $path );
|
||||
|
||||
$f = @fopen( $path, 'a' );
|
||||
if ( $f === false ) {
|
||||
if ( false === $f ) {
|
||||
return false;
|
||||
}
|
||||
fclose( $f );
|
||||
@@ -2633,7 +2633,7 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
|
||||
|
||||
$upload = wp_upload_dir( $time );
|
||||
|
||||
if ( $upload['error'] !== false ) {
|
||||
if ( false !== $upload['error'] ) {
|
||||
return $upload;
|
||||
}
|
||||
|
||||
@@ -4321,7 +4321,7 @@ function smilies_init() {
|
||||
|
||||
// New subpattern?
|
||||
if ( $firstchar != $subchar ) {
|
||||
if ( $subchar != '' ) {
|
||||
if ( '' != $subchar ) {
|
||||
$wp_smiliessearch .= ')(?=' . $spaces . '|$)'; // End previous "subpattern".
|
||||
$wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern".
|
||||
}
|
||||
@@ -5461,7 +5461,7 @@ function is_main_site( $site_id = null, $network_id = null ) {
|
||||
|
||||
$site_id = (int) $site_id;
|
||||
|
||||
return $site_id === get_main_site_id( $network_id );
|
||||
return get_main_site_id( $network_id ) === $site_id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5505,7 +5505,7 @@ function is_main_network( $network_id = null ) {
|
||||
|
||||
$network_id = (int) $network_id;
|
||||
|
||||
return ( $network_id === get_main_network_id() );
|
||||
return ( get_main_network_id() === $network_id );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7513,7 +7513,7 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $max_execution_time === null ) {
|
||||
if ( null === $max_execution_time ) {
|
||||
// Keep the previous behavior but attempt to prevent fatal errors from timeout if possible.
|
||||
if ( function_exists( 'ini_get' ) ) {
|
||||
$max_execution_time = ini_get( 'max_execution_time' );
|
||||
@@ -7532,7 +7532,7 @@ function recurse_dirsize( $directory, $exclude = null, $max_execution_time = nul
|
||||
if ( $handle ) {
|
||||
while ( ( $file = readdir( $handle ) ) !== false ) {
|
||||
$path = $directory . '/' . $file;
|
||||
if ( $file != '.' && $file != '..' ) {
|
||||
if ( '.' !== $file && '..' !== $file ) {
|
||||
if ( is_file( $path ) ) {
|
||||
$size += filesize( $path );
|
||||
} elseif ( is_dir( $path ) ) {
|
||||
|
||||
Reference in New Issue
Block a user