Файловый менеджер - Редактировать - /home/ephorei/www/wp-includes/images/media/q2m9hb/voxel.tar
Назад
actions/change-membership-plan.php 0000644 00000007505 15006204201 0013220 0 ustar 00 <?php /** * ChangeMembershipPlan. * php version 5.6 * * @category ChangeMembershipPlan * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; /** * ChangeMembershipPlan * * @category ChangeMembershipPlan * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class ChangeMembershipPlan extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_change_membership_plan'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Change Membership Plan', 'suretriggers' ), 'action' => 'voxel_change_membership_plan', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $user_email = $selected_options['wp_user_email']; if ( is_email( $user_email ) ) { $user = get_user_by( 'email', $user_email ); $user_id = $user ? $user->ID : 1; } // Get the plan key. $plan_key = $selected_options['membership_plan_key']; if ( ! class_exists( 'Voxel\User' ) || ! class_exists( 'Voxel\Stripe' ) || ! class_exists( 'Voxel\Plan' ) ) { return false; } // If price id is provided. $price_id = isset( $selected_options['price_id'] ) ? $selected_options['price_id'] : ''; $price_type = 'payment'; if ( '' !== $price_id ) { $stripe = \Voxel\Stripe::getClient(); $price = $stripe->prices->retrieve( $price_id ); $price_type = 'recurring' === $price->type ? 'subscription' : 'payment'; } // Get the user. $voxel_user = \Voxel\User::get( $user_id ); if ( ! $voxel_user ) { throw new Exception( 'User not found' ); } // Get the plan. $plan = \Voxel\Plan::get( $plan_key ); if ( ! $plan ) { throw new Exception( 'Plan not found' ); } // Check if user has at least one role that supports chosen plan. if ( ! $plan->supports_user( $voxel_user ) ) { throw new Exception( "This plan is not supported for the specified user's role" ); } // Change the plan. $meta_key = \Voxel\Stripe::is_test_mode() ? 'voxel:test_plan' : 'voxel:plan'; update_user_meta( $voxel_user->get_id(), $meta_key, wp_slash( wp_json_encode( [ 'plan' => $plan_key, 'price_id' => $price_id, 'type' => $price_type, 'status' => 'active', 'metadata' => [ 'voxel:payment_for' => 'membership', 'voxel:plan' => $plan_key, 'voxel:limits' => wp_json_encode( [] ), 'voxel:original_price_id' => $price_id, ], ] ) ) ); do_action( 'voxel/membership/pricing-plan-updated', $voxel_user, $voxel_user->get_membership(), $voxel_user->get_membership( $refresh_cache = true ) ); // @phpcs:ignore return [ 'success' => true, 'message' => esc_attr__( 'Membership plan updated successfully', 'suretriggers' ), 'user_id' => $user_id, 'plan' => $plan_key, ]; } } ChangeMembershipPlan::get_instance(); actions/claim-post.php 0000644 00000006112 15006204201 0010753 0 ustar 00 <?php /** * ClaimPost. * php version 5.6 * * @category ClaimPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; use Exception; /** * ClaimPost * * @category ClaimPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class ClaimPost extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_claim_post'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Claim Post', 'suretriggers' ), 'action' => 'voxel_claim_post', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $user_email = $selected_options['wp_user_email']; $post_id = (int) $selected_options['post_id']; if ( ! class_exists( 'Voxel\Post' ) || ! class_exists( 'Voxel\User' ) || ! function_exists( 'Voxel\get' ) ) { return false; } // Check if claims are enabled. if ( ! \Voxel\get( 'product_settings.claims.enabled' ) ) { throw new Exception( 'Claims are not enabled.' ); } if ( is_email( $user_email ) ) { $user = get_user_by( 'email', $user_email ); if ( $user ) { $user_id = $user->ID; } } // Get the post. $post = \Voxel\Post::get( $post_id ); if ( ! $post ) { throw new Exception( 'Post not found.' ); } $current_user = \Voxel\User::get( $user_id ); if ( ! $current_user ) { throw new Exception( 'User not found.' ); } // Set the post author to claimer. wp_update_post( [ 'ID' => $post_id, 'post_author' => $user_id, ] ); // Get the post. $post = \Voxel\Post::force_get( $post_id ); // Set the post verified. $post->set_verified( true ); delete_user_meta( $user_id, 'voxel:post_stats' ); return [ 'success' => true, 'message' => esc_attr__( 'Post claimed successfully.', 'suretriggers' ), 'post_id' => $post_id, 'post_following_user' => WordPress::get_user_context( $user_id ), 'claimed' => WordPress::get_post_context( $post_id ), ]; } } ClaimPost::get_instance(); actions/send-direct-message.php 0000644 00000011724 15006204201 0012533 0 ustar 00 <?php /** * SendDirectMessage. * php version 5.6 * * @category SendDirectMessage * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use Exception; /** * SendDirectMessage * * @category SendDirectMessage * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class SendDirectMessage extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_send_direct_message'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Send Direct Message', 'suretriggers' ), 'action' => 'voxel_send_direct_message', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $content = $selected_options['content']; $sender_id = $selected_options['wp_user_email']; $receiver_id = $selected_options['receiver_email']; if ( ! class_exists( 'Voxel\Direct_Messages\Message' ) || ! class_exists( 'Voxel\User' ) || ! class_exists( 'Voxel\Events\Direct_Messages\User_Received_Message_Event' ) ) { return false; } if ( is_email( $sender_id ) || is_email( $receiver_id ) ) { $sender = get_user_by( 'email', $sender_id ); $receiver = get_user_by( 'email', $receiver_id ); if ( $sender ) { if ( $receiver ) { $sender_id = $sender->ID; $receiver_id = $receiver->ID; global $wpdb; // Get the sender user. $sender_user = \Voxel\User::get( $sender_id ); // Get the receiver user. $receiver_user = \Voxel\User::get( $receiver_id ); // check if users have blocked each other. if ( $sender_user->get_follow_status( 'user', $receiver_user->get_id() ) === -1 || $receiver_user->get_follow_status( 'user', $sender_user->get_id() ) === -1 ) { throw new Exception( 'You cannot message the user.' ); } $message = \Voxel\Direct_Messages\Message::create( [ 'sender_type' => 'user', 'sender_id' => $sender_id, 'sender_deleted' => 0, 'receiver_type' => 'user', 'receiver_id' => $receiver_id, 'receiver_deleted' => 0, 'content' => $content, 'seen' => 0, ] ); $receiver_user->set_inbox_activity( true ); $receiver_author = $receiver_user; if ( $receiver_author ) { $receiver_author->update_inbox_meta( [ 'unread' => true, ] ); } $message->update_chat(); $has_recently_received_message = ! ! $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}voxel_messages WHERE sender_type = %s AND sender_id = %d AND receiver_type = %s AND receiver_id = %d AND created_at > %s AND id != %d LIMIT 1", 'user', $sender_id, 'user', $receiver_id, gmdate( 'Y-m-d H:i:s', time() - ( 15 * MINUTE_IN_SECONDS ) ), $message->get_id() ) ); // Dispatch the message. if ( ! $has_recently_received_message ) { ( new \Voxel\Events\Direct_Messages\User_Received_Message_Event() )->dispatch( $message->get_id() ); } return [ 'sender' => WordPress::get_user_context( $message->get_sender_id() ), 'receiver' => WordPress::get_user_context( $message->get_receiver_id() ), 'message' => [ 'id' => $message->get_id(), 'time' => $message->get_time_for_display(), 'chat_time' => $message->get_time_for_chat_display(), 'seen' => $message->is_seen(), 'has_content' => ! empty( $message->get_content() ), 'content' => $message->get_content_for_display(), 'excerpt' => $message->get_excerpt( true ), 'is_deleted' => false, 'is_hidden' => false, ], ]; } else { throw new Exception( 'Please enter valid receiver.' ); } } else { throw new Exception( 'Please enter valid sender.' ); } } else { throw new Exception( 'Please enter valid email address.' ); } } } SendDirectMessage::get_instance(); actions/send-custom-in-app-notification.php 0000644 00000011044 15006204201 0015012 0 ustar 00 <?php /** * SendCustomInAppNotification. * php version 5.6 * * @category SendCustomInAppNotification * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; /** * SendCustomInAppNotification * * @category SendCustomInAppNotification * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class SendCustomInAppNotification extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_send_custom_in_app_notification'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Send Custom In App Notification', 'suretriggers' ), 'action' => 'voxel_send_custom_in_app_notification', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { // Get the user ID. $user_email = $selected_options['user_email']; // If user ID is email, then get the user by email. if ( is_email( $user_email ) ) { $user = get_user_by( 'email', $user_email ); $user_email = $user ? $user->ID : 1; } // Get the notification message. $message = $selected_options['message']; // Get post id to link. $post_id = isset( $selected_options['post_id'] ) ? (int) $selected_options['post_id'] : 0; if ( ! class_exists( 'Voxel\Post' ) || ! class_exists( 'Voxel\User' ) || ! class_exists( 'Voxel\Notification' ) || ! function_exists( 'Voxel\get' ) || ! function_exists( 'Voxel\set' ) ) { return false; } // Get the recipient. $recipient = \Voxel\User::get( $user_email ); // Get the post to link. $post = \Voxel\Post::force_get( $post_id ); $post_type = $post->post_type; $notification = \Voxel\Notification::create( [ 'user_id' => $recipient->get_id(), 'subject' => 'SureTriggers: Notification created', 'type' => 'post-types/' . $post_type->wp_post_type->name . '/post:updated', 'details' => [ 'post_id' => $post_id, 'destination' => 'post_author', ], ] ); // Update the notification count for the user. $recipient->update_notification_count(); // Get the voxel events. $events = (array) \Voxel\get( 'events', [] ); $defaults = [ 'post_author' => [ 'label' => 'Notify user', 'recipient' => function( $event ) { return $event->author; }, 'inapp' => [ 'enabled' => false, 'subject' => $message, 'details' => function( $event ) { return [ 'post_id' => $event->post->get_id(), ]; }, 'apply_details' => function( $event, $details ) { $event->prepare( $details['post_id'] ); }, 'links_to' => function( $event ) { return $event->post->get_link(); }, 'image_id' => function( $event ) { return $event->post->get_logo_id(); }, ], 'email' => [ 'enabled' => false, 'subject' => 'Your post has been updated successfully.', 'message' => [ 'html' => [ 'subject' => 'Your post has been updated successfully.', 'body' => 'Your post <strong>@post(:title)</strong> has been updated successfully. <a href="@post(:url)">Open</a> HTML', ], ], ], ], ]; // Add the event to the events array. $events[ 'post-types/' . $post_type->wp_post_type->name . '/post:updated' ] = [ 'notifications' => $defaults, ]; // Set the events. \Voxel\set( 'events', $events, false ); return [ 'success' => true, 'message' => esc_attr__( 'Custom In-app notification sent successfully', 'suretriggers' ), 'user_id' => $user_email, 'notification' => $message, ]; } } SendCustomInAppNotification::get_instance(); actions/send-email.php 0000644 00000004654 15006204201 0010732 0 ustar 00 <?php /** * SendEmail. * php version 5.6 * * @category SendEmail * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; /** * SendEmail * * @category SendEmail * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class SendEmail extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_send_email'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Send Email', 'suretriggers' ), 'action' => 'voxel_send_email', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $message = $selected_options['message']; $subject = $selected_options['subject']; $recipient = $selected_options['wp_user_email']; if ( ! class_exists( 'Voxel\Queues\Async_Email' ) ) { return false; } if ( is_email( $recipient ) ) { $args = [ 'emails' => [ [ 'recipient' => $recipient, 'subject' => $subject, 'message' => $message, 'headers' => [ 'Content-type: text/html;', ], ], ], ]; $email = \Voxel\Queues\Async_Email::instance()->data( $args )->dispatch(); if ( ! $email ) { throw new Exception( 'Email not sent' ); } else { return [ 'success' => true, 'message' => esc_attr__( 'Email sent successfully', 'suretriggers' ), ]; } } else { throw new Exception( 'Please enter valid email address.' ); } } } SendEmail::get_instance(); actions/new-collection-post.php 0000644 00000007332 15006204201 0012615 0 ustar 00 <?php /** * NewCollectionPost. * php version 5.6 * * @category NewCollectionPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; use SureTriggers\Integrations\Voxel\Voxel; /** * NewCollectionPost * * @category NewCollectionPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class NewCollectionPost extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_create_new_collection_post'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Create New Collection Post', 'suretriggers' ), 'action' => 'voxel_create_new_collection_post', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $user_id = $selected_options['wp_user_id']; if ( ! class_exists( 'Voxel\Post' ) ) { return false; } if ( is_email( $user_id ) ) { $user = get_user_by( 'email', $user_id ); $user_id = $user ? $user->ID : 1; $data['post_author'] = $user_id; } $post_fields = []; foreach ( $selected_options['field_row_repeater'] as $key => $field ) { $field_name = $field['value']['name']; if ( 'repeater' == $field['value']['type'] ) { if ( 'work-hours' == $field['value']['name'] ) { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ]['days'] = $val['work_days']; $post_fields[ $field_name ][ $key ]['status'] = $val['work_status']; if ( '' != $val['work_hours'] ) { $hours = explode( '-', $val['work_hours'] ); $post_fields[ $field_name ][ $key ]['hours'][] = [ 'from' => $hours[0], 'to' => $hours[1], ]; } } } else { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ] = $val; } } } else { $value = trim( $selected_options['field_row'][ $key ][ $field_name ] ); $post_fields[ $field_name ] = $value; } } $data = [ 'post_type' => 'collection', 'post_title' => isset( $post_fields['title'] ) && ! is_array( $post_fields['title'] ) ? (string) $post_fields['title'] : '', 'post_status' => 'publish', 'post_author' => $user_id, ]; $collection_id = wp_insert_post( $data ); // Update Collection fields. Voxel::voxel_update_post( $post_fields, $collection_id, 'collection' ); return [ 'success' => true, 'message' => esc_attr__( 'Collection created successfully', 'suretriggers' ), 'collection_id' => $collection_id, 'collection_url' => get_permalink( $collection_id ), ]; } } NewCollectionPost::get_instance(); actions/update-collection-post.php 0000644 00000006437 15006204201 0013313 0 ustar 00 <?php /** * UpdateCollectionPost. * php version 5.6 * * @category UpdateCollectionPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; use SureTriggers\Integrations\Voxel\Voxel; /** * UpdateCollectionPost * * @category UpdateCollectionPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class UpdateCollectionPost extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_update_existing_collection_post'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Update Collection Post', 'suretriggers' ), 'action' => 'voxel_update_existing_collection_post', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { if ( ! class_exists( 'Voxel\Post' ) ) { return false; } $collection_id = $selected_options['collection_post_id']; $post_fields = []; foreach ( $selected_options['field_row_repeater'] as $key => $field ) { $field_name = $field['value']['name']; if ( 'repeater' == $field['value']['type'] ) { if ( 'work-hours' == $field['value']['name'] ) { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ]['days'] = $val['work_days']; $post_fields[ $field_name ][ $key ]['status'] = $val['work_status']; if ( '' != $val['work_hours'] ) { $hours = explode( '-', $val['work_hours'] ); $post_fields[ $field_name ][ $key ]['hours'][] = [ 'from' => $hours[0], 'to' => $hours[1], ]; } } } else { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ] = $val; } } } else { $value = trim( $selected_options['field_row'][ $key ][ $field_name ] ); $post_fields[ $field_name ] = $value; } } // Update Collection fields. Voxel::voxel_update_post( $post_fields, $collection_id, 'collection' ); return [ 'success' => true, 'message' => esc_attr__( 'Collection created successfully', 'suretriggers' ), 'collection_id' => $collection_id, 'collection_url' => get_permalink( $collection_id ), ]; } } UpdateCollectionPost::get_instance(); actions/add-post-profile-wall.php 0000644 00000007077 15006204201 0013024 0 ustar 00 <?php /** * AddPostProfileWall. * php version 5.6 * * @category AddPostProfileWall * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; use Exception; /** * AddPostProfileWall * * @category AddPostProfileWall * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class AddPostProfileWall extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_add_post_profile_wall'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Add Post to Profile Wall', 'suretriggers' ), 'action' => 'voxel_add_post_profile_wall', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $user_email = $selected_options['wp_user_email']; $content = $selected_options['content']; $file_ids = isset( $selected_options['image_ids'] ) && '' !== $selected_options['image_ids'] ? explode( ',', $selected_options['image_ids'] ) : []; if ( ! class_exists( 'Voxel\User' ) || ! class_exists( 'Voxel\Timeline\Status' ) || ! class_exists( 'Voxel\Post' ) || ! class_exists( 'Voxel\Events\Timeline\Statuses\Post_Wall_Status_Created_Event' ) || ! defined( 'Voxel\MODERATION_APPROVED' ) || ! defined( 'Voxel\MODERATION_PENDING' ) ) { return false; } if ( is_email( $user_email ) ) { $user = get_user_by( 'email', $user_email ); $user_id = $user ? $user->ID : 1; } $profile = \Voxel\User::get( $user_id ); $profile_id = $profile->get_profile_id(); if ( ! $profile ) { throw new Exception( 'Profile not found' ); } $details = []; if ( ! empty( $file_ids ) ) { $details['files'] = Voxel::sanitize_files( $file_ids ); } $status = \Voxel\Timeline\Status::create( [ 'feed' => 'user_timeline', 'user_id' => $user_id, 'post_id' => $profile_id, 'content' => $content, 'details' => ! empty( $details ) ? $details : null, 'moderation' => $profile->timeline_posts_require_approval() ? \Voxel\MODERATION_PENDING : \Voxel\MODERATION_APPROVED, ], [ 'link_preview' => 'instant' ] ); $post = \Voxel\Post::force_get( $profile_id ); // Create and send the wall post created event. ( new \Voxel\Events\Timeline\Statuses\Post_Wall_Status_Created_Event( $post->post_type ) )->dispatch( $status->get_id() ); return [ 'success' => true, 'message' => esc_attr__( "Post added to user's profile wall successfully", 'suretriggers' ), 'profile_id' => $profile_id, 'profile_url' => get_author_posts_url( $user_id ), 'status_id' => $status->get_id(), ]; } } AddPostProfileWall::get_instance(); actions/set-collection-post-verified.php 0000644 00000004212 15006204201 0014404 0 ustar 00 <?php /** * SetCollectionPostVerified. * php version 5.6 * * @category SetCollectionPostVerified * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; /** * SetCollectionPostVerified * * @category SetCollectionPostVerified * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class SetCollectionPostVerified extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_set_collection_post_verified'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Set Collection Post Verified', 'suretriggers' ), 'action' => 'voxel_set_collection_post_verified', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $post_id = $selected_options['post_id']; if ( ! class_exists( 'Voxel\Post' ) ) { return false; } $post = \Voxel\Post::force_get( $post_id ); if ( ! $post ) { throw new Exception( 'Post not found' ); } // Set the post as verified. $post->set_verified( true ); return [ 'success' => true, 'message' => esc_attr__( 'Post Set as Verified', 'suretriggers' ), ]; } } SetCollectionPostVerified::get_instance(); actions/set-post-verified.php 0000644 00000004046 15006204201 0012260 0 ustar 00 <?php /** * SetPostVerified. * php version 5.6 * * @category SetPostVerified * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; /** * SetPostVerified * * @category SetPostVerified * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class SetPostVerified extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_set_post_verified'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Send Email', 'suretriggers' ), 'action' => 'voxel_set_post_verified', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $post_id = $selected_options['post_id']; if ( ! class_exists( 'Voxel\Post' ) ) { return false; } $post = \Voxel\Post::force_get( $post_id ); if ( ! $post ) { throw new Exception( 'Post not found' ); } // Set the post as verified. $post->set_verified( true ); return [ 'success' => true, 'message' => esc_attr__( 'Post Set as Verified', 'suretriggers' ), ]; } } SetPostVerified::get_instance(); actions/get-address-by-coordinates.php 0000644 00000012374 15006204201 0014034 0 ustar 00 <?php /** * GetAddressByCoordinates. * php version 5.6 * * @category GetAddressByCoordinates * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; use SureTriggers\Integrations\Voxel\Voxel; /** * GetAddressByCoordinates * * @category GetAddressByCoordinates * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class GetAddressByCoordinates extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_get_address_by_coordinates'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Get Address By Coordinates', 'suretriggers' ), 'action' => 'voxel_get_address_by_coordinates', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { // Get the latitude and longitude. $latitude = $selected_options['latitude']; $longitude = $selected_options['longitude']; if ( ! function_exists( 'Voxel\get' ) ) { return false; } $address = [ 'latitude' => $latitude, 'longitude' => $longitude, ]; if ( is_array( $address ) ) { $latitude = isset( $address['latitude'] ) ? $address['latitude'] : null; $longitude = isset( $address['longitude'] ) ? $address['longitude'] : null; if ( ! is_numeric( $latitude ) || ! is_numeric( $longitude ) ) { return [ 'response' => 'Invalid coordinates provided.' ]; } } elseif ( ! is_string( $address ) || empty( trim( $address ) ) ) { return [ 'response' => 'Invalid address provided.' ]; } if ( \Voxel\get( 'settings.maps.provider' ) === 'mapbox' ) { $url = 'https://api.mapbox.com/geocoding/v5/mapbox.places/%s.json?%s'; $params = [ 'access_token' => \Voxel\get( 'settings.maps.mapbox.api_key' ), 'language' => 'en', 'limit' => 1, ]; if ( is_array( $address ) ) { $location = join( ',', array_reverse( array_map( 'floatval', $address ) ) ); } else { $location = rawurlencode( $address ); } $request = wp_remote_get( sprintf( $url, $location, http_build_query( $params ) ), [ 'httpversion' => '1.1', 'sslverify' => false, ] ); if ( is_wp_error( $request ) ) { throw new Exception( 'Could not perform geocoding request.' ); } $response = json_decode( wp_remote_retrieve_body( $request ), false ); if ( is_object( $response ) && property_exists( $response, 'features' ) ) { if ( empty( $response->features ) && property_exists( $response, 'message' ) ) { return [ 'response' => isset( $response->message ) ? $response->message : 'Geocoding request failed.' ]; } $result = $response->features[0]; return [ 'latitude' => $result->geometry->coordinates[1], 'longitude' => $result->geometry->coordinates[0], 'address' => $result->place_name, ]; } else { return [ 'response' => 'Geocoding request failed.' ]; } } else { $params = [ 'key' => \Voxel\get( 'settings.maps.google_maps.api_key' ), 'language' => 'en', ]; if ( is_array( $address ) ) { $params['latlng'] = join( ',', array_map( 'floatval', $address ) ); } else { $params['address'] = (string) $address; } $request = wp_remote_get( sprintf( 'https://maps.googleapis.com/maps/api/geocode/json?%s', http_build_query( $params ) ), [ 'httpversion' => '1.1', 'sslverify' => false, ] ); if ( is_wp_error( $request ) ) { throw new Exception( 'Could not perform geocoding request.' ); } $response = json_decode( wp_remote_retrieve_body( $request ), false ); if ( is_object( $response ) && property_exists( $response, 'results' ) ) { if ( ( property_exists( $response, 'status' ) && property_exists( $response, 'error_message' ) && 'OK' !== $response->status ) || empty( $response->results ) ) { return [ 'status' => isset( $response->status ) ? $response->status : 'REQUEST_FAILED', 'error_message' => isset( $response->error_message ) ? $response->error_message : 'Geocoding request failed.', ]; } $result = $response->results[0]; return [ 'latitude' => $result->geometry->location->lat, 'longitude' => $result->geometry->location->lng, 'address' => $result->formatted_address, ]; } else { return [ 'response' => 'Request failed.' ]; } } } } GetAddressByCoordinates::get_instance(); actions/add-post-wall.php 0000644 00000007074 15006204201 0011363 0 ustar 00 <?php /** * AddPostWall. * php version 5.6 * * @category AddPostWall * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; use Exception; /** * AddPostWall * * @category AddPostWall * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class AddPostWall extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_add_post_wall'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Add Post to Wall', 'suretriggers' ), 'action' => 'voxel_add_post_wall', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $user_email = $selected_options['wp_user_email']; $content = $selected_options['content']; $post_id = (int) $selected_options['post_id']; $file_ids = isset( $selected_options['image_ids'] ) && '' !== $selected_options['image_ids'] ? explode( ',', $selected_options['image_ids'] ) : []; if ( ! class_exists( 'Voxel\Post' ) || ! class_exists( 'Voxel\Timeline\Status' ) || ! class_exists( 'Voxel\Events\Timeline\Statuses\Post_Wall_Status_Created_Event' ) || ! defined( 'Voxel\MODERATION_APPROVED' ) || ! defined( 'Voxel\MODERATION_PENDING' ) ) { return false; } if ( is_email( $user_email ) ) { $user = get_user_by( 'email', $user_email ); $user_id = $user ? $user->ID : 1; } // Get the post. $post = \Voxel\Post::force_get( $post_id ); if ( ! $post ) { throw new Exception( 'Post not found' ); } $details = []; if ( ! empty( $file_ids ) ) { $details['files'] = Voxel::sanitize_files( $file_ids ); } $status = \Voxel\Timeline\Status::create( [ 'feed' => 'post_wall', 'user_id' => $user_id, 'post_id' => $post->get_id(), 'content' => $content, 'details' => ! empty( $details ) ? $details : null, 'moderation' => $post->post_type->timeline->wall_posts_require_approval() ? \Voxel\MODERATION_PENDING : \Voxel\MODERATION_APPROVED, ], [ 'link_preview' => 'instant' ] ); // Create and send the wall post created event. ( new \Voxel\Events\Timeline\Statuses\Post_Wall_Status_Created_Event( $post->post_type ) )->dispatch( $status->get_id() ); return [ 'success' => true, 'message' => esc_attr__( "Post added to Post's wall successfully", 'suretriggers' ), 'post_id' => $post_id, 'post_url' => get_permalink( $post_id ), 'status_id' => $status->get_id(), 'creator' => WordPress::get_user_context( $user_id ), 'content' => $content, ]; } } AddPostWall::get_instance(); actions/new-post.php 0000644 00000007534 15006204201 0010470 0 ustar 00 <?php /** * NewPost. * php version 5.6 * * @category NewPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; use Exception; /** * NewPost * * @category NewPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class NewPost extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_create_new_post'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Create New Post', 'suretriggers' ), 'action' => 'voxel_create_new_post', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $user_email = $selected_options['post_author_email']; if ( ! class_exists( 'Voxel\Post' ) ) { return false; } // Get the post type. $post_type = isset( $selected_options['voxel_post_type'] ) && '' !== $selected_options['voxel_post_type'] ? $selected_options['voxel_post_type'] : 'post'; $post_fields = []; foreach ( $selected_options['field_row_repeater'] as $key => $field ) { $field_name = $field['value']['name']; if ( 'repeater' == $field['value']['type'] ) { if ( 'work-hours' == $field['value']['name'] ) { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ]['days'] = $val['work_days']; $post_fields[ $field_name ][ $key ]['status'] = $val['work_status']; if ( '' != $val['work_hours'] ) { $hours = explode( '-', $val['work_hours'] ); $post_fields[ $field_name ][ $key ]['hours'][] = [ 'from' => $hours[0], 'to' => $hours[1], ]; } } } else { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ] = $val; } } } else { $value = trim( $selected_options['field_row'][ $key ][ $field_name ] ); $post_fields[ $field_name ] = $value; } } $data = [ 'post_type' => $post_type, 'post_title' => isset( $post_fields['title'] ) && ! is_array( $post_fields['title'] ) ? (string) $post_fields['title'] : '', 'post_status' => isset( $selected_options['post_status'] ) && '' !== $selected_options['post_status'] ? $selected_options['post_status'] : 'draft', ]; if ( is_email( $user_email ) ) { $user = get_user_by( 'email', $user_email ); $user_id = $user ? $user->ID : 1; $data['post_author'] = $user_id; } $post_id = wp_insert_post( $data ); // Update Collection fields. Voxel::voxel_update_post( $post_fields, $post_id, $post_type ); return [ 'success' => true, 'message' => esc_attr__( 'Post created successfully', 'suretriggers' ), 'post_id' => $post_id, 'post_url' => get_permalink( $post_id ), ]; } } NewPost::get_instance(); actions/delete-wall-post.php 0000644 00000004152 15006204201 0012067 0 ustar 00 <?php /** * DeleteWallPost. * php version 5.6 * * @category DeleteWallPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; /** * DeleteWallPost * * @category DeleteWallPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class DeleteWallPost extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_delete_wall_post'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Delete Post Wall', 'suretriggers' ), 'action' => 'voxel_delete_wall_post', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $post_id = (int) $selected_options['wall_post_id']; if ( ! class_exists( 'Voxel\Timeline\Status' ) ) { return false; } // Get the post. $post = \Voxel\Timeline\Status::get( $post_id ); if ( ! $post ) { throw new Exception( 'Wall Post not found' ); } // Delete the post. $post->delete(); return [ 'success' => true, 'message' => esc_attr__( 'Wall Post deleted successfully', 'suretriggers' ), 'post_id' => $post_id, ]; } } DeleteWallPost::get_instance(); actions/update-post.php 0000644 00000007046 15006204201 0011157 0 ustar 00 <?php /** * UpdatePost. * php version 5.6 * * @category UpdatePost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; use Exception; /** * UpdatePost * * @category UpdatePost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class UpdatePost extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_update_existing_post'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Update Post', 'suretriggers' ), 'action' => 'voxel_update_existing_post', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { if ( ! class_exists( 'Voxel\Post' ) ) { return false; } // Get the post type. $post_type = $selected_options['voxel_post_type']; $post_id = $selected_options['post_id']; $selected_post_posttype = get_post_type( $post_id ); if ( $post_type != $selected_post_posttype ) { throw new Exception( 'Post ID type does not match the selected post type.' ); } $post_fields = []; foreach ( $selected_options['field_row_repeater'] as $key => $field ) { $field_name = $field['value']['name']; if ( 'repeater' == $field['value']['type'] ) { if ( 'work-hours' == $field['value']['name'] ) { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ]['days'] = $val['work_days']; $post_fields[ $field_name ][ $key ]['status'] = $val['work_status']; if ( '' != $val['work_hours'] ) { $hours = explode( '-', $val['work_hours'] ); $post_fields[ $field_name ][ $key ]['hours'][] = [ 'from' => $hours[0], 'to' => $hours[1], ]; } } } else { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ] = $val; } } } else { $value = trim( $selected_options['field_row'][ $key ][ $field_name ] ); $post_fields[ $field_name ] = $value; } } $post_fields['post_status'] = isset( $selected_options['post_status'] ) && '' !== $selected_options['post_status'] ? $selected_options['post_status'] : ''; // Update Post fields. Voxel::voxel_update_post( $post_fields, $post_id, $post_type ); return [ 'success' => true, 'message' => esc_attr__( 'Post updated successfully', 'suretriggers' ), 'post_id' => $post_id, 'post_url' => get_permalink( $post_id ), ]; } } UpdatePost::get_instance(); actions/remove-post-from-collection.php 0000644 00000006226 15006204201 0014263 0 ustar 00 <?php /** * RemovePostFromCollection. * php version 5.6 * * @category RemovePostFromCollection * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; /** * RemovePostFromCollection * * @category RemovePostFromCollection * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class RemovePostFromCollection extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_remove_post_from_collection'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Remove Post from Collection', 'suretriggers' ), 'action' => 'voxel_remove_post_from_collection', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { // Get the collection ID. $collection_id = (int) $selected_options['collection_post_id']; // Get the post ID. $post_id = (int) $selected_options['post_id']; if ( ! class_exists( 'Voxel\Post' ) ) { return false; } // Get the post. $post = \Voxel\Post::force_get( $post_id ); if ( ! $post ) { throw new Exception( 'Post not found' ); } // Get the collection. $collection = \Voxel\Post::force_get( $collection_id ); if ( ! $collection ) { throw new Exception( 'Collection not found' ); } // Get the items field. $field = $collection->get_field( 'items' ); // Get previous items. $items = $field->get_value(); // If items are not available, return error. if ( ! $items ) { throw new Exception( 'Collection items not found' ); } // If the post is not in the collection, then skip. if ( ! in_array( $post_id, $items, true ) ) { throw new Exception( 'Post not found in collection' ); } // Remove the post from the items. $items = array_diff( $items, [ $post_id ] ); // Add the post to the collection. $field->set_value( $items ); return [ 'success' => true, 'message' => esc_attr__( 'Post removed from collection successfully', 'suretriggers' ), 'post_id' => $post_id, 'collection_id' => $collection_id, 'collection_url' => get_permalink( $collection_id ), 'collection_items' => wp_json_encode( $items ), ]; } } RemovePostFromCollection::get_instance(); actions/get-post-by-id.php 0000644 00000007430 15006204201 0011453 0 ustar 00 <?php /** * GetPostByID. * php version 5.6 * * @category GetPostByID * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; use SureTriggers\Integrations\Voxel\Voxel; /** * GetPostByID * * @category GetPostByID * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class GetPostByID extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_get_post_by_id'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Get Post By ID', 'suretriggers' ), 'action' => 'voxel_get_post_by_id', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $post_id = (int) $selected_options['post_id']; $post = get_post( $post_id ); if ( ! class_exists( 'Voxel\Post' ) ) { return false; } if ( ! $post ) { throw new Exception( 'Post not found' ); } // Get the post fields. $post_fields = [ 'post_id' => $post->ID, 'post_title' => $post->post_title, 'post_content' => $post->post_content, 'post_status' => $post->post_status, 'post_author_id' => $post->post_author, 'post_permalink' => get_permalink( $post->ID ), 'post_type' => get_post_type( $post->ID ), ]; // Set the fields. $fields = []; // Get the post fields. $wp_post = \Voxel\Post::force_get( $post_id ); if ( $wp_post ) { // Loop through each field and add to the simple entry. foreach ( $wp_post->get_fields() as $field ) { $key = $field->get_key(); if ( $field->get_type() === 'taxonomy' ) { $content = join( ', ', array_map( function( $term ) { return $term->get_label(); }, $field->get_value() ) ); } elseif ( $field->get_type() === 'location' ) { $content = isset( $field->get_value()['address'] ) ? $field->get_value()['address'] : null; } else { $content = $field->get_value(); } $fields[ $key ] = is_array( $content ) ? wp_json_encode( $content ) : $content; } // If fields are available, then add to the simple entry. if ( ! empty( $fields ) ) { $post_fields['all_fields'] = $fields; // Loop through each field and add to the simple entry. foreach ( $fields as $key => $value ) { $post_fields[ 'field_' . $key ] = $value; } } } $author = get_user_by( 'id', $post->post_author ); if ( $author ) { $user = get_userdata( $author->ID ); if ( ! empty( $user ) ) { $user_data = (array) $user->data; $post_fields['user_id'] = $user_data['ID']; $post_fields['user_name'] = $user_data['user_nicename']; $post_fields['user_display_name'] = $user_data['display_name']; $post_fields['user_email'] = $user_data['user_email']; } } return $post_fields; } } GetPostByID::get_instance(); actions/follow-post.php 0000644 00000005553 15006204201 0011200 0 ustar 00 <?php /** * FollowPost. * php version 5.6 * * @category FollowPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; use Exception; /** * FollowPost * * @category FollowPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class FollowPost extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_follow_post'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Follow Post', 'suretriggers' ), 'action' => 'voxel_follow_post', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $user_email = $selected_options['wp_user_email']; $post_id = (int) $selected_options['post_id']; if ( ! class_exists( 'Voxel\Post' ) || ! class_exists( 'Voxel\User' ) ) { return false; } if ( is_email( $user_email ) ) { $user = get_user_by( 'email', $user_email ); if ( $user ) { $user_id = $user->ID; } } // Get the post. $post = \Voxel\Post::get( $post_id ); if ( ! $post ) { throw new Exception( 'Post not found.' ); } $current_user = \Voxel\User::get( $user_id ); if ( ! $current_user ) { throw new Exception( 'User not found.' ); } $current_status = $current_user->get_follow_status( 'post', $post->get_id() ); if ( 1 === $current_status ) { $current_user->set_follow_status( 'post', $post->get_id(), null ); } else { $current_user->set_follow_status( 'post', $post->get_id(), 1 ); } return [ 'success' => true, 'message' => esc_attr__( 'Post followed successfully.', 'suretriggers' ), 'post_id' => $post_id, 'post_following_user' => WordPress::get_user_context( $user_id ), 'followed' => WordPress::get_post_context( $post_id ), ]; } } FollowPost::get_instance(); actions/set-profile-verified.php 0000644 00000004123 15006204201 0012727 0 ustar 00 <?php /** * SetProfileVerified. * php version 5.6 * * @category SetProfileVerified * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; /** * SetProfileVerified * * @category SetProfileVerified * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class SetProfileVerified extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_set_profile_verified'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Send Email', 'suretriggers' ), 'action' => 'voxel_set_profile_verified', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $profile_id = $selected_options['profile_id']; if ( ! class_exists( 'Voxel\Post' ) ) { return false; } $post = \Voxel\Post::force_get( $profile_id ); if ( ! $post ) { throw new Exception( 'Profile not found' ); } // Set the post as verified. $post->set_verified( true ); return [ 'success' => true, 'message' => esc_attr__( 'Profile Verified Successfully', 'suretriggers' ), ]; } } SetProfileVerified::get_instance(); actions/get-member-by-profile-id.php 0000644 00000007460 15006204201 0013376 0 ustar 00 <?php /** * GetMemberByProfileID. * php version 5.6 * * @category GetMemberByProfileID * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; use SureTriggers\Integrations\Voxel\Voxel; /** * GetMemberByProfileID * * @category GetMemberByProfileID * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class GetMemberByProfileID extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_get_member_by_profile_id'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Get Member By Profile ID', 'suretriggers' ), 'action' => 'voxel_get_member_by_profile_id', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $member_profile_id = (int) $selected_options['member_profile_id']; if ( ! class_exists( 'Voxel\User' ) || ! class_exists( 'Voxel\Post' ) ) { return false; } $member = \Voxel\User::get_by_profile_id( $member_profile_id ); if ( ! $member ) { throw new Exception( 'Member not found' ); } $member_id = $member->get_id(); $member = \Voxel\User::get( $member_id ); if ( ! $member ) { throw new Exception( 'Member not found' ); } $profile_id = $member->get_profile_id(); // Get the membership details. $membership = $member->get_membership(); $membership = $membership ? $membership->get_details_for_app_event() : []; // Get the member fields. $member_fields = []; // Get user. $user = get_userdata( $member_id ); if ( $user ) { $user_data = (array) $user->data; $member_fields['user_display_name'] = $user_data['display_name']; $member_fields['user_name'] = $user_data['user_nicename']; $member_fields['user_email'] = $user_data['user_email']; } foreach ( (array) $membership as $key => $value ) { // Prepend the membership_ to the key. $key = 'membership_' . $key; $member_fields[ $key ] = $value; } // Add the profile ID. $member_fields['profile_id'] = $profile_id; // Get the post fields. $wp_post = \Voxel\Post::force_get( $profile_id ); // If WP post is available, then get the fields. if ( $wp_post ) { // Loop through each field and add to the simple entry. foreach ( $wp_post->get_fields() as $field ) { $key = $field->get_key(); if ( $field->get_type() === 'taxonomy' ) { $content = join( ', ', array_map( function( $term ) { return $term->get_label(); }, $field->get_value() ) ); } elseif ( $field->get_type() === 'location' ) { $content = isset( $field->get_value()['address'] ) ? $field->get_value()['address'] : null; } else { $content = $field->get_value(); } $member_fields[ $key ] = $content; } } return $member_fields; } } GetMemberByProfileID::get_instance(); actions/add-post-to-collection.php 0000644 00000006434 15006204201 0013176 0 ustar 00 <?php /** * AddPostToCollection. * php version 5.6 * * @category AddPostToCollection * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; /** * AddPostToCollection * * @category AddPostToCollection * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class AddPostToCollection extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_add_post_to_collection'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Add Post to Collection', 'suretriggers' ), 'action' => 'voxel_add_post_to_collection', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $collection_id = (int) $selected_options['collection_post_id']; $post_id = $selected_options['post_id']; if ( ! class_exists( 'Voxel\Post' ) ) { return false; } // In case multiple posts, explode the post ID. $post_ids = explode( ',', $post_id ); $items = []; // Loop through the post IDs. foreach ( $post_ids as $c_post_id ) { // Get the post. $post = \Voxel\Post::force_get( $c_post_id ); if ( ! $post ) { throw new Exception( 'Post not found' ); } // Get the collection. $collection = \Voxel\Post::force_get( $collection_id ); if ( ! ( $collection && $collection->post_type && $collection->get_status() === 'publish' && $collection->post_type->get_key() === 'collection' ) ) { throw new Exception( 'Collection not found' ); } // Get the items field. $field = $collection->get_field( 'items' ); $items = $field->get_value(); // If items are not available, then set as empty array. if ( ! $items ) { $items = []; } // If the post is already in the collection, then skip. if ( in_array( $c_post_id, $items, true ) ) { continue; } // Add the post to the items. $items[] = (int) $c_post_id; $items = array_unique( $items ); $field->set_value( $items ); } return [ 'success' => true, 'message' => esc_attr__( 'Post added to collection successfully', 'suretriggers' ), 'post_id' => $post_id, 'collection_id' => $collection_id, 'collection_url' => get_permalink( $collection_id ), 'collection_items' => wp_json_encode( $items ), ]; } } AddPostToCollection::get_instance(); actions/new-profile.php 0000644 00000007524 15006204201 0011142 0 ustar 00 <?php /** * NewProfile. * php version 5.6 * * @category NewProfile * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; use SureTriggers\Integrations\Voxel\Voxel; /** * NewProfile * * @category NewProfile * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class NewProfile extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_create_new_profile'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Create New Profile', 'suretriggers' ), 'action' => 'voxel_create_new_profile', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $user_id = $selected_options['user_email']; if ( ! class_exists( 'Voxel\User' ) ) { return false; } if ( is_email( $user_id ) ) { $user = get_user_by( 'email', $user_id ); if ( $user ) { $user_id = $user->ID; // Get user details. $user = \Voxel\User::get( $user_id ); // Check if profile is already exists. $profile_id = $user->get_profile_id(); // Create the profile, if not exist. if ( ! $profile_id ) { $profile = $user->get_or_create_profile(); $profile_id = $profile->get_id(); } $post_fields = []; foreach ( $selected_options['field_row_repeater'] as $key => $field ) { $field_name = $field['value']['name']; if ( 'repeater' == $field['value']['type'] ) { if ( 'work-hours' == $field['value']['name'] ) { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ]['days'] = $val['work_days']; $post_fields[ $field_name ][ $key ]['status'] = $val['work_status']; if ( '' != $val['work_hours'] ) { $hours = explode( '-', $val['work_hours'] ); $post_fields[ $field_name ][ $key ]['hours'][] = [ 'from' => $hours[0], 'to' => $hours[1], ]; } } } else { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ] = $val; } } } else { $value = trim( $selected_options['field_row'][ $key ][ $field_name ] ); $post_fields[ $field_name ] = $value; } } // Update Collection fields. Voxel::voxel_update_post( $post_fields, $profile_id, 'profile' ); return [ 'success' => true, 'message' => esc_attr__( 'Profile created successfully', 'suretriggers' ), 'profile_id' => $profile_id, 'profile_url' => get_author_posts_url( $user_id ), 'profile_author' => $user_id, ]; } else { throw new Exception( 'User not found' ); } } else { throw new Exception( 'Enter valid email address' ); } } } NewProfile::get_instance(); actions/get-member-by-id.php 0000644 00000006775 15006204201 0011750 0 ustar 00 <?php /** * GetMemberByID. * php version 5.6 * * @category GetMemberByID * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; use SureTriggers\Integrations\Voxel\Voxel; /** * GetMemberByID * * @category GetMemberByID * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class GetMemberByID extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_get_member_by_id'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Get Member By ID', 'suretriggers' ), 'action' => 'voxel_get_member_by_id', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $member_id = (int) $selected_options['member_id']; if ( ! class_exists( 'Voxel\User' ) || ! class_exists( 'Voxel\Post' ) ) { return false; } $member = \Voxel\User::get( $member_id ); if ( ! $member ) { throw new Exception( 'Member not found' ); } $profile_id = $member->get_profile_id(); // Get the membership details. $membership = $member->get_membership(); $membership = $membership ? $membership->get_details_for_app_event() : []; // Get the member fields. $member_fields = []; $user = get_userdata( $member_id ); if ( $user ) { $user_data = (array) $user->data; $member_fields['user_display_name'] = $user_data['display_name']; $member_fields['user_name'] = $user_data['user_nicename']; $member_fields['user_email'] = $user_data['user_email']; } foreach ( (array) $membership as $key => $value ) { $key = 'membership_' . $key; $member_fields[ $key ] = $value; } // Add the profile ID. $member_fields['profile_id'] = $profile_id; // Get the post fields. $wp_post = \Voxel\Post::force_get( $profile_id ); // If WP post is available, then get the fields. if ( $wp_post ) { // Loop through each field and add to the simple entry. foreach ( $wp_post->get_fields() as $field ) { $key = $field->get_key(); if ( $field->get_type() === 'taxonomy' ) { $content = join( ', ', array_map( function( $term ) { return $term->get_label(); }, $field->get_value() ) ); } elseif ( $field->get_type() === 'location' ) { $content = isset( $field->get_value()['address'] ) ? $field->get_value()['address'] : null; } else { $content = $field->get_value(); } $member_fields[ $key ] = $content; } } return $member_fields; } } GetMemberByID::get_instance(); actions/update-profile.php 0000644 00000006627 15006204201 0011636 0 ustar 00 <?php /** * UpdateProfile. * php version 5.6 * * @category UpdateProfile * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; use SureTriggers\Integrations\Voxel\Voxel; /** * UpdateProfile * * @category UpdateProfile * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class UpdateProfile extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_update_existing_profile'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Update Profile', 'suretriggers' ), 'action' => 'voxel_update_existing_profile', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { if ( ! class_exists( 'Voxel\User' ) ) { return false; } $profile_id = $selected_options['profile_id']; $profile = \Voxel\User::get_by_profile_id( $profile_id ); if ( ! $profile ) { throw new Exception( 'Profile not found' ); } // Create the profile, if not exist. $post_fields = []; foreach ( $selected_options['field_row_repeater'] as $key => $field ) { $field_name = $field['value']['name']; if ( 'repeater' == $field['value']['type'] ) { if ( 'work-hours' == $field['value']['name'] ) { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ]['days'] = $val['work_days']; $post_fields[ $field_name ][ $key ]['status'] = $val['work_status']; if ( '' != $val['work_hours'] ) { $hours = explode( '-', $val['work_hours'] ); $post_fields[ $field_name ][ $key ]['hours'][] = [ 'from' => $hours[0], 'to' => $hours[1], ]; } } } else { $arr_value = $selected_options['field_row'][ $key ][ $field_name ]; foreach ( $arr_value as $key => $val ) { $post_fields[ $field_name ][ $key ] = $val; } } } else { $value = trim( $selected_options['field_row'][ $key ][ $field_name ] ); $post_fields[ $field_name ] = $value; } } // Update Collection fields. Voxel::voxel_update_post( $post_fields, $profile_id, 'profile' ); return [ 'success' => true, 'message' => esc_attr__( 'Profile created successfully', 'suretriggers' ), 'profile_id' => $profile_id, 'profile_url' => get_author_posts_url( $user_id ), 'profile_author' => $user_id, ]; } } UpdateProfile::get_instance(); actions/get-posts-by-voxel-field.php 0000644 00000010540 15006204201 0013454 0 ustar 00 <?php /** * GetPostsByVoxelField. * php version 5.6 * * @category GetPostsByVoxelField * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; use SureTriggers\Integrations\Voxel\Voxel; /** * GetPostsByVoxelField * * @category GetPostsByVoxelField * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class GetPostsByVoxelField extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_get_posts_by_voxel_field'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Get Posts by Voxel Field', 'suretriggers' ), 'action' => 'voxel_get_posts_by_voxel_field', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $post_type = $selected_options['vx_post_type']; $field_key = $selected_options['vx_field_key']; $field_val = $selected_options['vx_field_value']; $number = isset( $selected_options['vx_posts_no'] ) ? (int) $selected_options['vx_posts_no'] : -1; if ( ! class_exists( 'Voxel\Post_Type' ) ) { return false; } // Get fields for post. $post_type_obj = \Voxel\Post_Type::get( $post_type ); $post_fields = $post_type_obj->get_fields(); $post_field = []; foreach ( $post_fields as $key => $field ) { if ( $key === $field_key ) { $post_field = $field->get_props(); break; } } if ( ! empty( $post_field ) && isset( $post_field['type'] ) && 'post-relation' === $post_field['type'] ) { global $wpdb; $field = $post_type_obj->get_field( $field_key ); $rows = $wpdb->get_col( $wpdb->prepare( "SELECT parent_id FROM {$wpdb->prefix}voxel_relations LEFT JOIN {$wpdb->posts} AS p ON parent_id = p.ID WHERE child_id = %d AND relation_key = %s ORDER BY 'order ASC", $field_val, $field_key ) ); $post_ids = array_map( 'absint', (array) $rows ); $posts = get_posts( [ 'post_type' => $post_type, 'numberposts' => $number, 'post__in' => $post_ids, 'orderby' => 'post__in', 'no_found_rows' => true, 'suppress_filters' => false, ] ); } elseif ( isset( $post_field['type'] ) && 'taxonomy' === $post_field['type'] ) { $posts = get_posts( [ 'post_type' => $post_type, 'numberposts' => $number, 'tax_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query [ 'taxonomy' => $post_field['taxonomy'], 'field' => 'slug', 'terms' => $field_val, ], ], ] ); } else { $posts = get_posts( [ 'post_type' => $post_type, 'numberposts' => $number, 'meta_query' => [ [ 'key' => $field_key, 'value' => $field_val, 'compare' => 'LIKE', ], ], ] ); } if ( ! $posts ) { throw new Exception( 'No posts found' ); } $posts_array = [ 'all_posts' => [], ]; foreach ( $posts as $key => $post ) { $post_array = [ 'post_id' => $post->ID, 'post_title' => $post->post_title, 'post_status' => $post->post_status, 'post_content' => stripslashes( esc_attr( $post->post_content ) ), 'post_author_id' => $post->post_author, 'post_permalink' => get_permalink( $post->ID ), ]; $posts_array['all_posts'][ $key ] = $post_array; } return $posts_array; } } GetPostsByVoxelField::get_instance(); actions/get-member-by-email.php 0000644 00000010115 15006204201 0012422 0 ustar 00 <?php /** * GetMemberByEmail. * php version 5.6 * * @category GetMemberByEmail * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; use SureTriggers\Integrations\Voxel\Voxel; /** * GetMemberByEmail * * @category GetMemberByEmail * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class GetMemberByEmail extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_get_member_by_email'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Get Member By Email', 'suretriggers' ), 'action' => 'voxel_get_member_by_email', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $user_email = $selected_options['member_email']; if ( ! class_exists( 'Voxel\User' ) || ! class_exists( 'Voxel\Post' ) ) { return false; } $member = get_user_by( 'email', $user_email ); if ( ! $member ) { throw new Exception( 'Member not found' ); } $member_id = $member->ID; $member = \Voxel\User::get( $member_id ); if ( ! $member ) { throw new Exception( 'Member not found' ); } $profile_id = $member->get_profile_id(); // Get the membership details. $membership = $member->get_membership(); $membership = $membership ? $membership->get_details_for_app_event() : []; // Get the member fields. $member_fields = []; // Get user. $user = get_userdata( $member_id ); if ( $user ) { $user_data = (array) $user->data; $member_fields['user_display_name'] = $user_data['display_name']; $member_fields['user_name'] = $user_data['user_nicename']; $member_fields['user_email'] = $user_data['user_email']; } foreach ( (array) $membership as $key => $value ) { // Prepend the membership_ to the key. $key = 'membership_' . $key; $member_fields[ $key ] = $value; } // Add the profile ID. $member_fields['profile_id'] = $profile_id; // Get the post fields. $wp_post = \Voxel\Post::force_get( $profile_id ); // If WP post is available, then get the fields. if ( $wp_post ) { // Loop through each field and add to the simple entry. foreach ( $wp_post->get_fields() as $field ) { $key = $field->get_key(); if ( $field->get_type() === 'taxonomy' ) { $content = join( ', ', array_map( function( $term ) { return $term->get_label(); }, $field->get_value() ) ); } elseif ( $field->get_type() === 'location' ) { $content = isset( $field->get_value()['address'] ) ? $field->get_value()['address'] : null; } else { $content = $field->get_value(); } $fields[ $key ] = is_array( $content ) ? wp_json_encode( $content ) : $content; } // If fields are available, then add to the simple entry. if ( ! empty( $fields ) ) { $member_fields['all_fields'] = wp_json_encode( $fields ); // Loop through each field and add to the simple entry. foreach ( $fields as $key => $value ) { $member_fields[ 'field_' . $key ] = $value; } } } return $member_fields; } } GetMemberByEmail::get_instance(); actions/get-coordinates-by-address.php 0000644 00000012127 15006204201 0014030 0 ustar 00 <?php /** * GetCoordinatesByAddress. * php version 5.6 * * @category GetCoordinatesByAddress * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; use SureTriggers\Integrations\Voxel\Voxel; /** * GetCoordinatesByAddress * * @category GetCoordinatesByAddress * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class GetCoordinatesByAddress extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_get_cooordinates_by_address'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Get Coordinates By Address', 'suretriggers' ), 'action' => 'voxel_get_cooordinates_by_address', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $address = $selected_options['address']; if ( ! function_exists( 'Voxel\get' ) ) { return false; } if ( is_array( $address ) ) { $latitude = isset( $address['latitude'] ) ? $address['latitude'] : null; $longitude = isset( $address['longitude'] ) ? $address['longitude'] : null; if ( ! is_numeric( $latitude ) || ! is_numeric( $longitude ) ) { return [ 'response' => 'Invalid coordinates provided.' ]; } } elseif ( ! is_string( $address ) || empty( trim( $address ) ) ) { return [ 'response' => 'Invalid address provided.' ]; } if ( \Voxel\get( 'settings.maps.provider' ) === 'mapbox' ) { $url = 'https://api.mapbox.com/geocoding/v5/mapbox.places/%s.json?%s'; $params = [ 'access_token' => \Voxel\get( 'settings.maps.mapbox.api_key' ), 'language' => 'en', 'limit' => 1, ]; if ( is_array( $address ) ) { $location = join( ',', array_reverse( array_map( 'floatval', $address ) ) ); } else { $location = rawurlencode( $address ); } $request = wp_remote_get( sprintf( $url, $location, http_build_query( $params ) ), [ 'httpversion' => '1.1', 'sslverify' => false, ] ); if ( is_wp_error( $request ) ) { throw new Exception( 'Could not perform geocoding request.' ); } $response = json_decode( wp_remote_retrieve_body( $request ), false ); if ( is_object( $response ) && property_exists( $response, 'features' ) ) { if ( empty( $response->features ) && property_exists( $response, 'message' ) ) { return [ 'response' => isset( $response->message ) ? $response->message : 'Geocoding request failed.' ]; } $result = $response->features[0]; return [ 'latitude' => $result->geometry->coordinates[1], 'longitude' => $result->geometry->coordinates[0], 'address' => $result->place_name, ]; } else { return [ 'response' => 'Geocoding request failed.' ]; } } else { $params = [ 'key' => \Voxel\get( 'settings.maps.google_maps.api_key' ), 'language' => 'en', ]; if ( is_array( $address ) ) { $params['latlng'] = join( ',', array_map( 'floatval', $address ) ); } else { $params['address'] = (string) $address; } $request = wp_remote_get( sprintf( 'https://maps.googleapis.com/maps/api/geocode/json?%s', http_build_query( $params ) ), [ 'httpversion' => '1.1', 'sslverify' => false, ] ); if ( is_wp_error( $request ) ) { throw new Exception( 'Could not perform geocoding request.' ); } $response = json_decode( wp_remote_retrieve_body( $request ), false ); if ( is_object( $response ) && property_exists( $response, 'results' ) ) { if ( ( property_exists( $response, 'status' ) && property_exists( $response, 'error_message' ) && 'OK' !== $response->status ) || empty( $response->results ) ) { return [ 'status' => isset( $response->status ) ? $response->status : 'REQUEST_FAILED', 'error_message' => isset( $response->error_message ) ? $response->error_message : 'Geocoding request failed.', ]; } $result = $response->results[0]; return [ 'latitude' => $result->geometry->location->lat, 'longitude' => $result->geometry->location->lng, 'address' => $result->formatted_address, ]; } else { return [ 'response' => 'Request failed.' ]; } } } } GetCoordinatesByAddress::get_instance(); actions/set-custom-priority.php 0000644 00000005011 15006204201 0012662 0 ustar 00 <?php /** * SetCustomPriority. * php version 5.6 * * @category SetCustomPriority * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Actions; use SureTriggers\Integrations\AutomateAction; use SureTriggers\Traits\SingletonLoader; use Exception; /** * SetCustomPriority * * @category SetCustomPriority * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ class SetCustomPriority extends AutomateAction { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Action name. * * @var string */ public $action = 'voxel_set_custom_priority'; use SingletonLoader; /** * Register action. * * @param array $actions action data. * @return array */ public function register( $actions ) { $actions[ $this->integration ][ $this->action ] = [ 'label' => __( 'Set Custom Priority', 'suretriggers' ), 'action' => 'voxel_set_custom_priority', 'function' => [ $this, 'action_listener' ], ]; return $actions; } /** * Action listener. * * @param int $user_id user_id. * @param int $automation_id automation_id. * @param array $fields fields. * @param array $selected_options selectedOptions. * * @throws Exception Exception. * * @return bool|array */ public function _action_listener( $user_id, $automation_id, $fields, $selected_options ) { $post_id = $selected_options['post_id']; // Get the priority. $priority = (int) $selected_options['priority']; if ( ! class_exists( 'Voxel\Post' ) || ! function_exists( 'Voxel\clamp' ) ) { return false; } // Get the post. $post = \Voxel\Post::force_get( $post_id ); if ( ! $post ) { throw new Exception( 'Post not found' ); } // Set the priority. $custom_priority = $priority; $custom_priority = \Voxel\clamp( $custom_priority, -128, 127 ); if ( 0 !== $custom_priority ) { update_post_meta( $post->get_id(), 'voxel:priority', $custom_priority ); // Reindex post. $post->should_index() ? $post->index() : $post->unindex(); } return [ 'success' => true, 'message' => esc_attr__( 'Custom priority set successfully', 'suretriggers' ), 'post_id' => $post_id, 'priority' => $priority, ]; } } SetCustomPriority::get_instance(); voxel.php 0000644 00000056710 15006204201 0006411 0 ustar 00 <?php /** * Voxel integrations file * * @since 1.0.0 * @package SureTrigger */ namespace SureTriggers\Integrations\Voxel; use SureTriggers\Controllers\IntegrationsController; use SureTriggers\Integrations\Integrations; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; /** * Class SureTrigger * * @package SureTriggers\Integrations\Voxel */ class Voxel extends Integrations { use SingletonLoader; /** * ID * * @var string */ protected $id = 'Voxel'; /** * SureTrigger constructor. */ public function __construct() { $this->name = __( 'Voxel', 'suretriggers' ); $this->description = __( 'Voxel is a complete no code solution in a single packageto create WordPress dynamic sites.', 'suretriggers' ); $this->icon_url = SURE_TRIGGERS_URL . 'assets/icons/voxel.svg'; add_action( 'init', [ $this, 'suretriggers_voxel_follow_post' ], 10 ); parent::__construct(); } /** * Update post. * * @access public * @since 1.0 * @param array $fields Workflow step fields. * @param int $post_id Post ID. * @param string $post_type Post type. * @return array|bool|string */ public static function voxel_update_post( $fields, $post_id, $post_type ) { if ( ! class_exists( 'Voxel\Post' ) || ! class_exists( 'Voxel\Post_Type' ) ) { return []; } $post_title = isset( $fields['title'] ) && '' !== $fields['title'] ? $fields['title'] : ''; $post = \Voxel\Post::force_get( $post_id ); if ( ! $post ) { return wp_json_encode( [ 'success' => false, 'message' => esc_attr__( 'Post not found', 'suretriggers' ), ] ); } if ( $post_title ) { $args = [ 'ID' => $post_id, 'post_title' => $post_title, ]; if ( isset( $fields['post_status'] ) && '' !== $fields['post_status'] ) { $args['post_status'] = $fields['post_status']; } wp_update_post( $args ); } $post_type = \Voxel\Post_Type::get( $post_type ); $post_fields = $post_type->get_fields(); $field_opts = self::get_fields(); foreach ( $post_fields as $key => $field ) { $post_fields[ $key ] = $field->get_props(); } // Loop through the post fields. foreach ( $post_fields as $key => $field ) { $field_key = $key; $field_type = $field['type']; $post_field = $post->get_field( $field_key ); // If field is not available, then skip. if ( ! $post_field ) { continue; } // If field is ui-step, ui-html and ui-heading, then skip. if ( in_array( $field_type, [ 'ui-step', 'ui-html', 'ui-heading', 'ui-image' ], true ) ) { continue; } // Update the repeater field data. if ( 'repeater' === $field_type ) { $repeater_fields = $field['fields']; $repeater_values_final = []; if ( count( $repeater_fields ) > 1 ) { foreach ( $fields[ $field_key ] as $row_index => $row_values ) { $repeater_value = []; foreach ( $repeater_fields as $input_key => $input_field ) { if ( isset( $row_values[ $input_field['key'] ] ) ) { $repeater_value[ $input_field['key'] ] = $row_values[ $input_field['key'] ]; } } if ( ! empty( $repeater_value ) ) { $repeater_values_final[] = $repeater_value; } } } if ( ! empty( $repeater_values_final ) ) { $post_field->update( $repeater_values_final ); } continue; } $field_inputs = $field_opts[ $field_type ]['fields']; $field_value = ''; // If input field is location, then update the location. if ( 'location' === $field_key ) { $location_values = $field_opts[ $field_key ]['value']; $gallery_value = []; foreach ( $location_values as $value_item => $item_value ) { if ( isset( $fields[ $field_key . '_' . $value_item ] ) ) { $location_value[ $value_item ] = $fields[ $field_key . '_' . $value_item ]; } } if ( ! empty( $location_value ) ) { $post_field->update( $location_value ); } continue; } // If field inputs are more than one, then get the value from the inputs. if ( count( $field_inputs ) > 1 ) { $field_value = []; foreach ( $field_inputs as $input_key => $input_field ) { if ( isset( $fields[ $field_key . '_' . $input_field['key'] ] ) ) { $field_value[ $field_key ] = $fields[ $field_key . '_' . $input_field['key'] ]; } } } // Update work hours field. if ( 'work-hours' === $field_type ) { $schedules = []; foreach ( $fields[ $field_key ] as $schedule ) { $work_days_value = []; $field_value = []; if ( isset( $schedule['work_days'] ) ) { $work_days_value = explode( ',', $schedule['work_days'] ); $field_value['days'] = $work_days_value; } if ( array_key_exists( 'work_hours', $schedule ) && isset( $schedule['work_hours'] ) ) { $work_hours_array = explode( '-', $schedule['work_hours'] ); $formatted_work_hours = [ [ 'from' => isset( $work_hours_array[0] ) ? $work_hours_array[0] : '', 'to' => isset( $work_hours_array[1] ) ? $work_hours_array[1] : '', ], ]; $field_value['hours'] = $formatted_work_hours; } if ( isset( $schedule['work_status'] ) ) { $field_value['status'] = $schedule['work_status']; } if ( ! empty( $field_value ) ) { $schedules[] = $field_value; } } if ( ! empty( $schedules ) ) { $post_field->update( $schedules ); } continue; } // Update event-date field. if ( 'recurring-date' === $field_type || 'event-date' === $field_type ) { $event_date_value = []; $field_value = []; if ( isset( $fields[ $field_key . '_event_start_date' ] ) ) { $event_date_value['start'] = $fields[ $field_key . '_event_start_date' ]; } if ( isset( $fields[ $field_key . '_event_end_date' ] ) ) { $event_date_value['end'] = $fields[ $field_key . '_event_end_date' ]; } if ( isset( $fields[ $field_key . '_event_frequency' ] ) ) { $event_date_value['frequency'] = $fields[ $field_key . '_event_frequency' ]; } if ( isset( $fields[ $field_key . '_repeat_every' ] ) ) { $event_date_value['unit'] = $fields[ $field_key . '_repeat_every' ]; } if ( isset( $fields[ $field_key . '_event_until' ] ) ) { $event_date_value['until'] = $fields[ $field_key . '_event_until' ]; } if ( ! empty( $event_date_value ) ) { $post_field->update( [ $event_date_value ] ); } continue; } // If field is available in the fields, then update the post field. if ( isset( $fields[ $field_key ] ) ) { $field_value = $fields[ $field_key ]; if ( '' != $field_value ) { if ( in_array( $field_type, [ 'file', 'image', 'profile-avatar' ], true ) ) { $field_value = [ [ 'source' => 'existing', 'file_id' => (int) $field_value, ], ]; } elseif ( 'post-relation' === $field_type ) { $field_value = array_map( function( $post_id ) { return (int) $post_id; }, explode( ',', $field_value ) ); } elseif ( 'taxonomy' === $field_type ) { $field_value = explode( ',', $field_value ); } // If value is boolean false, then set it to false. if ( 'false' === $field_value ) { $field_value = false; } $post_field->update( $field_value ); } } } return true; } /** * Voxel fields with types and input requirements. * * @access public * @since 1.0 * @return array */ public static function get_fields() { return [ // Post type fields. 'title' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'title', 'label' => esc_attr__( 'Title', 'suretriggers' ), 'type' => 'text', ], ], ], 'description' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'description', 'label' => esc_attr__( 'Description', 'suretriggers' ), 'type' => 'text', ], ], ], 'timezone' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'timezone', 'label' => esc_attr__( 'Timezone', 'suretriggers' ), 'type' => 'text', ], ], ], 'location' => [ 'type' => 'array', 'value' => [ 'address' => '', 'latitude' => '', 'longitude' => '', ], 'fields' => [ [ 'key' => 'address', 'label' => esc_attr__( 'Address', 'suretriggers' ), 'type' => 'text', ], [ 'key' => 'latitude', 'label' => esc_attr__( 'Latitude', 'suretriggers' ), 'type' => 'text', ], [ 'key' => 'longitude', 'label' => esc_attr__( 'Longitude', 'suretriggers' ), 'type' => 'text', ], ], ], 'email' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'email', 'label' => esc_attr__( 'Email', 'suretriggers' ), 'type' => 'text', ], ], ], 'logo' => [ 'type' => 'array', 'value' => [ 0 ], 'fields' => [ [ 'key' => 'image_id', 'label' => esc_attr__( 'Image ID', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide Image ID', 'suretriggers' ), ], ], ], 'cover-image' => [ 'type' => 'array', 'value' => [ 0 ], 'fields' => [ [ 'key' => 'image_id', 'label' => esc_attr__( 'Image ID', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide Image ID', 'suretriggers' ), ], ], ], 'gallery' => [ 'type' => 'array', 'value' => [ [ 0 ], ], 'fields' => [ [ 'key' => 'image_id', 'label' => esc_attr__( 'Image ID', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide Image IDs, separated by comma', 'suretriggers' ), ], ], ], 'featured-image' => [ 'type' => 'array', 'value' => [ 0 ], 'fields' => [ [ 'key' => 'image_id', 'label' => esc_attr__( 'Image ID', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide Image IDs, separated by comma', 'suretriggers' ), ], ], ], 'website' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'website', 'label' => esc_attr__( 'Website URL', 'suretriggers' ), 'type' => 'text', ], ], ], 'phone-number' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'phone_number', 'label' => esc_attr__( 'Phone Number', 'suretriggers' ), 'type' => 'text', ], ], ], 'event-date' => [ 'type' => 'array', 'value' => [ 'start' => '', 'end' => '', 'frequency' => '', 'unit' => '', 'until' => '', ], 'fields' => [ [ 'key' => 'event_start_date', 'label' => esc_attr__( 'Event Start Date', 'suretriggers' ), 'type' => 'text', ], [ 'key' => 'event_end_date', 'label' => esc_attr__( 'Event End Date', 'suretriggers' ), 'type' => 'text', ], [ 'key' => 'event_frequency', 'label' => esc_attr__( 'Event Frequency', 'suretriggers' ), 'type' => 'text', ], [ 'key' => 'repeat_every', 'label' => esc_attr__( 'Event Unit', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Accepted values: day, week, month, year', 'suretriggers' ), ], [ 'key' => 'event_until', 'label' => esc_attr__( 'Event Until', 'suretriggers' ), 'type' => 'text', ], ], ], 'work-hours' => [ 'type' => 'array', 'value' => [ [ 'days', 'status', 'hours', ], ], 'fields' => [ [ 'key' => 'work_days', 'label' => esc_attr__( 'Work Days', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Accepted values: mon, tue, wed, thu, fri, sat, sun', 'suretriggers' ), ], [ 'key' => 'work_hours', 'label' => esc_attr__( 'Work Hours', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Enter value pairs as start and end time, separated by dash. For multiple pairs, use comma separator. Eg. 09:00-17:00, 09:00-12:00', 'suretriggers' ), ], [ 'key' => 'work_status', 'label' => esc_attr__( 'Work Status', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Accepted values: hours, open, close, appointments_only', 'suretriggers' ), ], ], ], 'profile-picture' => [ 'type' => 'array', 'value' => [ 0 ], 'fields' => [ [ 'key' => 'image_id', 'label' => esc_attr__( 'Image ID', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide Image ID', 'suretriggers' ), ], ], ], 'profile-avatar' => [ 'type' => 'array', 'value' => [ 0 ], 'fields' => [ [ 'key' => 'image_id', 'label' => esc_attr__( 'Image ID', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide Image ID', 'suretriggers' ), ], ], ], 'profile-name' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'profile_name', 'label' => esc_attr__( 'Profile Name', 'suretriggers' ), 'type' => 'text', ], ], ], // Custom field types. 'text' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'text', 'label' => esc_attr__( 'Text', 'suretriggers' ), 'type' => 'text', ], ], ], 'number' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'number', 'label' => esc_attr__( 'Number', 'suretriggers' ), 'type' => 'text', ], ], ], 'switcher' => [ 'type' => 'switcher', 'value' => true, 'fields' => [ [ 'key' => 'switcher', 'label' => esc_attr__( 'Switcher', 'suretriggers' ), 'type' => 'yes/no', ], ], ], 'texteditor' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'text_editor', 'label' => esc_attr__( 'Text Editor', 'suretriggers' ), 'type' => 'textarea', ], ], ], 'taxonomy' => [ 'type' => 'array', 'value' => [], 'fields' => [ [ 'key' => 'taxonomy', 'label' => esc_attr__( 'Taxonomy Slug', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide related taxonomy slug(s). If multiples allowed, separate with comma.', 'suretriggers' ), ], ], ], 'product' => [ 'type' => 'array', 'value' => [], 'fields' => [ [ 'key' => 'product', 'label' => esc_attr__( 'Product ID', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide Product ID', 'suretriggers' ), ], ], ], 'phone' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'phone', 'label' => esc_attr__( 'Phone', 'suretriggers' ), 'type' => 'text', ], ], ], 'url' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'url', 'label' => esc_attr__( 'URL', 'suretriggers' ), 'type' => 'text', ], ], ], 'image' => [ 'type' => 'array', 'value' => [ 'url' => '', 'alt' => '', ], 'fields' => [ [ 'key' => 'image_id', 'label' => esc_attr__( 'Image ID', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide Image IDs. Separate with comma.', 'suretriggers' ), ], ], ], 'file' => [ 'type' => 'array', 'value' => [ 'url' => '', 'alt' => '', ], 'fields' => [ [ 'key' => 'file_id', 'label' => esc_attr__( 'File ID', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide File ID', 'suretriggers' ), ], ], ], 'repeater' => [ 'type' => 'array', 'value' => [ [ 'url' => '', 'alt' => '', ], ], 'fields' => [ [ 'key' => 'repeater', 'label' => esc_attr__( 'Repeater', 'suretriggers' ), 'type' => 'repeater', ], ], ], 'recurring-date' => [ 'type' => 'array', 'value' => [ [ 'start' => '', 'end' => '', 'frequency' => '', 'unit' => '', 'until' => '', ], ], 'fields' => [ [ 'key' => 'event_start_date', 'label' => esc_attr__( 'Event Start Date', 'suretriggers' ), 'type' => 'text', ], [ 'key' => 'event_end_date', 'label' => esc_attr__( 'Event End Date', 'suretriggers' ), 'type' => 'text', ], [ 'key' => 'event_frequency', 'label' => esc_attr__( 'Event Frequency', 'suretriggers' ), 'type' => 'text', ], [ 'key' => 'repeat_every', 'label' => esc_attr__( 'Event Unit', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Accepted values: day, week, month, year', 'suretriggers' ), ], [ 'key' => 'event_until', 'label' => esc_attr__( 'Event Until', 'suretriggers' ), 'type' => 'text', ], ], ], 'post-relation' => [ 'type' => 'array', 'value' => [ 0 ], 'fields' => [ [ 'key' => 'post_id', 'label' => esc_attr__( 'Post ID', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide Post ID', 'suretriggers' ), ], ], ], 'date' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'date', 'label' => esc_attr__( 'Date', 'suretriggers' ), 'type' => 'text', ], ], ], 'select' => [ 'type' => 'text', 'value' => '', 'fields' => [ [ 'key' => 'select', 'label' => esc_attr__( 'Select', 'suretriggers' ), 'type' => 'select', ], ], ], 'color' => [ 'type' => 'color', 'value' => '', 'fields' => [ [ 'key' => 'color', 'label' => esc_attr__( 'Color', 'suretriggers' ), 'type' => 'text', ], ], ], // Layout fields. 'ui-image' => [ 'type' => 'array', 'value' => [ 0 ], 'fields' => [ [ 'key' => 'image_id', 'label' => esc_attr__( 'Image IDs', 'suretriggers' ), 'type' => 'text', 'help' => esc_attr__( 'Provide Image IDs. Separate with comma.', 'suretriggers' ), ], ], ], ]; } /** * Sanitize the content. * * @access public * @since 1.0 * @param string $content Content to sanitize. * @return string|bool */ public static function sanitize_content( $content ) { if ( ! class_exists( 'Voxel\Timeline\Fields\Status_Message_Field' ) ) { return false; } $field = new \Voxel\Timeline\Fields\Status_Message_Field(); $content = $field->sanitize( $content ); $field->validate( $content ); return $content; } /** * Sanitize the files. * * @access public * @since 1.0 * @param array $files Files to sanitize. * @return array */ public static function sanitize_files( $files ) { if ( ! function_exists( 'Voxel\get' ) ) { return []; } if ( ! \Voxel\get( 'settings.timeline.posts.images.enabled', true ) || ! class_exists( 'Voxel\Timeline\Fields\Status_Files_Field' ) ) { return []; } $field = new \Voxel\Timeline\Fields\Status_Files_Field(); $files = $field->sanitize( $files ); $field->validate( $files ); $file_ids = $field->prepare_for_storage( $files ); return $file_ids; } /** * Get Post Fields and it's values. * * @access public * @since 1.0 * @param int $post_id Post ID. * @return array */ public static function get_post_fields( $post_id ) { if ( ! class_exists( 'Voxel\Post' ) ) { return []; } $post = \Voxel\Post::force_get( $post_id ); $context = []; $context_data = []; if ( ! empty( $post ) ) { $fields = $post->get_fields(); if ( is_array( $fields ) && ! empty( $fields ) ) { foreach ( $fields as $field ) { $field_key = $field->get_key(); $field_type = $field->get_type(); $field_value = $field->get_value(); $field_content = null; switch ( $field_type ) { case 'taxonomy': $field_content = join( ', ', array_map( function( $term ) { return $term->get_label(); }, $field_value ) ); break; case 'location': $field_content = $field_value['address']; break; case 'work-hours': $hours = []; if ( is_array( $field_value ) && ! empty( $field_value ) ) { foreach ( $field_value as $work_hour ) { if ( 'hours' === $work_hour['status'] ) { foreach ( $work_hour['days'] as $day ) { foreach ( $work_hour['hours'] as $hour_key => $hour ) { $hours[ $day . '_' . $hour_key ] = $hour['from'] . '-' . $hour['to']; } } } } } $field_content = $field_value; $context[ $field_key . '_simplified' ] = wp_json_encode( $hours ); break; case 'file': case 'image': case 'profile-avatar': case 'gallery': if ( is_array( $field_value ) ) { foreach ( $field_value as $file_key => $file_id ) { $field_content[ $field_key . '_' . $file_key . '_url' ] = wp_get_attachment_url( $file_id ); } } else { $field_content[ $field_key . '_url' ] = wp_get_attachment_url( $field_value ); } break; default: $field_content = $field_value; break; } $context[ $field_key ] = $field_content; } } } if ( ! empty( $context ) ) { foreach ( $context as $key => $value ) { $context_data[ 'field_' . $key ] = $value; } } return $context_data; } /** * Custom hook for Follow post and UnFollow Post triggers. * * @access public * @since 1.0 * @return void */ public function suretriggers_voxel_follow_post() { if ( ! function_exists( 'Voxel\current_user' ) || ! class_exists( 'Voxel\Post' ) ) { return; } if ( isset( $_GET['_wpnonce'] ) ) { if ( ! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'vx_user_follow' ) ) { return; } } if ( isset( $_GET['action'] ) && 'user.follow_post' === $_GET['action'] ) { $current_user = \Voxel\current_user(); $post_id = ! empty( $_GET['post_id'] ) ? absint( $_GET['post_id'] ) : null; if ( ! $post_id ) { return; } $post = \Voxel\Post::get( $post_id ); if ( $post && $current_user ) { $current_status = $current_user->get_follow_status( 'post', $post->get_id() ); $new_status = ( 1 === $current_status ) ? 'unfollow' : 'follow'; $follow_data = [ 'post_id' => $post_id, 'user_id' => $current_user->get_id(), 'status' => $new_status, ]; $follow_data = array_merge( $follow_data, self::get_post_fields( $post_id ), WordPress::get_post_context( $post_id ) ); $action_to_perform = ( 'follow' === $new_status ) ? 'st_voxel_post_followed' : 'st_voxel_post_unfollowed'; do_action( $action_to_perform, $follow_data ); } } } /** * Is Plugin depended plugin is installed or not. * * @return bool */ public function is_plugin_installed() { $bricks_theme = wp_get_theme( 'voxel' ); return $bricks_theme->exists(); } } IntegrationsController::register( Voxel::class ); triggers/comment-reply-created-timeline.php 0000644 00000005334 15006204201 0015102 0 ustar 00 <?php /** * CommentReplyCreatedTimeline. * php version 5.6 * * @category CommentReplyCreatedTimeline * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'CommentReplyCreatedTimeline' ) ) : /** * CommentReplyCreatedTimeline * * @category CommentReplyCreatedTimeline * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class CommentReplyCreatedTimeline { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_comment_reply_created_timeline'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'New Comment Reply Created on Timeline', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/timeline/comment-reply:created', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'reply' ) || ! property_exists( $event, 'comment' ) ) { return; } $context['replied_by'] = WordPress::get_user_context( $event->reply->get_user_id() ); $context['comment_by'] = WordPress::get_user_context( $event->comment->get_user_id() ); $context['comment'] = $event->comment->get_content(); $context['comment_id'] = $event->comment->get_id(); $context['reply_id'] = $event->reply->get_id(); $context['reply'] = $event->reply->get_content(); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ CommentReplyCreatedTimeline::get_instance(); endif; triggers/membership-user-registered.php 0000644 00000004453 15006204201 0014341 0 ustar 00 <?php /** * MembershipUserRegistered. * php version 5.6 * * @category MembershipUserRegistered * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'MembershipUserRegistered' ) ) : /** * MembershipUserRegistered * * @category MembershipUserRegistered * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class MembershipUserRegistered { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_membership_user_registered'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'User Registered', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/membership/user:registered', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'user' ) ) { return; } $context = WordPress::get_user_context( $event->user->get_id() ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ MembershipUserRegistered::get_instance(); endif; triggers/post-submitted.php 0000644 00000005717 15006204201 0012066 0 ustar 00 <?php /** * PostSubmitted. * php version 5.6 * * @category PostSubmitted * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Controllers\OptionController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'PostSubmitted' ) ) : /** * PostSubmitted * * @category PostSubmitted * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class PostSubmitted { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_submitted'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $trigger_data = OptionController::get_option( 'trigger_data' ); $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Post Submitted', 'suretriggers' ), 'action' => $this->trigger, 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; if ( ! empty( $trigger_data ) && is_array( $trigger_data ) && isset( $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] ) ) { $triggers[ $this->integration ][ $this->trigger ]['common_action'] = 'voxel/app-events/post-types/' . $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] . '/post:submitted'; } return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) ) { return; } $post = WordPress::get_post_context( $event->post->get_id() ); $context = $post; $context['post'] = Voxel::get_post_fields( $event->post->get_id() ); // Get the post type. $post_type = get_post_type( $event->post->get_id() ); $context['post_type'] = $post_type; AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ PostSubmitted::get_instance(); endif; triggers/order-approved-by-vendor.php 0000644 00000012555 15006204201 0013735 0 ustar 00 <?php /** * OrderApprovedByVendor. * php version 5.6 * * @category OrderApprovedByVendor * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'OrderApprovedByVendor' ) ) : /** * OrderApprovedByVendor * * @category OrderApprovedByVendor * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class OrderApprovedByVendor { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_order_approved_by_vendor'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Order Approved By Vendor', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/products/orders/vendor:order_approved', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'order' ) || ! property_exists( $event, 'customer' ) ) { return; } // Get Order. $order = $event->order; $context['id'] = $order->get_id(); $context['vendor_id'] = $order->get_vendor_id(); $context['details'] = $order->get_details(); $context['payment_method'] = $order->get_payment_method_key(); $context['tax_amount'] = $order->get_tax_amount(); $context['discount_amount'] = $order->get_discount_amount(); $context['shipping_amount'] = $order->get_shipping_amount(); $context['status'] = $order->get_status(); $context['created_at'] = $order->get_created_at(); $context['subtotal'] = $order->get_subtotal(); $context['total'] = $order->get_total(); // Get order items. $order_items = $order->get_items(); $context['order_item_count'] = $order->get_item_count(); foreach ( $order_items as $item ) { $addon_data = []; if ( is_object( $item ) && method_exists( $item, 'get_addons' ) ) { $addons = $item->get_addons(); $addon_data = []; if ( $addons && isset( $addons['summary'] ) ) { $addon_data = $addons['summary']; } } $context['order_items'][] = [ 'id' => $item->get_id(), 'type' => $item->get_type(), 'currency' => $item->get_currency(), 'quantity' => $item->get_quantity(), 'subtotal' => $item->get_subtotal(), 'product_id' => $item->get_post()->get_id(), 'product_label' => $item->get_product_label(), 'product_thumbnail_url' => $item->get_product_thumbnail_url(), 'product_link' => $item->get_product_link(), 'description' => $item->get_product_description(), 'addon_data' => $addon_data, ]; // If booking item, get booking details. if ( 'booking' === $item->get_type() ) { $details = $item->get_order_page_details(); $context['order_items']['booking_type'] = $details['booking']['type']; if ( isset( $details['booking']['count_mode'] ) ) { $context['order_items']['booking_count_mode'] = $details['booking']['count_mode']; } if ( 'date_range' === $details['booking']['type'] ) { $context['order_items']['booking_start_date'] = $details['booking']['start_date']; $context['order_items']['booking_end_date'] = $details['booking']['end_date']; } elseif ( 'single_day' === $details['booking']['type'] ) { $context['order_items']['booking_date'] = $details['booking']['date']; } elseif ( 'timeslots' === $details['booking']['type'] ) { $context['order_items']['booking_date'] = $details['booking']['date']; $context['order_items']['booking_slot_from'] = $details['booking']['slot']['from']; $context['order_items']['booking_slot_to'] = $details['booking']['slot']['to']; } } } // Get Customer. $context['customer'] = WordPress::get_user_context( $event->customer->get_id() ); // Get Vendor. $context['vendor'] = WordPress::get_user_context( $order->get_vendor_id() ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ OrderApprovedByVendor::get_instance(); endif; triggers/profile-reviewed.php 0000644 00000007371 15006204201 0012351 0 ustar 00 <?php /** * ProfileReviewed. * php version 5.6 * * @category ProfileReviewed * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; if ( ! class_exists( 'ProfileReviewed' ) ) : /** * ProfileReviewed * * @category ProfileReviewed * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class ProfileReviewed { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_profile_reviewed'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Profile Reviewed', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/post-types/profile/review:created', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) || ! class_exists( 'Voxel\Timeline\Status' ) || ! class_exists( 'Voxel\Post_Type' ) ) { return; } $context = []; // Get the review details. $args = [ 'post_id' => $event->post->get_id(), ]; $statuses = \Voxel\Timeline\Status::query( $args ); $review_details = $statuses['items'][0]; foreach ( (array) $review_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); if ( 'user_can_edit' == $clean_key || 'publisher' == $clean_key || 'user_can_edit' == $clean_key || 'user_can_moderate' == $clean_key ) { continue; } if ( 'files' === $clean_key ) { $value = wp_json_encode( $value ); } elseif ( 'details' === $clean_key ) { $review_ratings = isset( $value['rating'] ) && is_array( $value['rating'] ) ? $value['rating'] : []; $value['rating'] = []; $type = \Voxel\Post_Type::get( 'profile' ); if ( ! empty( $review_ratings ) ) { $rating_levels = $type->reviews->get_rating_levels(); $categories = $type->reviews->get_categories(); foreach ( $categories as $category ) { $category_key = $category['key']; $category_label = strtolower( $category['label'] ); if ( isset( $review_ratings[ $category_key ] ) && $category_label ) { foreach ( $rating_levels as $rating_level ) { if ( $review_ratings[ $category_key ] === $rating_level['score'] ) { $value['rating'][ $category_label ] = $rating_level['label']; break; } } } } } } else { $clean_key = 'review_' . $clean_key; } $context[ $clean_key ] = $value; } AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ ProfileReviewed::get_instance(); endif; triggers/timeline-post-approved.php 0000644 00000006063 15006204201 0013505 0 ustar 00 <?php /** * VoxelTimelinePostApproved. * php version 5.6 * * @category VoxelTimelinePostApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Controllers\OptionController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'VoxelTimelinePostApproved' ) ) : /** * VoxelTimelinePostApproved * * @category VoxelTimelinePostApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelTimelinePostApproved { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_timeline_post_approved'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $trigger_data = OptionController::get_option( 'trigger_data' ); $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Timeline Post Approved', 'suretriggers' ), 'action' => $this->trigger, 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; if ( ! empty( $trigger_data ) && is_array( $trigger_data ) && isset( $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] ) ) { $triggers[ $this->integration ][ $this->trigger ]['common_action'] = 'voxel/app-events/post-types/' . $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] . '/status:approved'; } return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) ) { return; } $post = WordPress::get_post_context( $event->post->get_id() ); $context = $post; $context['post'] = Voxel::get_post_fields( $event->post->get_id() ); // Get the post type. $post_type = get_post_type( $event->post->get_id() ); $context['post_type'] = $post_type; AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelTimelinePostApproved::get_instance(); endif; triggers/orders-promotion-canceled.php 0000644 00000007426 15006204201 0014160 0 ustar 00 <?php /** * OrdersPromotionCanceled. * php version 5.6 * * @category OrdersPromotionCanceled * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'OrdersPromotionCanceled' ) ) : /** * OrdersPromotionCanceled * * @category OrdersPromotionCanceled * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class OrdersPromotionCanceled { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_orders_promotion_canceled'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Order Promotion Canceled', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/promotions/promotion:canceled', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'order' ) || ! property_exists( $event, 'customer' ) ) { return; } $order = $event->order; $context['id'] = $order->get_id(); $context['payment_method'] = $order->get_payment_method_key(); $context['tax_amount'] = $order->get_tax_amount(); $context['discount_amount'] = $order->get_discount_amount(); $context['shipping_amount'] = $order->get_shipping_amount(); $context['status'] = $order->get_status(); $context['created_at'] = $order->get_created_at(); $context['subtotal'] = $order->get_subtotal(); $context['total'] = $order->get_total(); // Get order items. $order_items = $order->get_items(); $context['order_item_count'] = $order->get_item_count(); foreach ( $order_items as $item ) { $context['order_items'][] = [ 'id' => $item->get_id(), 'type' => $item->get_type(), 'currency' => $item->get_currency(), 'quantity' => $item->get_quantity(), 'subtotal' => $item->get_subtotal(), 'product_id' => $item->get_post()->get_id(), 'product_label' => $item->get_product_label(), 'product_thumbnail_url' => $item->get_product_thumbnail_url(), 'product_link' => $item->get_product_link(), 'description' => $item->get_product_description(), ]; } $context['details'] = $order->get_details(); // Get Customer. $context['customer'] = WordPress::get_user_context( $event->customer->get_id() ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ OrdersPromotionCanceled::get_instance(); endif; triggers/post-reviewed.php 0000644 00000006425 15006204201 0011675 0 ustar 00 <?php /** * PostReviewed. * php version 5.6 * * @category PostReviewed * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Controllers\OptionController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'PostReviewed' ) ) : /** * PostReviewed * * @category PostReviewed * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class PostReviewed { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_reviewed'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $trigger_data = OptionController::get_option( 'trigger_data' ); $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Post Reviewed', 'suretriggers' ), 'action' => $this->trigger, 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; if ( ! empty( $trigger_data ) && is_array( $trigger_data ) && isset( $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] ) ) { $triggers[ $this->integration ][ $this->trigger ]['common_action'] = 'voxel/app-events/post-types/' . $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] . '/review:created'; } return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) || ! property_exists( $event, 'review' ) ) { return; } $context = WordPress::get_post_context( $event->post->get_id() ); $context['post'] = Voxel::get_post_fields( $event->post->get_id() ); $context['review_content'] = $event->review->get_content(); $context['review_created_at'] = $event->review->get_created_at(); $context['review_details'] = $event->review->get_details(); $context['review_by'] = WordPress::get_user_context( $event->review->get_user_id() ); // Get the post type. $post_type = get_post_type( $event->post->get_id() ); $context['post_type'] = $post_type; AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ PostReviewed::get_instance(); endif; triggers/voxel-post-unfollowed.php 0000644 00000004715 15006204201 0013374 0 ustar 00 <?php /** * VoxelPostUnFollowed. * php version 5.6 * * @category VoxelPostUnFollowed * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; if ( ! class_exists( 'VoxelPostUnFollowed' ) ) : /** * VoxelPostUnFollowed * * @category VoxelPostUnFollowed * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelPostUnFollowed { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_unfollowed'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Post UnFollowed', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'st_voxel_post_unfollowed', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param array $unfollow_data UnFollow data. * @return void */ public function trigger_listener( $unfollow_data ) { if ( empty( $unfollow_data ) ) { return; } global $wpdb; $sql = "SELECT COUNT(*) FROM {$wpdb->prefix}voxel_followers WHERE object_id= %d"; $followers = $wpdb->get_var( $wpdb->prepare( $sql, $unfollow_data['ID'] ));// @phpcs:ignore $unfollow_data['total_followers'] = $followers; $context = $unfollow_data; AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelPostUnFollowed::get_instance(); endif; triggers/new-wall-post-by-user.php 0000644 00000007544 15006204201 0013200 0 ustar 00 <?php /** * NewWallPostByUser. * php version 5.6 * * @category NewWallPostByUser * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Controllers\OptionController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'NewWallPostByUser' ) ) : /** * NewWallPostByUser * * @category NewWallPostByUser * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class NewWallPostByUser { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_new_wall_post_by_user'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $trigger_data = OptionController::get_option( 'trigger_data' ); $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'New Wall Post by User', 'suretriggers' ), 'action' => $this->trigger, 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; if ( ! empty( $trigger_data ) && is_array( $trigger_data ) && isset( $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] ) ) { $triggers[ $this->integration ][ $this->trigger ]['common_action'] = 'voxel/app-events/post-types/' . $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] . '/wall-post:created'; } return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'status' ) || ! property_exists( $event, 'post' ) || ! property_exists( $event, 'author' ) ) { return; } $context['post'] = Voxel::get_post_fields( $event->status->get_post_id() ); $user = get_userdata( $event->author->get_id() ); if ( $user ) { $user_data = (array) $user->data; $context['user_display_name'] = $user_data['display_name']; $context['user_name'] = $user_data['user_nicename']; $context['user_email'] = $user_data['user_email']; $context['user_id'] = $event->status->get_author(); } if ( class_exists( 'Voxel\Timeline\Status' ) ) { // Get the status details. $status_details = \Voxel\Timeline\Status::get( $event->status->get_id() ); foreach ( (array) $status_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); if ( is_object( $value ) ) { $encoded_value = wp_json_encode( $value ); if ( is_string( $encoded_value ) ) { $value = json_decode( $encoded_value, true ); } } $context['wall_post'][ $clean_key ] = $value; } } // Get the post type. $post_type = get_post_type( $event->post->get_id() ); $context['post_type'] = $post_type; AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ NewWallPostByUser::get_instance(); endif; triggers/membership-plan-activated.php 0000644 00000005712 15006204201 0014123 0 ustar 00 <?php /** * MembershipPlanActivated. * php version 5.6 * * @category MembershipPlanActivated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'MembershipPlanActivated' ) ) : /** * MembershipPlanActivated * * @category MembershipPlanActivated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class MembershipPlanActivated { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_membership_plan_activated'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Membership Plan Activated', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/membership/plan:activated', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'user' ) || ! class_exists( 'Voxel\Stripe' ) ) { return; } global $wpdb; $context = WordPress::get_user_context( $event->user->get_id() ); $meta_key = \Voxel\Stripe::is_test_mode() ? 'voxel:test_plan' : 'voxel:plan'; $sql = "SELECT m.user_id AS id, m.meta_value AS details FROM wp_usermeta as m LEFT JOIN wp_users AS u ON m.user_id = u.ID WHERE m.meta_key = %s AND m.user_id = %d AND JSON_UNQUOTE( JSON_EXTRACT( m.meta_value, '$.plan' ) ) != 'default' ORDER BY m.user_id DESC LIMIT 25 OFFSET 0"; $results = $wpdb->get_results( $wpdb->prepare( $sql, $meta_key, $event->user->get_id() ), ARRAY_A );// @phpcs:ignore $context['details'] = json_decode( $results[0]['details'], true ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ MembershipPlanActivated::get_instance(); endif; triggers/membership-plan-switched.php 0000644 00000005700 15006204201 0013766 0 ustar 00 <?php /** * MembershipPlanSwitched. * php version 5.6 * * @category MembershipPlanSwitched * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'MembershipPlanSwitched' ) ) : /** * MembershipPlanSwitched * * @category MembershipPlanSwitched * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class MembershipPlanSwitched { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_membership_plan_switched'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Membership Plan Switched', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/membership/plan:switched', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'user' ) || ! class_exists( 'Voxel\Stripe' ) ) { return; } global $wpdb; $context = WordPress::get_user_context( $event->user->get_id() ); $meta_key = \Voxel\Stripe::is_test_mode() ? 'voxel:test_plan' : 'voxel:plan'; $sql = "SELECT m.user_id AS id, m.meta_value AS details FROM wp_usermeta as m LEFT JOIN wp_users AS u ON m.user_id = u.ID WHERE m.meta_key = %s AND m.user_id = %d AND JSON_UNQUOTE( JSON_EXTRACT( m.meta_value, '$.plan' ) ) != 'default' ORDER BY m.user_id DESC LIMIT 25 OFFSET 0"; $results = $wpdb->get_results( $wpdb->prepare( $sql, $meta_key, $event->user->get_id() ), ARRAY_A );// @phpcs:ignore $context['details'] = json_decode( $results[0]['details'], true ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ MembershipPlanSwitched::get_instance(); endif; triggers/users-timeline-approved.php 0000644 00000005703 15006204201 0013661 0 ustar 00 <?php /** * VoxelUsersTimelineApproved. * php version 5.6 * * @category VoxelUsersTimelineApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'VoxelUsersTimelineApproved' ) ) : /** * VoxelUsersTimelineApproved * * @category VoxelUsersTimelineApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelUsersTimelineApproved { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_users_timeline_approved'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Users Timeline Approved', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/users/timeline/status:approved', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'status' ) || ! property_exists( $event, 'author' ) ) { return; } $user = get_userdata( $event->author->get_id() ); if ( $user ) { $user_data = (array) $user->data; $context['user_display_name'] = $user_data['display_name']; $context['user_name'] = $user_data['user_nicename']; $context['user_email'] = $user_data['user_email']; } if ( class_exists( 'Voxel\Timeline\Status' ) ) { $status_details = \Voxel\Timeline\Status::get( $event->status->get_id() ); foreach ( (array) $status_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); $context[ $clean_key ] = $value; } } if ( ! empty( $context ) ) { AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelUsersTimelineApproved::get_instance(); endif; triggers/new-profile-created.php 0000644 00000005202 15006204201 0012724 0 ustar 00 <?php /** * NewProfileCreated. * php version 5.6 * * @category NewProfileCreated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'NewProfileCreated' ) ) : /** * NewProfileCreated * * @category NewProfileCreated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class NewProfileCreated { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_new_profile_created'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'New Profile Created', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/post-types/profile/post:submitted', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) ) { return; } $context = Voxel::get_post_fields( $event->post->get_id() ); $user = get_userdata( $event->post->get_author() ); if ( $user ) { $user_data = (array) $user->data; $context['profile_display_name'] = $user_data['display_name']; $context['profile_email'] = $user_data['user_email']; $context['profile_user_id'] = $user_data['ID']; $context['profile_id'] = $event->post->get_id(); } AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ NewProfileCreated::get_instance(); endif; triggers/profile-updated.php 0000644 00000005311 15006204201 0012155 0 ustar 00 <?php /** * ProfileUpdated. * php version 5.6 * * @category ProfileUpdated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'ProfileUpdated' ) ) : /** * ProfileUpdated * * @category ProfileUpdated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class ProfileUpdated { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_profile_updated'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Profile Updated', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/post-types/profile/post:updated', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) || ! property_exists( $event, 'author' ) ) { return; } $context = Voxel::get_post_fields( $event->post->get_id() ); $user = get_userdata( $event->author->get_id() ); if ( $user ) { $user_data = (array) $user->data; $context['profile_display_name'] = $user_data['display_name']; $context['profile_email'] = $user_data['user_email']; $context['profile_user_id'] = $user_data['ID']; $context['field_voxel:name'] = $user_data['display_name']; $context['profile_id'] = $event->post->get_id(); } AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ ProfileUpdated::get_instance(); endif; triggers/orders-claim-listing.php 0000644 00000007343 15006204201 0013130 0 ustar 00 <?php /** * OrdersClaimListing. * php version 5.6 * * @category OrdersClaimListing * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'OrdersClaimListing' ) ) : /** * OrdersClaimListing * * @category OrdersClaimListing * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class OrdersClaimListing { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_orders_claim_listing'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Orders Claim Listing', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/claims/claim:processed', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'order' ) || ! property_exists( $event, 'customer' ) ) { return; } $order = $event->order; $context['id'] = $order->get_id(); $context['payment_method'] = $order->get_payment_method_key(); $context['tax_amount'] = $order->get_tax_amount(); $context['discount_amount'] = $order->get_discount_amount(); $context['shipping_amount'] = $order->get_shipping_amount(); $context['status'] = $order->get_status(); $context['created_at'] = $order->get_created_at(); $context['subtotal'] = $order->get_subtotal(); $context['total'] = $order->get_total(); // Get order items. $order_items = $order->get_items(); $context['order_item_count'] = $order->get_item_count(); foreach ( $order_items as $item ) { $context['order_items'][] = [ 'id' => $item->get_id(), 'type' => $item->get_type(), 'currency' => $item->get_currency(), 'quantity' => $item->get_quantity(), 'subtotal' => $item->get_subtotal(), 'product_id' => $item->get_post()->get_id(), 'product_label' => $item->get_product_label(), 'product_thumbnail_url' => $item->get_product_thumbnail_url(), 'product_link' => $item->get_product_link(), 'description' => $item->get_product_description(), ]; } $context['details'] = $order->get_details(); // Get Customer. $context['customer'] = WordPress::get_user_context( $event->customer->get_id() ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ OrdersClaimListing::get_instance(); endif; triggers/wall-post-approved.php 0000644 00000007572 15006204201 0012644 0 ustar 00 <?php /** * VoxelWallPostApproved. * php version 5.6 * * @category VoxelWallPostApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Controllers\OptionController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'VoxelWallPostApproved' ) ) : /** * VoxelWallPostApproved * * @category VoxelWallPostApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelWallPostApproved { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_wall_approved'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $trigger_data = OptionController::get_option( 'trigger_data' ); $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Wall Post Approved', 'suretriggers' ), 'action' => $this->trigger, 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; if ( ! empty( $trigger_data ) && is_array( $trigger_data ) && isset( $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] ) ) { $triggers[ $this->integration ][ $this->trigger ]['common_action'] = 'voxel/app-events/post-types/' . $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] . '/wall-post:approved'; } return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'status' ) || ! property_exists( $event, 'post' ) || ! property_exists( $event, 'author' ) ) { return; } $context['post'] = Voxel::get_post_fields( $event->status->get_post_id() ); $user = get_userdata( $event->author->get_id() ); if ( $user ) { $user_data = (array) $user->data; $context['user_display_name'] = $user_data['display_name']; $context['user_name'] = $user_data['user_nicename']; $context['user_email'] = $user_data['user_email']; $context['user_id'] = $event->status->get_author(); } if ( class_exists( 'Voxel\Timeline\Status' ) ) { // Get the status details. $status_details = \Voxel\Timeline\Status::get( $event->status->get_id() ); foreach ( (array) $status_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); if ( is_object( $value ) ) { $encoded_value = wp_json_encode( $value ); if ( is_string( $encoded_value ) ) { $value = json_decode( $encoded_value, true ); } } $context['wall_post'][ $clean_key ] = $value; } } // Get the post type. $post_type = get_post_type( $event->post->get_id() ); $context['post_type'] = $post_type; AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelWallPostApproved::get_instance(); endif; triggers/voxel-post-quoted.php 0000644 00000007251 15006204201 0012515 0 ustar 00 <?php /** * VoxelPostQuoted. * php version 5.6 * * @category VoxelPostQuoted * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'VoxelPostQuoted' ) ) : /** * VoxelPostQuoted * * @category VoxelPostQuoted * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelPostQuoted { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_quoted'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Post Reposted', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/users/timeline/post-quoted', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'status' ) || ! property_exists( $event, 'author' ) || ! property_exists( $event, 'recipient' ) || ! property_exists( $event, 'quote_of' ) ) { return; } $author = get_userdata( $event->author->get_id() ); if ( $author ) { $author_data = (array) $author->data; $context['author_display_name'] = $author_data['display_name']; $context['author_name'] = $author_data['user_nicename']; $context['author_email'] = $author_data['user_email']; } $recipient_user = get_userdata( $event->recipient->get_id() ); if ( $recipient_user ) { $recipient_user_data = (array) $recipient_user->data; $context['recipient']['user_display_name'] = $recipient_user_data['display_name']; $context['recipient']['user_name'] = $recipient_user_data['user_nicename']; $context['recipient']['user_email'] = $recipient_user_data['user_email']; } if ( class_exists( 'Voxel\Timeline\Status' ) ) { $status_details = \Voxel\Timeline\Status::get( $event->status->get_id() ); foreach ( (array) $status_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); $context['status'][ $clean_key ] = $value; } $repost_details = \Voxel\Timeline\Status::get( $event->quote_of->get_id() ); foreach ( (array) $repost_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); $context['quote_of'][ $clean_key ] = $value; } } if ( ! empty( $context ) ) { AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelPostQuoted::get_instance(); endif; triggers/voxel-post-liked.php 0000644 00000006457 15006204201 0012313 0 ustar 00 <?php /** * VoxelPostLiked. * php version 5.6 * * @category VoxelPostLiked * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'VoxelPostLiked' ) ) : /** * VoxelPostLiked * * @category VoxelPostLiked * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelPostLiked { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_liked'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Post Liked', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/users/timeline/post-liked', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'status' ) || ! property_exists( $event, 'user' ) || ! property_exists( $event, 'recipient' ) ) { return; } $user = get_userdata( $event->user->get_id() ); if ( $user ) { $user_data = (array) $user->data; $context['user_display_name'] = $user_data['display_name']; $context['user_name'] = $user_data['user_nicename']; $context['user_email'] = $user_data['user_email']; } $recipient_user = get_userdata( $event->recipient->get_id() ); if ( $recipient_user ) { $recipient_user_data = (array) $recipient_user->data; $context['recipient']['user_display_name'] = $recipient_user_data['display_name']; $context['recipient']['user_name'] = $recipient_user_data['user_nicename']; $context['recipient']['user_email'] = $recipient_user_data['user_email']; } if ( class_exists( 'Voxel\Timeline\Status' ) ) { $status_details = \Voxel\Timeline\Status::get( $event->status->get_id() ); foreach ( (array) $status_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); $context[ $clean_key ] = $value; } } if ( ! empty( $context ) ) { AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelPostLiked::get_instance(); endif; triggers/voxel-user-mentioned-in-comment.php 0000644 00000005033 15006204201 0015227 0 ustar 00 <?php /** * VoxelUserMentionedInComment. * php version 5.6 * * @category VoxelUserMentionedInComment * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'VoxelUserMentionedInComment' ) ) : /** * VoxelUserMentionedInComment * * @category VoxelUserMentionedInComment * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelUserMentionedInComment { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_user_mentioned_in_comment'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'User Mentioned In Comment', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/users/timeline/mentioned-in-comment', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'comment' ) ) { return; } $context['comment_by'] = WordPress::get_user_context( $event->comment->get_user_id() ); $context['id'] = $event->comment->get_id(); $context['status_id'] = $event->comment->get_status_id(); $context['content'] = $event->comment->get_content(); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelUserMentionedInComment::get_instance(); endif; triggers/membership-plan-canceled.php 0000644 00000005700 15006204201 0013712 0 ustar 00 <?php /** * MembershipPlanCanceled. * php version 5.6 * * @category MembershipPlanCanceled * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'MembershipPlanCanceled' ) ) : /** * MembershipPlanCanceled * * @category MembershipPlanCanceled * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class MembershipPlanCanceled { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_membership_plan_canceled'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Membership Plan Canceled', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/membership/plan:canceled', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'user' ) || ! class_exists( 'Voxel\Stripe' ) ) { return; } global $wpdb; $context = WordPress::get_user_context( $event->user->get_id() ); $meta_key = \Voxel\Stripe::is_test_mode() ? 'voxel:test_plan' : 'voxel:plan'; $sql = "SELECT m.user_id AS id, m.meta_value AS details FROM wp_usermeta as m LEFT JOIN wp_users AS u ON m.user_id = u.ID WHERE m.meta_key = %s AND m.user_id = %d AND JSON_UNQUOTE( JSON_EXTRACT( m.meta_value, '$.plan' ) ) != 'default' ORDER BY m.user_id DESC LIMIT 25 OFFSET 0"; $results = $wpdb->get_results( $wpdb->prepare( $sql, $meta_key, $event->user->get_id() ), ARRAY_A );// @phpcs:ignore $context['details'] = json_decode( $results[0]['details'], true ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ MembershipPlanCanceled::get_instance(); endif; triggers/post-approved.php 0000644 00000005705 15006204201 0011703 0 ustar 00 <?php /** * PostApproved. * php version 5.6 * * @category PostApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Controllers\OptionController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'PostApproved' ) ) : /** * PostApproved * * @category PostApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class PostApproved { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_approved'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $trigger_data = OptionController::get_option( 'trigger_data' ); $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Post Approved', 'suretriggers' ), 'action' => $this->trigger, 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; if ( ! empty( $trigger_data ) && is_array( $trigger_data ) && isset( $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] ) ) { $triggers[ $this->integration ][ $this->trigger ]['common_action'] = 'voxel/app-events/post-types/' . $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] . '/post:approved'; } return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) ) { return; } $post = WordPress::get_post_context( $event->post->get_id() ); $context = $post; $context['post'] = Voxel::get_post_fields( $event->post->get_id() ); // Get the post type. $post_type = get_post_type( $event->post->get_id() ); $context['post_type'] = $post_type; AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ PostApproved::get_instance(); endif; triggers/profile-rejected.php 0000644 00000005220 15006204201 0012313 0 ustar 00 <?php /** * ProfileRejected. * php version 5.6 * * @category ProfileRejected * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'ProfileRejected' ) ) : /** * ProfileRejected * * @category ProfileRejected * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class ProfileRejected { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_profile_rejected'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Profile Rejected', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/post-types/profile/post:rejected', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) || ! property_exists( $event, 'author' ) ) { return; } $context = Voxel::get_post_fields( $event->post->get_id() ); $user = get_userdata( $event->author->get_id() ); if ( $user ) { $user_data = (array) $user->data; $context['profile_display_name'] = $user_data['display_name']; $context['profile_email'] = $user_data['user_email']; $context['profile_user_id'] = $user_data['ID']; $context['profile_id'] = $event->post->get_id(); } AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ ProfileRejected::get_instance(); endif; triggers/profile-approved.php 0000644 00000005220 15006204201 0012346 0 ustar 00 <?php /** * ProfileApproved. * php version 5.6 * * @category ProfileApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'ProfileApproved' ) ) : /** * ProfileApproved * * @category ProfileApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class ProfileApproved { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_profile_approved'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Profile Approved', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/post-types/profile/post:approved', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) || ! property_exists( $event, 'author' ) ) { return; } $context = Voxel::get_post_fields( $event->post->get_id() ); $user = get_userdata( $event->author->get_id() ); if ( $user ) { $user_data = (array) $user->data; $context['profile_display_name'] = $user_data['display_name']; $context['profile_email'] = $user_data['user_email']; $context['profile_user_id'] = $user_data['ID']; $context['profile_id'] = $event->post->get_id(); } AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ ProfileApproved::get_instance(); endif; triggers/collection-post-updated.php 0000644 00000004656 15006204201 0013646 0 ustar 00 <?php /** * CollectionPostUpdated. * php version 5.6 * * @category CollectionPostUpdated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'CollectionPostUpdated' ) ) : /** * CollectionPostUpdated * * @category CollectionPostUpdated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class CollectionPostUpdated { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_collection_post_updated'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Collection Post Updated', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/post-types/collection/post:updated', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) ) { return; } $context = Voxel::get_post_fields( $event->post->get_id() ); $context['collection'] = WordPress::get_post_context( $event->post->get_id() ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ CollectionPostUpdated::get_instance(); endif; triggers/post-rejected.php 0000644 00000005705 15006204201 0011650 0 ustar 00 <?php /** * PostRejected. * php version 5.6 * * @category PostRejected * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Controllers\OptionController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'PostRejected' ) ) : /** * PostRejected * * @category PostRejected * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class PostRejected { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_rejected'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $trigger_data = OptionController::get_option( 'trigger_data' ); $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Post Rejected', 'suretriggers' ), 'action' => $this->trigger, 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; if ( ! empty( $trigger_data ) && is_array( $trigger_data ) && isset( $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] ) ) { $triggers[ $this->integration ][ $this->trigger ]['common_action'] = 'voxel/app-events/post-types/' . $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] . '/post:rejected'; } return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) ) { return; } $post = WordPress::get_post_context( $event->post->get_id() ); $context = $post; $context['post'] = Voxel::get_post_fields( $event->post->get_id() ); // Get the post type. $post_type = get_post_type( $event->post->get_id() ); $context['post_type'] = $post_type; AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ PostRejected::get_instance(); endif; triggers/voxel-user-mentioned-in-post.php 0000644 00000005666 15006204201 0014566 0 ustar 00 <?php /** * VoxelUserMentionedInPost. * php version 5.6 * * @category VoxelUserMentionedInPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'VoxelUserMentionedInPost' ) ) : /** * VoxelUserMentionedInPost * * @category VoxelUserMentionedInPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelUserMentionedInPost { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_user_mentioned_in_post'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'User Mentioned In Post', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/users/timeline/mentioned-in-post', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'status' ) || ! property_exists( $event, 'author' ) ) { return; } $user = get_userdata( $event->author->get_id() ); if ( $user ) { $user_data = (array) $user->data; $context['user_display_name'] = $user_data['display_name']; $context['user_name'] = $user_data['user_nicename']; $context['user_email'] = $user_data['user_email']; } if ( class_exists( 'Voxel\Timeline\Status' ) ) { $status_details = \Voxel\Timeline\Status::get( $event->status->get_id() ); foreach ( (array) $status_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); $context[ $clean_key ] = $value; } } if ( ! empty( $context ) ) { AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelUserMentionedInPost::get_instance(); endif; triggers/users-timeline-created.php 0000644 00000005671 15006204201 0013454 0 ustar 00 <?php /** * VoxelUsersTimelineCreated. * php version 5.6 * * @category VoxelUsersTimelineCreated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'VoxelUsersTimelineCreated' ) ) : /** * VoxelUsersTimelineCreated * * @category VoxelUsersTimelineCreated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelUsersTimelineCreated { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_users_timeline_created'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Users Timeline Created', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/users/timeline/status:created', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'status' ) || ! property_exists( $event, 'author' ) ) { return; } $user = get_userdata( $event->author->get_id() ); if ( $user ) { $user_data = (array) $user->data; $context['user_display_name'] = $user_data['display_name']; $context['user_name'] = $user_data['user_nicename']; $context['user_email'] = $user_data['user_email']; } if ( class_exists( 'Voxel\Timeline\Status' ) ) { $status_details = \Voxel\Timeline\Status::get( $event->status->get_id() ); foreach ( (array) $status_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); $context[ $clean_key ] = $value; } } if ( ! empty( $context ) ) { AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelUsersTimelineCreated::get_instance(); endif; triggers/user-receives-message.php 0000644 00000004675 15006204201 0013310 0 ustar 00 <?php /** * UserReceivesMessage. * php version 5.6 * * @category UserReceivesMessage * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'UserReceivesMessage' ) ) : /** * UserReceivesMessage * * @category UserReceivesMessage * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class UserReceivesMessage { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_user_receives_message'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'User Receives Message', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/messages/user:received_message', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'message' ) ) { return; } $context['sender'] = WordPress::get_user_context( $event->message->get_sender_id() ); $context['receiver'] = WordPress::get_user_context( $event->message->get_receiver_id() ); $context['content'] = $event->message->get_content(); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ UserReceivesMessage::get_instance(); endif; triggers/post-review-approved.php 0000644 00000006561 15006204201 0013203 0 ustar 00 <?php /** * VoxelPostReviewApproved. * php version 5.6 * * @category VoxelPostReviewApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Controllers\OptionController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'VoxelPostReviewApproved' ) ) : /** * VoxelPostReviewApproved * * @category VoxelPostReviewApproved * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelPostReviewApproved { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_review_approved'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $trigger_data = OptionController::get_option( 'trigger_data' ); $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Post Review Approved', 'suretriggers' ), 'action' => $this->trigger, 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; if ( ! empty( $trigger_data ) && is_array( $trigger_data ) && isset( $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] ) ) { $triggers[ $this->integration ][ $this->trigger ]['common_action'] = 'voxel/app-events/post-types/' . $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] . '/review:approved'; } return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) || ! property_exists( $event, 'review' ) ) { return; } $context = WordPress::get_post_context( $event->post->get_id() ); $context['post'] = Voxel::get_post_fields( $event->post->get_id() ); $context['review_content'] = $event->review->get_content(); $context['review_created_at'] = $event->review->get_created_at(); $context['review_details'] = $event->review->get_details(); $context['review_by'] = WordPress::get_user_context( $event->review->get_user_id() ); // Get the post type. $post_type = get_post_type( $event->post->get_id() ); $context['post_type'] = $post_type; AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelPostReviewApproved::get_instance(); endif; triggers/new-comment-timeline.php 0000644 00000004711 15006204201 0013131 0 ustar 00 <?php /** * NewCommentTimeline. * php version 5.6 * * @category NewCommentTimeline * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'NewCommentTimeline' ) ) : /** * NewCommentTimeline * * @category NewCommentTimeline * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class NewCommentTimeline { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_new_comment_timeline'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'New Comment Created on Timeline', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/timeline/comment:created', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'reply' ) ) { return; } $context['comment_by'] = WordPress::get_user_context( $event->reply->get_user_id() ); $context['id'] = $event->reply->get_id(); $context['status_id'] = $event->reply->get_status_id(); $context['content'] = $event->reply->get_content(); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ NewCommentTimeline::get_instance(); endif; triggers/voxel-post-followed.php 0000644 00000004653 15006204201 0013032 0 ustar 00 <?php /** * VoxelPostFollowed. * php version 5.6 * * @category VoxelPostFollowed * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; if ( ! class_exists( 'VoxelPostFollowed' ) ) : /** * VoxelPostFollowed * * @category VoxelPostFollowed * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelPostFollowed { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_followed'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Post Followed', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'st_voxel_post_followed', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param array $follow_data Follow data. * @return void */ public function trigger_listener( $follow_data ) { if ( empty( $follow_data ) ) { return; } global $wpdb; $sql = "SELECT COUNT(*) FROM {$wpdb->prefix}voxel_followers WHERE object_id= %d"; $followers = $wpdb->get_var( $wpdb->prepare( $sql, $follow_data['ID'] ));// @phpcs:ignore $follow_data['total_followers'] = $followers + 1; $context = $follow_data; AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelPostFollowed::get_instance(); endif; triggers/post-updated.php 0000644 00000005673 15006204201 0011515 0 ustar 00 <?php /** * PostUpdated. * php version 5.6 * * @category PostUpdated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Controllers\OptionController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'PostUpdated' ) ) : /** * PostUpdated * * @category PostUpdated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class PostUpdated { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_updated'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $trigger_data = OptionController::get_option( 'trigger_data' ); $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Post Updated', 'suretriggers' ), 'action' => $this->trigger, 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; if ( ! empty( $trigger_data ) && is_array( $trigger_data ) && isset( $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] ) ) { $triggers[ $this->integration ][ $this->trigger ]['common_action'] = 'voxel/app-events/post-types/' . $trigger_data[ $this->integration ][ $this->trigger ]['selected_options']['post_type']['value'] . '/post:updated'; } return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) ) { return; } $post = WordPress::get_post_context( $event->post->get_id() ); $context = $post; $context['post'] = Voxel::get_post_fields( $event->post->get_id() ); // Get the post type. $post_type = get_post_type( $event->post->get_id() ); $context['post_type'] = $post_type; AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ PostUpdated::get_instance(); endif; triggers/order-declined-by-vendor.php 0000644 00000012555 15006204201 0013664 0 ustar 00 <?php /** * OrderDeclinedByVendor. * php version 5.6 * * @category OrderDeclinedByVendor * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'OrderDeclinedByVendor' ) ) : /** * OrderDeclinedByVendor * * @category OrderDeclinedByVendor * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class OrderDeclinedByVendor { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_order_declined_by_vendor'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Order Declined By Vendor', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/products/orders/vendor:order_declined', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'order' ) || ! property_exists( $event, 'customer' ) ) { return; } // Get Order. $order = $event->order; $context['id'] = $order->get_id(); $context['vendor_id'] = $order->get_vendor_id(); $context['details'] = $order->get_details(); $context['payment_method'] = $order->get_payment_method_key(); $context['tax_amount'] = $order->get_tax_amount(); $context['discount_amount'] = $order->get_discount_amount(); $context['shipping_amount'] = $order->get_shipping_amount(); $context['status'] = $order->get_status(); $context['created_at'] = $order->get_created_at(); $context['subtotal'] = $order->get_subtotal(); $context['total'] = $order->get_total(); // Get order items. $order_items = $order->get_items(); $context['order_item_count'] = $order->get_item_count(); foreach ( $order_items as $item ) { $addon_data = []; if ( is_object( $item ) && method_exists( $item, 'get_addons' ) ) { $addons = $item->get_addons(); $addon_data = []; if ( $addons && isset( $addons['summary'] ) ) { $addon_data = $addons['summary']; } } $context['order_items'][] = [ 'id' => $item->get_id(), 'type' => $item->get_type(), 'currency' => $item->get_currency(), 'quantity' => $item->get_quantity(), 'subtotal' => $item->get_subtotal(), 'product_id' => $item->get_post()->get_id(), 'product_label' => $item->get_product_label(), 'product_thumbnail_url' => $item->get_product_thumbnail_url(), 'product_link' => $item->get_product_link(), 'description' => $item->get_product_description(), 'addon_data' => $addon_data, ]; // If booking item, get booking details. if ( 'booking' === $item->get_type() ) { $details = $item->get_order_page_details(); $context['order_items']['booking_type'] = $details['booking']['type']; if ( isset( $details['booking']['count_mode'] ) ) { $context['order_items']['booking_count_mode'] = $details['booking']['count_mode']; } if ( 'date_range' === $details['booking']['type'] ) { $context['order_items']['booking_start_date'] = $details['booking']['start_date']; $context['order_items']['booking_end_date'] = $details['booking']['end_date']; } elseif ( 'single_day' === $details['booking']['type'] ) { $context['order_items']['booking_date'] = $details['booking']['date']; } elseif ( 'timeslots' === $details['booking']['type'] ) { $context['order_items']['booking_date'] = $details['booking']['date']; $context['order_items']['booking_slot_from'] = $details['booking']['slot']['from']; $context['order_items']['booking_slot_to'] = $details['booking']['slot']['to']; } } } // Get Customer. $context['customer'] = WordPress::get_user_context( $event->customer->get_id() ); // Get Vendor. $context['vendor'] = WordPress::get_user_context( $order->get_vendor_id() ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ OrderDeclinedByVendor::get_instance(); endif; triggers/orders-promotion-activated.php 0000644 00000007437 15006204201 0014370 0 ustar 00 <?php /** * OrdersPromotionActivated. * php version 5.6 * * @category OrdersPromotionActivated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'OrdersPromotionActivated' ) ) : /** * OrdersPromotionActivated * * @category OrdersPromotionActivated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class OrdersPromotionActivated { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_orders_promotion_activated'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Order Approved By Vendor', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/promotions/promotion:activated', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'order' ) || ! property_exists( $event, 'customer' ) ) { return; } $order = $event->order; $context['id'] = $order->get_id(); $context['payment_method'] = $order->get_payment_method_key(); $context['tax_amount'] = $order->get_tax_amount(); $context['discount_amount'] = $order->get_discount_amount(); $context['shipping_amount'] = $order->get_shipping_amount(); $context['status'] = $order->get_status(); $context['created_at'] = $order->get_created_at(); $context['subtotal'] = $order->get_subtotal(); $context['total'] = $order->get_total(); // Get order items. $order_items = $order->get_items(); $context['order_item_count'] = $order->get_item_count(); foreach ( $order_items as $item ) { $context['order_items'][] = [ 'id' => $item->get_id(), 'type' => $item->get_type(), 'currency' => $item->get_currency(), 'quantity' => $item->get_quantity(), 'subtotal' => $item->get_subtotal(), 'product_id' => $item->get_post()->get_id(), 'product_label' => $item->get_product_label(), 'product_thumbnail_url' => $item->get_product_thumbnail_url(), 'product_link' => $item->get_product_link(), 'description' => $item->get_product_description(), ]; } $context['details'] = $order->get_details(); // Get Customer. $context['customer'] = WordPress::get_user_context( $event->customer->get_id() ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ OrdersPromotionActivated::get_instance(); endif; triggers/order-canceled-by-customer.php 0000644 00000012437 15006204201 0014216 0 ustar 00 <?php /** * OrderCanceledByCustomer. * php version 5.6 * * @category OrderCanceledByCustomer * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'OrderCanceledByCustomer' ) ) : /** * OrderCanceledByCustomer * * @category OrderCanceledByCustomer * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class OrderCanceledByCustomer { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_order_canceled_by_customer'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Order Canceled by Customer', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/products/orders/customer:order_canceled', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'order' ) || ! property_exists( $event, 'customer' ) ) { return; } // Get Order. $order = $event->order; $context['id'] = $order->get_id(); $context['vendor_id'] = $order->get_vendor_id(); $context['details'] = $order->get_details(); $context['payment_method'] = $order->get_payment_method_key(); $context['tax_amount'] = $order->get_tax_amount(); $context['discount_amount'] = $order->get_discount_amount(); $context['shipping_amount'] = $order->get_shipping_amount(); $context['status'] = $order->get_status(); $context['created_at'] = $order->get_created_at(); $context['subtotal'] = $order->get_subtotal(); $context['total'] = $order->get_total(); // Get order items. $order_items = $order->get_items(); $context['order_item_count'] = $order->get_item_count(); foreach ( $order_items as $item ) { $addon_data = []; if ( is_object( $item ) && method_exists( $item, 'get_addons' ) ) { $addons = $item->get_addons(); $addon_data = []; if ( $addons && isset( $addons['summary'] ) ) { $addon_data = $addons['summary']; } } $context['order_items'][] = [ 'id' => $item->get_id(), 'type' => $item->get_type(), 'currency' => $item->get_currency(), 'quantity' => $item->get_quantity(), 'subtotal' => $item->get_subtotal(), 'product_id' => $item->get_post()->get_id(), 'product_label' => $item->get_product_label(), 'product_thumbnail_url' => $item->get_product_thumbnail_url(), 'product_link' => $item->get_product_link(), 'description' => $item->get_product_description(), 'addon_data' => $addon_data, ]; // If booking item, get booking details. if ( 'booking' === $item->get_type() ) { $details = $item->get_order_page_details(); $context['order_items']['booking_type'] = $details['booking']['type']; if ( isset( $details['booking']['count_mode'] ) ) { $context['order_items']['booking_count_mode'] = $details['booking']['count_mode']; } if ( 'date_range' === $details['booking']['type'] ) { $context['order_items']['booking_start_date'] = $details['booking']['start_date']; $context['order_items']['booking_end_date'] = $details['booking']['end_date']; } elseif ( 'single_day' === $details['booking']['type'] ) { $context['order_items']['booking_date'] = $details['booking']['date']; } elseif ( 'timeslots' === $details['booking']['type'] ) { $context['order_items']['booking_date'] = $details['booking']['date']; $context['order_items']['booking_slot_from'] = $details['booking']['slot']['from']; $context['order_items']['booking_slot_to'] = $details['booking']['slot']['to']; } } } // Get Customer. $context['customer'] = WordPress::get_user_context( $event->customer->get_id() ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ OrderCanceledByCustomer::get_instance(); endif; triggers/voxel-comment-liked.php 0000644 00000006514 15006204201 0012762 0 ustar 00 <?php /** * VoxelCommentLiked. * php version 5.6 * * @category VoxelCommentLiked * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'VoxelCommentLiked' ) ) : /** * VoxelCommentLiked * * @category VoxelCommentLiked * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelCommentLiked { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_comment_liked'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Comment Liked', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/users/timeline/comment-liked', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'comment' ) || ! property_exists( $event, 'user' ) || ! property_exists( $event, 'recipient' ) ) { return; } $user = get_userdata( $event->user->get_id() ); if ( $user ) { $user_data = (array) $user->data; $context['user_display_name'] = $user_data['display_name']; $context['user_name'] = $user_data['user_nicename']; $context['user_email'] = $user_data['user_email']; } $recipient_user = get_userdata( $event->recipient->get_id() ); if ( $recipient_user ) { $recipient_user_data = (array) $recipient_user->data; $context['recipient']['user_display_name'] = $recipient_user_data['display_name']; $context['recipient']['user_name'] = $recipient_user_data['user_nicename']; $context['recipient']['user_email'] = $recipient_user_data['user_email']; } if ( class_exists( 'Voxel\Timeline\Reply' ) ) { $reply_details = \Voxel\Timeline\Reply::get( $event->comment->get_id() ); foreach ( (array) $reply_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); $context[ $clean_key ] = $value; } } if ( ! empty( $context ) ) { AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelCommentLiked::get_instance(); endif; triggers/profile-wall-new-post.php 0000644 00000006376 15006204201 0013254 0 ustar 00 <?php /** * ProfileWallNewPost. * php version 5.6 * * @category ProfileWallNewPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'ProfileWallNewPost' ) ) : /** * ProfileWallNewPost * * @category ProfileWallNewPost * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class ProfileWallNewPost { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_profile_new_wall_post'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Profile New Wall Post', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/post-types/profile/wall-post:created', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'status' ) || ! property_exists( $event, 'author' ) ) { return; } $context['profile'] = Voxel::get_post_fields( $event->status->get_post_id() ); $user = get_userdata( $event->author->get_id() ); if ( $user ) { $user_data = (array) $user->data; $context['profile_display_name'] = $user_data['display_name']; $context['profile_name'] = $user_data['user_nicename']; $context['profile_email'] = $user_data['user_email']; $context['profile_user_id'] = $event->status->get_author(); } if ( class_exists( 'Voxel\Timeline\Status' ) ) { // Get the status details. $status_details = \Voxel\Timeline\Status::get( $event->status->get_id() ); foreach ( (array) $status_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); if ( is_object( $value ) ) { $encoded_value = wp_json_encode( $value ); if ( is_string( $encoded_value ) ) { $value = json_decode( $encoded_value, true ); } } $context['wall_post'][ $clean_key ] = $value; } } AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ ProfileWallNewPost::get_instance(); endif; triggers/voxel-post-reposted.php 0000644 00000007277 15006204201 0013051 0 ustar 00 <?php /** * VoxelPostReposted. * php version 5.6 * * @category VoxelPostReposted * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'VoxelPostReposted' ) ) : /** * VoxelPostReposted * * @category VoxelPostReposted * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class VoxelPostReposted { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_post_reposted'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Post Reposted', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/users/timeline/post-reposted', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'status' ) || ! property_exists( $event, 'author' ) || ! property_exists( $event, 'recipient' ) || ! property_exists( $event, 'repost_of' ) ) { return; } $author = get_userdata( $event->author->get_id() ); if ( $author ) { $author_data = (array) $author->data; $context['author_display_name'] = $author_data['display_name']; $context['author_name'] = $author_data['user_nicename']; $context['author_email'] = $author_data['user_email']; } $recipient_user = get_userdata( $event->recipient->get_id() ); if ( $recipient_user ) { $recipient_user_data = (array) $recipient_user->data; $context['recipient']['user_display_name'] = $recipient_user_data['display_name']; $context['recipient']['user_name'] = $recipient_user_data['user_nicename']; $context['recipient']['user_email'] = $recipient_user_data['user_email']; } if ( class_exists( 'Voxel\Timeline\Status' ) ) { $status_details = \Voxel\Timeline\Status::get( $event->status->get_id() ); foreach ( (array) $status_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); $context['status'][ $clean_key ] = $value; } $repost_details = \Voxel\Timeline\Status::get( $event->repost_of->get_id() ); foreach ( (array) $repost_details as $key => $value ) { $clean_key = preg_replace( '/^\0.*?\0/', '', $key ); $context['repost_of'][ $clean_key ] = $value; } } if ( ! empty( $context ) ) { AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ VoxelPostReposted::get_instance(); endif; triggers/new-order-placed.php 0000644 00000012256 15006204201 0012227 0 ustar 00 <?php /** * NewOrderPlaced. * php version 5.6 * * @category NewOrderPlaced * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; if ( ! class_exists( 'NewOrderPlaced' ) ) : /** * NewOrderPlaced * * @category NewOrderPlaced * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class NewOrderPlaced { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_new_order_placed'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'New Order Placed', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/products/orders/customer:order_placed', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'order' ) || ! property_exists( $event, 'customer' ) ) { return; } // Get Order. $order = $event->order; $context['id'] = $order->get_id(); $context['vendor_id'] = $order->get_vendor_id(); $context['details'] = $order->get_details(); $context['payment_method'] = $order->get_payment_method_key(); $context['tax_amount'] = $order->get_tax_amount(); $context['discount_amount'] = $order->get_discount_amount(); $context['shipping_amount'] = $order->get_shipping_amount(); $context['status'] = $order->get_status(); $context['created_at'] = $order->get_created_at(); $context['subtotal'] = $order->get_subtotal(); $context['total'] = $order->get_total(); // Get order items. $order_items = $order->get_items(); $context['order_item_count'] = $order->get_item_count(); foreach ( $order_items as $item ) { $addon_data = []; if ( is_object( $item ) && method_exists( $item, 'get_addons' ) ) { $addons = $item->get_addons(); if ( $addons && isset( $addons['summary'] ) ) { $addon_data = $addons['summary']; } } $context['order_items'][] = [ 'id' => $item->get_id(), 'type' => $item->get_type(), 'currency' => $item->get_currency(), 'quantity' => $item->get_quantity(), 'subtotal' => $item->get_subtotal(), 'product_id' => $item->get_post()->get_id(), 'product_label' => $item->get_product_label(), 'product_thumbnail_url' => $item->get_product_thumbnail_url(), 'product_link' => $item->get_product_link(), 'description' => $item->get_product_description(), 'addon_data' => $addon_data, ]; // If booking item, get booking details. if ( 'booking' === $item->get_type() ) { $details = $item->get_order_page_details(); $context['order_items']['booking_type'] = $details['booking']['type']; if ( isset( $details['booking']['count_mode'] ) ) { $context['order_items']['booking_count_mode'] = $details['booking']['count_mode']; } if ( 'date_range' === $details['booking']['type'] ) { $context['order_items']['booking_start_date'] = $details['booking']['start_date']; $context['order_items']['booking_end_date'] = $details['booking']['end_date']; } elseif ( 'single_day' === $details['booking']['type'] ) { $context['order_items']['booking_date'] = $details['booking']['date']; } elseif ( 'timeslots' === $details['booking']['type'] ) { $context['order_items']['booking_date'] = $details['booking']['date']; $context['order_items']['booking_slot_from'] = $details['booking']['slot']['from']; $context['order_items']['booking_slot_to'] = $details['booking']['slot']['to']; } } } // Get Customer. $context['customer'] = WordPress::get_user_context( $event->customer->get_id() ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ NewOrderPlaced::get_instance(); endif; triggers/collection-post-created.php 0000644 00000004662 15006204201 0013624 0 ustar 00 <?php /** * CollectionPostCreated. * php version 5.6 * * @category CollectionPostCreated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 */ namespace SureTriggers\Integrations\Voxel\Triggers; use SureTriggers\Controllers\AutomationController; use SureTriggers\Traits\SingletonLoader; use SureTriggers\Integrations\WordPress\WordPress; use SureTriggers\Integrations\Voxel\Voxel; if ( ! class_exists( 'CollectionPostCreated' ) ) : /** * CollectionPostCreated * * @category CollectionPostCreated * @package SureTriggers * @author BSF <username@example.com> * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3 * @link https://www.brainstormforce.com/ * @since 1.0.0 * * @psalm-suppress UndefinedTrait */ class CollectionPostCreated { /** * Integration type. * * @var string */ public $integration = 'Voxel'; /** * Trigger name. * * @var string */ public $trigger = 'voxel_collection_post_created'; use SingletonLoader; /** * Constructor * * @since 1.0.0 */ public function __construct() { add_filter( 'sure_trigger_register_trigger', [ $this, 'register' ] ); } /** * Register action. * * @param array $triggers trigger data. * @return array */ public function register( $triggers ) { $triggers[ $this->integration ][ $this->trigger ] = [ 'label' => __( 'Collection Post Submitted', 'suretriggers' ), 'action' => $this->trigger, 'common_action' => 'voxel/app-events/post-types/collection/post:submitted', 'function' => [ $this, 'trigger_listener' ], 'priority' => 10, 'accepted_args' => 1, ]; return $triggers; } /** * Trigger listener * * @param object $event Event. * @return void */ public function trigger_listener( $event ) { if ( ! property_exists( $event, 'post' ) ) { return; } $context = Voxel::get_post_fields( $event->post->get_id() ); $context['collection'] = WordPress::get_post_context( $event->post->get_id() ); AutomationController::sure_trigger_handle_trigger( [ 'trigger' => $this->trigger, 'context' => $context, ] ); } } /** * Ignore false positive * * @psalm-suppress UndefinedMethod */ CollectionPostCreated::get_instance(); endif;
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка