111 lines
4.5 KiB
PHP
111 lines
4.5 KiB
PHP
<?php
|
|
|
|
// Upstudy sensei course features metabox
|
|
add_action('cmb2_admin_init', 'tpc_upstudy_sensei_course_video');
|
|
|
|
function tpc_upstudy_sensei_course_video()
|
|
{
|
|
$prefix = '_upstudy_';
|
|
$cmb_sensei_course_metabox = new_cmb2_box(array(
|
|
'id' => $prefix . 'upstudy_sensei_course_video_metabox',
|
|
'title' => __('Course Intro Video', 'upstudy'),
|
|
'object_types' => array('course'), // Post type
|
|
'context' => 'normal', // 'normal', 'advanced', or 'side'
|
|
'priority' => 'core', // 'high', 'core', 'default' or 'low'
|
|
'show_names' => true, // Show field names on the left
|
|
));
|
|
$cmb_sensei_course_metabox->add_field(array(
|
|
'name' => 'Add Intro Video URL',
|
|
'id' => 'upstudy_sensei_video',
|
|
'type' => 'oembed',
|
|
));
|
|
$cmb_sensei_course_metabox->add_field( array(
|
|
'name' => __( 'Header Image', 'upstudy' ),
|
|
'id' => $prefix . 'header_img',
|
|
'type' => 'file',
|
|
'options' => array(
|
|
'url' => false
|
|
),
|
|
'text' => array(
|
|
'add_upload_file_text' => __( 'Add Image', 'upstudy' )
|
|
),
|
|
'description' => __( 'This image will be shown at the course single page header section.', 'upstudy' )
|
|
) );
|
|
}
|
|
|
|
// Upstudy sensei course features metabox
|
|
add_action('cmb2_admin_init', 'tpc_upstudy_sensei_course_levels');
|
|
|
|
function tpc_upstudy_sensei_course_levels()
|
|
{
|
|
$prefix = '_upstudy_';
|
|
$cmb_sensei_course_metabox = new_cmb2_box(array(
|
|
'id' => $prefix . 'sensei_course_levels_metabox',
|
|
'title' => __('Course Levels', 'upstudy'),
|
|
'object_types' => array('course'), // Post type
|
|
'context' => 'normal', // 'normal', 'advanced', or 'side'
|
|
'priority' => 'core', // 'high', 'core', 'default' or 'low'
|
|
'show_names' => true, // Show field names on the left
|
|
));
|
|
|
|
$cmb_sensei_course_metabox->add_field( array(
|
|
'name' => 'Course Levels',
|
|
'id' => 'upstudy_sensei_course_level_key',
|
|
'type' => 'radio',
|
|
// 'show_option_none' => true,
|
|
'options' => array(
|
|
'all_levels' => __( 'All Levels', 'upstudy' ),
|
|
'beginner' => __( 'Beginner', 'upstudy' ),
|
|
'intermediate' => __( 'Intermediate', 'upstudy' ),
|
|
'expert' => __( 'Expert', 'upstudy' ),
|
|
),
|
|
) );
|
|
}
|
|
|
|
// ========= Sensei course custom features metxbox ========
|
|
|
|
add_action('cmb2_admin_init', 'tpc_upstudy_sensei_course_feature_metaboxes');
|
|
function tpc_upstudy_sensei_course_feature_metaboxes()
|
|
{
|
|
$prefix = '_upstudy_';
|
|
|
|
$cmb = new_cmb2_box(array(
|
|
'id' => 'upstudy_sensei_course_feature_repeater',
|
|
'title' => 'Custom Course Features',
|
|
'object_types' => array('course'), // Post type
|
|
'context' => 'normal',
|
|
'priority' => 'high',
|
|
'show_names' => true, // Show field names on the left
|
|
));
|
|
|
|
$sensei_custom_feature_group_id = $cmb->add_field(array(
|
|
'id' => 'sensei_custom_feature_group',
|
|
'type' => 'group',
|
|
'repeatable' => true,
|
|
'options' => array(
|
|
'group_title' => 'Course Features {#}',
|
|
'add_button' => 'Add Another Feature',
|
|
'remove_button' => 'Remove Feature',
|
|
'closed' => true, // Repeater fields closed by default - neat & compact.
|
|
'sortable' => true, // Allow changing the order of repeated groups.
|
|
),
|
|
));
|
|
$cmb->add_group_field($sensei_custom_feature_group_id, array(
|
|
'name' => __('Add Icon', 'upstudy'),
|
|
'desc' => __('You can add Dashicon or Elementor icon class here. <a target="_blank" href="https://devthrow.com/support/docs/upstudy/#icons">More info</a>', 'upstudy'),
|
|
'id' => 'sensei_custom_feature_group_icon',
|
|
'type' => 'text', // This field type
|
|
));
|
|
$cmb->add_group_field($sensei_custom_feature_group_id, array(
|
|
'name' => __('Label', 'upstudy'),
|
|
'desc' => __('Add your custom course feature label', 'upstudy'),
|
|
'id' => 'sensei_custom_feature_group_label',
|
|
'type' => 'text',
|
|
));
|
|
$cmb->add_group_field($sensei_custom_feature_group_id, array(
|
|
'name' => __('Value', 'upstudy'),
|
|
'desc' => __('Add your custom course feature label value', 'upstudy'),
|
|
'id' => 'sensei_custom_feature_group_value',
|
|
'type' => 'text',
|
|
));
|
|
} |