Make WordPress Core

Ticket #21459: 21459-filter.diff

File 21459-filter.diff, 1.8 KB (added by ryan, 12 years ago)
  • wp-includes/option.php

     
    3232function get_option( $option, $default = false ) {
    3333        global $wpdb;
    3434
     35        $filter = is_ms_switched() ? 'blog_option_' : 'option_';
     36
    3537        // Allow plugins to short-circuit options.
    36         $pre = apply_filters( 'pre_option_' . $option, false );
     38        $pre = apply_filters( 'pre_' . $filter . $option, false );
    3739        if ( false !== $pre )
    3840                return $pre;
    3941
     
    4850                // prevent non-existent options from triggering multiple queries
    4951                $notoptions = wp_cache_get( 'notoptions', 'options' );
    5052                if ( isset( $notoptions[$option] ) )
    51                         return apply_filters( 'default_option_' . $option, $default );
     53                        return apply_filters( 'default_' . $filter . $option, $default );
    5254
    5355                $alloptions = wp_load_alloptions();
    5456
     
    6769                                } else { // option does not exist, so we must cache its non-existence
    6870                                        $notoptions[$option] = true;
    6971                                        wp_cache_set( 'notoptions', $notoptions, 'options' );
    70                                         return apply_filters( 'default_option_' . $option, $default );
     72                                        return apply_filters( 'default_' . $filter . $option, $default );
    7173                                }
    7274                        }
    7375                }
     
    7880                if ( is_object( $row ) )
    7981                        $value = $row->option_value;
    8082                else
    81                         return apply_filters( 'default_option_' . $option, $default );
     83                        return apply_filters( 'default_' . $filter . $option, $default );
    8284        }
    8385
    8486        // If home is not set use siteurl.
     
    8890        if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) )
    8991                $value = untrailingslashit( $value );
    9092
    91         return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );
     93        return apply_filters( $filter . $option, maybe_unserialize( $value ) );
    9294}
    9395
    9496/**