packages/kirki-framework/core/src/Values.php
public static function get_value( $config_id = '', $field_id = '' ) {

		// Make sure value is defined.
		$value = '';

		// This allows us to skip the $config_id argument.
		// If we skip adding a $config_id, use the 'global' configuration.
		if ( ( '' === $field_id ) && '' !== $config_id ) {
			$field_id  = $config_id;
			$config_id = 'global';
		}

		// If $config_id is empty, set it to 'global'.
		$config_id = ( '' === $config_id ) ? 'global' : $config_id;

		// Fallback to 'global' if $config_id is not found.
		if ( ! isset( Kirki::$config[ $config_id ] ) ) {
			$config_id = 'global';
		}

		if ( 'theme_mod' === Kirki::$config[ $config_id ]['option_type'] ) {

			// We're using theme_mods so just get the value using get_theme_mod.
			$default_value = null;
			if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) {
				$default_value = Kirki::$fields[ $field_id ]['default'];
			}
			$value = get_theme_mod( $field_id, $default_value );
			return apply_filters( 'kirki_values_get_value', $value, $field_id );
		}

		if ( 'option' === Kirki::$config[ $config_id ]['option_type'] ) {

			// We're using options.
			if ( '' !== Kirki::$config[ $config_id ]['option_name'] ) {

				// Options are serialized as a single option in the db.
				// We'll have to get the option and then get the item from the array.
				$options = get_option( Kirki::$config[ $config_id ]['option_name'] );

				if ( ! isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']' ] ) ) {
					$field_id = Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']';
				}
				$setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) );

				$default_value = ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) ? Kirki::$fields[ $field_id ]['default'] : '';
				$value         = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value;
				$value         = maybe_unserialize( $value );
				return apply_filters( 'kirki_values_get_value', $value, $field_id );
			}

			// Each option separately saved in the db.
			$value = get_option( $field_id, Kirki::$fields[ $field_id ]['default'] );
			return apply_filters( 'kirki_values_get_value', $value, $field_id );

		}
		return apply_filters( 'kirki_values_get_value', $value, $field_id );
	}
public static function get_value( $config_id = '', $field_id = '' ) {

		// Make sure value is defined.
		$value = '';

		// This allows us to skip the $config_id argument.
		// If we skip adding a $config_id, use the 'global' configuration.
		if ( ( '' === $field_id ) && '' !== $config_id ) {
			$field_id  = $config_id;
			$config_id = 'global';
		}

		// If $config_id is empty, set it to 'global'.
		$config_id = ( '' === $config_id ) ? 'global' : $config_id;

		// Fallback to 'global' if $config_id is not found.
		if ( ! isset( Kirki::$config[ $config_id ] ) ) {
			$config_id = 'global';
		}

		if ( 'theme_mod' === Kirki::$config[ $config_id ]['option_type'] ) {

			// We're using theme_mods so just get the value using get_theme_mod.
			$default_value = null;
			if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) {
				$default_value = Kirki::$fields[ $field_id ]['default'];
			}
			$value = get_theme_mod( $field_id, $default_value );
			return apply_filters( 'kirki_values_get_value', $value, $field_id );
		}

		if ( 'option' === Kirki::$config[ $config_id ]['option_type'] ) {

			// We're using options.
			if ( '' !== Kirki::$config[ $config_id ]['option_name'] ) {

				// Options are serialized as a single option in the db.
				// We'll have to get the option and then get the item from the array.
				$options = get_option( Kirki::$config[ $config_id ]['option_name'] );

				if ( ! isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']' ] ) ) {
					$field_id = Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']';
				}
				$setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) );

				$default_value = ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) ? Kirki::$fields[ $field_id ]['default'] : '';
				$value         = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value;
				$value         = maybe_unserialize( $value );
				return apply_filters( 'kirki_values_get_value', $value, $field_id );
			}

			// Each option separately saved in the db.
			$value = get_option( $field_id, Kirki::$fields[ $field_id ]['default'] );
			return apply_filters( 'kirki_values_get_value', $value, $field_id );

		}
		return apply_filters( 'kirki_values_get_value', $value, $field_id );
	}
public static function get_value ( $ config_id = '' , $ field_id = '' ) { // Make sure value is defined. $ value = '' ; // This allows us to skip the $config_id argument. // If we skip adding a $config_id, use the 'global' configuration. if ( ( '' === $ field_id ) && '' !== $ config_id ) { $ field_id = $ config_id ; $ config_id = 'global' ; } // If $config_id is empty, set it to 'global'. $ config_id = ( '' === $ config_id ) ? 'global' : $ config_id ; // Fallback to 'global' if $config_id is not found. if ( ! isset ( Kirki :: $ config [ $ config_id ] ) ) { $ config_id = 'global' ; } if ( 'theme_mod' === Kirki :: $ config [ $ config_id ] [ 'option_type' ] ) { // We're using theme_mods so just get the value using get_theme_mod. $ default_value = null ; if ( isset ( Kirki :: $ fields [ $ field_id ] ) && isset ( Kirki :: $ fields [ $ field_id ] [ 'default' ] ) ) { $ default_value = Kirki :: $ fields [ $ field_id ] [ 'default' ] ; } $ value = get_theme_mod ( $ field_id , $ default_value ) ; return apply_filters ( 'kirki_values_get_value' , $ value , $ field_id ) ; } if ( 'option' === Kirki :: $ config [ $ config_id ] [ 'option_type' ] ) { // We're using options. if ( '' !== Kirki :: $ config [ $ config_id ] [ 'option_name' ] ) { // Options are serialized as a single option in the db. // We'll have to get the option and then get the item from the array. $ options = get_option ( Kirki :: $ config [ $ config_id ] [ 'option_name' ] ) ; if ( ! isset ( Kirki :: $ fields [ $ field_id ] ) && isset ( Kirki :: $ fields [ Kirki :: $ config [ $ config_id ] [ 'option_name' ] . '[' . $ field_id . ']' ] ) ) { $ field_id = Kirki :: $ config [ $ config_id ] [ 'option_name' ] . '[' . $ field_id . ']' ; } $ setting_modified = str_replace ( ']' , '' , str_replace ( Kirki :: $ config [ $ config_id ] [ 'option_name' ] . '[' , '' , $ field_id ) ) ; $ default_value = ( isset ( Kirki :: $ fields [ $ field_id ] ) && isset ( Kirki :: $ fields [ $ field_id ] [ 'default' ] ) ) ? Kirki :: $ fields [ $ field_id ] [ 'default' ] : '' ; $ value = ( isset ( $ options [ $ setting_modified ] ) ) ? $ options [ $ setting_modified ] : $ default_value ; $ value = maybe_unserialize ( $ value ) ; return apply_filters ( 'kirki_values_get_value' , $ value , $ field_id ) ; } // Each option separately saved in the db. $ value = get_option ( $ field_id , Kirki :: $ fields [ $ field_id ] [ 'default' ] ) ; return apply_filters ( 'kirki_values_get_value' , $ value , $ field_id ) ; } return apply_filters ( 'kirki_values_get_value' , $ value , $ field_id ) ; }
Get the value of a field.

@static
@access public
@param string $config_id The configuration ID. @see Kirki\Core\Config.
@param string $field_id  The field ID.
@return string|array
Get the value of a field .