PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 7.9.8
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v7.9.8
8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 All 46 releases
gamipress / integrations / thrive-leads / includes / triggers.php

triggers.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 7.9.8, at integrations/thrive-leads/includes/triggers.php

165 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Triggers
4 *
5 * @package GamiPress\Thrive_Leads\Triggers
6 * @since 1.0.0
7 */
8
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * Register Thrive Leads specific triggers
14 *
15 * @since 1.0.0
16 *
17 * @param array $triggers
18 * @return mixed
19 */
20 function gamipress_thrive_leads_activity_triggers( $triggers ) {
21
22 $triggers[__( 'Thrive Leads', 'gamipress' )] = array(
23 'gamipress_thrive_leads_new_form_submission' => __( 'Successful submit a form', 'gamipress' ),
24 'gamipress_thrive_leads_specific_new_form_submission' => __( 'Successful submit a specific form', 'gamipress' ),
25 );
26
27 return $triggers;
28
29 }
30 add_filter( 'gamipress_activity_triggers', 'gamipress_thrive_leads_activity_triggers' );
31
32 /**
33 * Register Thrive Leads specific activity triggers
34 *
35 * @since 1.0.0
36 *
37 * @param array $specific_activity_triggers
38 * @return array
39 */
40 function gamipress_thrive_leads_specific_activity_triggers( $specific_activity_triggers ) {
41
42 $specific_activity_triggers['gamipress_thrive_leads_specific_new_form_submission'] = array( 'thrive_form' );
43
44 return $specific_activity_triggers;
45 }
46 add_filter( 'gamipress_specific_activity_triggers', 'gamipress_thrive_leads_specific_activity_triggers' );
47
48 /**
49 * Get Thrive Leads specific activity trigger post title
50 *
51 * @since 1.0.1
52 *
53 * @param string $post_title
54 * @param integer $specific_id
55 * @param string $trigger_type
56 * @return string
57 */
58 function gamipress_thrive_leads_specific_activity_trigger_post_title( $post_title, $specific_id, $trigger_type ) {
59
60 switch( $trigger_type ) {
61 case 'gamipress_thrive_leads_specific_new_form_submission':
62 if( absint( $specific_id ) !== 0 ) {
63 $form = gamipress_thrive_leads_get_form_title( $specific_id );
64
65 $post_title = $form;
66 }
67 break;
68 }
69
70 return $post_title;
71
72 }
73 add_filter( 'gamipress_specific_activity_trigger_post_title', 'gamipress_thrive_leads_specific_activity_trigger_post_title', 10, 3 );
74
75 /**
76 * Register Thrive Leads specific activity triggers labels
77 *
78 * @since 1.0.0
79 *
80 * @param array $specific_activity_trigger_labels
81 * @return array
82 */
83 function gamipress_thrive_leads_specific_activity_trigger_label( $specific_activity_trigger_labels ) {
84
85 $specific_activity_trigger_labels['gamipress_thrive_leads_specific_new_form_submission'] = __( 'Submit %s', 'gamipress' );
86
87 return $specific_activity_trigger_labels;
88 }
89 add_filter( 'gamipress_specific_activity_trigger_label', 'gamipress_thrive_leads_specific_activity_trigger_label' );
90
91 /**
92 * Get user for a given trigger action.
93 *
94 * @since 1.0.0
95 *
96 * @param integer $user_id user ID to override.
97 * @param string $trigger Trigger name.
98 * @param array $args Passed trigger args.
99 * @return integer User ID.
100 */
101 function gamipress_thrive_leads_trigger_get_user_id( $user_id, $trigger, $args ) {
102
103 switch ( $trigger ) {
104 case 'gamipress_thrive_leads_new_form_submission':
105 case 'gamipress_thrive_leads_specific_new_form_submission':
106 $user_id = $args[1];
107 break;
108 }
109
110 return $user_id;
111
112 }
113 add_filter( 'gamipress_trigger_get_user_id', 'gamipress_thrive_leads_trigger_get_user_id', 10, 3);
114
115
116 /**
117 * Get the id for a given specific trigger action.
118 *
119 * @since 1.0.0
120 *
121 * @param integer $specific_id Specific ID.
122 * @param string $trigger Trigger name.
123 * @param array $args Passed trigger args.
124 *
125 * @return integer Specific ID.
126 */
127 function gamipress_thrive_leads_specific_trigger_get_id( $specific_id, $trigger = '', $args = array() ) {
128
129 switch ( $trigger ) {
130 case 'gamipress_thrive_leads_specific_new_form_submission':
131 $specific_id = $args[0];
132 break;
133 }
134
135 return $specific_id;
136 }
137 add_filter( 'gamipress_specific_trigger_get_id', 'gamipress_thrive_leads_specific_trigger_get_id', 10, 3 );
138
139 /**
140 * Extended meta data for event trigger logging
141 *
142 * @since 1.0.0
143 *
144 * @param array $log_meta
145 * @param integer $user_id
146 * @param string $trigger
147 * @param integer $site_id
148 * @param array $args
149 *
150 * @return array
151 */
152 function gamipress_thrive_leads_log_event_trigger_meta_data( $log_meta, $user_id, $trigger, $site_id, $args ) {
153
154 switch ( $trigger ) {
155 case 'gamipress_thrive_leads_new_form_submission':
156 case 'gamipress_thrive_leads_specific_new_form_submission':
157 // Add the form ID
158 $log_meta['form_id'] = $args[0];
159 break;
160 }
161
162 return $log_meta;
163 }
164 add_filter( 'gamipress_log_event_trigger_meta_data', 'gamipress_thrive_leads_log_event_trigger_meta_data', 10, 5 );
165