Make WordPress Core


Ignore:
Timestamp:
07/05/2020 03:05:02 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Options, Meta APIs: Introduce register_setting and unregister_setting actions.

Props Howdy_McGee, Pionect.
Fixes #37245.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/option.php

    r48320 r48321  
    22132213
    22142214    $new_whitelist_options[ $option_group ][] = $option_name;
     2215
    22152216    if ( ! empty( $args['sanitize_callback'] ) ) {
    22162217        add_filter( "sanitize_option_{$option_name}", $args['sanitize_callback'] );
     
    22202221    }
    22212222
     2223    /**
     2224     * Fires immediately before the setting is registered but after its filters are in place.
     2225     *
     2226     * @since 5.5.0
     2227     *
     2228     * @param string $option_group Setting group.
     2229     * @param string $option_name  Setting name.
     2230     * @param array  $args         Array of setting registration arguments.
     2231     */
     2232    do_action( 'register_setting', $option_group, $option_name, $args );
     2233
    22222234    $wp_registered_settings[ $option_name ] = $args;
    22232235}
     
    22322244 * @global array $wp_registered_settings
    22332245 *
    2234  * @param string   $option_group      The settings group name used during registration.
    2235  * @param string   $option_name       The name of the option to unregister.
    2236  * @param callable $deprecated        Deprecated.
     2246 * @param string   $option_group The settings group name used during registration.
     2247 * @param string   $option_name  The name of the option to unregister.
     2248 * @param callable $deprecated   Deprecated.
    22372249 */
    22382250function unregister_setting( $option_group, $option_name, $deprecated = '' ) {
     
    22662278
    22672279    $pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ], true );
     2280
    22682281    if ( false !== $pos ) {
    22692282        unset( $new_whitelist_options[ $option_group ][ $pos ] );
    22702283    }
     2284
    22712285    if ( '' !== $deprecated ) {
    22722286        _deprecated_argument(
     
    22942308        }
    22952309
     2310        /**
     2311         * Fires immediately before the setting is unregistered and after its filters have been removed.
     2312         *
     2313         * @since 5.5.0
     2314         *
     2315         * @param string $option_group Setting group.
     2316         * @param string $option_name  Setting name.
     2317         */
     2318        do_action( 'unregister_setting', $option_group, $option_name );
     2319
    22962320        unset( $wp_registered_settings[ $option_name ] );
    22972321    }
Note: See TracChangeset for help on using the changeset viewer.