PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.5
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.5
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
← All changes | integrations/wp-simple-pay/includes/triggers.php +140 -0 7.9.2 → 8.0.5 View file →
@@ -1,0 +1,140 @@
1 +<?php
2 +/**
3 + * Triggers
4 + *
5 + * @package GamiPress\WP_Simple_Pay\Triggers
6 + * @since 1.0.0
7 + */
8 +// Exit if accessed directly
9 +if( !defined( 'ABSPATH' ) ) exit;
10 +
11 +/**
12 + * Register plugin specific triggers
13 + *
14 + * @param array $triggers
15 + * @return mixed
16 + */
17 +function gamipress_wp_simple_pay_activity_triggers( $triggers ) {
18 +
19 + $triggers['WP Simple Pay'] = array(
20 + 'gamipress_wp_simple_pay_purchase' => __( 'Complete a purchase through any form', 'gamipress' ),
21 + 'gamipress_wp_simple_pay_specific_purchase' => __( 'Complete a purchase through a specific form', 'gamipress' ),
22 + );
23 +
24 + if( SIMPLE_PAY_PLUGIN_NAME === 'WP Simple Pay Pro' ) {
25 + $triggers['WP Simple Pay']['gamipress_wp_simple_pay_renew_subscription'] = __( 'Renew a subscription', 'gamipress' );
26 + }
27 +
28 + return $triggers;
29 +
30 +}
31 +add_filter( 'gamipress_activity_triggers', 'gamipress_wp_simple_pay_activity_triggers' );
32 +
33 +/**
34 + * Register plugin specific activity triggers
35 + *
36 + * @since 1.0.0
37 + *
38 + * @param array $specific_activity_triggers
39 + * @return array
40 + */
41 +function gamipress_wp_simple_pay_specific_activity_triggers( $specific_activity_triggers ) {
42 +
43 + $specific_activity_triggers['gamipress_wp_simple_pay_specific_purchase'] = array( 'simple-pay' );
44 +
45 + return $specific_activity_triggers;
46 +}
47 +add_filter( 'gamipress_specific_activity_triggers', 'gamipress_wp_simple_pay_specific_activity_triggers' );
48 +
49 +/**
50 + * Register plugin specific activity triggers labels
51 + *
52 + * @since 1.0.0
53 + *
54 + * @param array $specific_activity_trigger_labels
55 + * @return array
56 + */
57 +function gamipress_wp_simple_pay_specific_activity_trigger_label( $specific_activity_trigger_labels ) {
58 +
59 + $specific_activity_trigger_labels['gamipress_wp_simple_pay_specific_purchase'] = __( 'Complete a purchase through %s form', 'gamipress' );
60 +
61 + return $specific_activity_trigger_labels;
62 +}
63 +add_filter( 'gamipress_specific_activity_trigger_label', 'gamipress_wp_simple_pay_specific_activity_trigger_label' );
64 +
65 +/**
66 + * Get user for a given trigger action.
67 + *
68 + * @since 1.0.0
69 + *
70 + * @param integer $user_id user ID to override.
71 + * @param string $trigger Trigger name.
72 + * @param array $args Passed trigger args.
73 + * @return integer User ID.
74 + */
75 +function gamipress_wp_simple_pay_trigger_get_user_id( $user_id, $trigger, $args ) {
76 +
77 + switch ( $trigger ) {
78 + case 'gamipress_wp_simple_pay_purchase':
79 + case 'gamipress_wp_simple_pay_specific_purchase':
80 + case 'gamipress_wp_simple_pay_renew_subscription':
81 + $user_id = $args[1];
82 + break;
83 + }
84 +
85 + return $user_id;
86 +
87 +}
88 +add_filter( 'gamipress_trigger_get_user_id', 'gamipress_wp_simple_pay_trigger_get_user_id', 10, 3);
89 +
90 +
91 +/**
92 + * Get the id for a given specific trigger action.
93 + *
94 + * @since 1.0.0
95 + *
96 + * @param integer $specific_id Specific ID.
97 + * @param string $trigger Trigger name.
98 + * @param array $args Passed trigger args.
99 + *
100 + * @return integer Specific ID.
101 + */
102 +function gamipress_wp_simple_pay_specific_trigger_get_id( $specific_id, $trigger = '', $args = array() ) {
103 +
104 + switch ( $trigger ) {
105 + case 'gamipress_wp_simple_pay_specific_purchase':
106 + $specific_id = $args[0];
107 + break;
108 + }
109 +
110 + return $specific_id;
111 +}
112 +add_filter( 'gamipress_specific_trigger_get_id', 'gamipress_wp_simple_pay_specific_trigger_get_id', 10, 3 );
113 +
114 +/**
115 + * Extended meta data for event trigger logging
116 + *
117 + * @since 1.0.0
118 + *
119 + * @param array $log_meta
120 + * @param integer $user_id
121 + * @param string $trigger
122 + * @param integer $site_id
123 + * @param array $args
124 + *
125 + * @return array
126 + */
127 +function gamipress_wp_simple_pay_log_event_trigger_meta_data( $log_meta, $user_id, $trigger, $site_id, $args ) {
128 +
129 + switch ( $trigger ) {
130 + case 'gamipress_wp_simple_pay_purchase':
131 + case 'gamipress_wp_simple_pay_specific_purchase':
132 + case 'gamipress_wp_simple_pay_renew_subscription':
133 + // Add the post ID
134 + $log_meta['post_id'] = $args[0];
135 + break;
136 + }
137 +
138 + return $log_meta;
139 +}
140 +add_filter( 'gamipress_log_event_trigger_meta_data', 'gamipress_wp_simple_pay_log_event_trigger_meta_data', 10, 5 );