| @@ -1,0 +1,87 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Automation Type | |
| 4 | + * | |
| 5 | + * @package AutomatorWP\Classes\Automation_Type | |
| 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 | +class AutomatorWP_Automation_Type { | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * Integration | |
| 16 | + * | |
| 17 | + * @since 1.0.0 | |
| 18 | + * | |
| 19 | + * @var string $integration | |
| 20 | + */ | |
| 21 | + public $integration = ''; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * Type | |
| 25 | + * | |
| 26 | + * @since 1.0.0 | |
| 27 | + * | |
| 28 | + * @var string $type | |
| 29 | + */ | |
| 30 | + public $type = ''; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * Type | |
| 34 | + * | |
| 35 | + * @since 1.0.0 | |
| 36 | + * | |
| 37 | + * @var array $args | |
| 38 | + */ | |
| 39 | + public $args = array( | |
| 40 | + 'image' => AUTOMATORWP_URL . 'assets/img/automatorwp-logo.svg', | |
| 41 | + 'label' => '', | |
| 42 | + 'desc' => '', | |
| 43 | + ); | |
| 44 | + | |
| 45 | + public function __construct() { | |
| 46 | + | |
| 47 | + $this->hooks(); | |
| 48 | + | |
| 49 | + } | |
| 50 | + | |
| 51 | + public function hooks() { | |
| 52 | + | |
| 53 | + if ( ! did_action( 'automatorwp_init' ) ) { | |
| 54 | + // Default hook to register | |
| 55 | + add_action('automatorwp_init', array( $this, 'register' ) ); | |
| 56 | + } else { | |
| 57 | + // Hook for triggers registered from the theme's functions | |
| 58 | + add_action( 'after_setup_theme', array( $this, 'register' ) ); | |
| 59 | + } | |
| 60 | + | |
| 61 | + // Register type | |
| 62 | + add_filter('automatorwp_automation_types', array( $this, 'register_type' ) ); | |
| 63 | + | |
| 64 | + } | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * Register the automation type | |
| 68 | + * | |
| 69 | + * @since 1.0.0 | |
| 70 | + */ | |
| 71 | + public function register() { | |
| 72 | + // Override | |
| 73 | + } | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * Register the action | |
| 77 | + * | |
| 78 | + * @since 1.0.0 | |
| 79 | + */ | |
| 80 | + public function register_type( $types ) { | |
| 81 | + | |
| 82 | + $types[$this->type] = $this->args; | |
| 83 | + | |
| 84 | + return $types; | |
| 85 | + } | |
| 86 | + | |
| 87 | +} | |