Created
April 20, 2019 04:11
-
-
Save yeriepiscesa/08e79cc3fb624bfd0e26a3074163c06c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'cmb2_admin_init', 'solusipress_event_detail_metaboxes' ); | |
add_action( 'cmb2_admin_init', 'solusipress_event_price_metaboxes' ); | |
function solusipress_event_detail_metaboxes() { | |
$prefix = '_spevt_'; | |
$cmb = new_cmb2_box( array( | |
'id' => 'spevt_event_metabox', | |
'title' => __( 'Event Detail', 'cmb2' ), | |
'object_types' => array( 'event', ), // Post type | |
'context' => 'normal', | |
'priority' => 'high', | |
'show_names' => true, | |
) ); | |
$cmb->add_field( array( | |
'name' => __( 'Start Date/Time', 'cmb2' ), | |
'id' => $prefix . 'start_date', | |
'type' => 'text_datetime_timestamp', | |
) ); | |
$cmb->add_field( array( | |
'name' => __( 'End Date/Time', 'cmb2' ), | |
'id' => $prefix . 'end_date', | |
'type' => 'text_datetime_timestamp', | |
) ); | |
$group_field_id = $cmb->add_field( array( | |
'id' => $prefix.'sponsor_group', | |
'type' => 'group', | |
'description' => __( 'Sponsors', 'cmb2' ), | |
'options' => array( | |
'group_title' => __( 'Sponsor {#}', 'cmb2' ), // since version 1.1.4, {#} gets replaced by row number | |
'add_button' => __( 'Add Sponsor', 'cmb2' ), | |
'remove_button' => __( 'Remove Sponsor', 'cmb2' ), | |
'sortable' => true, // beta | |
'closed' => false, | |
), | |
) ); | |
$cmb->add_group_field( $group_field_id, array( | |
'name' => 'Company', | |
'id' => 'company', | |
'type' => 'text', | |
) ); | |
$cmb->add_group_field( $group_field_id, array( | |
'name' => 'Logo', | |
'description' => 'Upload image file for company logo', | |
'id' => 'logo', | |
'type' => 'file', | |
'options' => array( | |
'url' => false, // Hide the text input for the url | |
), | |
'text' => array( | |
'add_upload_file_text' => 'Add Image' | |
), | |
'query_args' => array( | |
'type' => array( | |
'image/jpg', | |
'image/jpeg', | |
'image/png', | |
), | |
), | |
'preview_size' => 'large' | |
) ); | |
$cmb->add_group_field( $group_field_id, array( | |
'name' => 'Website', | |
'id' => 'company_url', | |
'type' => 'text_url', | |
) ); | |
} | |
function solusipress_event_price_metaboxes() { | |
$prefix = '_spevt_'; | |
$cmb = new_cmb2_box( array( | |
'id' => 'spevt_event_price', | |
'title' => __( 'Event Price', 'cmb2' ), | |
'object_types' => array( 'event', ), // Post type | |
'context' => 'side', | |
'priority' => 'high', | |
'show_names' => true, // Show field names on the left | |
) ); | |
$cmb->add_field( array( | |
'name' => __( 'Ticket Price', 'cmb2' ), | |
'desc' => __( 'Leave empty for free event', 'cmb2' ), | |
'id' => $prefix.'price', | |
'type' => 'text_money', | |
'before_field' => 'IDR', | |
) ); | |
$cmb->add_field( array( | |
'name' => __( 'Buy URL', 'cmb2' ), | |
'desc' => __( 'Link to buy the ticket (e.g. https://tiket.com/awesome-event-by-solusipress)', 'cmb2' ), | |
'id' => $prefix.'buy_url', | |
'type' => 'text_url', | |
) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment