Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: rest_pre_get_setting

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
90                 *
91                 * @since 4.7.0
92                 *
93                 * @param mixed  $result Value to use for the requested setting. Can be a scalar
94                 *                       matching the registered schema for the setting, or null to
95                 *                       follow the default get_option() behavior.
96                 * @param string $name   Setting name (as shown in REST API responses).
97                 * @param array  $args   Arguments passed to register_setting() for this setting.
98                 */
99                $response[ $name ] = apply_filters( 'rest_pre_get_setting', null, $name, $args );
100
101                if ( is_null( $response[ $name ] ) ) {
102                     // Default to a null value as "null" in the response means "not set".
103                     $response[ $name ] = get_option( $args['option_name'], $args['schema']['default'] );
104                }
105
106                /*
107                 * Because get_option() is lossy, we have to
108                 * cast values to the type they are registered with.