Make WordPress Core

Ticket #18476: 18476.diff

File 18476.diff, 18.1 KB (added by DrewAPicture, 12 years ago)

docs cleanup, first-pass

  • src/wp-admin/includes/class-wp-filesystem-base.php

     
    1212 * @since 2.5
    1313 */
    1414class WP_Filesystem_Base {
     15
    1516        /**
    1617         * Whether to display debug data for the connection.
    1718         *
    18          * @since 2.5
    1919         * @access public
     20         * @since 2.5.0
    2021         * @var bool
    2122         */
    2223        var $verbose = false;
     24
    2325        /**
    2426         * Cached list of local filepaths to mapped remote filepaths.
    2527         *
    26          * @since 2.7
    2728         * @access private
     29         * @since 2.7.0
    2830         * @var array
    2931         */
    3032        var $cache = array();
     
    3234        /**
    3335         * The Access method of the current connection, Set automatically.
    3436         *
    35          * @since 2.5
    3637         * @access public
     38         * @since 2.5.0
    3739         * @var string
    3840         */
    3941        var $method = '';
    4042
    4143        /**
    42          * Returns the path on the remote filesystem of ABSPATH
     44         * Constructor (empty).
     45         */
     46        function __construct() {}
     47
     48        /**
     49         * Return the path on the remote filesystem of ABSPATH.
    4350         *
    44          * @since 2.7
    4551         * @access public
     52         * @since 2.7.0
     53         *
    4654         * @return string The location of the remote path.
    4755         */
    4856        function abspath() {
     
    5361                return $folder;
    5462        }
    5563        /**
    56          * Returns the path on the remote filesystem of WP_CONTENT_DIR
     64         * Return the path on the remote filesystem of WP_CONTENT_DIR.
    5765         *
    58          * @since 2.7
    5966         * @access public
     67         * @since 2.7.0
     68         *
    6069         * @return string The location of the remote path.
    6170         */
    6271        function wp_content_dir() {
    6372                return $this->find_folder(WP_CONTENT_DIR);
    6473        }
    6574        /**
    66          * Returns the path on the remote filesystem of WP_PLUGIN_DIR
     75         * Return the path on the remote filesystem of WP_PLUGIN_DIR.
    6776         *
    68          * @since 2.7
    6977         * @access public
     78         * @since 2.7.0
    7079         *
    7180         * @return string The location of the remote path.
    7281         */
     
    7483                return $this->find_folder(WP_PLUGIN_DIR);
    7584        }
    7685        /**
    77          * Returns the path on the remote filesystem of the Themes Directory
     86         * Return the path on the remote filesystem of the Themes Directory.
    7887         *
    79          * @since 2.7
    8088         * @access public
     89         * @since 2.7.0
    8190         *
    82          * @param string $theme The Theme stylesheet or template for the directory
     91         * @param string $theme The Theme stylesheet or template for the directory.
    8392         * @return string The location of the remote path.
    8493         */
    8594        function wp_themes_dir( $theme = false ) {
     
    92101                return $this->find_folder( $theme_root );
    93102        }
    94103        /**
    95          * Returns the path on the remote filesystem of WP_LANG_DIR
     104         * Return the path on the remote filesystem of WP_LANG_DIR.
    96105         *
     106         * @access public
    97107         * @since 3.2.0
    98          * @access public
    99108         *
    100109         * @return string The location of the remote path.
    101110         */
     
    104113        }
    105114
    106115        /**
    107          * Locates a folder on the remote filesystem.
     116         * Locate a folder on the remote filesystem.
    108117         *
    109          * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
    110          *
    111          * @since 2.5
    112          * @deprecated 2.7
    113118         * @access public
     119         * @since 2.5.0
     120         * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() instead.
     121         * @see WP_Filesystem::abspath()
     122         * @see WP_Filesystem::wp_content_dir()
     123         * @see WP_Filesystem::wp_plugins_dir()
     124         * @see WP_Filesystem::wp_themes_dir()
     125         * @see WP_Filesystem::wp_lang_dir()
    114126         *
    115          * @param string $base The folder to start searching from
    116          * @param bool $echo True to display debug information
     127         * @param string $base The folder to start searching from.
     128         * @param bool   $echo True to display debug information.
    117129         * @return string The location of the remote path.
    118130         */
    119         function find_base_dir($base = '.', $echo = false) {
     131        function find_base_dir( $base = '.', $echo = false ) {
    120132                _deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
    121133                $this->verbose = $echo;
    122134                return $this->abspath();
    123135        }
    124136        /**
    125          * Locates a folder on the remote filesystem.
     137         * Locate a folder on the remote filesystem.
    126138         *
    127          * Deprecated; use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
    128          *
    129          * @since 2.5
    130          * @deprecated 2.7
    131139         * @access public
     140         * @since 2.5.0
     141         * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
     142         * @see WP_Filesystem::abspath()
     143         * @see WP_Filesystem::wp_content_dir()
     144         * @see WP_Filesystem::wp_plugins_dir()
     145         * @see WP_Filesystem::wp_themes_dir()
     146         * @see WP_Filesystem::wp_lang_dir()
    132147         *
    133          * @param string $base The folder to start searching from
    134          * @param bool $echo True to display debug information
     148         * @param string $base The folder to start searching from.
     149         * @param bool   $echo True to display debug information.
    135150         * @return string The location of the remote path.
    136151         */
    137         function get_base_dir($base = '.', $echo = false) {
     152        function get_base_dir( $base = '.', $echo = false ) {
    138153                _deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
    139154                $this->verbose = $echo;
    140155                return $this->abspath();
    141156        }
    142157
    143158        /**
    144          * Locates a folder on the remote filesystem.
     159         * Locate a folder on the remote filesystem.
    145160         *
    146          * Assumes that on Windows systems, Stripping off the Drive letter is OK
    147          * Sanitizes \\ to / in windows filepaths.
     161         * Assumes that on Windows systems, Stripping off the Drive
     162         * letter is OK Sanitizes \\ to / in windows filepaths.
    148163         *
    149          * @since 2.7
    150164         * @access public
     165         * @since 2.7.0
    151166         *
    152          * @param string $folder the folder to locate
     167         * @param string $folder the folder to locate.
    153168         * @return string The location of the remote path.
    154169         */
    155         function find_folder($folder) {
     170        function find_folder( $folder ) {
    156171
    157172                if ( isset( $this->cache[ $folder ] ) )
    158173                        return $this->cache[ $folder ];
     
    209224        }
    210225
    211226        /**
    212          * Locates a folder on the remote filesystem.
     227         * Locate a folder on the remote filesystem.
    213228         *
    214          * Expects Windows sanitized path
     229         * Expects Windows sanitized path.
    215230         *
    216          * @since 2.7
    217231         * @access private
     232         * @since 2.7.0
    218233         *
    219          * @param string $folder the folder to locate
    220          * @param string $base the folder to start searching from
    221          * @param bool $loop if the function has recursed, Internal use only
     234         * @param string $folder The folder to locate.
     235         * @param string $base   The folder to start searching from.
     236         * @param bool   $loop   If the function has recursed, Internal use only.
    222237         * @return string The location of the remote path.
    223238         */
    224         function search_for_folder($folder, $base = '.', $loop = false ) {
     239        function search_for_folder( $folder, $base = '.', $loop = false ) {
    225240                if ( empty( $base ) || '.' == $base )
    226241                        $base = trailingslashit($this->cwd());
    227242
     
    276291        }
    277292
    278293        /**
    279          * Returns the *nix style file permissions for a file
     294         * Return the *nix-style file permissions for a file.
    280295         *
    281          * From the PHP documentation page for fileperms()
     296         * From the PHP documentation page for fileperms().
    282297         *
    283298         * @link http://docs.php.net/fileperms
    284          * @since 2.5
     299         *
    285300         * @access public
     301         * @since 2.5.0
    286302         *
    287          * @param string $file string filename
    288          * @return string *nix style representation of permissions
     303         * @param string $file String filename.
     304         * @return string The *nix-style representation of permissions.
    289305         */
    290         function gethchmod($file){
     306        function gethchmod( $file ){
    291307                $perms = $this->getchmod($file);
    292308                if (($perms & 0xC000) == 0xC000) // Socket
    293309                        $info = 's';
     
    330346        }
    331347
    332348        /**
    333          * Converts *nix style file permissions to a octal number.
     349         * Convert *nix-style file permissions to a octal number.
    334350         *
    335351         * Converts '-rw-r--r--' to 0644
    336352         * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
    337353         *
    338354         * @link http://docs.php.net/manual/en/function.chmod.php#49614
    339          * @since 2.5
     355         *
    340356         * @access public
     357         * @since 2.5.0
    341358         *
    342          * @param string $mode string *nix style file permission
     359         * @param string $mode string The *nix-style file permission.
    343360         * @return int octal representation
    344361         */
    345362        function getnumchmodfromh($mode) {
     
    363380        }
    364381
    365382        /**
    366          * Determines if the string provided contains binary characters.
     383         * Determine if the string provided contains binary characters.
    367384         *
    368          * @since 2.7
    369385         * @access private
     386         * @since 2.7.0
    370387         *
    371          * @param string $text String to test against
    372          * @return bool true if string is binary, false otherwise
     388         * @param string $text String to test against.
     389         * @return bool true if string is binary, false otherwise.
    373390         */
    374391        function is_binary( $text ) {
    375392                return (bool) preg_match('|[^\x20-\x7E]|', $text); //chr(32)..chr(127)
    376393        }
     394
     395        /**
     396         * Change the ownership of a file / folder.
     397         *
     398         * Default behavior is to do nothing, override this in your subclass, if desired.
     399         *
     400         * @since Unknown
     401         *
     402         * @param string $file      Path to the file.
     403         * @param mixed  $owner     A user name or number.
     404         * @param bool   $recursive (optional) If set True changes file owner recursivly. Defaults to False.
     405         * @return bool Returns true on success or false on failure.
     406         */
     407        function chown( $file, $owner, $recursive = false ) {
     408                return false;
     409        }
     410
     411        /**
     412         * Connect filesystem.
     413         *
     414         * @since Unknown
     415         *
     416         * @return bool True on success or false on failure (always true for WP_Filesystem_Direct).
     417         */
     418        function connect() {
     419                return true;
     420        }
     421
     422        /**
     423         * Read entire file into a string.
     424         *
     425         * @since Unknown
     426         *
     427         * @param string $file Name of the file to read.
     428         * @return string|bool Returns the read data or false on failure.
     429         */
     430        function get_contents( $file ) {
     431                return false;
     432        }
     433
     434        /**
     435         * Read entire file into an array.
     436         *
     437         * @since Unknown
     438         *
     439         * @param string $file Path to the file.
     440         * @return array|bool the file contents in an array or false on failure.
     441         */
     442        function get_contents_array( $file ) {
     443                return false;
     444        }
     445
     446        /**
     447         * Write a string to a file.
     448         *
     449         * @since Unknown
     450         *
     451         * @param string $file     Remote path to the file where to write the data.
     452         * @param string $contents The data to write.
     453         * @param int    $mode     (optional) The file permissions as octal number, usually 0644.
     454         * @return bool False on failure.
     455         */
     456        function put_contents( $file, $contents, $mode = false ) {
     457                return false;
     458        }
     459
     460        /**
     461         * Get the current working directory.
     462         *
     463         * @since Unknown
     464         *
     465         * @return string|bool The current working directory on success, or false on failure.
     466         */
     467        function cwd() {
     468                return false;
     469        }
     470
     471        /**
     472         * Change current directory.
     473         *
     474         * @since Unknown
     475         *
     476         * @param string $dir The new current directory.
     477         * @return bool Returns true on success or false on failure.
     478         */
     479        function chdir( $dir ) {
     480                return false;
     481        }
     482
     483        /**
     484         * Change the file group.
     485         *
     486         * @since Unknown
     487         *
     488         * @param string $file      Path to the file.
     489         * @param mixed  $group     A group name or number.
     490         * @param bool   $recursive (optional) If set True changes file group recursivly. Defaults to False.
     491         * @return bool Returns true on success or false on failure.
     492         */
     493        function chgrp( $file, $group, $recursive = false ) {
     494                return false;
     495        }
     496
     497        /**
     498         * Change filesystem permissions.
     499         *
     500         * @since Unknown
     501         *
     502         * @param string $file      Path to the file.
     503         * @param int    $mode      (optional) The permissions as octal number, usually 0644 for files, 0755 for dirs.
     504         * @param bool   $recursive (optional) If set True changes file group recursivly. Defaults to False.
     505         * @return bool Returns true on success or false on failure.
     506         */
     507        function chmod( $file, $mode = false, $recursive = false ) {
     508                return false;
     509        }
     510
     511        /**
     512         * Get the file owner.
     513         *
     514         * @since Unknown
     515         *
     516         * @param string $file Path to the file.
     517         * @return string|bool Username of the user or false on error.
     518         */
     519        function owner($file) {
     520                return false;
     521        }
     522
     523        /**
     524         * Get the file's group.
     525         *
     526         * @since Unknown
     527         *
     528         * @param string $file Path to the file.
     529         * @return string|bool The group or false on error.
     530         */
     531        function group($file) {
     532                return false;
     533        }
     534
     535        /**
     536         * Copy a file.
     537         *
     538         * @since Unknown
     539         *
     540         * @param string $source
     541         * @param string $destination
     542         * @param bool   $overwrite
     543         * @param int    $mode
     544         * @return bool
     545         */
     546        function copy( $source, $destination, $overwrite = false, $mode = false ) {
     547                return false;
     548        }
     549
     550        /**
     551         * Move a file.
     552         *
     553         * @since Unknown
     554         *
     555         * @param string $source
     556         * @param string $destination
     557         * @param bool   $overwrite
     558         * @return bool
     559         */
     560        function move( $source, $destination, $overwrite = false ) {
     561                return false;
     562        }
     563
     564        /**
     565         * Delete a file / directory.
     566         *
     567         * @since Unknown
     568         *
     569         * @param string $file
     570         * @param bool   $recursive
     571         * @param type   $type      (f = file, other values = directory).
     572         * @return bool
     573         */
     574        function delete( $file, $recursive = false, $type = false ) {
     575                return false;
     576        }
     577
     578        /**
     579         * Check if a file exists.
     580         *
     581         * @since Unknown
     582         *
     583         * @param string $file
     584         * @return bool
     585         */
     586        function exists($file) {
     587                return false;
     588        }
     589
     590        /**
     591         * Check if a file is a regular file.
     592         *
     593         * @since Unknown
     594         *
     595         * @param string $file
     596         * @return bool
     597         */
     598        function is_file( $file ) {
     599                return false;
     600        }
     601
     602        /**
     603         * Check if a path is a directory.
     604         *
     605         * @since Unknown
     606         *
     607         * @param string $path
     608         * @return bool
     609         */
     610        function is_dir( $path ) {
     611                return false;
     612        }
     613
     614        /**
     615         * Check if a file is readable.
     616         *
     617         * @since Unknown
     618         *
     619         * @param string $file
     620         * @return bool
     621         */
     622        function is_readable( $file ) {
     623                return false;
     624        }
     625
     626        /**
     627         * Check if a file is writable.
     628         *
     629         * @since Unknown
     630         *
     631         * @param string $file
     632         * @return bool
     633         */
     634        function is_writable( $file ) {
     635                return false;
     636        }
     637
     638        /**
     639         * Get a file's last access time.
     640         *
     641         * @since Unknown
     642         *
     643         * @param string $file
     644         * @return int|bool
     645         */
     646        function atime( $file ) {
     647                return false;
     648        }
     649
     650        /**
     651         * Get a file's last modified time.
     652         *
     653         * @since Unknown
     654         *
     655         * @param string $file
     656         * @return int|bool
     657         */
     658        function mtime( $file ) {
     659                return false;
     660        }
     661
     662        /**
     663         * Get a file's size.
     664         *
     665         * @since Unknown
     666         *
     667         * @param string $file
     668         * @return int|bool
     669         */
     670        function size( $file ) {
     671                return false;
     672        }
     673
     674        /**
     675         * Update a file's access time and modified time.
     676         *
     677         * @since Unknown
     678         *
     679         * @param string $file
     680         * @param int    $time
     681         * @param int    $atime
     682         * @return bool
     683         */
     684        function touch( $file, $time = 0, $atime = 0 ) {
     685                return false;
     686        }
     687
     688        /**
     689         * Create a directory.
     690         *
     691         * @since Unknown
     692         *
     693         * @param string           $path
     694         * @param string|int|false $chmod
     695         * @param string|int|false $chown
     696         * @param string|int|false $chgrp
     697         * @return bool
     698         */
     699        function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
     700                return false;
     701        }
     702
     703        /**
     704         * Delete a directory.
     705         *
     706         * @since Unknown
     707         *
     708         * @param string $path
     709         * @param bool   $recursive
     710         * @return bool
     711         */
     712        function rmdir( $path, $recursive = false ) {
     713                return false;
     714        }
     715
     716        /**
     717         * Get a recursive directory listing.
     718         *
     719         * @since Unknown
     720         *
     721         * @param string $path
     722         * @param bool   $include_hidden
     723         * @param bool   $recursive
     724         * @return array|bool
     725         */
     726        function dirlist( $path, $include_hidden = true, $recursive = false ) {
     727                return false;
     728        }
    377729}
  • src/wp-admin/includes/class-wp-filesystem-direct.php

     
    1515 * @uses WP_Filesystem_Base Extends class
    1616 */
    1717class WP_Filesystem_Direct extends WP_Filesystem_Base {
    18         var $errors = null;
     18
    1919        /**
    2020         * constructor
    2121         *
     
    2626                $this->errors = new WP_Error();
    2727        }
    2828        /**
    29          * connect filesystem.
    30          *
    31          * @return bool Returns true on success or false on failure (always true for WP_Filesystem_Direct).
    32          */
    33         function connect() {
    34                 return true;
    35         }
    36         /**
    3729         * Reads entire file into a string
    3830         *
    3931         * @param string $file Name of the file to read.
     
    161153         * Gets file owner
    162154         *
    163155         * @param string $file Path to the file.
    164          * @return string Username of the user.
     156         * @return string|bool Username of the user or false on error.
    165157         */
    166158        function owner($file) {
    167159                $owneruid = @fileowner($file);
  • src/wp-admin/includes/class-wp-filesystem-ftpext.php

     
    168168                        return (bool)@ftp_site($this->link, sprintf('CHMOD %o %s', $mode, $file));
    169169                return (bool)@ftp_chmod($this->link, $mode, $file);
    170170        }
    171         function chown($file, $owner, $recursive = false ) {
    172                 return false;
    173         }
    174171        function owner($file) {
    175172                $dir = $this->dirlist($file);
    176173                return $dir[$file]['owner'];
  • src/wp-admin/includes/class-wp-filesystem-ftpsockets.php

     
    174174                return $this->ftp->chmod($file, $mode);
    175175        }
    176176
    177         function chown($file, $owner, $recursive = false ) {
    178                 return false;
    179         }
    180 
    181177        function owner($file) {
    182178                $dir = $this->dirlist($file);
    183179                return $dir[$file]['owner'];
  • src/wp-admin/includes/class-wp-filesystem-ssh2.php

     
    206206                return $this->run_command(sprintf('chmod -R %o %s', $mode, escapeshellarg($file)), true);
    207207        }
    208208
    209         function chown($file, $owner, $recursive = false ) {
     209        /**
     210         * Change the ownership of a file / folder.
     211         *
     212         * @since Unknown
     213         *
     214         * @param string $file    Path to the file.
     215         * @param mixed  $owner   A user name or number.
     216         * @param bool $recursive (optional) If set True changes file owner recursivly. Defaults to False.
     217         * @return bool Returns true on success or false on failure.
     218         */
     219        function chown( $file, $owner, $recursive = false ) {
    210220                if ( ! $this->exists($file) )
    211221                        return false;
    212222                if ( ! $recursive || ! $this->is_dir($file) )