Automator_Get_Data::item_code_from_item_id( null $item_id = null )

Accepts a trigger, action, or closure id and return the corresponding trigger_code, action_code, or closure_code


Parameters Parameters

$item_id

(null) (Optional)

Default value: null


Top ↑

Return Return

(null|string)


Source Source

File: src/core/lib/utilities/class-automator-get-data.php

	public function item_code_from_item_id( $item_id = null ) {

		$item_code = null;

		$recipes_data = Automator()->get_recipes_data( true );
		if ( empty( $recipes_data ) ) {
			return null;
		}

		$item_codes = array();

		foreach ( $recipes_data as $recipe_data ) {

			foreach ( $recipe_data['triggers'] as $trigger ) {
				$item_codes[ $trigger['ID'] ] = $trigger['meta']['code'];
			}

			foreach ( $recipe_data['actions'] as $action ) {
				$item_codes[ $action['ID'] ] = $action['meta']['code'];
			}

			foreach ( $recipe_data['closures'] as $closure ) {
				$item_codes[ $closure['ID'] ] = $closure['meta']['code'];
			}
		}

		if ( isset( $item_codes[ $item_id ] ) ) {
			$item_code = $item_codes[ $item_id ];
		}

		return $item_code;
	}