Make WordPress Core

Ticket #19910: default_option.diff

File default_option.diff, 1.7 KB (added by Otto42, 13 years ago)

add and use a default_option_ filter

  • wp-includes/class-wp-customize-setting.php

     
    6868                        case 'option' :
    6969                                if ( empty( $this->id_data[ 'keys' ] ) )
    7070                                        add_filter( 'pre_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
    71                                 else
     71                                else {
    7272                                        add_filter( 'option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
     73                                        add_filter( 'default_option_' . $this->id_data[ 'base' ], array( $this, '_preview_filter' ) );
     74                                }
    7375                                break;
    7476                        default :
    7577                                do_action( 'customize_preview_' . $this->id );
  • wp-includes/option.php

     
    4848                // prevent non-existent options from triggering multiple queries
    4949                $notoptions = wp_cache_get( 'notoptions', 'options' );
    5050                if ( isset( $notoptions[$option] ) )
    51                         return $default;
     51                        return apply_filters('default_option_'.$option, $default);
    5252
    5353                $alloptions = wp_load_alloptions();
    5454
     
    6767                                } else { // option does not exist, so we must cache its non-existence
    6868                                        $notoptions[$option] = true;
    6969                                        wp_cache_set( 'notoptions', $notoptions, 'options' );
    70                                         return $default;
     70                                        return apply_filters('default_option_'.$option, $default);
    7171                                }
    7272                        }
    7373                }
     
    7878                if ( is_object( $row ) )
    7979                        $value = $row->option_value;
    8080                else
    81                         return $default;
     81                        return apply_filters('default_option_'.$option, $default);
    8282        }
    8383
    8484        // If home is not set use siteurl.