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.5 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 All 47 releases
gamipress / integrations / the-events-calendar / includes / triggers.php

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

183 lines 7.1 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\The_Events_Calendar\Triggers
6 * @since 1.0.0
7 */
8 // Exit if accessed directly
9 if( !defined( 'ABSPATH' ) ) exit;
10
11 /**
12 * Register plugin triggers
13 *
14 * @since 1.0.0
15 *
16 * @param array $triggers
17 * @return mixed
18 */
19 function gamipress_the_events_calendar_activity_triggers( $triggers ) {
20
21 $event_post_type = ( class_exists( 'Tribe__Events__Main' ) ? Tribe__Events__Main::POSTTYPE : 'tribe_events' );
22
23 $triggers[__( 'The Events Calendar', 'gamipress' )] = array(
24
25 // Publishing
26 'gamipress_publish_' . $event_post_type => __( 'Publish a new event', 'gamipress' ), // Internal GamiPress listener
27 'gamipress_delete_' . $event_post_type => __( 'Delete an event', 'gamipress' ), // Internal GamiPress listener
28 );
29
30 if( class_exists( 'Tribe__Tickets__Main' ) ) {
31 $triggers[__( 'Event Tickets', 'gamipress' )] = array(
32 // RSVP
33 'gamipress_the_events_calendar_rsvp_event' => __( 'Confirm RSVP for an event', 'gamipress' ),
34 'gamipress_the_events_calendar_rsvp_specific_event' => __( 'Confirm RSVP for a specific event', 'gamipress' ),
35
36 // Purchase tickets
37 'gamipress_the_events_calendar_purchase_ticket' => __( 'Purchase a ticket for an event', 'gamipress' ),
38 'gamipress_the_events_calendar_purchase_ticket_specific_event' => __( 'Purchase a ticket for a specific event', 'gamipress' ),
39
40 // Checkin
41 'gamipress_the_events_calendar_checkin_event' => __( 'Check-in at an event', 'gamipress' ),
42 'gamipress_the_events_calendar_checkin_specific_event' => __( 'Check-in at specific event', 'gamipress' ),
43 );
44 }
45
46 return $triggers;
47
48 }
49 add_filter( 'gamipress_activity_triggers', 'gamipress_the_events_calendar_activity_triggers' );
50
51 /**
52 * Register plugin specific activity triggers
53 *
54 * @since 1.0.0
55 *
56 * @param array $specific_activity_triggers
57 * @return array
58 */
59 function gamipress_the_events_calendar_specific_activity_triggers( $specific_activity_triggers ) {
60
61 $event_post_type = ( class_exists( 'Tribe__Events__Main' ) ? Tribe__Events__Main::POSTTYPE : 'tribe_events' );
62
63 $specific_activity_triggers['gamipress_the_events_calendar_rsvp_specific_event'] = array( $event_post_type );
64 $specific_activity_triggers['gamipress_the_events_calendar_purchase_ticket_specific_event'] = array( $event_post_type );
65 $specific_activity_triggers['gamipress_the_events_calendar_checkin_specific_event'] = array( $event_post_type );
66
67 return $specific_activity_triggers;
68
69 }
70 add_filter( 'gamipress_specific_activity_triggers', 'gamipress_the_events_calendar_specific_activity_triggers' );
71
72 /**
73 * Register plugin specific activity triggers labels
74 *
75 * @since 1.0.0
76 *
77 * @param array $specific_activity_trigger_labels
78 * @return array
79 */
80 function gamipress_the_events_calendar_specific_activity_trigger_label( $specific_activity_trigger_labels ) {
81
82 $specific_activity_trigger_labels['gamipress_the_events_calendar_rsvp_specific_event'] = __( 'Confirm RSVP for %s event', 'gamipress' );
83 $specific_activity_trigger_labels['gamipress_the_events_calendar_purchase_ticket_specific_event'] = __( 'Purchase a ticket for %s event', 'gamipress' );
84 $specific_activity_trigger_labels['gamipress_the_events_calendar_checkin_specific_event'] = __( 'Check-in at %s event', 'gamipress' );
85
86 return $specific_activity_trigger_labels;
87 }
88 add_filter( 'gamipress_specific_activity_trigger_label', 'gamipress_the_events_calendar_specific_activity_trigger_label' );
89
90 /**
91 * Get user for a given trigger action.
92 *
93 * @since 1.0.0
94 *
95 * @param integer $user_id user ID to override.
96 * @param string $trigger Trigger name.
97 * @param array $args Passed trigger args.
98 * @return integer User ID.
99 */
100 function gamipress_the_events_calendar_trigger_get_user_id( $user_id, $trigger, $args ) {
101
102 $event_post_type = ( class_exists( 'Tribe__Events__Main' ) ? Tribe__Events__Main::POSTTYPE : 'tribe_events' );
103
104 switch ( $trigger ) {
105 case 'gamipress_publish_' . $event_post_type: // Internal GamiPress listener
106 case 'gamipress_delete_' . $event_post_type: // Internal GamiPress listener
107 case 'gamipress_the_events_calendar_rsvp_event':
108 case 'gamipress_the_events_calendar_rsvp_specific_event':
109 case 'gamipress_the_events_calendar_purchase_ticket':
110 case 'gamipress_the_events_calendar_purchase_ticket_specific_event':
111 case 'gamipress_the_events_calendar_checkin_event':
112 case 'gamipress_the_events_calendar_checkin_specific_event':
113 $user_id = $args[1];
114 break;
115 }
116
117 return $user_id;
118
119 }
120 add_filter( 'gamipress_trigger_get_user_id', 'gamipress_the_events_calendar_trigger_get_user_id', 10, 3 );
121
122 /**
123 * Get the id for a given specific trigger action.
124 *
125 * @since 1.0.0
126 *
127 * @param integer $specific_id Specific ID to override.
128 * @param string $trigger Trigger name.
129 * @param array $args Passed trigger args.
130 *
131 * @return integer Specific ID.
132 */
133 function gamipress_the_events_calendar_specific_trigger_get_id( $specific_id, $trigger, $args ) {
134
135 switch ( $trigger ) {
136 case 'gamipress_the_events_calendar_rsvp_specific_event':
137 case 'gamipress_the_events_calendar_purchase_ticket_specific_event':
138 case 'gamipress_the_events_calendar_checkin_specific_event':
139 $specific_id = $args[0];
140 break;
141 }
142
143 return $specific_id;
144
145 }
146 add_filter( 'gamipress_specific_trigger_get_id', 'gamipress_the_events_calendar_specific_trigger_get_id', 10, 3 );
147
148 /**
149 * Extended meta data for event trigger logging
150 *
151 * @since 1.0.0
152 *
153 * @param array $log_meta
154 * @param integer $user_id
155 * @param string $trigger
156 * @param integer $site_id
157 * @param array $args
158 *
159 * @return array
160 */
161 function gamipress_the_events_calendar_log_event_trigger_meta_data( $log_meta, $user_id, $trigger, $site_id, $args ) {
162
163 switch ( $trigger ) {
164 case 'gamipress_the_events_calendar_rsvp_event':
165 case 'gamipress_the_events_calendar_rsvp_specific_event':
166 case 'gamipress_the_events_calendar_purchase_ticket':
167 case 'gamipress_the_events_calendar_purchase_ticket_specific_event':
168 // Add the event ID
169 $log_meta['event_id'] = $args[0];
170 $log_meta['post_id'] = $args[0]; // Set post ID as the event ID to being displayed on logs
171 $log_meta['ticket_id'] = $args[2];
172 break;
173 case 'gamipress_the_events_calendar_checkin_event':
174 case 'gamipress_the_events_calendar_checkin_specific_event':
175 $log_meta['event_id'] = $args[0];
176 $log_meta['post_id'] = $args[0]; // Set post ID as the event ID to being displayed on logs
177 $log_meta['attendee_id'] = $args[2];
178 break;
179 }
180
181 return $log_meta;
182 }
183 add_filter( 'gamipress_log_event_trigger_meta_data', 'gamipress_the_events_calendar_log_event_trigger_meta_data', 10, 5 );