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 |
---|---|
185 | * @since 3.4.0 |
186 | * @since 4.4.0 The `$option` parameter was added. |
187 | * @since 4.7.0 The `$passed_default` parameter was added to distinguish between a `false` value and the default parameter value. |
188 | * |
189 | * @param mixed $default_value The default value to return if the option does not exist |
190 | * in the database. |
191 | * @param string $option Option name. |
192 | * @param bool $passed_default Was `get_option()` passed a default value? |
193 | */ |
194 | return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); |
195 | } |
196 |
|
197 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); |
198 |
|
199 | // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values. |
200 | if ( is_object( $row ) ) { |
201 | $value = $row->option_value; |
202 | wp_cache_add( $option, $value, 'options' ); |
203 | } else { // Option does not exist, so we must cache its non-existence. |
204 | $notoptions[ $option ] = true; |
205 | wp_cache_set( 'notoptions', $notoptions, 'options' ); |
206 |
|
207 | /** This filter is documented in wp-includes/option.php */ |
208 | return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); |
209 | } |
210 | } |
211 | } |
212 | } else { |
213 | $suppress = $wpdb->suppress_errors(); |
214 | $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); |
215 | $wpdb->suppress_errors( $suppress ); |
216 |
|
217 | if ( is_object( $row ) ) { |
218 | $value = $row->option_value; |
219 | } else { |
220 | /** This filter is documented in wp-includes/option.php */ |
221 | return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); |
222 | } |
223 | } |
224 |
|
225 | // If home is not set, use siteurl. |
226 | if ( 'home' === $option && '' === $value ) { |
227 | return get_option( 'siteurl' ); |
228 | } |
229 |
|
230 | if ( in_array( $option, array( 'siteurl', 'home', 'category_base', 'tag_base' ), true ) ) { |
Line | Code |
899 | * unnecessary database calls for otherwise identical object instances. |
900 | * |
901 | * See https://core.trac.wordpress.org/ticket/38903 |
902 | */ |
903 | if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) { |
904 | return false; |
905 | } |
906 |
|
907 | /** This filter is documented in wp-includes/option.php */ |
908 | if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) { |
909 | return add_option( $option, $value, '', $autoload ); |
910 | } |
911 |
|
912 | $serialized_value = maybe_serialize( $value ); |
913 |
|
914 | /** |
915 | * Fires immediately before an option value is updated. |
916 | * |
917 | * @since 2.9.0 |
Line | Code |
1092 |
|
1093 | /* |
1094 | * Make sure the option doesn't already exist. |
1095 | * We can check the 'notoptions' cache before we ask for a DB query. |
1096 | */ |
1097 | $notoptions = wp_cache_get( 'notoptions', 'options' ); |
1098 |
|
1099 | if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) { |
1100 | /** This filter is documented in wp-includes/option.php */ |
1101 | if ( apply_filters( "default_option_{$option}", false, $option, false ) !== get_option( $option ) ) { |
1102 | return false; |
1103 | } |
1104 | } |
1105 |
|
1106 | $serialized_value = maybe_serialize( $value ); |
1107 |
|
1108 | $autoload = wp_determine_option_autoload_value( $option, $value, $serialized_value, $autoload ); |
1109 |
|
1110 | /** |