Make WordPress Core

Ticket #21989: 21989.2.diff

File 21989.2.diff, 1.6 KB (added by rmccue, 10 years ago)

Add new parameter to add_option

  • wp-includes/option.php

    diff --git wp-includes/option.php wp-includes/option.php
    index 1d2c35d..571b055 100644
    function update_option( $option, $value ) { 
    271271                return false;
    272272
    273273        if ( false === $old_value )
    274                 return add_option( $option, $value );
     274                return add_option( $option, $value, '', 'yes', false );
    275275
    276276        $serialized_value = maybe_serialize( $value );
    277277
    function update_option( $option, $value ) { 
    349349 * @param mixed $value Optional. Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
    350350 * @param mixed $deprecated Optional. Description. Not used anymore.
    351351 * @param bool $autoload Optional. Default is enabled. Whether to load the option when WordPress starts up.
     352 * @param boolean $sanitize Whether to sanitize the option value.
    352353 * @return bool False if option was not added and true if option was added.
    353354 */
    354 function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
     355function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes', $sanitize = true ) {
    355356        global $wpdb;
    356357
    357358        if ( !empty( $deprecated ) )
    function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) 
    366367        if ( is_object($value) )
    367368                $value = clone $value;
    368369
    369         $value = sanitize_option( $option, $value );
     370        if ( $sanitize ) {
     371                $value = sanitize_option( $option, $value );
     372        }
    370373
    371374        // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query
    372375        $notoptions = wp_cache_get( 'notoptions', 'options' );