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 | includes/admin/meta-boxes/achievements.php +212 -0 7.9.9.6 → 8.0.5 View file →
@@ -1,0 +1,212 @@
1 +<?php
2 +/**
3 + * Achievements Meta Boxes
4 + *
5 + * @package GamiPress\Admin\Meta_Boxes\Achievements
6 + * @author GamiPress <[email protected]>, Ruben Garcia <[email protected]>
7 + * @since 1.4.7
8 + */
9 +// Exit if accessed directly
10 +if( !defined( 'ABSPATH' ) ) exit;
11 +
12 +/**
13 + * Register achievements meta boxes
14 + *
15 + * @param string $post_type
16 + *
17 + * @since 1.0.0
18 + */
19 +function gamipress_achievements_meta_boxes( $post_type ) {
20 +
21 + // Start with an underscore to hide fields from custom fields list
22 + $prefix = '_gamipress_';
23 +
24 + // Grab our achievement types slugs
25 + $achievement_types = gamipress_get_achievement_types_slugs();
26 +
27 + if( ! in_array( $post_type, $achievement_types ) ) {
28 + return;
29 + }
30 +
31 + // Build a rank options (for rank type required field)
32 + $rank_types_options = array();
33 +
34 + foreach( gamipress_get_rank_types() as $slug => $data ) {
35 + $rank_types_options[$slug] = $data['singular_name'];
36 + }
37 +
38 + // Achievement Data
39 + gamipress_add_meta_box(
40 + 'achievement-data',
41 + __( 'Achievement Data', 'gamipress' ),
42 + $achievement_types,
43 + array(
44 + $prefix . 'earned_by' => array(
45 + 'name' => __( 'Earned By:', 'gamipress' ),
46 + 'tooltip' => __( 'How this achievement can be earned.', 'gamipress' ),
47 + 'label_cb' => 'cmb_tooltip_label_cb',
48 + 'type' => 'select',
49 + 'options' => apply_filters( 'gamipress_achievement_earned_by', array(
50 + 'triggers' => __( 'Completing Steps', 'gamipress' ),
51 + 'points' => __( 'Minimum Number of Points', 'gamipress' ),
52 + 'rank' => __( 'Reaching a Rank', 'gamipress' ),
53 + 'admin' => __( 'Admin-awarded Only', 'gamipress' ),
54 + ) ),
55 + 'default' => 'triggers',
56 + ),
57 + $prefix . 'points' => array(
58 + 'name' => __( 'Points Awarded', 'gamipress' ),
59 + 'tooltip' => __( 'Points awarded for earning this achievement (optional). Leave empty if no points are awarded.', 'gamipress' ),
60 + 'label_cb' => 'cmb_tooltip_label_cb',
61 + 'type' => 'gamipress_points',
62 + 'default' => '0',
63 + ),
64 + $prefix . 'points_required' => array(
65 + 'name' => __( 'Minimum Points Required', 'gamipress' ),
66 + 'tooltip' => __( 'Fewest points required to earn this achievement.', 'gamipress' ),
67 + 'label_cb' => 'cmb_tooltip_label_cb',
68 + 'type' => 'gamipress_points',
69 + 'points_type_key' => $prefix . 'points_type_required',
70 + 'default' => '0',
71 + ),
72 + $prefix . 'rank_type_required' => array(
73 + 'name' => __( 'Rank Type Required', 'gamipress' ),
74 + 'tooltip' => __( 'Rank Type of the required rank to earn this achievement.', 'gamipress' ),
75 + 'label_cb' => 'cmb_tooltip_label_cb',
76 + 'type' => 'select',
77 + 'options' => $rank_types_options
78 + ),
79 + $prefix . 'rank_required' => array(
80 + 'name' => __( 'Rank Required', 'gamipress' ),
81 + 'tooltip' => __( 'Rank required to earn this achievement.', 'gamipress' ),
82 + 'label_cb' => 'cmb_tooltip_label_cb',
83 + 'type' => 'select',
84 + 'options_cb' => 'gamipress_options_cb_posts'
85 + ),
86 + $prefix . 'congratulations_text' => array(
87 + 'name' => __( 'Congratulations Text', 'gamipress' ),
88 + 'tooltip' => __( 'Displayed after achievement is earned.', 'gamipress' ),
89 + 'label_cb' => 'cmb_tooltip_label_cb',
90 + 'type' => 'wysiwyg',
91 + 'options' => array(
92 + 'textarea_rows' => 8,
93 + ),
94 + ),
95 + $prefix . 'maximum_earnings' => array(
96 + 'name' => __( 'Maximum Earnings Per User', 'gamipress' ),
97 + 'tooltip' => __( 'Number of times a user can earn this achievement (set it to 0 for no maximum).', 'gamipress' ),
98 + 'label_cb' => 'cmb_tooltip_label_cb',
99 + 'type' => 'text_small',
100 + 'attributes' => array(
101 + 'type' => 'number'
102 + ),
103 + 'default' => '1',
104 + ),
105 + $prefix . 'global_maximum_earnings' => array(
106 + 'name' => __( 'Global Maximum Earnings', 'gamipress' ),
107 + 'tooltip' => __( 'Number of times this achievement can be earned globally (set it to 0 for no maximum).', 'gamipress' )
108 + . '<br>' . __( '<strong>Note:</strong> This limit decides how many times this achievement can be earned on your site. Setting it to 10, for example, will limit this achievement to only the first 10 users who achieve it.' , 'gamipress' ),
109 + 'label_cb' => 'cmb_tooltip_label_cb',
110 + 'type' => 'text_small',
111 + 'attributes' => array(
112 + 'type' => 'number'
113 + ),
114 + 'default' => '0',
115 + ),
116 + $prefix . 'hidden' => array(
117 + 'name' => __( 'Hide', 'gamipress' ),
118 + 'tooltip' => __( 'Hide this achievement at frontend.', 'gamipress' )
119 + . '<br>' . __( 'Check this option to hide this achievement on achievements listings.' , 'gamipress' ),
120 + 'label_cb' => 'cmb_tooltip_label_cb',
121 + 'type' => 'select',
122 + 'options' => array(
123 + 'show' => __( 'Show to User', 'gamipress' ),
124 + 'hidden' => __( 'Hidden to User', 'gamipress' ),
125 + ),
126 + ),
127 + $prefix . 'unlock_with_points' => array(
128 + 'name' => __( 'Unlock using points', 'gamipress' ),
129 + 'tooltip' => __( 'Allow users to unlock this achievement by expending an amount of points.', 'gamipress' ),
130 + 'label_cb' => 'cmb_tooltip_label_cb',
131 + 'type' => 'checkbox',
132 + 'classes' => 'gamipress-switch'
133 + ),
134 + $prefix . 'points_to_unlock' => array(
135 + 'name' => __( 'Points to Unlock', 'gamipress' ),
136 + 'tooltip' => __( 'Amount of points needed to optionally unlock this achievement by expending them.', 'gamipress' ),
137 + 'label_cb' => 'cmb_tooltip_label_cb',
138 + 'type' => 'gamipress_points',
139 + 'points_type_key' => $prefix . 'points_type_to_unlock',
140 + 'default' => '0',
141 + ),
142 + ),
143 + array(
144 + 'context' => 'advanced',
145 + 'priority' => 'high',
146 + )
147 + );
148 +
149 + // Achievement Template
150 + gamipress_add_meta_box(
151 + 'achievement-template',
152 + __( 'Achievement Template', 'gamipress' ),
153 + $achievement_types,
154 + array(
155 + $prefix . 'show_times_earned' => array(
156 + 'name' => __( 'Show Times Earned', 'gamipress' ),
157 + 'tooltip' => __( 'Display the times the user has earned this achievement if it has been earned more than once.', 'gamipress' ),
158 + 'label_cb' => 'cmb_tooltip_label_cb',
159 + 'type' => 'checkbox',
160 + 'classes' => 'gamipress-switch'
161 + ),
162 + $prefix . 'show_global_times_earned' => array(
163 + 'name' => __( 'Show Times Earned By All Users', 'gamipress' ),
164 + 'tooltip' => __( 'Display the number of times all users have earned this achievement.', 'gamipress' ),
165 + 'label_cb' => 'cmb_tooltip_label_cb',
166 + 'type' => 'checkbox',
167 + 'classes' => 'gamipress-switch'
168 + ),
169 + $prefix . 'show_earners' => array(
170 + 'name' => __( 'Show Earners', 'gamipress' ),
171 + 'tooltip' => __( 'Display a list of users who have earned this achievement.', 'gamipress' ),
172 + 'label_cb' => 'cmb_tooltip_label_cb',
173 + 'type' => 'checkbox',
174 + 'classes' => 'gamipress-switch'
175 + ),
176 + $prefix . 'maximum_earners' => array(
177 + 'name' => __( 'Maximum Earners', 'gamipress' ),
178 + 'tooltip' => __( 'Set the maximum number of earners to show (0 for no maximum).', 'gamipress' ),
179 + 'label_cb' => 'cmb_tooltip_label_cb',
180 + 'type' => 'text',
181 + 'attributes' => array(
182 + 'type' => 'number',
183 + 'step' => '1',
184 + ),
185 + 'default' => '0'
186 + ),
187 + $prefix . 'layout' => array(
188 + 'name' => __( 'Layout', 'gamipress' ),
189 + 'tooltip' => __( 'Layout to show the achievement.', 'gamipress' ),
190 + 'label_cb' => 'cmb_tooltip_label_cb',
191 + 'type' => 'radio',
192 + 'options' => gamipress_get_layout_options(),
193 + 'default' => 'left',
194 + 'inline' => true,
195 + 'classes' => 'gamipress-image-options'
196 + ),
197 + $prefix . 'align' => array(
198 + 'name' => __( 'Alignment', 'gamipress' ),
199 + 'tooltip' => __( 'Alignment to show the achievement.', 'gamipress' ),
200 + 'label_cb' => 'cmb_tooltip_label_cb',
201 + 'type' => 'radio',
202 + 'options' => gamipress_get_alignment_options(),
203 + 'default' => 'none',
204 + 'inline' => true,
205 + 'classes' => 'gamipress-image-options'
206 + ),
207 + ),
208 + array( 'context' => 'side', )
209 + );
210 +
211 +}
212 +add_action( 'gamipress_init_meta_boxes', 'gamipress_achievements_meta_boxes' );