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 |
---|---|
104 | * @since 3.4.0 |
105 | * @since 4.4.0 The `$option` parameter was added. |
106 | * @since 4.7.0 The `$passed_default` parameter was added to distinguish between a `false` value and the default parameter value. |
107 | * |
108 | * @param mixed $default The default value to return if the option does not exist |
109 | * in the database. |
110 | * @param string $option Option name. |
111 | * @param bool $passed_default Was `get_option()` passed a default value? |
112 | */ |
113 | return apply_filters( "default_option_{$option}", $default, $option, $passed_default ); |
114 | } |
115 |
|
116 | $alloptions = wp_load_alloptions(); |
117 |
|
118 | if ( isset( $alloptions[ $option ] ) ) { |
119 | $value = $alloptions[ $option ]; |
120 | } else { |
121 | $value = wp_cache_get( $option, 'options' ); |
122 |
|
Line | Code |
130 | } else { // Option does not exist, so we must cache its non-existence. |
131 | if ( ! is_array( $notoptions ) ) { |
132 | $notoptions = array(); |
133 | } |
134 |
|
135 | $notoptions[ $option ] = true; |
136 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
137 |
|
138 | /** This filter is documented in wp-includes/option.php */ |
139 | return apply_filters( "default_option_{$option}", $default, $option, $passed_default ); |
140 | } |
141 | } |
142 | } |
143 | } else { |
144 | $suppress = $wpdb->suppress_errors(); |
145 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); |
146 | $wpdb->suppress_errors( $suppress ); |
147 |
|
148 | if ( is_object( $row ) ) { |
149 | $value = $row->option_value; |
150 | } else { |
151 | /** This filter is documented in wp-includes/option.php */ |
152 | return apply_filters( "default_option_{$option}", $default, $option, $passed_default ); |
153 | } |
154 | } |
155 |
|
156 | // If home is not set, use siteurl. |
157 | if ( 'home' === $option && '' === $value ) { |
158 | return get_option( 'siteurl' ); |
159 | } |
160 |
|
161 | if ( in_array( $option, array( 'siteurl', 'home', 'category_base', 'tag_base' ), true ) ) { |
Line | Code |
401 | * unnecessary database calls for otherwise identical object instances. |
402 | * |
403 | * See https://core.trac.wordpress.org/ticket/38903 |
404 | */ |
405 | if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) { |
406 | return false; |
407 | } |
408 |
|
409 | /** This filter is documented in wp-includes/option.php */ |
410 | if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) { |
411 | // Default setting for new options is 'yes'. |
412 | if ( null === $autoload ) { |
413 | $autoload = 'yes'; |
414 | } |
415 |
|
416 | return add_option( $option, $value, '', $autoload ); |
417 | } |
418 |
|
419 | $serialized_value = maybe_serialize( $value ); |
Line | Code |
554 |
|
555 | $value = sanitize_option( $option, $value ); |
556 |
|
557 | // Make sure the option doesn't already exist. |
558 | // We can check the 'notoptions' cache before we ask for a DB query. |
559 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
560 |
|
561 | if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) { |
562 | /** This filter is documented in wp-includes/option.php */ |
563 | if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) ) { |
564 | return false; |
565 | } |
566 | } |
567 |
|
568 | $serialized_value = maybe_serialize( $value ); |
569 | $autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes'; |
570 |
|
571 | /** |
572 | * Fires before an option is added. |