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 5 times in this file.
Line | Code |
---|---|
151 | * @since 3.4.0 |
152 | * @since 4.4.0 The `$option` parameter was added. |
153 | * @since 4.7.0 The `$passed_default` parameter was added to distinguish between a `false` value and the default parameter value. |
154 | * |
155 | * @param mixed $default The default value to return if the option does not exist |
156 | * in the database. |
157 | * @param string $option Option name. |
158 | * @param bool $passed_default Was `get_option()` passed a default value? |
159 | */ |
160 | return apply_filters( "default_option_{$option}", $default, $option, $passed_default ); |
161 | } |
162 |
|
163 | $alloptions = wp_load_alloptions(); |
164 |
|
165 | if ( isset( $alloptions[ $option ] ) ) { |
166 | $value = $alloptions[ $option ]; |
167 | } else { |
168 | $value = wp_cache_get( $option, 'options' ); |
169 |
|
Line | Code |
177 | } else { // Option does not exist, so we must cache its non-existence. |
178 | if ( ! is_array( $notoptions ) ) { |
179 | $notoptions = array(); |
180 | } |
181 |
|
182 | $notoptions[ $option ] = true; |
183 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
184 |
|
185 | /** This filter is documented in wp-includes/option.php */ |
186 | return apply_filters( "default_option_{$option}", $default, $option, $passed_default ); |
187 | } |
188 | } |
189 | } |
190 | } else { |
191 | $suppress = $wpdb->suppress_errors(); |
192 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); |
193 | $wpdb->suppress_errors( $suppress ); |
194 |
|
195 | if ( is_object( $row ) ) { |
196 | $value = $row->option_value; |
197 | } else { |
198 | /** This filter is documented in wp-includes/option.php */ |
199 | return apply_filters( "default_option_{$option}", $default, $option, $passed_default ); |
200 | } |
201 | } |
202 |
|
203 | // If home is not set, use siteurl. |
204 | if ( 'home' === $option && '' === $value ) { |
205 | return get_option( 'siteurl' ); |
206 | } |
207 |
|
208 | if ( in_array( $option, array( 'siteurl', 'home', 'category_base', 'tag_base' ), true ) ) { |
Line | Code |
448 | * unnecessary database calls for otherwise identical object instances. |
449 | * |
450 | * See https://core.trac.wordpress.org/ticket/38903 |
451 | */ |
452 | if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) { |
453 | return false; |
454 | } |
455 |
|
456 | /** This filter is documented in wp-includes/option.php */ |
457 | if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) { |
458 | // Default setting for new options is 'yes'. |
459 | if ( null === $autoload ) { |
460 | $autoload = 'yes'; |
461 | } |
462 |
|
463 | return add_option( $option, $value, '', $autoload ); |
464 | } |
465 |
|
466 | $serialized_value = maybe_serialize( $value ); |
Line | Code |
601 |
|
602 | $value = sanitize_option( $option, $value ); |
603 |
|
604 | // Make sure the option doesn't already exist. |
605 | // We can check the 'notoptions' cache before we ask for a DB query. |
606 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
607 |
|
608 | if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) { |
609 | /** This filter is documented in wp-includes/option.php */ |
610 | if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) ) { |
611 | return false; |
612 | } |
613 | } |
614 |
|
615 | $serialized_value = maybe_serialize( $value ); |
616 | $autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes'; |
617 |
|
618 | /** |
619 | * Fires before an option is added. |