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 / jetpack / includes / triggers.php

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

84 lines 2.2 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\Jetpack\Triggers
6 * @since 1.0.0
7 */
8
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * Register plugin activity triggers
14 *
15 * @since 1.0.0
16 *
17 * @param array $triggers
18 * @return mixed
19 */
20 function gamipress_jetpack_activity_triggers( $triggers ) {
21
22 $triggers[__( 'Jetpack', 'gamipress' )] = array(
23 'gamipress_jetpack_site_subscription' => __( 'Site subscription', 'gamipress' ),
24 'gamipress_jetpack_comment_subscription' => __( 'Comment subscription', 'gamipress' ),
25 );
26
27 return $triggers;
28
29 }
30 add_filter( 'gamipress_activity_triggers', 'gamipress_jetpack_activity_triggers' );
31
32 /**
33 * Get user for a given trigger action.
34 *
35 * @since 1.0.0
36 *
37 * @param integer $user_id user ID to override.
38 * @param string $trigger Trigger name.
39 * @param array $args Passed trigger args.
40 * @return integer User ID.
41 */
42 function gamipress_jetpack_trigger_get_user_id( $user_id, $trigger, $args ) {
43
44 switch ( $trigger ) {
45 case 'gamipress_jetpack_site_subscription':
46 case 'gamipress_jetpack_comment_subscription':
47 $user_id = $args[1];
48 break;
49 }
50
51 return $user_id;
52
53 }
54 add_filter( 'gamipress_trigger_get_user_id', 'gamipress_jetpack_trigger_get_user_id', 10, 3 );
55
56 /**
57 * Extended meta data for event trigger logging
58 *
59 * @since 1.0.0
60 *
61 * @param array $log_meta
62 * @param integer $user_id
63 * @param string $trigger
64 * @param integer $site_id
65 * @param array $args
66 *
67 * @return array
68 */
69 function gamipress_jetpack_log_event_trigger_meta_data( $log_meta, $user_id, $trigger, $site_id, $args ) {
70
71 switch ( $trigger ) {
72 case 'gamipress_jetpack_site_subscription':
73 // Add the blog ID
74 $log_meta['blog_id'] = $args[0];
75 break;
76 case 'gamipress_jetpack_comment_subscription':
77 // Add the post ID
78 $log_meta['post_id'] = $args[0];
79 break;
80 }
81
82 return $log_meta;
83 }
84 add_filter( 'gamipress_log_event_trigger_meta_data', 'gamipress_jetpack_log_event_trigger_meta_data', 10, 5 );