meta-boxes.php
1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Point Meta Boxes.
*
* @package Badgeos
* @subpackage Point
* @author LearningTimes, LLC
* @license http://www.gnu.org/licenses/agpl.txt GNU AGPL v3.0
* @link https://credly.com
*/
/**
* Register custom meta box for Badgeos Point type.
*/
function badgeos_credits_type_metaboxes() {
/**
* Start with an underscore to hide fields from custom fields list.
*/
$prefix = '_point_';
/**
* Setup our $post_id, if available.
*/
$post_id = isset( $_GET['post'] ) ? sanitize_text_field( wp_unslash( $_GET['post'] ) ) : 0;
/**
* New Achievement Types.
*/
$settings = ( badgeos_utilities::get_option( 'badgeos_settings' ) ) ? badgeos_utilities::get_option( 'badgeos_settings' ) : array();
$cmb_obj = new_cmb2_box(
array(
'id' => 'points_type_data',
'title' => esc_html__( 'Point Data', 'badgeos' ),
'object_types' => array( trim( $settings['points_main_post_type'] ) ),
'context' => 'normal',
'priority' => 'high',
'show_names' => true,
)
);
$cmb_obj->add_field(
array(
'name' => esc_html__( 'Plural Name', 'badgeos' ),
'desc' => esc_html__( 'The plural name for this point (Title is singular name).', 'badgeos' ),
'id' => $prefix . 'plural_name',
'type' => 'text_medium',
)
);
}
add_action( 'cmb2_admin_init', 'badgeos_credits_type_metaboxes' );