Hide upload_path and upload_url_path from the Media Settings screen, assuming they are both set to their default values.

These can be set on options.php, or the UPLOADS constant or the filters in wp_upload_dir() should be used. WordPress should aim to avoid UI options that require filesystem changes as well, not to mention requiring the user to convert between paths and URLs.

fixes #21720.



git-svn-id: https://develop.svn.wordpress.org/trunk@21852 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2012-09-14 21:00:39 +00:00
parent 42a2b4a12f
commit 93f6ea672e
2 changed files with 12 additions and 3 deletions

View File

@ -121,6 +121,10 @@ include('./admin-header.php');
<?php if ( !is_multisite() ) : ?> <?php if ( !is_multisite() ) : ?>
<h3><?php _e('Uploading Files'); ?></h3> <h3><?php _e('Uploading Files'); ?></h3>
<table class="form-table"> <table class="form-table">
<?php
// If upload_url_path is not the default (empty), and upload_path is not the default ('wp-content/uploads' or empty)
if ( get_option('upload_url_path') || ( get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path') ) ) :
?>
<tr valign="top"> <tr valign="top">
<th scope="row"><label for="upload_path"><?php _e('Store uploads in this folder'); ?></label></th> <th scope="row"><label for="upload_path"><?php _e('Store uploads in this folder'); ?></label></th>
<td><input name="upload_path" type="text" id="upload_path" value="<?php echo esc_attr(get_option('upload_path')); ?>" class="regular-text code" /> <td><input name="upload_path" type="text" id="upload_path" value="<?php echo esc_attr(get_option('upload_path')); ?>" class="regular-text code" />
@ -134,7 +138,7 @@ include('./admin-header.php');
<p class="description"><?php _e('Configuring this is optional. By default, it should be blank.'); ?></p> <p class="description"><?php _e('Configuring this is optional. By default, it should be blank.'); ?></p>
</td> </td>
</tr> </tr>
<?php endif; ?>
<tr> <tr>
<th scope="row" colspan="2" class="th-full"> <th scope="row" colspan="2" class="th-full">
<label for="uploads_use_yearmonth_folders"> <label for="uploads_use_yearmonth_folders">

View File

@ -68,7 +68,6 @@ $whitelist_options = array(
$whitelist_options['misc'] = $whitelist_options['options'] = $whitelist_options['privacy'] = array(); $whitelist_options['misc'] = $whitelist_options['options'] = $whitelist_options['privacy'] = array();
$mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass'); $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass');
$uploads_options = array('uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path');
if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) )
$whitelist_options['reading'][] = 'blog_charset'; $whitelist_options['reading'][] = 'blog_charset';
@ -86,7 +85,13 @@ if ( !is_multisite() ) {
$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options); $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
$whitelist_options['writing'][] = 'ping_sites'; $whitelist_options['writing'][] = 'ping_sites';
$whitelist_options['media'] = array_merge($whitelist_options['media'], $uploads_options); $whitelist_options['media'][] = 'uploads_use_yearmonth_folders';
// If upload_url_path and upload_path are both default values, they're locked.
if ( get_option( 'upload_url_path' ) || ( get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path') ) ) {
$whitelist_options['media'][] = 'upload_path';
$whitelist_options['media'][] = 'upload_url_path';
}
} else { } else {
$whitelist_options['general'][] = 'new_admin_email'; $whitelist_options['general'][] = 'new_admin_email';
$whitelist_options['general'][] = 'WPLANG'; $whitelist_options['general'][] = 'WPLANG';