Update WP and plugins
This commit is contained in:
parent
10a4713229
commit
1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions
|
|
@ -53,10 +53,11 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function abspath() {
|
||||
$folder = $this->find_folder(ABSPATH);
|
||||
$folder = $this->find_folder( ABSPATH );
|
||||
// Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
|
||||
if ( ! $folder && $this->is_dir( '/' . WPINC ) )
|
||||
if ( ! $folder && $this->is_dir( '/' . WPINC ) ) {
|
||||
$folder = '/';
|
||||
}
|
||||
return $folder;
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +69,7 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function wp_content_dir() {
|
||||
return $this->find_folder(WP_CONTENT_DIR);
|
||||
return $this->find_folder( WP_CONTENT_DIR );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -79,7 +80,7 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function wp_plugins_dir() {
|
||||
return $this->find_folder(WP_PLUGIN_DIR);
|
||||
return $this->find_folder( WP_PLUGIN_DIR );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -94,8 +95,9 @@ class WP_Filesystem_Base {
|
|||
$theme_root = get_theme_root( $theme );
|
||||
|
||||
// Account for relative theme roots
|
||||
if ( '/themes' == $theme_root || ! is_dir( $theme_root ) )
|
||||
if ( '/themes' == $theme_root || ! is_dir( $theme_root ) ) {
|
||||
$theme_root = WP_CONTENT_DIR . $theme_root;
|
||||
}
|
||||
|
||||
return $this->find_folder( $theme_root );
|
||||
}
|
||||
|
|
@ -108,7 +110,7 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function wp_lang_dir() {
|
||||
return $this->find_folder(WP_LANG_DIR);
|
||||
return $this->find_folder( WP_LANG_DIR );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -128,7 +130,7 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function find_base_dir( $base = '.', $echo = false ) {
|
||||
_deprecated_function(__FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
|
||||
_deprecated_function( __FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
|
||||
$this->verbose = $echo;
|
||||
return $this->abspath();
|
||||
}
|
||||
|
|
@ -149,7 +151,7 @@ class WP_Filesystem_Base {
|
|||
* @return string The location of the remote path.
|
||||
*/
|
||||
public function get_base_dir( $base = '.', $echo = false ) {
|
||||
_deprecated_function(__FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
|
||||
_deprecated_function( __FUNCTION__, '2.7.0', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
|
||||
$this->verbose = $echo;
|
||||
return $this->abspath();
|
||||
}
|
||||
|
|
@ -166,29 +168,33 @@ class WP_Filesystem_Base {
|
|||
* @return string|false The location of the remote path, false on failure.
|
||||
*/
|
||||
public function find_folder( $folder ) {
|
||||
if ( isset( $this->cache[ $folder ] ) )
|
||||
if ( isset( $this->cache[ $folder ] ) ) {
|
||||
return $this->cache[ $folder ];
|
||||
}
|
||||
|
||||
if ( stripos($this->method, 'ftp') !== false ) {
|
||||
if ( stripos( $this->method, 'ftp' ) !== false ) {
|
||||
$constant_overrides = array(
|
||||
'FTP_BASE' => ABSPATH,
|
||||
'FTP_BASE' => ABSPATH,
|
||||
'FTP_CONTENT_DIR' => WP_CONTENT_DIR,
|
||||
'FTP_PLUGIN_DIR' => WP_PLUGIN_DIR,
|
||||
'FTP_LANG_DIR' => WP_LANG_DIR
|
||||
'FTP_PLUGIN_DIR' => WP_PLUGIN_DIR,
|
||||
'FTP_LANG_DIR' => WP_LANG_DIR,
|
||||
);
|
||||
|
||||
// Direct matches ( folder = CONSTANT/ )
|
||||
foreach ( $constant_overrides as $constant => $dir ) {
|
||||
if ( ! defined( $constant ) )
|
||||
if ( ! defined( $constant ) ) {
|
||||
continue;
|
||||
if ( $folder === $dir )
|
||||
}
|
||||
if ( $folder === $dir ) {
|
||||
return trailingslashit( constant( $constant ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Prefix Matches ( folder = CONSTANT/subdir )
|
||||
foreach ( $constant_overrides as $constant => $dir ) {
|
||||
if ( ! defined( $constant ) )
|
||||
if ( ! defined( $constant ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( 0 === stripos( $folder, $dir ) ) { // $folder starts with $dir
|
||||
$potential_folder = preg_replace( '#^' . preg_quote( $dir, '#' ) . '/#i', trailingslashit( constant( $constant ) ), $folder );
|
||||
$potential_folder = trailingslashit( $potential_folder );
|
||||
|
|
@ -200,23 +206,25 @@ class WP_Filesystem_Base {
|
|||
}
|
||||
}
|
||||
} elseif ( 'direct' == $this->method ) {
|
||||
$folder = str_replace('\\', '/', $folder); // Windows path sanitisation
|
||||
return trailingslashit($folder);
|
||||
$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation
|
||||
return trailingslashit( $folder );
|
||||
}
|
||||
|
||||
$folder = preg_replace('|^([a-z]{1}):|i', '', $folder); // Strip out windows drive letter if it's there.
|
||||
$folder = str_replace('\\', '/', $folder); // Windows path sanitisation
|
||||
$folder = preg_replace( '|^([a-z]{1}):|i', '', $folder ); // Strip out windows drive letter if it's there.
|
||||
$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation
|
||||
|
||||
if ( isset($this->cache[ $folder ] ) )
|
||||
if ( isset( $this->cache[ $folder ] ) ) {
|
||||
return $this->cache[ $folder ];
|
||||
}
|
||||
|
||||
if ( $this->exists($folder) ) { // Folder exists at that absolute path.
|
||||
$folder = trailingslashit($folder);
|
||||
if ( $this->exists( $folder ) ) { // Folder exists at that absolute path.
|
||||
$folder = trailingslashit( $folder );
|
||||
$this->cache[ $folder ] = $folder;
|
||||
return $folder;
|
||||
}
|
||||
if ( $return = $this->search_for_folder($folder) )
|
||||
if ( $return = $this->search_for_folder( $folder ) ) {
|
||||
$this->cache[ $folder ] = $return;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
|
@ -233,26 +241,28 @@ class WP_Filesystem_Base {
|
|||
* @return string|false The location of the remote path, false to cease looping.
|
||||
*/
|
||||
public function search_for_folder( $folder, $base = '.', $loop = false ) {
|
||||
if ( empty( $base ) || '.' == $base )
|
||||
$base = trailingslashit($this->cwd());
|
||||
if ( empty( $base ) || '.' == $base ) {
|
||||
$base = trailingslashit( $this->cwd() );
|
||||
}
|
||||
|
||||
$folder = untrailingslashit($folder);
|
||||
$folder = untrailingslashit( $folder );
|
||||
|
||||
if ( $this->verbose ) {
|
||||
/* translators: 1: folder to locate, 2: folder to start searching from */
|
||||
printf( "\n" . __( 'Looking for %1$s in %2$s' ) . "<br/>\n", $folder, $base );
|
||||
}
|
||||
|
||||
$folder_parts = explode('/', $folder);
|
||||
$folder_parts = explode( '/', $folder );
|
||||
$folder_part_keys = array_keys( $folder_parts );
|
||||
$last_index = array_pop( $folder_part_keys );
|
||||
$last_path = $folder_parts[ $last_index ];
|
||||
$last_index = array_pop( $folder_part_keys );
|
||||
$last_path = $folder_parts[ $last_index ];
|
||||
|
||||
$files = $this->dirlist( $base );
|
||||
|
||||
foreach ( $folder_parts as $index => $key ) {
|
||||
if ( $index == $last_index )
|
||||
if ( $index == $last_index ) {
|
||||
continue; // We want this to be caught by the next code block.
|
||||
}
|
||||
|
||||
/*
|
||||
* Working from /home/ to /user/ to /wordpress/ see if that file exists within
|
||||
|
|
@ -261,10 +271,10 @@ class WP_Filesystem_Base {
|
|||
* folder level, and see if that matches, and so on. If it reaches the end, and still
|
||||
* cant find it, it'll return false for the entire function.
|
||||
*/
|
||||
if ( isset($files[ $key ]) ){
|
||||
if ( isset( $files[ $key ] ) ) {
|
||||
|
||||
// Let's try that folder:
|
||||
$newdir = trailingslashit(path_join($base, $key));
|
||||
$newdir = trailingslashit( path_join( $base, $key ) );
|
||||
if ( $this->verbose ) {
|
||||
/* translators: %s: directory name */
|
||||
printf( "\n" . __( 'Changing to %s' ) . "<br/>\n", $newdir );
|
||||
|
|
@ -272,25 +282,27 @@ class WP_Filesystem_Base {
|
|||
|
||||
// Only search for the remaining path tokens in the directory, not the full path again.
|
||||
$newfolder = implode( '/', array_slice( $folder_parts, $index + 1 ) );
|
||||
if ( $ret = $this->search_for_folder( $newfolder, $newdir, $loop) )
|
||||
if ( $ret = $this->search_for_folder( $newfolder, $newdir, $loop ) ) {
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only check this as a last resort, to prevent locating the incorrect install.
|
||||
// All above procedures will fail quickly if this is the right branch to take.
|
||||
if (isset( $files[ $last_path ] ) ) {
|
||||
if ( isset( $files[ $last_path ] ) ) {
|
||||
if ( $this->verbose ) {
|
||||
/* translators: %s: directory name */
|
||||
printf( "\n" . __( 'Found %s' ) . "<br/>\n", $base . $last_path );
|
||||
printf( "\n" . __( 'Found %s' ) . "<br/>\n", $base . $last_path );
|
||||
}
|
||||
return trailingslashit($base . $last_path);
|
||||
return trailingslashit( $base . $last_path );
|
||||
}
|
||||
|
||||
// Prevent this function from looping again.
|
||||
// No need to proceed if we've just searched in /
|
||||
if ( $loop || '/' == $base )
|
||||
if ( $loop || '/' == $base ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// As an extra last resort, Change back to / if the folder wasn't found.
|
||||
// This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
|
||||
|
|
@ -310,45 +322,46 @@ class WP_Filesystem_Base {
|
|||
* @param string $file String filename.
|
||||
* @return string The *nix-style representation of permissions.
|
||||
*/
|
||||
public function gethchmod( $file ){
|
||||
public function gethchmod( $file ) {
|
||||
$perms = intval( $this->getchmod( $file ), 8 );
|
||||
if (($perms & 0xC000) == 0xC000) // Socket
|
||||
if ( ( $perms & 0xC000 ) == 0xC000 ) { // Socket
|
||||
$info = 's';
|
||||
elseif (($perms & 0xA000) == 0xA000) // Symbolic Link
|
||||
} elseif ( ( $perms & 0xA000 ) == 0xA000 ) { // Symbolic Link
|
||||
$info = 'l';
|
||||
elseif (($perms & 0x8000) == 0x8000) // Regular
|
||||
} elseif ( ( $perms & 0x8000 ) == 0x8000 ) { // Regular
|
||||
$info = '-';
|
||||
elseif (($perms & 0x6000) == 0x6000) // Block special
|
||||
} elseif ( ( $perms & 0x6000 ) == 0x6000 ) { // Block special
|
||||
$info = 'b';
|
||||
elseif (($perms & 0x4000) == 0x4000) // Directory
|
||||
} elseif ( ( $perms & 0x4000 ) == 0x4000 ) { // Directory
|
||||
$info = 'd';
|
||||
elseif (($perms & 0x2000) == 0x2000) // Character special
|
||||
} elseif ( ( $perms & 0x2000 ) == 0x2000 ) { // Character special
|
||||
$info = 'c';
|
||||
elseif (($perms & 0x1000) == 0x1000) // FIFO pipe
|
||||
} elseif ( ( $perms & 0x1000 ) == 0x1000 ) { // FIFO pipe
|
||||
$info = 'p';
|
||||
else // Unknown
|
||||
} else { // Unknown
|
||||
$info = 'u';
|
||||
}
|
||||
|
||||
// Owner
|
||||
$info .= (($perms & 0x0100) ? 'r' : '-');
|
||||
$info .= (($perms & 0x0080) ? 'w' : '-');
|
||||
$info .= (($perms & 0x0040) ?
|
||||
(($perms & 0x0800) ? 's' : 'x' ) :
|
||||
(($perms & 0x0800) ? 'S' : '-'));
|
||||
$info .= ( ( $perms & 0x0100 ) ? 'r' : '-' );
|
||||
$info .= ( ( $perms & 0x0080 ) ? 'w' : '-' );
|
||||
$info .= ( ( $perms & 0x0040 ) ?
|
||||
( ( $perms & 0x0800 ) ? 's' : 'x' ) :
|
||||
( ( $perms & 0x0800 ) ? 'S' : '-' ) );
|
||||
|
||||
// Group
|
||||
$info .= (($perms & 0x0020) ? 'r' : '-');
|
||||
$info .= (($perms & 0x0010) ? 'w' : '-');
|
||||
$info .= (($perms & 0x0008) ?
|
||||
(($perms & 0x0400) ? 's' : 'x' ) :
|
||||
(($perms & 0x0400) ? 'S' : '-'));
|
||||
$info .= ( ( $perms & 0x0020 ) ? 'r' : '-' );
|
||||
$info .= ( ( $perms & 0x0010 ) ? 'w' : '-' );
|
||||
$info .= ( ( $perms & 0x0008 ) ?
|
||||
( ( $perms & 0x0400 ) ? 's' : 'x' ) :
|
||||
( ( $perms & 0x0400 ) ? 'S' : '-' ) );
|
||||
|
||||
// World
|
||||
$info .= (($perms & 0x0004) ? 'r' : '-');
|
||||
$info .= (($perms & 0x0002) ? 'w' : '-');
|
||||
$info .= (($perms & 0x0001) ?
|
||||
(($perms & 0x0200) ? 't' : 'x' ) :
|
||||
(($perms & 0x0200) ? 'T' : '-'));
|
||||
$info .= ( ( $perms & 0x0004 ) ? 'r' : '-' );
|
||||
$info .= ( ( $perms & 0x0002 ) ? 'w' : '-' );
|
||||
$info .= ( ( $perms & 0x0001 ) ?
|
||||
( ( $perms & 0x0200 ) ? 't' : 'x' ) :
|
||||
( ( $perms & 0x0200 ) ? 'T' : '-' ) );
|
||||
return $info;
|
||||
}
|
||||
|
||||
|
|
@ -368,7 +381,7 @@ class WP_Filesystem_Base {
|
|||
*
|
||||
* Converts '-rw-r--r--' to 0644
|
||||
* From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
|
||||
*
|
||||
*
|
||||
* @link https://secure.php.net/manual/en/function.chmod.php#49614
|
||||
*
|
||||
* @since 2.5.0
|
||||
|
|
@ -378,20 +391,25 @@ class WP_Filesystem_Base {
|
|||
*/
|
||||
public function getnumchmodfromh( $mode ) {
|
||||
$realmode = '';
|
||||
$legal = array('', 'w', 'r', 'x', '-');
|
||||
$attarray = preg_split('//', $mode);
|
||||
$legal = array( '', 'w', 'r', 'x', '-' );
|
||||
$attarray = preg_split( '//', $mode );
|
||||
|
||||
for ( $i = 0, $c = count( $attarray ); $i < $c; $i++ ) {
|
||||
if ($key = array_search($attarray[$i], $legal)) {
|
||||
$realmode .= $legal[$key];
|
||||
}
|
||||
if ( $key = array_search( $attarray[ $i ], $legal ) ) {
|
||||
$realmode .= $legal[ $key ];
|
||||
}
|
||||
}
|
||||
|
||||
$mode = str_pad($realmode, 10, '-', STR_PAD_LEFT);
|
||||
$trans = array('-'=>'0', 'r'=>'4', 'w'=>'2', 'x'=>'1');
|
||||
$mode = strtr($mode,$trans);
|
||||
$mode = str_pad( $realmode, 10, '-', STR_PAD_LEFT );
|
||||
$trans = array(
|
||||
'-' => '0',
|
||||
'r' => '4',
|
||||
'w' => '2',
|
||||
'x' => '1',
|
||||
);
|
||||
$mode = strtr( $mode, $trans );
|
||||
|
||||
$newmode = $mode[0];
|
||||
$newmode = $mode[0];
|
||||
$newmode .= $mode[1] + $mode[2] + $mode[3];
|
||||
$newmode .= $mode[4] + $mode[5] + $mode[6];
|
||||
$newmode .= $mode[7] + $mode[8] + $mode[9];
|
||||
|
|
@ -539,7 +557,7 @@ class WP_Filesystem_Base {
|
|||
*
|
||||
* @since 2.5.0
|
||||
* @abstract
|
||||
*
|
||||
*
|
||||
* @param string $file Path to the file.
|
||||
* @return string|bool Username of the user or false on error.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue