WP_Theme_JSON::maybe_opt_in_into_settings() WordPress Method

The WP_Theme_JSON::maybe_opt_in_into_settings() method allows a theme to opt-in to having its settings data included in the WordPress Theme Customizer. This is useful for themes that want to make use of the WordPress Theme Customizer but don't necessarily want to provide their own settings page. By opting-in, the theme's settings data will be included in the WordPress Theme Customizer along with the other theme settings.

WP_Theme_JSON::maybe_opt_in_into_settings( array $theme_json ) #

Enables some opt-in settings if theme declared support.


Parameters

$theme_json

(array)(Required)A theme.json structure to modify.


Top ↑

Return

(array) The modified theme.json structure.


Top ↑

Source

File: wp-includes/class-wp-theme-json.php

	protected static function maybe_opt_in_into_settings( $theme_json ) {
		$new_theme_json = $theme_json;

		if (
			isset( $new_theme_json['settings']['appearanceTools'] ) &&
			true === $new_theme_json['settings']['appearanceTools']
		) {
			static::do_opt_in_into_settings( $new_theme_json['settings'] );
		}

		if ( isset( $new_theme_json['settings']['blocks'] ) && is_array( $new_theme_json['settings']['blocks'] ) ) {
			foreach ( $new_theme_json['settings']['blocks'] as &$block ) {
				if ( isset( $block['appearanceTools'] ) && ( true === $block['appearanceTools'] ) ) {
					static::do_opt_in_into_settings( $block );
				}
			}
		}

		return $new_theme_json;
	}

Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.