Tribe__Customizer__Section::should_include_setting_css( string $setting, int $section_id = null )

Function that encapsulates the logic for if a setting should be added to the Customizer style template.

Note: this depends on a default value being set – if the setting value is empty OR set to the default value, it’s not displayed.


Parameters

$setting

(string) (Required) The setting slug, like 'grid_lines_color'.

$section_id

(int) (Optional) The ID for the section - defaults to the current one if not set.

Default value: null


Top ↑

Return

(boolean) If the setting should be added to the style template.


Top ↑

Source

File: src/Tribe/Customizer/Section.php

	public function should_include_setting_css( $setting, $section_id = null ) {
		if ( empty( $setting ) || ! is_string( $setting ) ) {
			return false;
		}

		if ( empty( $section_id ) ) {
			$section_id = $this->ID;
		}

		$setting_value = tribe( 'customizer' )->get_option( [ $section_id, $setting ] );
		$section       = tribe( 'customizer' )->get_section( $section_id );

		// Something has gone wrong and we can't get the section.
		if ( false === $section ) {
			return;
		}

		return ! empty( $setting_value ) && $section->get_default( $setting ) !== $setting_value;
	}

Top ↑

Changelog

Changelog
Version Description
4.13.3 Introduced.