File: /home/slyfwmm/studiomilighetti/wp-content/plugins/domik-add-ons/inc/cmb2/functions.php
<?php
/* add_ons_php */
/**
* Gets a number of terms and displays them as options
* @param string $taxonomy Taxonomy terms to retrieve. Default is category.
* @param string|array $args Optional. get_terms optional arguments
* @return array An array of options that matches the CMB2 options array
*/
function domik_get_term_options( $taxonomy = 'category', $args = array() ) {
$args['taxonomy'] = $taxonomy;
// $defaults = array( 'taxonomy' => 'category' );
$args = wp_parse_args( $args, array( 'taxonomy' => 'category' ) );
$taxonomy = $args['taxonomy'];
$terms = get_terms( $taxonomy, $args );
// Initate an empty array
$term_options = array();
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
$term_options[ $term->term_id ] = $term->name;
}
}
return $term_options;
}
add_action( 'cmb2_admin_init', 'domik_cmb2_sample_metaboxes' );
/**
* Define the metabox and field configurations.
*/
function domik_cmb2_sample_metaboxes() {
// Start with an underscore to hide fields from custom fields list
$prefix = '_cmb_';
/**
* Initiate Post metabox
*/
$post_cmb = new_cmb2_box( array(
'id' => 'post_options',
'title' => esc_html__( 'Post Format Options', 'domik-add-ons' ),
'object_types' => array( 'post'), // Post type
'context' => 'normal',// normal, side and advanced
'priority' => 'high',// default, high and low - core
'show_names' => true, // Show field names on the left
) );
$post_cmb->add_field( array(
'name' => esc_html__('Post Slider and Gallery Images', 'domik-add-ons' ),
'id' => $prefix . 'post_slider_images',
'type' => 'file_list',
'preview_size' => array( 150, 150 ), // Default: array( 50, 50 )
) );
$post_cmb->add_field( array(
'name' => esc_html__('Gallery Columns', 'domik-add-ons' ),
'desc' => esc_html__('For Gallery post format only.','domik-add-ons'),
'id' => $prefix . 'gallery_cols',
'type' => 'select',
'default'=>'three',
'options' => array(
'one' => esc_html__( 'One column', 'domik-add-ons' ),
'two' => esc_html__( 'Two columns', 'domik-add-ons' ),
'three' => esc_html__( 'Three columns', 'domik-add-ons' ),
'four' => esc_html__( 'Four columns', 'domik-add-ons' ),
'five' => esc_html__( 'Five columns', 'domik-add-ons' ),
),
) );
$post_cmb->add_field( array(
'name' => esc_html__('oEmbed for Post Format', 'domik-add-ons' ),
'desc' => wp_kses(__('Enter a youtube, twitter, or instagram URL. Supports services listed at <a href="http://codex.wordpress.org/Embeds">http://codex.wordpress.org/Embeds</a>.', 'domik-add-ons' ),array('a'=>array('href'=>array()))),
'id' => $prefix . 'embed_video',
'type' => 'oembed',
) );
$post_cmb->add_field( array(
'name' => esc_html__('Centered Layout', 'domik-add-ons' ),
'desc' => esc_html__('Set this to Yes if you want to use content fullwidth centered layout instead of 70% width in left side.','domik-add-ons'),
'id' => $prefix . 'fullwidth_layout',
'type' => 'select',
'default'=>'no',
'options' => array(
'yes' => esc_html__( 'Yes', 'domik-add-ons' ),
'no' => esc_html__( 'No', 'domik-add-ons' ),
),
) );
$post_cmb->add_field( array(
'name' => esc_html__('Right Parallax Background', 'domik-add-ons' ),
'id' => $prefix . 'right_parallax_bg',
'type' => 'file',
// Optional:
'options' => array(
'url' => true, // Hide the text input for the url
),
) );
/**
* Initiate Portfolio metabox
*/
$folio_cmb = new_cmb2_box( array(
'id' => 'porfolio_list_fields',
'title' => esc_html__('Portfolio List Options', 'domik-add-ons' ),
'object_types' => array( 'portfolio'), // Post type
'context' => 'normal',// normal, side and advanced
'priority' => 'high',// default, high and low - core
'show_names' => true, // Show field names on the left
) );
// $folio_cmb->add_field( array(
// 'name' => esc_html__('Video Link', 'domik' ),
// 'desc' => wp_kses(__('Enter a youtube, twitter, or instagram URL to display video as a thumbnail. Supports services listed at <a href="http://codex.wordpress.org/Embeds" target="_blank">http://codex.wordpress.org/Embeds</a>.', 'domik' ),array('a'=>array('href'=>array(),'target'=>array()))),
// 'id' => $prefix . 'folio_video',
// 'type' => 'oembed',
// ) );
$folio_cmb->add_field( array(
'name' => esc_html__( 'Masonry Size', 'domik-add-ons' ),
'desc' => esc_html__( 'Choose the size of item thumbnail that show in portfolio masonry grid. You must select a Featured image for this portfolio item.', 'domik-add-ons' ),
'id' => $prefix . 'masonry_size',
'type' => 'select',
'show_option_none' => false,
'default' => 'one',
'options' => array(
'one' => esc_html__( 'Size One', 'domik-add-ons' ),
'one-tall' => esc_html__( 'Size One - Two Tall', 'domik-add-ons' ),
'second' => esc_html__( 'Size Two', 'domik-add-ons' ),
'three' => esc_html__( 'Size Three', 'domik-add-ons' ),
),
) );
$folio_cmb->add_field( array(
'name' => esc_html__( 'Additional Info', 'domik-add-ons' ),
'desc' => esc_html__( 'This text will show on portfolio grid view.', 'domik-add-ons' ),
'id' => $prefix . 'folio_add_info',
'default' => '',
'type' => 'textarea_small',
) );
$folio_cmb->add_field( array(
'name' => esc_html__('Popup Image or Video', 'domik-add-ons' ),
'desc' => esc_html__('Select image or Youtube, Vimeo video link for popup. Leave empty for single portfolio page link.', 'domik-add-ons' ),
'id' => $prefix . 'folio_popup_link',
'type' => 'file',
// Optional:
'options' => array(
'url' => true, // Hide the text input for the url
),
) );
$folio_cmb->add_field( array(
'name' => esc_html__( 'External Link', 'domik-add-ons' ),
'desc' => esc_html__( 'Link your portfolio item to EXTERNAL page instead of the portfolio page.', 'domik-add-ons' ),
'id' => $prefix . 'folio_external_link',
'default' => '',
'type' => 'text',
) );
// $folio_cmb->add_field( array(
// 'name' => esc_html__('Popup Gallery', 'domik' ),
// 'desc' => esc_html__('Select images for this portfolio gallery. The gallery will display when user click to the portfolio thumbnail on list.', 'domik' ),
// 'id' => $prefix . 'folio_popup_gallery',
// 'type' => 'file_list',
// // Optional:
// 'options' => array(
// 'url' => true, // Hide the text input for the url
// // 'add_upload_file_text' => 'Add File' // Change upload button text. Default: "Add or Upload File"
// ),
// ) );
/**
* Initiate Portfolio metabox
*/
$folio2_cmb = new_cmb2_box( array(
'id' => 'portfolio_single_fields',
'title' => esc_html__('Portfolio Single Page Options', 'domik-add-ons' ),
'object_types' => array( 'portfolio'), // Post type
'context' => 'normal',// normal, side and advanced
'priority' => 'high',// default, high and low - core
'show_names' => true, // Show field names on the left
) );
if(domik_global_var('folio_single_use_old')){
$folio2_cmb->add_field( array(
'name' => esc_html__( 'Single Style', 'domik-add-ons' ),
'desc' => esc_html__( 'Select style for this portfolio to display from front-end', 'domik-add-ons' ),
'id' => $prefix . 'single_style',
'type' => 'select',
'show_option_none' => false,
'options' => array(
'none' => esc_html__( 'Default in V2.8', 'domik-add-ons' ),
'style-1' => esc_html__( 'Style 1', 'domik-add-ons' ),
'style-2' => esc_html__( 'Style 2', 'domik-add-ons' ),
'style-3' => esc_html__( 'Style 3', 'domik-add-ons' ),
'style-4' => esc_html__( 'Style 4', 'domik-add-ons' ),
'style-5' => esc_html__( 'Style 5', 'domik-add-ons' ),
'style-6' => esc_html__( 'Style 6', 'domik-add-ons' ),
),
'default' =>'none',
) );
$folio2_cmb->add_field( array(
'name' => esc_html__('Use Older Settings?', 'domik-add-ons' ),
'desc' => esc_html__('Set this option to Yes if you used domik theme as older 2.2 version to edit your portfolio content.','domik-add-ons' ),
'id' => $prefix . 'use_older_settings',
'type' => 'radio_inline',
'options' => array(
'yes' => esc_html__( 'Yes', 'domik-add-ons' ),
'no' => esc_html__( 'No', 'domik-add-ons' ),
),
'default'=>'no',
) );
$folio2_cmb->add_field( array(
'name' => esc_html__( 'Portfolio Subtitle (for theme version less than 2.2)', 'domik-add-ons' ),
//'desc' => '',
'id' => $prefix . 'folio_subtitle',
'default' => '',
'type' => 'textarea_code',
) );
}
$folio2_cmb->add_field( array(
'name' => esc_html__('Right Background Image', 'domik-add-ons' ),
'desc' => esc_html__('For Right Image template only. For version less than 2.7: Portfolio single style 1 and style 5 as the right parallax image. Or in Portfolio style 4 as video background image for mobile device.', 'domik-add-ons' ),
'id' => $prefix . 'right_parallax_bg',
'type' => 'file',
// Optional:
'options' => array(
'url' => true, // Hide the text input for the url
),
) );
if(domik_global_var('folio_single_use_old')){
$folio2_cmb->add_field( array(
'name' => esc_html__('Portfolio Video or Audio Link (for theme version less than 2.2)', 'domik-add-ons' ),
'desc' => wp_kses(__('Enter a youtube, twitter, or instagram URL. Supports services listed at <a href="http://codex.wordpress.org/Embeds">http://codex.wordpress.org/Embeds</a>.', 'domik-add-ons' ),array('a'=>array('href'=>array()))),
'id' => $prefix . 'embed_video',
'type' => 'oembed',
) );
}
/**
* Initiate Story metabox
*/
$story_cmb = new_cmb2_box( array(
'id' => 'story_fields',
'title' => esc_html__('Meta Options', 'domik-add-ons' ),
'object_types' => array( 'story'), // Post type
'context' => 'normal',// normal, side and advanced
'priority' => 'high',// default, high and low - core
'show_names' => true, // Show field names on the left
) );
$story_cmb->add_field( array(
'name' => esc_html__( 'Story Date', 'domik-add-ons' ),
//'desc' => '',
'id' => $prefix . 'story_date',
'default' => '',
'type' => 'text',
) );
$story_cmb->add_field( array(
'name' => esc_html__( 'Additional Info Type', 'domik-add-ons' ),
'desc' => esc_html__( 'Select an additional info type to show.', 'domik-add-ons' ),
'id' => $prefix . 'show_info_type',
'type' => 'select',
'show_option_none' => false,
'options' => array(
'gallery' => esc_html__( 'Gallery Images', 'domik-add-ons' ),
'video' => esc_html__( 'Video', 'domik-add-ons' ),
'none' => esc_html__( 'None', 'domik-add-ons' ),
),
'default' => 'none',
) );
$story_cmb->add_field( array(
'name' => esc_html__('Gallery Images for Gallery info', 'domik-add-ons' ),
'desc' => '',
'id' => $prefix . 'gallery_images',
'type' => 'file_list',
) );
$story_cmb->add_field( array(
'name' => esc_html__('Enter Video Link for Video info', 'domik-add-ons' ),
'desc' => wp_kses(__('Enter a youtube, twitter, or instagram URL. Supports services listed at <a href="http://codex.wordpress.org/Embeds">http://codex.wordpress.org/Embeds</a>.', 'domik-add-ons' ),array('a'=>array('href'=>array()))),
'id' => $prefix . 'embed_video',
'type' => 'oembed',
) );
/**
* Initiate Page metabox
*/
$page_cmb = new_cmb2_box( array(
'id' => 'page_options',
'title' => esc_html__( 'Page Options', 'domik-add-ons' ),
'object_types' => array( 'page'), // Post type
'context' => 'normal',// normal, side and advanced
'priority' => 'high',// default, high and low - core
'show_names' => true, // Show field names on the left
) );
$page_cmb->add_field( array(
'name' => esc_html__('Centered Layout', 'domik-add-ons' ),
'desc' => esc_html__('Set this to Yes if you want to use content fullwidth centered layout instead of 70% width in left side.','domik-add-ons'),
'id' => $prefix . 'fullwidth_layout',
'type' => 'select',
'default'=>'no',
'options' => array(
'yes' => esc_html__( 'Yes', 'domik-add-ons' ),
'no' => esc_html__( 'No', 'domik-add-ons' ),
),
) );
$page_cmb->add_field( array(
'name' => esc_html__('Right Parallax Background', 'domik-add-ons' ),
'id' => $prefix . 'right_parallax_bg',
'type' => 'file',
// Optional:
'options' => array(
'url' => true, // Hide the text input for the url
),
) );
$page_cmb->add_field( array(
'name' => esc_html__('Rotate Background', 'domik-add-ons' ),
'desc' => esc_html__('Select rotate background for this page. Will override the option from Domik Options panel.', 'domik-add-ons' ),
'id' => $prefix . 'rotate_bg',
'type' => 'file',
// Optional:
'options' => array(
'url' => true, // Hide the text input for the url
),
) );
/**
* Initiate Portfolio Page Template metabox
*/
$page2_cmb = new_cmb2_box( array(
'id' => 'portfolio_page_options',
'title' => esc_html__( 'Portfolio Page Template Options', 'domik-add-ons' ),
'object_types' => array( 'page'), // Post type
'context' => 'normal',// normal, side and advanced
'priority' => 'high',// default, high and low - core
'show_names' => true, // Show field names on the left
) );
$page2_cmb->add_field( array(
'name' => esc_html__('Show Filter', 'domik-add-ons' ),
//'desc' => '',
'id' => $prefix . 'folio_show_filter',
'type' => 'radio_inline',
'options' => array(
'yes' => esc_html__( 'Yes', 'domik-add-ons' ),
'no' => esc_html__( 'No', 'domik-add-ons' ),
),
'default'=>'yes',
) );
$page2_cmb->add_field( array(
'name' => esc_html__('Show Info', 'domik-add-ons' ),
//'desc' => '',
'id' => $prefix . 'folio_show_info',
'type' => 'radio_inline',
'options' => array(
'yes' => esc_html__( 'Yes', 'domik-add-ons' ),
'no' => esc_html__( 'No', 'domik-add-ons' ),
),
'default'=>'yes',
) );
$page2_cmb->add_field( array(
'name' => esc_html__('Portfolio Categories', 'domik-add-ons' ),
'desc' => esc_html__('Select portfolio categories to get items from. For Portfolio page templates only.', 'domik-add-ons' ),
'id' => $prefix . 'portfolio_categories',
'type' => 'multicheck',
'options' => domik_get_term_options('skill'),
'select_all_button' => false
) );
$page2_cmb->add_field( array(
'name' => esc_html__('Exclude Portfolio Items', 'domik-add-ons' ),
'desc' => esc_html__('Portfolio ids separated by comma. Include Portfolio Items field must blank.', 'domik-add-ons' ),
'id' => $prefix . 'folio_exclude',
'type' => 'text',
) );
$page2_cmb->add_field( array(
'name' => esc_html__('Include Portfolio Items', 'domik-add-ons' ),
'desc' => esc_html__('Portfolio ids separated by comma. Exclude Portfolio Items field must blank.', 'domik-add-ons' ),
'id' => $prefix . 'folio_include',
'type' => 'text',
) );
$page2_cmb->add_field( array(
'name' => esc_html__('Items per page (-1 for all)', 'domik-add-ons' ),
//'desc' => esc_html__('', 'domik' ),
'id' => $prefix . 'portfolio_count',
'type' => 'text',
'default' => '-1',
) );
$page2_cmb->add_field( array(
'name' => esc_html__('Order By', 'domik-add-ons' ),
//'desc' => '',
'id' => $prefix . 'folio_orderby',
'type' => 'select',
'options' => array(
'date' => esc_html__( 'Date', 'domik-add-ons' ),
'ID' => esc_html__( 'ID', 'domik-add-ons' ),
'author' => esc_html__( 'Author', 'domik-add-ons' ),
'name' => esc_html__( 'Name', 'domik-add-ons' ),
'title' => esc_html__( 'Title', 'domik-add-ons' ),
'modified' => esc_html__( 'Modified', 'domik-add-ons' ),
'rand' => esc_html__( 'Random', 'domik-add-ons' ),
),
'default' =>'title',
) );
$page2_cmb->add_field( array(
'name' => esc_html__('Sort Order', 'domik-add-ons' ),
//'desc' => '',
'id' => $prefix . 'folio_order',
'type' => 'select',
'options' => array(
'DESC' => esc_html__( 'Descending', 'domik-add-ons' ),
'ASC' => esc_html__( 'Ascending', 'domik-add-ons' ),
),
'default' =>'DESC',
) );
$page2_cmb->add_field( array(
'name' => esc_html__('Columns Layout (for Portfolio Style 2 and Style 3 templates)', 'domik-add-ons' ),
//'desc' => '',
'id' => $prefix . 'folio_columns',
'type' => 'select',
'options' => array(
//'six' => esc_html__( 'Six Columns', 'domik' ),
'five' => esc_html__( 'Five Columns', 'domik-add-ons' ),
'four' => esc_html__( 'Four Columns', 'domik-add-ons' ),
'three' => esc_html__( 'Three Columns', 'domik-add-ons' ),
'two' => esc_html__( 'Two Columns', 'domik-add-ons' ),
'one' => esc_html__( 'One Column', 'domik-add-ons' ),
),
'default' =>'three',
) );
$page2_cmb->add_field( array(
'name' => esc_html__('Spacing', 'domik-add-ons' ),
//'desc' => '',
'id' => $prefix . 'folio_pad',
'type' => 'select',
'options' => array(
'small' => esc_html__( 'Small', 'domik-add-ons' ),
'big' => esc_html__( 'Big', 'domik-add-ons' ),
'none' => esc_html__( 'None', 'domik-add-ons' ),
),
'default' =>'small',
) );
$page2_cmb->add_field( array(
'name' => esc_html__('Enable Image Gallery on Portfolio Grid', 'domik-add-ons' ),
//'desc' => '',
'id' => $prefix . 'folio_enable_gallery',
'type' => 'select',
'show_option_none' => false,
'default' => 'no',
'options' => array(
'no' => esc_html__( 'No', 'domik-add-ons' ),
'yes' => esc_html__( 'Yes', 'domik-add-ons' ),
),
) );
/**
* Initiate User Profile metabox
*/
$user_cmb = new_cmb2_box( array(
'id' => 'user_edit',
'title' => esc_html__( 'User Profile Metabox', 'domik-add-ons' ),
'object_types' => array( 'user' ), // Tells CMB to use user_meta vs post_meta
'context' => 'normal',// normal, side and advanced
'priority' => 'core',// default, high and low - core
'show_names' => true, // Show field names on the left
) );
// $user_cmb->add_field( array(
// 'name' => esc_html__('Avatar', 'domik' ),
// // 'desc' => esc_html__('Select an image for resume grid view','domik'),
// 'id' => $prefix . 'avatar',
// 'type' => 'file',
// ) );
$user_cmb->add_field( array(
'name' => esc_html__( 'Facebook URL', 'domik-add-ons' ),
'id' => $prefix . 'facebookurl',
'type' => 'text_url',
) );
$user_cmb->add_field( array(
'name' => esc_html__( 'Twitter URL', 'domik-add-ons' ),
'id' => $prefix . 'twitterurl',
'type' => 'text_url',
) );
$user_cmb->add_field( array(
'name' => esc_html__( 'Google+ URL', 'domik-add-ons' ),
'id' => $prefix . 'googleplusurl',
'type' => 'text_url',
) );
$user_cmb->add_field( array(
'name' => esc_html__( 'Linkedin URL', 'domik-add-ons' ),
'id' => $prefix . 'linkedinurl',
'type' => 'text_url',
) );
$user_cmb->add_field( array(
'name' => esc_html__( 'Instagram URL', 'domik-add-ons' ),
'id' => $prefix . 'instagramurl',
'type' => 'text_url',
) );
$user_cmb->add_field( array(
'name' => esc_html__( 'Tumblr URL', 'domik-add-ons' ),
'id' => $prefix . 'tumblrurl',
'type' => 'text_url',
) );
}