| @@ -1,0 +1,57 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Triggers | |
| 4 | + * | |
| 5 | + * @package AutomatorWP\Triggers | |
| 6 | + * @author AutomatorWP <[email protected]>, Ruben Garcia <[email protected]> | |
| 7 | + * @since 1.0.0 | |
| 8 | + */ | |
| 9 | +// Exit if accessed directly | |
| 10 | +if( !defined( 'ABSPATH' ) ) exit; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Registers a new integration | |
| 14 | + * | |
| 15 | + * @since 1.0.0 | |
| 16 | + * | |
| 17 | + * @param string $integration | |
| 18 | + * @param array $args | |
| 19 | + */ | |
| 20 | +function automatorwp_register_integration( $integration, $args ) { | |
| 21 | + | |
| 22 | + $args = wp_parse_args( $args, array( | |
| 23 | + 'label' => '', | |
| 24 | + 'icon' => AUTOMATORWP_URL . 'assets/img/integration-default.svg', | |
| 25 | + ) ); | |
| 26 | + | |
| 27 | + AutomatorWP()->integrations[$integration] = $args; | |
| 28 | + | |
| 29 | +} | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * Get registered integrations | |
| 33 | + * | |
| 34 | + * @since 1.0.0 | |
| 35 | + * | |
| 36 | + * @return array | |
| 37 | + */ | |
| 38 | +function automatorwp_get_integrations() { | |
| 39 | + | |
| 40 | + return AutomatorWP()->integrations; | |
| 41 | + | |
| 42 | +} | |
| 43 | + | |
| 44 | +/** | |
| 45 | + * Get an integration | |
| 46 | + * | |
| 47 | + * @since 1.0.0 | |
| 48 | + * | |
| 49 | + * @param string $integration | |
| 50 | + * | |
| 51 | + * @return array|false | |
| 52 | + */ | |
| 53 | +function automatorwp_get_integration( $integration ) { | |
| 54 | + | |
| 55 | + return ( isset( AutomatorWP()->integrations[$integration] ) ? AutomatorWP()->integrations[$integration] : false ); | |
| 56 | + | |
| 57 | +} | |