Template_Tag_Handler::add_tag( string $slug, array $data )

Adds a new template tag.

Description

Template tag data must contain a ‘label’ and ‘callback’, and may optionally contain a ‘description’ and ‘group’.

See also

Parameters

$slug

(string) (Required) Template tag slug.

$data

(array) (Required) Template tag data.

Return

(bool) True on success, false on failure.

Source

File: src/components/template-tag-handler.php

	public function add_tag( $slug, $data ) {
		if ( $this->has_tag( $slug ) ) {
			return false;
		}

		try {
			$data = $this->validate_tag_data( $data );
		} catch ( InvalidArgumentException $e ) {
			return false;
		}

		$this->tags[ $slug ] = $data;

		return true;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.