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 |
|---|---|
| 66 | * The dynamic portion of the hook name, `$option`, refers to the option name. |
| 67 | * |
| 68 | * @since 3.4.0 |
| 69 | * @since 4.4.0 The `$option` parameter was added. |
| 70 | * |
| 71 | * @param mixed $default The default value to return if the option does not exist |
| 72 | * in the database. |
| 73 | * @param string $option Option name. |
| 74 | */ |
| 75 | return apply_filters( 'default_option_' . $option, $default, $option ); |
| 76 | } |
| 77 | |
| 78 | $alloptions = wp_load_alloptions(); |
| 79 | |
| 80 | if ( isset( $alloptions[$option] ) ) { |
| 81 | $value = $alloptions[$option]; |
| 82 | } else { |
| 83 | $value = wp_cache_get( $option, 'options' ); |
| 84 | |
| Line | Code |
| 91 | wp_cache_add( $option, $value, 'options' ); |
| 92 | } else { // option does not exist, so we must cache its non-existence |
| 93 | if ( ! is_array( $notoptions ) ) { |
| 94 | $notoptions = array(); |
| 95 | } |
| 96 | $notoptions[$option] = true; |
| 97 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
| 98 | |
| 99 | /** This filter is documented in wp-includes/option.php */ |
| 100 | return apply_filters( 'default_option_' . $option, $default, $option ); |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | } else { |
| 105 | $suppress = $wpdb->suppress_errors(); |
| 106 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); |
| 107 | $wpdb->suppress_errors( $suppress ); |
| 108 | if ( is_object( $row ) ) { |
| 109 | $value = $row->option_value; |
| 110 | } else { |
| 111 | /** This filter is documented in wp-includes/option.php */ |
| 112 | return apply_filters( 'default_option_' . $option, $default, $option ); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // If home is not set use siteurl. |
| 117 | if ( 'home' == $option && '' == $value ) |
| 118 | return get_option( 'siteurl' ); |
| 119 | |
| 120 | if ( in_array( $option, array('siteurl', 'home', 'category_base', 'tag_base') ) ) |
| 121 | $value = untrailingslashit( $value ); |
| Line | Code |
| 289 | * @param mixed $old_value The old option value. |
| 290 | */ |
| 291 | $value = apply_filters( 'pre_update_option', $value, $option, $old_value ); |
| 292 | |
| 293 | // If the new and old values are the same, no need to update. |
| 294 | if ( $value === $old_value ) |
| 295 | return false; |
| 296 | |
| 297 | /** This filter is documented in wp-includes/option.php */ |
| 298 | if ( apply_filters( 'default_option_' . $option, false, $option ) === $old_value ) { |
| 299 | // Default setting for new options is 'yes'. |
| 300 | if ( null === $autoload ) { |
| 301 | $autoload = 'yes'; |
| 302 | } |
| 303 | |
| 304 | return add_option( $option, $value, '', $autoload ); |
| 305 | } |
| 306 | |
| 307 | $serialized_value = maybe_serialize( $value ); |
| Line | Code |
| 410 | if ( is_object($value) ) |
| 411 | $value = clone $value; |
| 412 | |
| 413 | $value = sanitize_option( $option, $value ); |
| 414 | |
| 415 | // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query |
| 416 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
| 417 | if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) ) |
| 418 | /** This filter is documented in wp-includes/option.php */ |
| 419 | if ( apply_filters( 'default_option_' . $option, false, $option ) !== get_option( $option ) ) |
| 420 | return false; |
| 421 | |
| 422 | $serialized_value = maybe_serialize( $value ); |
| 423 | $autoload = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes'; |
| 424 | |
| 425 | /** |
| 426 | * Fires before an option is added. |
| 427 | * |
| 428 | * @since 2.9.0 |