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 |
---|---|
59 | * Filter the default value for an option. |
60 | * |
61 | * The dynamic portion of the hook name, `$option`, refers to the option name. |
62 | * |
63 | * @since 3.4.0 |
64 | * |
65 | * @param mixed $default The default value to return if the option does not exist |
66 | * in the database. |
67 | */ |
68 | return apply_filters( 'default_option_' . $option, $default ); |
69 | } |
70 |
|
71 | $alloptions = wp_load_alloptions(); |
72 |
|
73 | if ( isset( $alloptions[$option] ) ) { |
74 | $value = $alloptions[$option]; |
75 | } else { |
76 | $value = wp_cache_get( $option, 'options' ); |
77 |
|
Line | Code |
84 | wp_cache_add( $option, $value, 'options' ); |
85 | } else { // option does not exist, so we must cache its non-existence |
86 | if ( ! is_array( $notoptions ) ) { |
87 | $notoptions = array(); |
88 | } |
89 | $notoptions[$option] = true; |
90 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
91 |
|
92 | /** This filter is documented in wp-includes/option.php */ |
93 | return apply_filters( 'default_option_' . $option, $default ); |
94 | } |
95 | } |
96 | } |
97 | } else { |
98 | $suppress = $wpdb->suppress_errors(); |
99 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); |
100 | $wpdb->suppress_errors( $suppress ); |
101 | if ( is_object( $row ) ) { |
102 | $value = $row->option_value; |
103 | } else { |
104 | /** This filter is documented in wp-includes/option.php */ |
105 | return apply_filters( 'default_option_' . $option, $default ); |
106 | } |
107 | } |
108 |
|
109 | // If home is not set use siteurl. |
110 | if ( 'home' == $option && '' == $value ) |
111 | return get_option( 'siteurl' ); |
112 |
|
113 | if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) ) |
114 | $value = untrailingslashit( $value ); |
Line | Code |
278 | * @param mixed $old_value The old option value. |
279 | */ |
280 | $value = apply_filters( 'pre_update_option', $value, $option, $old_value ); |
281 |
|
282 | // If the new and old values are the same, no need to update. |
283 | if ( $value === $old_value ) |
284 | return false; |
285 |
|
286 | /** This filter is documented in wp-includes/option.php */ |
287 | if ( apply_filters( 'default_option_' . $option, false ) === $old_value ) { |
288 | // Default setting for new options is 'yes'. |
289 | if ( null === $autoload ) { |
290 | $autoload = 'yes'; |
291 | } |
292 |
|
293 | return add_option( $option, $value, '', $autoload ); |
294 | } |
295 |
|
296 | $serialized_value = maybe_serialize( $value ); |
Line | Code |
397 | if ( is_object($value) ) |
398 | $value = clone $value; |
399 |
|
400 | $value = sanitize_option( $option, $value ); |
401 |
|
402 | // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query |
403 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
404 | if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) ) |
405 | /** This filter is documented in wp-includes/option.php */ |
406 | if ( apply_filters( 'default_option_' . $option, false ) !== get_option( $option ) ) |
407 | return false; |
408 |
|
409 | $serialized_value = maybe_serialize( $value ); |
410 | $autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes'; |
411 |
|
412 | /** |
413 | * Fires before an option is added. |
414 | * |
415 | * @since 2.9.0 |