Automator_Get_Data::get_integration_publish_actions( mixed $integration = '' )

Return all integration published actions.


Parameters Parameters

$integration

(Optional) The integration.

Default value: ''


Top ↑

Return Return

(array) The recipe data.


Source Source

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

	public function get_integration_publish_actions( $integration = '' ) {
		// Get all published recipes.
		$published_recipes = array_filter(
			Automator()->get_recipes_data(),
			function( $recipe ) {
				return 'publish' === $recipe['post_status'];
			}
		);
		// Map all published integration actions.
		$published_actions = array_map(
			function( $published_recipe ) use ( $integration ) {
				// Filter the actions by integration and publish staus.
				$published_actions = array_filter(
					$published_recipe['actions'],
					function( $action ) use ( $integration ) {
						return 'publish' === $action['post_status'] && $integration === $action['meta']['integration'];
					}
				);
				// Return the specific integration actions that are published.
				return $published_actions;
			},
			$published_recipes
		);
		// Automatically remove empty elements.
		return array_filter( $published_actions );
	}