Ticket #2206: 2206.diff

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

     
    880880 
    881881// Returns an array containing the current upload directory's path and url, or an error message. 
    882882function wp_upload_dir() { 
    883         $dir = trim(get_settings('fileupload_realpath')); 
    884         $url = trim(get_settings('fileupload_url')); 
     883        $siteurl = get_settings('siteurl'); 
     884        //prepend ABSPATH to $dir and $siteurl to $url if they're not already there 
     885        $dir = ABSPATH . str_replace(ABSPATH, '', trim(get_settings('fileupload_realpath'))); 
     886        $url = $siteurl . str_replace($siteurl, '', trim(get_settings('fileupload_url'))); 
    885887 
    886         $custom = true; 
    887         if ( empty($dir) || empty($url) ) { 
     888        if ( $dir == ABSPATH ) { //the option was empty 
    888889                $dir = ABSPATH . 'wp-content/uploads'; 
    889                 $url = get_option('siteurl') . '/wp-content/uploads'; 
    890                 $custom = false; 
    891890        } 
     891        if ( $url == $siteurl ) { //the option was empty 
     892                $url = get_option('siteurl') . '/' . str_replace(ABSPATH, '', $dir); 
     893        } 
    892894 
    893895        if ( defined('UPLOADS') ) { 
    894896                $dir = ABSPATH . UPLOADS; 
    895897                $url =  get_option('siteurl') . '/' . UPLOADS; 
    896                 $custom = false; 
    897898        } 
    898899 
    899         if ( ! $custom) { 
     900        if ( get_settings('uploads_yearmonth_folders')) { 
    900901                // Generate the yearly and monthly dirs 
    901902                $time = current_time( 'mysql' ); 
    902903                $y = substr( $time, 0, 4 ); 
  • wp-includes/functions.php

     
    355355 
    356356        // If the new and old values are the same, no need to update. 
    357357        $oldvalue = get_option($option_name); 
    358         if ( $newvalue == $oldvalue ) 
     358        if ( $newvalue == $oldvalue ) { 
    359359                return false; 
     360        } 
    360361 
    361         if ( false === $oldvalue ) { 
    362                 add_option($option_name, $newvalue); 
    363                 return true; 
     362        if ( false === $oldvalue ) { 
     363                add_option($option_name, $newvalue); 
     364                return true; 
    364365        } 
    365366 
    366367        if ( is_array($newvalue) || is_object($newvalue) ) 
  • wp-admin/options.php

     
    4747        // Options that if not there have 0 value but need to be something like "closed" 
    4848        $nonbools = array('default_ping_status', 'default_comment_status'); 
    4949        if ($options) { 
    50           foreach ($options as $option) { 
    51             $option = trim($option); 
    52             $value = trim(stripslashes($_POST[$option])); 
    53             if( in_array($option, $nonbools) && ( $value == '0' || $value == '') ) 
    54               $value = 'closed'; 
    55  
    56             if( $option == 'blogdescription' || $option == 'blogname' ) 
    57                     if (current_user_can('unfiltered_html') == false) 
    58                             $value = wp_filter_post_kses( $value ); 
    59  
    60             if ( update_option($option, $value) ) 
    61               $any_changed++; 
    62           } 
    63         } 
     50                foreach ($options as $option) { 
     51                        $option = trim($option); 
     52                        $value = trim(stripslashes($_POST[$option])); 
     53                                if( in_array($option, $nonbools) && ( $value == '0' || $value == '') ) 
     54                                $value = 'closed'; 
     55                         
     56                        if( $option == 'blogdescription' || $option == 'blogname' ) 
     57                                if (current_user_can('unfiltered_html') == false) 
     58                                        $value = wp_filter_post_kses( $value ); 
     59                         
     60                        if (update_option($option, $value) ) { 
     61                                $any_changed++; 
     62                        } 
     63                } 
     64        } 
    6465     
    6566        if ($any_changed) { 
    6667                        // If siteurl or home changed, reset cookies. 
     
    7879                        //$message = sprintf(__('%d setting(s) saved... '), $any_changed); 
    7980    } 
    8081     
    81                 $referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']); 
    82                 $goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']); 
    83                 $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback); 
    84                 wp_redirect($goback); 
     82        $referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']); 
     83        $goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']); 
     84        $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback); 
     85        wp_redirect($goback); 
    8586    break; 
    8687 
    8788default: 
  • wp-admin/options-writing.php

     
    4444</table> 
    4545 
    4646<fieldset class="options"> 
    47 <legend><?php _e('Writing by e-mail') ?></legend> 
     47<legend><?php _e('Uploading'); ?></legend> 
     48<table width="100%" cellspacing="2" cellpadding="5" class="editform"> 
     49        <tr valign="top"><th scope="row" width="33%">Where to store images:</th> 
     50        <td> 
     51                <label for="uploads_yearmonth_folders"> 
     52                        <input name="uploads_yearmonth_folders" type="checkbox" id="uploads_yearmonth_folders" value="1" <?php checked('1', get_settings('uploads_yearmonth_folders')); ?> /> 
     53                        <?php _e('Organize my uploads into month- and year-based folders'); ?> 
     54                </label> 
     55        </td></tr> 
     56        <tr valign="top"><th scope="row"><?php _e('Store uploads in (default is wp-content/uploads):'); ?></th> 
     57        <td> 
     58                <input name="fileupload_realpath" type="text" id="fileupload_realpath" value="<?php echo str_replace(ABSPATH, '', get_settings('fileupload_realpath')); ?>" size="40" /> 
     59        </td></tr> 
     60</table> 
     61 
     62</fieldset> 
     63 
     64<fieldset class="options"> 
     65<legend><?php _e('Writing by e-mail'); ?></legend> 
    4866<p><?php printf(__('To post to WordPress by e-mail you must set up a secret e-mail account with POP3 access. Any mail received at this address will be posted, so it&#8217;s a good idea to keep this address very secret. Here are three random strings you could use: <code>%s</code>, <code>%s</code>, <code>%s</code>.'), substr(md5(uniqid(microtime())),0,5), substr(md5(uniqid(microtime())),0,5), substr(md5(uniqid(microtime())),0,5)) ?></p> 
    4967 
    5068<table width="100%" cellspacing="2" cellpadding="5" class="editform"> 
     
    90108 
    91109<p class="submit"> 
    92110<input type="hidden" name="action" value="update" />  
    93 <input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,rich_editing,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags" />  
     111<input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,rich_editing,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags,fileupload_realpath,uploads_yearmonth_folders" />  
    94112<input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />  
    95113</p> 
    96114</form>  
  • wp-admin/upgrade-schema.php

     
    216216        add_option('html_type', 'text/html'); 
    217217        // 1.5.1 
    218218        add_option('use_trackback', 0); 
    219         // 1.6 
     219        // 2.0 
    220220        add_option('default_role', 'subscriber'); 
    221221        add_option('rich_editing', 'true'); 
    222222        add_option('db_version', $wp_db_version); 
     223        // 2.1 
     224        add_option('uploads_yearmonth_folders', 1); 
     225        add_option('fileupload_realpath', ABSPATH . 'wp-content/uploads'); 
     226        add_option('fileupload_url', ''); //if this is empty it will be obtained from fileupload_realpath 
    223227         
    224228        // Delete unused options 
    225229        $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');