Make WordPress Core

Ticket #23122: patch.diff

File patch.diff, 10.0 KB (added by bananastalktome, 12 years ago)
  • wp-admin/includes/class-wp-filesystem-direct.php

     
    1616 */
    1717class WP_Filesystem_Direct extends WP_Filesystem_Base {
    1818        var $errors = null;
     19       
    1920        /**
    2021         * constructor
    2122         *
     
    2526                $this->method = 'direct';
    2627                $this->errors = new WP_Error();
    2728        }
     29       
    2830        /**
    2931         * connect filesystem.
    3032         *
     
    3335        function connect() {
    3436                return true;
    3537        }
     38       
    3639        /**
    3740         * Reads entire file into a string
    3841         *
     
    4245        function get_contents($file) {
    4346                return @file_get_contents($file);
    4447        }
     48       
    4549        /**
    4650         * Reads entire file into an array
    4751         *
     
    5155        function get_contents_array($file) {
    5256                return @file($file);
    5357        }
     58       
    5459        /**
    5560         * Write a string to a file
    5661         *
     
    6772                $this->chmod($file, $mode);
    6873                return true;
    6974        }
     75       
    7076        /**
    7177         * Gets the current working directory
    7278         *
     
    7581        function cwd() {
    7682                return @getcwd();
    7783        }
     84       
    7885        /**
    7986         * Change directory
    8087         *
     
    8491        function chdir($dir) {
    8592                return @chdir($dir);
    8693        }
     94       
    8795        /**
    8896         * Changes file group
    8997         *
     
    107115
    108116                return true;
    109117        }
     118       
    110119        /**
    111120         * Changes filesystem permissions
    112121         *
     
    135144
    136145                return true;
    137146        }
     147       
    138148        /**
    139149         * Changes file owner
    140150         *
     
    157167                }
    158168                return true;
    159169        }
     170       
    160171        /**
    161172         * Gets file owner
    162173         *
    163174         * @param string $file Path to the file.
    164          * @return string Username of the user.
     175         * @return mixed Username string of the user, int user ID if posix_getpwuid isn't available,
     176         *      or bool False if fileowner check fails.
    165177         */
    166178        function owner($file) {
    167179                $owneruid = @fileowner($file);
     
    172184                $ownerarray = posix_getpwuid($owneruid);
    173185                return $ownerarray['name'];
    174186        }
     187       
    175188        /**
    176189         * Gets file permissions
    177190         *
     
    183196        function getchmod($file) {
    184197                return substr(decoct(@fileperms($file)),3);
    185198        }
     199       
     200        /**
     201         * Gets file group.
     202         *
     203         * @param string $file Path to the file.
     204         * @return mixed String group name, int group ID if posix_getgrgid isn't available,
     205         *      or bool False if filegroup check fails.
     206         */
    186207        function group($file) {
    187208                $gid = @filegroup($file);
    188209                if ( ! $gid )
     
    192213                $grouparray = posix_getgrgid($gid);
    193214                return $grouparray['name'];
    194215        }
    195 
     216       
     217        /**
     218         * Copy a file.
     219         *
     220         * @param string $source Path to the file.
     221         * @param string $destination Path to the new file.
     222         * @param bool $overwrite (optional) Whether to overwrite file at $destination if it exists.
     223         * @param int $mode (optional) The permissions as octal number, usually 0644 for files, 0755 for dirs.
     224         * @return bool True if file copied successfully, False otherwise.
     225         */
    196226        function copy($source, $destination, $overwrite = false, $mode = false) {
    197227                if ( ! $overwrite && $this->exists($destination) )
    198228                        return false;
     
    202232                        $this->chmod($destination, $mode);
    203233                return $rtval;
    204234        }
    205 
     235       
     236        /**
     237         * Move a file.
     238         *
     239         * @param string $source Path to the file.
     240         * @param string $destination Path to the file destination.
     241         * @param bool $overwrite (optional) Whether to overwrite file at $destination if it exists.
     242         * @return bool True if file copied successfully, False otherwise.
     243         */
    206244        function move($source, $destination, $overwrite = false) {
    207245                if ( ! $overwrite && $this->exists($destination) )
    208246                        return false;
     
    219257                }
    220258        }
    221259
     260        /**
     261         * Delete a file or directory.
     262         *
     263         * @param string $file Path to File/directory.
     264         * @param bool $recursive (optional) Whether to recursively remove files.
     265         * @param string $type (optional) The type of resource being removed (values are 'f' or 'd').
     266         * @return bool True if deleted successfully, false otherwise.
     267         */
    222268        function delete($file, $recursive = false, $type = false) {
    223269                if ( empty($file) ) //Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
    224270                        return false;
     
    244290                return $retval;
    245291        }
    246292
     293        /**
     294         * Check if file or directory exists.
     295         *
     296         * @param string $file Path to file/directory.
     297         * @return bool Whether $file exists or not.
     298         */
    247299        function exists($file) {
    248300                return @file_exists($file);
    249301        }
    250302
     303        /**
     304         * Check if file.
     305         *
     306         * @param string $file File path.
     307         * @return bool Whether $file is a file.
     308         */
    251309        function is_file($file) {
    252310                return @is_file($file);
    253311        }
    254312
     313        /**
     314         * Check if directory.
     315         *
     316         * @param string $path Directory path.
     317         * @return bool Whether $path is a directory.
     318         */
    255319        function is_dir($path) {
    256320                return @is_dir($path);
    257321        }
    258322
     323        /**
     324         * Check if file is readable.
     325         *
     326         * @param string $file Path to file.
     327         * @return bool Whether $file is readable.
     328         */
    259329        function is_readable($file) {
    260330                return @is_readable($file);
    261331        }
    262332
     333        /**
     334         * Check if file/directory is writable.
     335         *
     336         * @param string $path Path to file/directory.
     337         * @return bool Whether $file is writable.
     338         */
    263339        function is_writable($file) {
    264340                return @is_writable($file);
    265341        }
    266342
     343        /**
     344         * Gets the file last access time.
     345         *
     346         * @param string $file Path to file.
     347         * @return int Unix timestamp representing last access time.
     348         */
    267349        function atime($file) {
    268350                return @fileatime($file);
    269351        }
    270352
     353        /**
     354         * Gets the file modification time.
     355         *
     356         * @param string $file Path to file.
     357         * @return int Unix timestamp representing modification time.
     358         */
    271359        function mtime($file) {
    272360                return @filemtime($file);
    273361        }
     362
     363        /**
     364         * Gets the file size (in bytes).
     365         *
     366         * @param string $file Path to file.
     367         * @return int Size of the file in bytes.
     368         */
    274369        function size($file) {
    275370                return @filesize($file);
    276371        }
    277 
     372       
     373        /**
     374         * Set the access and modification times of a file.
     375         *
     376         * Note: If $file doesn't exist, it will be created.
     377         *
     378         * @param string $file Path to file.
     379         * @param int $time (Optional) Modified time to set for file.
     380         * @param int $atime (Optional) Access time to set for file.
     381         * @return bool Whether operation was successful or not.
     382         */
    278383        function touch($file, $time = 0, $atime = 0) {
    279384                if ($time == 0)
    280385                        $time = time();
     
    283388                return @touch($file, $time, $atime);
    284389        }
    285390
     391        /**
     392         * Create a directory.
     393         *
     394         * @param string $path Path for new directory.
     395         * @param mixed $chmod (Optional) The permissions as octal number, (or False to skip chmod)
     396         * @param mixed $chown (Optional) A user name or number (or False to skip chown)
     397         * @param mixed $chgrp (Optional) A group name or number (or False to skip chgrp).
     398         * @return bool False if directory cannot be created, true otherwise.
     399         */
    286400        function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
    287401                // safe mode fails with a trailing slash under certain PHP versions.
    288402                $path = untrailingslashit($path);
     
    302416                return true;
    303417        }
    304418
     419        /**
     420         * Delete a directory.
     421         *
     422         * @param string $path Path to directory.
     423         * @param bool $recursive Whether to recursively remove files/directories.
     424         * @return bool Whether directory is deleted successfully or not.
     425         */
    305426        function rmdir($path, $recursive = false) {
    306427                return $this->delete($path, $recursive);
    307428        }
    308429
     430        /**
     431         * Gets details for files in a directory or a specific file.
     432         *
     433         * The returned array of files is keyed by file/directory name with arrays keyed as follows:
     434         * 'name' - Name of the file/directory
     435         * 'perms' - String *nix representation of permissions
     436         * 'permsn' - Octal representation of permissions
     437         * 'owner' - Owner name or ID
     438         * 'group' - Group name or ID
     439         * 'size' - Size of file (in bytes)
     440         * 'lastmodunix' - Last modified unix timestamp
     441         * 'lastmod' - Last modified month (3 letter) and Day (without leading 0)
     442         * 'time' - Last modified time
     443         * 'type' - Type of resource ('f' for file, 'd' for directory)
     444         * 'files' - If a directory and $recursive is true, contains another array of files
     445         *
     446         * @param string $path Path to directory or file.
     447         * @param bool $include_hidden (Optional) Whether to include details of hidden ("." prefixed) files.
     448         * @param bool $recursive (Optional) Whether to recursively include file details in nested directories.
     449         * @return array|bool False if unable to list directory contents, array otherwise.
     450         */
    309451        function dirlist($path, $include_hidden = true, $recursive = false) {
    310452                if ( $this->is_file($path) ) {
    311453                        $limit_file = basename($path);
  • wp-admin/includes/class-wp-list-table.php

     
    352352        }
    353353
    354354        /**
    355          * Display a monthly dropdown for filtering items
     355         * Display a monthly dropdown for filtering items.
    356356         *
     357         * Only includes months during which a $post_type was posted.
     358         *
    357359         * @since 3.1.0
    358360         * @access protected
     361         *
     362         * @param string $post_type
    359363         */
    360364        function months_dropdown( $post_type ) {
    361365                global $wpdb, $wp_locale;
     
    401405         *
    402406         * @since 3.1.0
    403407         * @access protected
     408         *
     409         * @param string $current_mode
    404410         */
    405411        function view_switcher( $current_mode ) {
    406412                $modes = array(
     
    465471         * @since 3.1.0
    466472         * @access protected
    467473         *
     474         * @param string $option Name of the user option.
     475         * @param int $default Default number of items to show per page.
    468476         * @return int
    469477         */
    470478        function get_items_per_page( $option, $default = 20 ) {
     
    480488         *
    481489         * @since 3.1.0
    482490         * @access protected
     491         *
     492         * @param string $which Position of the pagination being displayed (values are 'top' or 'bottom').
    483493         */
    484494        function pagination( $which ) {
    485495                if ( empty( $this->_pagination_args ) )
     
    757767         *
    758768         * @since 3.1.0
    759769         * @access protected
     770         *
     771         * @param string $which Position of the table navigation being generated
     772         *      (values are 'top' or 'bottom').
    760773         */
    761774        function display_tablenav( $which ) {
    762775                if ( 'top' == $which )
     
    782795         *
    783796         * @since 3.1.0
    784797         * @access protected
     798         *
     799         * @param string $which Position of the table navigation being displayed
     800         *      (values are 'top' or 'bottom').
    785801         */
    786802        function extra_tablenav( $which ) {}
    787803