WP_Customize_Nav_Menus::filter_dynamic_setting_args( false|array $setting_args, string $setting_id ): array|false

In this article

Filters a dynamic setting’s constructor args.

Description

For a dynamic setting to be registered, this filter must be employed to override the default false value with an array of args to pass to the WP_Customize_Setting constructor.

Parameters

$setting_argsfalse|arrayrequired
The arguments to the WP_Customize_Setting constructor.
$setting_idstringrequired
ID for dynamic setting, usually coming from $_POST['customized'].

Return

array|false

Source

public function filter_dynamic_setting_args( $setting_args, $setting_id ) {
	if ( preg_match( WP_Customize_Nav_Menu_Setting::ID_PATTERN, $setting_id ) ) {
		$setting_args = array(
			'type'      => WP_Customize_Nav_Menu_Setting::TYPE,
			'transport' => 'postMessage',
		);
	} elseif ( preg_match( WP_Customize_Nav_Menu_Item_Setting::ID_PATTERN, $setting_id ) ) {
		$setting_args = array(
			'type'      => WP_Customize_Nav_Menu_Item_Setting::TYPE,
			'transport' => 'postMessage',
		);
	}
	return $setting_args;
}

Changelog

VersionDescription
4.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.