$taxonomy ) { $taxonomies_arr[] = $taxonomy['slug']; } if ( ! empty( $taxonomies_arr ) ) { $cmb_term = new_cmb2_box( array( 'id' => 'custom_taxonomies_fontawesome', 'title' => __( 'Fontawesome Metabox', 'ba-tours-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' => __( 'Fontawesome 5 icon class', 'ba-tours-light' ), //'desc' => __( 'Field description (optional)', 'ba-tours-light' ), 'id' => 'fa_class', 'type' => 'fontawesome_icon', ) ); } } ////////////////////////////////////////////////// /** * Outputs ana dditional 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( 'batourslight_cmb2_render_fontawesome_icon', $output, $field, $field_type ); echo wp_kses_post($output); } ////////////////////////////////////////////////// /** * 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; } //////////////////////////////////////////////////////////// //// End of our class. //////////////////////////////////////////////////////////// } ////////////////////////////////////////////////// /** * Calling to setup class. */ BAT_CMB2_Admin::init();