_x( 'Service Categories', 'taxonomy general name', 'wp-bnb' ), 'singular_name' => _x( 'Service Category', 'taxonomy singular name', 'wp-bnb' ), 'search_items' => __( 'Search Service Categories', 'wp-bnb' ), 'popular_items' => __( 'Popular Service Categories', 'wp-bnb' ), 'all_items' => __( 'All Service Categories', 'wp-bnb' ), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __( 'Edit Service Category', 'wp-bnb' ), 'update_item' => __( 'Update Service Category', 'wp-bnb' ), 'add_new_item' => __( 'Add New Service Category', 'wp-bnb' ), 'new_item_name' => __( 'New Service Category Name', 'wp-bnb' ), 'separate_items_with_commas' => __( 'Separate categories with commas', 'wp-bnb' ), 'add_or_remove_items' => __( 'Add or remove categories', 'wp-bnb' ), 'choose_from_most_used' => __( 'Choose from the most used categories', 'wp-bnb' ), 'not_found' => __( 'No service categories found.', 'wp-bnb' ), 'menu_name' => __( 'Categories', 'wp-bnb' ), 'back_to_items' => __( '← Back to Categories', 'wp-bnb' ), ); $args = array( 'labels' => $labels, 'hierarchical' => false, // Non-hierarchical (like tags). 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_rest' => true, 'show_tagcloud' => false, 'show_in_quick_edit' => true, 'show_admin_column' => true, 'rewrite' => array( 'slug' => 'service-category', 'with_front' => false, ), 'query_var' => true, 'capabilities' => array( 'manage_terms' => 'manage_options', 'edit_terms' => 'manage_options', 'delete_terms' => 'manage_options', 'assign_terms' => 'edit_posts', ), ); register_taxonomy( self::TAXONOMY, array( 'bnb_service' ), $args ); } /** * Add custom fields to the add term form. * * @return void */ public static function add_form_fields(): void { ?>

term_id, 'service_category_icon', true ); $sort_order = get_term_meta( $term->term_id, 'service_category_sort_order', true ); ?>

$value ) { $new_columns[ $key ] = $value; if ( 'name' === $key ) { $new_columns['icon'] = __( 'Icon', 'wp-bnb' ); $new_columns['sort_order'] = __( 'Sort Order', 'wp-bnb' ); } } return $new_columns; } /** * Render custom column content. * * @param string $content Column content. * @param string $column_name Column name. * @param int $term_id Term ID. * @return string */ public static function render_column( string $content, string $column_name, int $term_id ): string { if ( 'icon' === $column_name ) { $icon = get_term_meta( $term_id, 'service_category_icon', true ); if ( $icon ) { return ''; } return '—'; } if ( 'sort_order' === $column_name ) { $sort_order = get_term_meta( $term_id, 'service_category_sort_order', true ); return esc_html( $sort_order ?: '0' ); } return $content; } /** * Get available icon options. * * @return array */ public static function get_icon_options(): array { return array( '' => __( '— Select Icon —', 'wp-bnb' ), 'food' => __( 'Food & Dining', 'wp-bnb' ), 'car' => __( 'Transportation', 'wp-bnb' ), 'heart' => __( 'Wellness & Spa', 'wp-bnb' ), 'tickets-alt' => __( 'Activities', 'wp-bnb' ), 'admin-home' => __( 'Housekeeping', 'wp-bnb' ), 'admin-appearance' => __( 'Room Service', 'wp-bnb' ), 'store' => __( 'Shopping', 'wp-bnb' ), 'groups' => __( 'Childcare', 'wp-bnb' ), 'pets' => __( 'Pet Services', 'wp-bnb' ), 'businessman' => __( 'Business', 'wp-bnb' ), 'calendar' => __( 'Events', 'wp-bnb' ), 'camera' => __( 'Photography', 'wp-bnb' ), 'admin-generic' => __( 'Other', 'wp-bnb' ), ); } /** * Get default service categories to seed on activation. * * @return array */ public static function get_default_terms(): array { return array( __( 'Food & Dining', 'wp-bnb' ) => array( 'icon' => 'food', 'sort_order' => 10, ), __( 'Transportation', 'wp-bnb' ) => array( 'icon' => 'car', 'sort_order' => 20, ), __( 'Wellness & Spa', 'wp-bnb' ) => array( 'icon' => 'heart', 'sort_order' => 30, ), __( 'Activities', 'wp-bnb' ) => array( 'icon' => 'tickets-alt', 'sort_order' => 40, ), __( 'Housekeeping', 'wp-bnb' ) => array( 'icon' => 'admin-home', 'sort_order' => 50, ), ); } }