Changeset 31640 for trunk/src/wp-includes/option.php
- Timestamp:
- 03/06/2015 01:56:44 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/option.php
r31628 r31640 226 226 * @param string $option Option name. Expected to not be SQL-escaped. 227 227 * @param mixed $value Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped. 228 * @param string|bool $autoload Optional. Whether to load the option when WordPress starts up. Accepts 'yes' or true to 229 * enable, 'no' or false to disable. Default is enabled. 228 * @param string|bool $autoload Optional. Whether to load the option when WordPress starts up. For existing options, 229 * `$autoload` can only be updated using `update_option()` if `$value` is also changed. 230 * Accepts 'yes' or true to enable, 'no' or false to disable. For non-existent options, 231 * the default value is 'yes'. 230 232 * @return bool False if value was not updated and true if value was updated. 231 233 */ 232 function update_option( $option, $value, $autoload = 'yes') {234 function update_option( $option, $value, $autoload = null ) { 233 235 global $wpdb; 234 236 … … 274 276 /** This filter is documented in wp-includes/option.php */ 275 277 if ( apply_filters( 'default_option_' . $option, false ) === $old_value ) { 278 // Default setting for new options is 'yes'. 279 if ( null === $autoload ) { 280 $autoload = 'yes'; 281 } 282 276 283 return add_option( $option, $value, '', $autoload ); 277 284 } … … 290 297 do_action( 'update_option', $option, $old_value, $value ); 291 298 292 $result = $wpdb->update( $wpdb->options, array( 'option_value' => $serialized_value ), array( 'option_name' => $option ) ); 299 $update_args = array( 300 'option_value' => $serialized_value, 301 ); 302 303 if ( null !== $autoload ) { 304 $update_args['autoload'] = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes'; 305 } 306 307 $result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => $option ) ); 293 308 if ( ! $result ) 294 309 return false;
Note: See TracChangeset
for help on using the changeset viewer.