$taxonomy ) {
$taxonomies_arr[] = $taxonomy['slug'];
}
if ( ! empty( $taxonomies_arr ) ) {
$cmb_term = new_cmb2_box( array(
'id' => 'custom_taxonomies_font_icons',
'title' => __( 'Icon fonts Metabox', 'ba-hotel-light' ), // Doesn't output for term boxes
'object_types' => array( 'term' ), // Tells CMB2 to use term_meta vs post_meta
'taxonomies' => $taxonomies_arr, // Tells CMB2 which taxonomies should have these fields
//'new_term_section' => true, // Will display in the "Add New Category" section
) );
$cmb_term->add_field( array(
'name' => esc_html__( 'Linearicons icon class', 'ba-hotel-light' ),
'desc' => sprintf(
/* translators: %1$s: URL */
__( 'Exapmle: lnr lnr-tag
Find icon classes list on Linearicons site', 'ba-hotel-light' ),
'https://linearicons.com/free/'
),
'id' => 'lnr_class',
'type' => 'text',
) );
$cmb_term->add_field( array(
'name' => esc_html__( 'Eleganticons icon class', 'ba-hotel-light' ),
'desc' => sprintf(
/* translators: %1$s: URL */
__( 'Example: eleganticon icon_folder-alt
Find icon classes list on Elegant Themes site', 'ba-hotel-light' ),
'https://www.elegantthemes.com/blog/resources/elegant-icon-font'
),
'id' => 'el_class',
'type' => 'text',
) );
$cmb_term->add_field( array(
'name' => esc_html__( 'Fontawesome 5 icon class', 'ba-hotel-light' ),
'desc' => sprintf(
/* translators: %1$s: URL */
__( 'Exapmle: fas fa-wifi
Find icon classes list on Fontawesome site', 'ba-hotel-light' ),
'https://fontawesome.com/cheatsheet/'
),
'id' => 'fa_class',
'type' => 'fontawesome_icon',
) );
}
}
//////////////////////////////////////////////////
/**
* Outputs an additional CMB custom field
* to allow the FontAwesome Icon selection.
*
* @return
*/
public static function cmb2_render_fontawesome_icon( $field, $escaped_value, $object_id, $object_type, $field_type ) {
$output = $field_type->input( array( 'type' => 'text', 'class' => 'fontawesome-icon-select regular-text' ) );
$output = apply_filters( 'bahotel_l_cmb2_render_fontawesome_icon', $output, $field, $field_type );
echo wp_kses( $output, BAH_L_Settings::$wp_allowedposttags );
}
//////////////////////////////////////////////////
/**
* Sanitizes icon class name.
*
* @return string
*/
public static function cmb2_sanitize_fontawesome_icon( $sanitized_val, $val ) {
if ( ! empty( $val ) ) {
return sanitize_text_field( $val );
}
return $sanitized_val;
}
//////////////////////////////////////////////////
/**
* Add extra fields to service posts
*
* @param object $cmb
* @param string $prefix
*
* @return
*/
public static function cmb2_service($cmb, $prefix) {
if ( ! class_exists( 'BABE_Post_types' ) ) {
return;
}
$cmb->add_field( array(
'name' => __( 'Service subtitle', 'ba-hotel-light' ),
'id' => $prefix . 'service_subtitle',
'type' => 'text',
) );
}
////////////////////////////////////////////////////////////
//// End of our class.
////////////////////////////////////////////////////////////
}
//////////////////////////////////////////////////
/**
* Calling to setup class.
*/
BAH_L_CMB2_Admin::init();