WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 3 times in this file.
Line | Code |
---|---|
57 | * Filter the default value for an option. |
58 | * |
59 | * The dynamic portion of the hook name, `$option`, refers to the option name. |
60 | * |
61 | * @since 3.4.0 |
62 | * |
63 | * @param mixed $default The default value to return if the option does not exist |
64 | * in the database. |
65 | */ |
66 | return apply_filters( 'default_option_' . $option, $default ); |
67 | } |
68 |
|
69 | $alloptions = wp_load_alloptions(); |
70 |
|
71 | if ( isset( $alloptions[$option] ) ) { |
72 | $value = $alloptions[$option]; |
73 | } else { |
74 | $value = wp_cache_get( $option, 'options' ); |
75 |
|
Line | Code |
79 | // Has to be get_row instead of get_var because of funkiness with 0, false, null values |
80 | if ( is_object( $row ) ) { |
81 | $value = $row->option_value; |
82 | wp_cache_add( $option, $value, 'options' ); |
83 | } else { // option does not exist, so we must cache its non-existence |
84 | $notoptions[$option] = true; |
85 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
86 |
|
87 | /** This filter is documented in wp-includes/option.php */ |
88 | return apply_filters( 'default_option_' . $option, $default ); |
89 | } |
90 | } |
91 | } |
92 | } else { |
93 | $suppress = $wpdb->suppress_errors(); |
94 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); |
95 | $wpdb->suppress_errors( $suppress ); |
96 | if ( is_object( $row ) ) { |
97 | $value = $row->option_value; |
98 | } else { |
99 | /** This filter is documented in wp-includes/option.php */ |
100 | return apply_filters( 'default_option_' . $option, $default ); |
101 | } |
102 | } |
103 |
|
104 | // If home is not set use siteurl. |
105 | if ( 'home' == $option && '' == $value ) |
106 | return get_option( 'siteurl' ); |
107 |
|
108 | if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) ) |
109 | $value = untrailingslashit( $value ); |