web/wp-admin/options.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    59 	wp_die(__('Cheatin’ uh?'));
    59 	wp_die(__('Cheatin’ uh?'));
    60 
    60 
    61 $whitelist_options = array(
    61 $whitelist_options = array(
    62 	'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ),
    62 	'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ),
    63 	'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
    63 	'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),
    64 	'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ),
    64 	'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ),
    65 	'privacy' => array( 'blog_public' ),
    65 	'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ),
    66 	'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ),
    66 	'writing' => array( 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format' )
    67 	'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format', 'enable_app', 'enable_xmlrpc' ),
    67 );
    68 	'options' => array( '' ) );
    68 $whitelist_options['misc'] = $whitelist_options['options'] = $whitelist_options['privacy'] = array();
    69 
    69 
    70 $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass');
    70 $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass');
    71 $uploads_options = array('uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path');
    71 
       
    72 if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) )
       
    73 	$whitelist_options['reading'][] = 'blog_charset';
    72 
    74 
    73 if ( !is_multisite() ) {
    75 if ( !is_multisite() ) {
    74 	if ( !defined( 'WP_SITEURL' ) )
    76 	if ( !defined( 'WP_SITEURL' ) )
    75 		$whitelist_options['general'][] = 'siteurl';
    77 		$whitelist_options['general'][] = 'siteurl';
    76 	if ( !defined( 'WP_HOME' ) )
    78 	if ( !defined( 'WP_HOME' ) )
    81 	$whitelist_options['general'][] = 'default_role';
    83 	$whitelist_options['general'][] = 'default_role';
    82 
    84 
    83 	$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
    85 	$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
    84 	$whitelist_options['writing'][] = 'ping_sites';
    86 	$whitelist_options['writing'][] = 'ping_sites';
    85 
    87 
    86 	$whitelist_options['media'] = array_merge($whitelist_options['media'], $uploads_options);
    88 	$whitelist_options['media'][] = 'uploads_use_yearmonth_folders';
       
    89 
       
    90 	// If upload_url_path and upload_path are both default values, they're locked.
       
    91 	if ( get_option( 'upload_url_path' ) || ( get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path') ) ) {
       
    92 		$whitelist_options['media'][] = 'upload_path';
       
    93 		$whitelist_options['media'][] = 'upload_url_path';
       
    94 	}
    87 } else {
    95 } else {
    88 	$whitelist_options['general'][] = 'new_admin_email';
    96 	$whitelist_options['general'][] = 'new_admin_email';
    89 	$whitelist_options['general'][] = 'WPLANG';
    97 	$whitelist_options['general'][] = 'WPLANG';
    90 	$whitelist_options['general'][] = 'language';
       
    91 
    98 
    92 	if ( apply_filters( 'enable_post_by_email_configuration', true ) )
    99 	if ( apply_filters( 'enable_post_by_email_configuration', true ) )
    93 		$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
   100 		$whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
    94 
       
    95 	$whitelist_options[ 'misc' ] = array();
       
    96 }
   101 }
    97 
   102 
    98 $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
   103 $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
    99 
   104 
   100 /*
   105 /*
   137 	if ( $options ) {
   142 	if ( $options ) {
   138 		foreach ( $options as $option ) {
   143 		foreach ( $options as $option ) {
   139 			if ( $unregistered )
   144 			if ( $unregistered )
   140 				_deprecated_argument( 'options.php', '2.7', sprintf( __( 'The <code>%1$s</code> setting is unregistered. Unregistered settings are deprecated. See http://codex.wordpress.org/Settings_API' ), $option, $option_page ) );
   145 				_deprecated_argument( 'options.php', '2.7', sprintf( __( 'The <code>%1$s</code> setting is unregistered. Unregistered settings are deprecated. See http://codex.wordpress.org/Settings_API' ), $option, $option_page ) );
   141 
   146 
   142 			$option = trim($option);
   147 			$option = trim( $option );
   143 			$value = null;
   148 			$value = null;
   144 			if ( isset($_POST[$option]) )
   149 			if ( isset( $_POST[ $option ] ) ) {
   145 				$value = $_POST[$option];
   150 				$value = $_POST[ $option ];
   146 			if ( !is_array($value) )
   151 				if ( ! is_array( $value ) )
   147 				$value = trim($value);
   152 					$value = trim( $value );
   148 			$value = stripslashes_deep($value);
   153 				$value = stripslashes_deep( $value );
   149 			update_option($option, $value);
   154 			}
       
   155 			update_option( $option, $value );
   150 		}
   156 		}
   151 	}
   157 	}
   152 
   158 
   153 	/**
   159 	/**
   154 	 * Handle settings errors and return to options page
   160 	 * Handle settings errors and return to options page