unregister_setting( string $option_group, string $option_name, callable $deprecated = '' )
Unregister a setting.
Description Description
Parameters Parameters
- $option_group
-
(string) (Required) The settings group name used during registration.
- $option_name
-
(string) (Required) The name of the option to unregister.
- $deprecated
-
(callable) (Optional) Deprecated.
Default value: ''
Source Source
File: wp-includes/option.php
2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 | function unregister_setting( $option_group , $option_name , $deprecated = '' ) { global $new_whitelist_options , $wp_registered_settings ; if ( 'misc' == $option_group ) { _deprecated_argument( __FUNCTION__ , '3.0.0' , /* translators: %s: misc */ sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) ); $option_group = 'general' ; } if ( 'privacy' == $option_group ) { _deprecated_argument( __FUNCTION__ , '3.5.0' , /* translators: %s: privacy */ sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) ); $option_group = 'reading' ; } $pos = array_search ( $option_name , ( array ) $new_whitelist_options [ $option_group ] ); if ( $pos !== false ) { unset( $new_whitelist_options [ $option_group ][ $pos ] ); } if ( '' !== $deprecated ) { _deprecated_argument( __FUNCTION__ , '4.7.0' , /* translators: 1: $sanitize_callback, 2: register_setting() */ sprintf( __( '%1$s is deprecated. The callback from %2$s is used instead.' ), '<code>$sanitize_callback</code>' , '<code>register_setting()</code>' ) ); remove_filter( "sanitize_option_{$option_name}" , $deprecated ); } if ( isset( $wp_registered_settings [ $option_name ] ) ) { // Remove the sanitize callback if one was set during registration. if ( ! empty ( $wp_registered_settings [ $option_name ][ 'sanitize_callback' ] ) ) { remove_filter( "sanitize_option_{$option_name}" , $wp_registered_settings [ $option_name ][ 'sanitize_callback' ] ); } // Remove the default filter if a default was provided during registration. if ( array_key_exists ( 'default' , $wp_registered_settings [ $option_name ] ) ) { remove_filter( "default_option_{$option_name}" , 'filter_default_option' , 10 ); } unset( $wp_registered_settings [ $option_name ] ); } } |
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
4.7.0 | $sanitize_callback was deprecated. The callback from register_setting() is now used instead. |
2.7.0 | Introduced. |