Utils::get_attributes_string( TribeShortcodearray $settings, TribeShortcodearray $allowed = array() )

Convert settings to a set of shortcode attributes.


Parameters

$settings

(<span class="TribeShortcodearray">TribeShortcodearray) (Required) Widget settings.

$allowed

(<span class="TribeShortcodearray">TribeShortcodearray) (Optional) Allowed settings for shortcode.

Default value: array()


Top ↑

Return

(string) Shortcode attributes string.


Top ↑

Source

File: src/Tribe/Shortcode/Utils.php

	public static function get_attributes_string( $settings, $allowed = [] ) {
		$settings_string = '';

		$allowed = array_flip( $allowed );

		foreach ( $settings as $key => $value ) {
			if ( ! empty( $allowed ) && ! isset( $allowed[ $key ] ) ) {
				continue;
			}

			$key = esc_attr( $key );

			if ( is_array( $value ) ) {
				$value = implode( ', ', $value );
			}

			$value = esc_attr( $value );

			$settings_string .= " {$key}=\"{$value}\"";
		}

		return $settings_string;
	}

Top ↑

Changelog

Changelog
Version Description
4.13.0 Introduced.