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 |
---|---|
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 ); |
Line | Code |
268 | * @param mixed $old_value The old option value. |
269 | */ |
270 | $value = apply_filters( 'pre_update_option', $value, $option, $old_value ); |
271 |
|
272 | // If the new and old values are the same, no need to update. |
273 | if ( $value === $old_value ) |
274 | return false; |
275 |
|
276 | /** This filter is documented in wp-includes/option.php */ |
277 | if ( apply_filters( 'default_option_' . $option, false ) === $old_value ) { |
278 | // Default setting for new options is 'yes'. |
279 | if ( null === $autoload ) { |
280 | $autoload = 'yes'; |
281 | } |
282 |
|
283 | return add_option( $option, $value, '', $autoload ); |
284 | } |
285 |
|
286 | $serialized_value = maybe_serialize( $value ); |
Line | Code |
385 | if ( is_object($value) ) |
386 | $value = clone $value; |
387 |
|
388 | $value = sanitize_option( $option, $value ); |
389 |
|
390 | // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query |
391 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
392 | if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) ) |
393 | /** This filter is documented in wp-includes/option.php */ |
394 | if ( apply_filters( 'default_option_' . $option, false ) !== get_option( $option ) ) |
395 | return false; |
396 |
|
397 | $serialized_value = maybe_serialize( $value ); |
398 | $autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes'; |
399 |
|
400 | /** |
401 | * Fires before an option is added. |
402 | * |
403 | * @since 2.9.0 |