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

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

143 lines 3.9 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\Download_Manager\Triggers
6 * @since 1.0.0
7 */
8
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * Register plugin specific triggers
14 *
15 * @since 1.0.0
16 *
17 * @param array $triggers
18 * @return mixed
19 */
20 function gamipress_download_manager_activity_triggers( $triggers ) {
21
22 $triggers[__( 'Download Manager', 'gamipress' )] = array(
23
24 'gamipress_download_manager_any_download' => __( 'Download any file', 'gamipress' ),
25 'gamipress_download_manager_specific_download' => __( 'Download specific file', 'gamipress' ),
26
27 );
28
29 return $triggers;
30
31 }
32 add_filter( 'gamipress_activity_triggers', 'gamipress_download_manager_activity_triggers' );
33
34 /**
35 * Register Download Manager specific activity triggers
36 *
37 * @since 1.0.0
38 *
39 * @param array $specific_activity_triggers
40 * @return array
41 */
42 function gamipress_download_manager_specific_activity_triggers( $specific_activity_triggers ) {
43
44 $specific_activity_triggers['gamipress_download_manager_specific_download'] = array( 'wpdmpro' );
45
46 return $specific_activity_triggers;
47 }
48 add_filter( 'gamipress_specific_activity_triggers', 'gamipress_download_manager_specific_activity_triggers' );
49
50 /**
51 * Register plugin specific activity triggers labels
52 *
53 * @since 1.0.0
54 *
55 * @param array $specific_activity_trigger_labels
56 * @return array
57 */
58 function gamipress_download_manager_specific_activity_trigger_label( $specific_activity_trigger_labels ) {
59
60 $specific_activity_trigger_labels['gamipress_download_manager_specific_download'] = __( 'Download %s file', 'gamipress' );
61
62 return $specific_activity_trigger_labels;
63 }
64 add_filter( 'gamipress_specific_activity_trigger_label', 'gamipress_download_manager_specific_activity_trigger_label' );
65
66 /**
67 * Get user for a given trigger action.
68 *
69 * @since 1.0.0
70 *
71 * @param integer $user_id user ID to override.
72 * @param string $trigger Trigger name.
73 * @param array $args Passed trigger args.
74 * @return integer User ID.
75 */
76 function gamipress_download_manager_trigger_get_user_id( $user_id, $trigger, $args ) {
77
78 switch ( $trigger ) {
79
80 case 'gamipress_download_manager_any_download':
81 case 'gamipress_download_manager_specific_download':
82 $user_id = $args[1];
83 break;
84
85 }
86
87 return $user_id;
88
89 }
90 add_filter( 'gamipress_trigger_get_user_id', 'gamipress_download_manager_trigger_get_user_id', 10, 3 );
91
92 /**
93 * Get the id for a given specific trigger action.
94 *
95 * @since 1.0.0
96 *
97 * @param integer $specific_id Specific ID.
98 * @param string $trigger Trigger name.
99 * @param array $args Passed trigger args.
100 *
101 * @return integer Specific ID.
102 */
103 function gamipress_download_manager_specific_trigger_get_id( $specific_id, $trigger = '', $args = array() ) {
104
105 switch ( $trigger ) {
106
107 case 'gamipress_download_manager_specific_download':
108 $specific_id = $args[0];
109 break;
110
111 }
112
113 return $specific_id;
114 }
115 add_filter( 'gamipress_specific_trigger_get_id', 'gamipress_download_manager_specific_trigger_get_id', 10, 3 );
116
117 /**
118 * Extended meta data for event trigger logging
119 *
120 * @since 1.0.0
121 *
122 * @param array $log_meta
123 * @param integer $user_id
124 * @param string $trigger
125 * @param integer $site_id
126 * @param array $args
127 *
128 * @return array
129 */
130 function gamipress_download_manager_log_event_trigger_meta_data( $log_meta, $user_id, $trigger, $site_id, $args ) {
131
132 switch ( $trigger ) {
133
134 case 'gamipress_download_manager_any_download':
135 case 'gamipress_download_manager_specific_download':
136 $log_meta['package_id'] = $args[0];
137 break;
138
139 }
140
141 return $log_meta;
142 }
143 add_filter( 'gamipress_log_event_trigger_meta_data', 'gamipress_download_manager_log_event_trigger_meta_data', 10, 5 );