PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / trunk
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI vtrunk
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 7.8.6 7.8.5 All 44 releases
gamipress / includes / admin / meta-boxes / points-type.php

points-type.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI trunk, at includes/admin/meta-boxes/points-type.php

127 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Points Type Meta Boxes
4 *
5 * @package GamiPress\Admin\Meta_Boxes\Points_Type
6 * @author GamiPress <contact@gamipress.com>, Ruben Garcia <rubengcdev@gmail.com>
7 * @since 1.4.7
8 */
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * Register points type meta boxes
14 *
15 * @since 1.0.0
16 */
17 function gamipress_points_type_meta_boxes() {
18
19 // Start with an underscore to hide fields from custom fields list
20 $prefix = '_gamipress_';
21
22 // Check if points types are public
23 $public_points_type = apply_filters( 'gamipress_public_points_type', false );
24
25 // Points Type Data
26 gamipress_add_meta_box(
27 'points-type-data',
28 __( 'Points Type Data', 'gamipress' ),
29 'points-type',
30 array(
31 'post_title' => array(
32 'name' => __( 'Singular Name', 'gamipress' ),
33 'tooltip' => __( 'The singular name for this points type.', 'gamipress' ),
34 'label_cb' => 'cmb_tooltip_label_cb',
35 'type' => 'text_medium',
36 ),
37 $prefix . 'plural_name' => array(
38 'name' => __( 'Plural Name', 'gamipress' ),
39 'tooltip' => __( 'The plural name for this points type.', 'gamipress' ),
40 'label_cb' => 'cmb_tooltip_label_cb',
41 'type' => 'text_medium',
42 ),
43 'post_name' => array(
44 'name' => __( 'Slug', 'gamipress' ),
45 'desc' => (( $public_points_type ) ? '<span class="gamipress-permalink hide-if-no-js">' . site_url() . '/<strong class="gamipress-post-name"></strong>/</span><br>' : '' ),
46 'tooltip' => __( 'Slug is used for internal references, as some shortcode attributes, to completely differentiate this points type from any other (leave blank to automatically generate one).', 'gamipress' ),
47 'label_cb' => 'cmb_tooltip_label_cb',
48 'type' => 'text_medium',
49 'attributes' => array(
50 'maxlength' => 20
51 )
52 ),
53 ),
54 array( 'priority' => 'high', )
55 );
56
57 // Points Display Options
58 gamipress_add_meta_box(
59 'points-display-options',
60 __( 'Points Display Options', 'gamipress' ),
61 'points-type',
62 array(
63 $prefix . 'label_position' => array(
64 'name' => __( 'Label Position', 'gamipress' ),
65 'tooltip' => __( 'Location of the points type label.', 'gamipress' ),
66 'label_cb' => 'cmb_tooltip_label_cb',
67 'type' => 'select',
68 'options_cb' => 'gamipress_options_cb_points_label_position',
69 'default' => 'after'
70 ),
71 $prefix . 'thousands_separator' => array(
72 'name' => __( 'Thousands Separator', 'gamipress' ),
73 'tooltip' => __( 'The symbol (usually , or .) to separate thousands.', 'gamipress' ),
74 'label_cb' => 'cmb_tooltip_label_cb',
75 'type' => 'text_small',
76 'default' => ''
77 ),
78 $prefix . 'html_display' => array(
79 'name' => __( 'HTML Display', 'gamipress' ),
80 'tooltip' => __( 'Set how this points type should get displayed when HTML is allowed.', 'gamipress' ),
81 'label_cb' => 'cmb_tooltip_label_cb',
82 'type' => 'radio',
83 'classes' => 'gamipress-switch',
84 'options_cb' => 'gamipress_options_cb_points_html_display',
85 'default' => 'label_image_after'
86 ),
87 ),
88 array( 'context' => 'side', )
89 );
90
91 }
92 add_action( 'gamipress_init_points-type_meta_boxes', 'gamipress_points_type_meta_boxes' );
93
94 // Options callback to return the points label position options using the current points type label
95 function gamipress_options_cb_points_label_position( $field ) {
96
97 $plural = gamipress_get_points_type_plural( $field->object_id, true );
98
99 return array(
100 'after' => sprintf( __( 'After (10 %s)', 'gamipress' ), $plural ),
101 'before' => sprintf( __( 'Before (%s 10)', 'gamipress' ), $plural ),
102 );
103
104 }
105
106 // Options callback for the points html display option
107 function gamipress_options_cb_points_html_display( $field ) {
108
109 $plural = gamipress_get_points_type_plural( $field->object_id, true );
110 $image = gamipress_get_points_type_thumbnail( $field->object_id, 'gamipress-points', 'gamipress-points-thumbnail gamipress-points-thumbnail-inline' );
111
112 if( ! $image ) {
113 $image = '<img src="' . GAMIPRESS_URL . 'assets/badges/points/gamipress-star.png' . '" class="gamipress-points-thumbnail gamipress-points-thumbnail-inline" />';
114 }
115
116 $image_label = $image . ' ' . $plural;
117
118 return array(
119 'label_image_after' => sprintf( __( '10 %s', 'gamipress' ), $image_label ),
120 'image_after' => sprintf( __( '10 %s', 'gamipress' ), $image ),
121 'label_after' => sprintf( __( '10 %s', 'gamipress' ), $plural ),
122 'label_image_before' => sprintf( __( '%s 10', 'gamipress' ), $image_label ),
123 'image_before' => sprintf( __( '%s 10', 'gamipress' ), $image ),
124 'label_before' => sprintf( __( '%s 10', 'gamipress' ), $plural ),
125 );
126
127 }