comment-created.php
6 months ago
comment-deleted.php
1 year ago
comment-updated.php
1 year ago
course-created.php
1 year ago
course-deleted.php
1 year ago
course-published.php
1 year ago
course-updated.php
1 year ago
feed-created.php
1 year ago
feed-updated.php
1 year ago
new-space-feed-created.php
1 year ago
space-created.php
1 year ago
user-completes-course.php
1 year ago
user-enrolls-course.php
1 year ago
user-joins-space.php
1 year ago
user-leaves-space.php
1 year ago
user-request-join-space.php
1 year ago
user-unenrolls-from-course.php
1 year ago
feed-created.php
109 lines
| 1 | <?php |
| 2 | /** |
| 3 | * FeedCreated. |
| 4 | * php version 7.0+ |
| 5 | * |
| 6 | * @category FeedCreated |
| 7 | * @package SureTriggers |
| 8 | * @author BSF |
| 9 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 |
| 10 | * @link https://www.brainstormforce.com/ |
| 11 | * @since 1.0.0 |
| 12 | */ |
| 13 | |
| 14 | namespace SureTriggers\Integrations\FluentCommunity\Triggers; |
| 15 | |
| 16 | use SureTriggers\Controllers\AutomationController; |
| 17 | use SureTriggers\Traits\SingletonLoader; |
| 18 | |
| 19 | if ( ! class_exists( 'FeedCreated' ) ) : |
| 20 | |
| 21 | /** |
| 22 | * FeedCreated Class |
| 23 | * |
| 24 | * Handles the trigger when a new feed is created in FluentCommunity. |
| 25 | * |
| 26 | * @since 1.0.0 |
| 27 | */ |
| 28 | class FeedCreated { |
| 29 | |
| 30 | use SingletonLoader; |
| 31 | |
| 32 | /** |
| 33 | * Integration type. |
| 34 | * |
| 35 | * @var string |
| 36 | */ |
| 37 | public $integration = 'FluentCommunity'; |
| 38 | |
| 39 | /** |
| 40 | * Trigger name. |
| 41 | * |
| 42 | * @var string |
| 43 | */ |
| 44 | public $trigger = 'fcs_feed_created'; |
| 45 | |
| 46 | /** |
| 47 | * Constructor |
| 48 | * |
| 49 | * Initializes the FeedCreated class. |
| 50 | * |
| 51 | * @since 1.0.0 |
| 52 | */ |
| 53 | public function __construct() { |
| 54 | add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Register the trigger. |
| 59 | * |
| 60 | * @param array $triggers Existing triggers. |
| 61 | * @return array Modified triggers with the new trigger added. |
| 62 | */ |
| 63 | public function register( $triggers ) { |
| 64 | $triggers[ $this->integration ][ $this->trigger ] = [ |
| 65 | 'label' => __( 'New Feed Created', 'suretriggers' ), |
| 66 | 'action' => $this->trigger, |
| 67 | 'common_action' => 'fluent_community/feed/created', |
| 68 | 'function' => [ $this, 'trigger_listener' ], |
| 69 | 'priority' => 10, |
| 70 | 'accepted_args' => 1, |
| 71 | ]; |
| 72 | |
| 73 | return $triggers; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Trigger listener |
| 78 | * |
| 79 | * Listens for the `fluent_community/feed/created` action and triggers automation. |
| 80 | * |
| 81 | * @param object $feed Feed object containing details of the created feed. |
| 82 | * @return void |
| 83 | */ |
| 84 | public function trigger_listener( $feed ) { |
| 85 | if ( empty( $feed ) ) { |
| 86 | return; |
| 87 | } |
| 88 | |
| 89 | // Prepare the context data for automation handling. |
| 90 | $context = [ |
| 91 | 'feed' => $feed, |
| 92 | ]; |
| 93 | |
| 94 | AutomationController::sure_trigger_handle_trigger( |
| 95 | [ |
| 96 | 'trigger' => $this->trigger, |
| 97 | 'context' => $context, |
| 98 | ] |
| 99 | ); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Initialize the singleton instance of FeedCreated. |
| 105 | */ |
| 106 | FeedCreated::get_instance(); |
| 107 | |
| 108 | endif; |
| 109 |