Ticket #2137: functions-post.php.diff

File functions-post.php.diff, 2.8 KB (added by johnjosephbachir, 6 years ago)
  • wp-includes/functions-post.php

     
    806806 
    807807// Returns an array containing the current upload directory's path and url, or an error message. 
    808808function wp_upload_dir() { 
    809         if ( defined('UPLOADS') ) 
    810                 $dir = UPLOADS; 
    811         else 
    812                 $dir = 'wp-content/uploads'; 
     809        if ( defined('UPLOADS') ) 
     810                $dir = UPLOADS; 
     811        else 
     812                $dir = 'wp-content/uploads'; 
    813813 
    814814        $path = ABSPATH . $dir; 
    815815         
     
    817817        $stat = stat(ABSPATH . 'wp-content'); 
    818818        $dir_perms = $stat['mode'] & 0000777;  // Get the permission bits. 
    819819 
    820         // Make sure we have an uploads dir 
    821         if ( ! file_exists( $path ) ) { 
    822                 if ( ! mkdir( $path ) ) 
    823                         return array('error' => "Unable to create directory $path. Is its parent directory writable by the server?"); 
     820        // Make sure we have an uploads dir 
     821        if ( ! file_exists( $path ) ) { 
     822                if ( ! mkdir( $path ) ) 
     823                        return array('error' => "Unable to create directory $path. Is its parent directory writable by the server?"); 
    824824                @ chmod( $path, $dir_perms ); 
    825825        } 
    826826 
    827         // Generate the yearly and monthly dirs 
    828         $time = current_time( 'mysql' ); 
    829         $y = substr( $time, 0, 4 ); 
    830         $m = substr( $time, 5, 2 ); 
    831         $pathy = "$path/$y"; 
    832         $pathym = "$path/$y/$m"; 
     827        // Generate the yearly and monthly dirs 
     828        $time = current_time( 'mysql' ); 
     829        $y = substr( $time, 0, 4 ); 
     830        $m = substr( $time, 5, 2 ); 
     831        $pathy = "$path/$y"; 
     832        $pathym = "$path/$y/$m"; 
    833833 
    834         // Make sure we have a yearly dir 
    835         if ( ! file_exists( $pathy ) ) { 
    836                 if ( ! mkdir( $pathy ) ) 
    837                         return array('error' => "Unable to create directory $pathy. Is $path writable?"); 
     834        // Make sure we have a yearly dir 
     835        if ( ! file_exists( $pathy ) ) { 
     836                if ( ! mkdir( $pathy ) ) 
     837                        return array('error' => "Unable to create directory $pathy. Is $path writable?"); 
    838838                @ chmod( $pathy, $dir_perms ); 
    839839        } 
    840840 
    841         // Make sure we have a monthly dir 
    842         if ( ! file_exists( $pathym ) ) { 
    843                 if ( ! mkdir( $pathym ) ) 
    844                         return array('error' => "Unable to create directory $pathym. Is $pathy writable?"); 
     841        // Make sure we have a monthly dir 
     842        if ( ! file_exists( $pathym ) ) { 
     843                if ( ! mkdir( $pathym ) ) 
     844                        return array('error' => "Unable to create directory $pathym. Is $pathy writable?"); 
    845845                @ chmod( $pathym, $dir_perms ); 
    846846        } 
    847847 
    848     $uploads = array('path' => $pathym, 'url' => get_option('siteurl') . "/$dir/$y/$m", 'error' => false); 
     848        $uploads = array('path' => $pathym, 'url' => get_option('siteurl') . "/$dir/$y/$m", 'error' => false); 
    849849        return apply_filters('upload_dir', $uploads); 
    850850} 
    851851