Changeset 47808 for trunk/src/wp-admin/includes/file.php
- Timestamp:
- 05/16/2020 06:40:52 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r47584 r47808 649 649 } 650 650 651 if ( empty( $filename ) || '.' == $filename || '/' == $filename || '\\' == $filename) {651 if ( empty( $filename ) || in_array( $filename, array( '.', '/', '\\' ), true ) ) { 652 652 $filename = uniqid(); 653 653 } … … 1104 1104 $signature_url = false; 1105 1105 $url_path = parse_url( $url, PHP_URL_PATH ); 1106 if ( substr( $url_path, -4 ) == '.zip' || substr( $url_path, -7 ) == '.tar.gz' ) { 1106 1107 if ( '.zip' === substr( $url_path, -4 ) || '.tar.gz' === substr( $url_path, -7 ) ) { 1107 1108 $signature_url = str_replace( $url_path, $url_path . '.sig', $url ); 1108 1109 } … … 1451 1452 return $result; 1452 1453 } elseif ( is_wp_error( $result ) ) { 1453 if ( 'incompatible_archive' != $result->get_error_code() ) {1454 if ( 'incompatible_archive' !== $result->get_error_code() ) { 1454 1455 return $result; 1455 1456 } … … 1563 1564 } 1564 1565 1565 if ( '/' == substr( $info['name'], -1 ) ) { // Directory.1566 if ( '/' === substr( $info['name'], -1 ) ) { // Directory. 1566 1567 continue; 1567 1568 } … … 1733 1734 } 1734 1735 1735 if ( 'f' == $fileinfo['type'] ) {1736 if ( 'f' === $fileinfo['type'] ) { 1736 1737 if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) { 1737 1738 // If copy failed, chmod file to 0644 and try again. … … 1741 1742 } 1742 1743 } 1743 } elseif ( 'd' == $fileinfo['type'] ) {1744 } elseif ( 'd' === $fileinfo['type'] ) { 1744 1745 if ( ! $wp_filesystem->is_dir( $to . $filename ) ) { 1745 1746 if ( ! $wp_filesystem->mkdir( $to . $filename, FS_CHMOD_DIR ) ) { … … 1762 1763 } 1763 1764 } 1765 1764 1766 return true; 1765 1767 } … … 1925 1927 } 1926 1928 1927 if ( ! $method && isset( $args['connection_type'] ) && 'ssh' == $args['connection_type'] && extension_loaded( 'ssh2' ) ) {1929 if ( ! $method && isset( $args['connection_type'] ) && 'ssh' === $args['connection_type'] && extension_loaded( 'ssh2' ) ) { 1928 1930 $method = 'ssh2'; 1929 1931 } … … 2011 2013 } 2012 2014 2013 if ( 'direct' == $type ) {2015 if ( 'direct' === $type ) { 2014 2016 return true; 2015 2017 } … … 2062 2064 } 2063 2065 2064 if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) {2066 if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' === FS_METHOD ) ) { 2065 2067 $credentials['connection_type'] = 'ssh'; 2066 } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { // Only the FTP Extension understands SSL.2068 } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' === $type ) { // Only the FTP Extension understands SSL. 2067 2069 $credentials['connection_type'] = 'ftps'; 2068 2070 } elseif ( ! empty( $submitted_form['connection_type'] ) ) { … … 2071 2073 $credentials['connection_type'] = 'ftp'; 2072 2074 } 2073 if ( ! $error &&2074 (2075 ( ! empty( $credentials['password'] ) && ! empty( $credentials['username'] ) && ! empty( $credentials['hostname'] ) ) ||2076 ( 'ssh' == $credentials['connection_type'] && ! empty( $credentials['public_key'] ) && ! empty( $credentials['private_key'] ))2077 )) {2075 if ( ! $error 2076 && ( ( ! empty( $credentials['password'] ) && ! empty( $credentials['username'] ) && ! empty( $credentials['hostname'] ) ) 2077 || ( 'ssh' === $credentials['connection_type'] && ! empty( $credentials['public_key'] ) && ! empty( $credentials['private_key'] ) ) 2078 ) 2079 ) { 2078 2080 $stored_credentials = $credentials; 2081 2079 2082 if ( ! empty( $stored_credentials['port'] ) ) { // Save port as part of hostname to simplify above code. 2080 2083 $stored_credentials['hostname'] .= ':' . $stored_credentials['port']; … … 2082 2085 2083 2086 unset( $stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key'] ); 2087 2084 2088 if ( ! wp_installing() ) { 2085 2089 update_option( 'ftp_credentials', $stored_credentials ); 2086 2090 } 2091 2087 2092 return $credentials; 2088 2093 } … … 2209 2214 if ( isset( $types['ssh'] ) ) { 2210 2215 $hidden_class = ''; 2211 if ( 'ssh' != $connection_type || empty( $connection_type ) ) {2216 if ( 'ssh' !== $connection_type || empty( $connection_type ) ) { 2212 2217 $hidden_class = ' class="hidden"'; 2213 2218 } … … 2252 2257 function wp_print_request_filesystem_credentials_modal() { 2253 2258 $filesystem_method = get_filesystem_method(); 2259 2254 2260 ob_start(); 2255 2261 $filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() ); 2256 2262 ob_end_clean(); 2263 2257 2264 $request_filesystem_credentials = ( 'direct' !== $filesystem_method && ! $filesystem_credentials_are_stored ); 2258 2265 if ( ! $request_filesystem_credentials ) {
Note: See TracChangeset
for help on using the changeset viewer.