feat: listing_category
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 59s

This commit is contained in:
2025-09-24 16:11:43 -04:00
parent 425ee29ddc
commit add3869f43
6 changed files with 850 additions and 543 deletions

View File

@@ -0,0 +1,68 @@
<?php
// Register 'listing-category' taxonomy
add_action( 'init', 'ccat_listing_category_register_taxonomy' );
function ccat_listing_category_register_taxonomy() {
register_taxonomy(
'listing_category',
array( 'listing' ),
array(
'labels' => array(
'name' => __( "Listing categories", 'ccat' ),
'singular_name' => __( "Listing category", 'ccat' ),
'search_items' => __( "Search listing-categories", 'ccat' ),
'popular_items' => __( "Popular listing-categories", 'ccat' ),
'all_items' => __( "All listing-categories", 'ccat' ),
'parent_item' => __( "Parent listing-category", 'ccat' ),
'parent_item_colon' => __( "Parent listing-category:", 'ccat' ),
'edit_item' => __( "Edit listing-category", 'ccat' ),
'update_item' => __( "Update listing-category", 'ccat' ),
'view_item' => __( "View listing-category", 'ccat' ),
'add_new_item' => __( "New listing-category", 'ccat' ),
'new_item_name' => __( "New listing-category", 'ccat' ),
'separate_items_with_commas' => __( "Separate listing-categories with commas", 'ccat' ),
'add_or_remove_items' => __( "Add or remove listing-categories", 'ccat' ),
'choose_from_most_used' => __( "Choose from the most used listing-categories", 'ccat' ),
'not_found' => __( "No listing-categories found.", 'ccat' ),
'no_terms' => __( "No listing-categories", 'ccat' ),
'menu_name' => __( "Listing categories", 'ccat' ),
'items_list_navigation' => __( "Listing categories list navigation", 'ccat' ),
'items_list' => __( "Listing categories list", 'ccat' ),
'most_used' => __( "Most used", 'ccat' ),
'back_to_items' => __( "&larr; Back to listing-categories", 'ccat' ),
),
'public' => false,
'hierarchical' => false,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => false,
'show_admin_column' => true,
'rewrite' => false,
'query_var' => true,
'show_in_rest' => true,
'rest_base' => 'listing_category',
'rest_controller_class' => 'WP_REST_Terms_Controller',
'meta_box_cb' => false,
'show_in_graphql' => true,
'graphql_single_name' => "ListingCategory",
'graphql_plural_name' => "ListingCategories",
'graphql_interfaces' => array( 'Node' ),
)
);
}
// Custom 'listing-category' term updated messages
add_filter( 'term_updated_messages', 'ccat_listing_category_term_updated_messages' );
function ccat_listing_category_term_updated_messages( $messages ) {
$messages['listing_category'] = array(
0 => '',
1 => __( "Listing category added.", 'ccat' ),
2 => __( "Listing category deleted.", 'ccat' ),
3 => __( "Listing category updated.", 'ccat' ),
4 => __( "Listing category not added.", 'ccat' ),
5 => __( "Listing category not updated.", 'ccat' ),
6 => __( "Listing categories deleted.", 'ccat' ),
);
return $messages;
}