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 |
---|---|
78 | * @since 3.4.0 |
79 | * @since 4.4.0 The `$option` parameter was added. |
80 | * @since 4.7.0 The `$passed_default` parameter was added to distinguish between a `false` value and the default parameter value. |
81 | * |
82 | * @param mixed $default The default value to return if the option does not exist |
83 | * in the database. |
84 | * @param string $option Option name. |
85 | * @param bool $passed_default Was `get_option()` passed a default value? |
86 | */ |
87 | return apply_filters( "default_option_{$option}", $default, $option, $passed_default ); |
88 | } |
89 |
|
90 | $alloptions = wp_load_alloptions(); |
91 |
|
92 | if ( isset( $alloptions[$option] ) ) { |
93 | $value = $alloptions[$option]; |
94 | } else { |
95 | $value = wp_cache_get( $option, 'options' ); |
96 |
|
Line | Code |
103 | wp_cache_add( $option, $value, 'options' ); |
104 | } else { // option does not exist, so we must cache its non-existence |
105 | if ( ! is_array( $notoptions ) ) { |
106 | $notoptions = array(); |
107 | } |
108 | $notoptions[$option] = true; |
109 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
110 |
|
111 | /** This filter is documented in wp-includes/option.php */ |
112 | return apply_filters( "default_option_{$option}", $default, $option, $passed_default ); |
113 | } |
114 | } |
115 | } |
116 | } else { |
117 | $suppress = $wpdb->suppress_errors(); |
118 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); |
119 | $wpdb->suppress_errors( $suppress ); |
120 | if ( is_object( $row ) ) { |
121 | $value = $row->option_value; |
122 | } else { |
123 | /** This filter is documented in wp-includes/option.php */ |
124 | return apply_filters( "default_option_{$option}", $default, $option, $passed_default ); |
125 | } |
126 | } |
127 |
|
128 | // If home is not set use siteurl. |
129 | if ( 'home' == $option && '' == $value ) |
130 | return get_option( 'siteurl' ); |
131 |
|
132 | if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) ) |
133 | $value = untrailingslashit( $value ); |
Line | Code |
330 | * unnecessary database calls for otherwise identical object instances. |
331 | * |
332 | * See https://core.trac.wordpress.org/ticket/38903 |
333 | */ |
334 | if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) { |
335 | return false; |
336 | } |
337 |
|
338 | /** This filter is documented in wp-includes/option.php */ |
339 | if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) { |
340 | // Default setting for new options is 'yes'. |
341 | if ( null === $autoload ) { |
342 | $autoload = 'yes'; |
343 | } |
344 |
|
345 | return add_option( $option, $value, '', $autoload ); |
346 | } |
347 |
|
348 | $serialized_value = maybe_serialize( $value ); |
Line | Code |
451 | if ( is_object($value) ) |
452 | $value = clone $value; |
453 |
|
454 | $value = sanitize_option( $option, $value ); |
455 |
|
456 | // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query |
457 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
458 | if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) ) |
459 | /** This filter is documented in wp-includes/option.php */ |
460 | if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) ) |
461 | return false; |
462 |
|
463 | $serialized_value = maybe_serialize( $value ); |
464 | $autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes'; |
465 |
|
466 | /** |
467 | * Fires before an option is added. |
468 | * |
469 | * @since 2.9.0 |