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
806 806 807 807 // Returns an array containing the current upload directory's path and url, or an error message. 808 808 function wp_upload_dir() { 809 if ( defined('UPLOADS') )810 $dir = UPLOADS;811 else812 $dir = 'wp-content/uploads';809 if ( defined('UPLOADS') ) 810 $dir = UPLOADS; 811 else 812 $dir = 'wp-content/uploads'; 813 813 814 814 $path = ABSPATH . $dir; 815 815 … … 817 817 $stat = stat(ABSPATH . 'wp-content'); 818 818 $dir_perms = $stat['mode'] & 0000777; // Get the permission bits. 819 819 820 // Make sure we have an uploads dir821 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?"); 824 824 @ chmod( $path, $dir_perms ); 825 825 } 826 826 827 // Generate the yearly and monthly dirs828 $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"; 833 833 834 // Make sure we have a yearly dir835 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?"); 838 838 @ chmod( $pathy, $dir_perms ); 839 839 } 840 840 841 // Make sure we have a monthly dir842 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?"); 845 845 @ chmod( $pathym, $dir_perms ); 846 846 } 847 847 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); 849 849 return apply_filters('upload_dir', $uploads); 850 850 } 851 851
