Tribe_Events::get_id()

Based on the either a argument “id” of the shortcode definition or the 8 first characters of the hashed version of a string serialization of the params sent to the shortcode we will create/get an ID for this instance of the tribe_events shortcode


Return

(string) The shortcode unique(ish) identifier.


Top ↑

Source

File: src/Tribe/Views/V2/Shortcodes/Tribe_Events.php

	public function get_id() {
		$arguments = $this->get_arguments();

		// In case we have the ID argument we just return that.
		if ( ! empty( $arguments['id'] ) ) {
			return $arguments['id'];
		}

		ksort( $arguments );

		/*
		 * Generate a string id based on the arguments used to setup the shortcode.
		 * Note that arguments are sorted to catch substantially same shortcode w. diff. order argument.
		 */
		$hash = substr( md5( maybe_serialize( $arguments ) ), 0, 8 );

		return $hash;
	}

Top ↑

Changelog

Changelog
Version Description
4.7.9 Introduced.