generated from pascalmartineau/wp-skeleton
feat: Initial plugins and theme
All checks were successful
WordPress deployment / deploy (push) Successful in 9s
All checks were successful
WordPress deployment / deploy (push) Successful in 9s
This commit is contained in:
92
wp-content/themes/ccat/includes/taxonomies/discipline.php
Normal file
92
wp-content/themes/ccat/includes/taxonomies/discipline.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
// Register 'discipline' taxonomy
|
||||
add_action( 'init', 'ccat_discipline_register_taxonomy' );
|
||||
function ccat_discipline_register_taxonomy() {
|
||||
register_taxonomy(
|
||||
'discipline',
|
||||
array( 'contributor', 'event' ),
|
||||
array(
|
||||
'labels' => array(
|
||||
'name' => __( "Disciplines", 'ccat' ),
|
||||
'singular_name' => __( "Discipline", 'ccat' ),
|
||||
'search_items' => __( "Search disciplines", 'ccat' ),
|
||||
'popular_items' => __( "Popular disciplines", 'ccat' ),
|
||||
'all_items' => __( "All disciplines", 'ccat' ),
|
||||
'parent_item' => __( "Parent discipline", 'ccat' ),
|
||||
'parent_item_colon' => __( "Parent discipline:", 'ccat' ),
|
||||
'edit_item' => __( "Edit discipline", 'ccat' ),
|
||||
'update_item' => __( "Update discipline", 'ccat' ),
|
||||
'view_item' => __( "View discipline", 'ccat' ),
|
||||
'add_new_item' => __( "New discipline", 'ccat' ),
|
||||
'new_item_name' => __( "New discipline", 'ccat' ),
|
||||
'separate_items_with_commas' => __( "Separate disciplines with commas", 'ccat' ),
|
||||
'add_or_remove_items' => __( "Add or remove disciplines", 'ccat' ),
|
||||
'choose_from_most_used' => __( "Choose from the most used disciplines", 'ccat' ),
|
||||
'not_found' => __( "No disciplines found.", 'ccat' ),
|
||||
'no_terms' => __( "No disciplines", 'ccat' ),
|
||||
'menu_name' => __( "Disciplines", 'ccat' ),
|
||||
'items_list_navigation' => __( "Disciplines list navigation", 'ccat' ),
|
||||
'items_list' => __( "Disciplines list", 'ccat' ),
|
||||
'most_used' => __( "Most used", 'ccat' ),
|
||||
'back_to_items' => __( "← Back to disciplines", 'ccat' ),
|
||||
),
|
||||
'public' => false,
|
||||
'hierarchical' => true,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'show_admin_column' => true,
|
||||
'rewrite' => false,
|
||||
'query_var' => true,
|
||||
'show_in_rest' => true,
|
||||
'rest_base' => 'discipline',
|
||||
'rest_controller_class' => 'WP_REST_Terms_Controller',
|
||||
'meta_box_cb' => false,
|
||||
'show_in_graphql' => true,
|
||||
'graphql_single_name' => "Discipline",
|
||||
'graphql_plural_name' => "Disciplines",
|
||||
'graphql_interfaces' => array( 'Node' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Custom 'discipline' term updated messages
|
||||
add_filter( 'term_updated_messages', 'ccat_discipline_term_updated_messages' );
|
||||
function ccat_discipline_term_updated_messages( $messages ) {
|
||||
$messages['discipline'] = array(
|
||||
0 => '',
|
||||
1 => __( "Discipline added.", 'ccat' ),
|
||||
2 => __( "Discipline deleted.", 'ccat' ),
|
||||
3 => __( "Discipline updated.", 'ccat' ),
|
||||
4 => __( "Discipline not added.", 'ccat' ),
|
||||
5 => __( "Discipline not updated.", 'ccat' ),
|
||||
6 => __( "Disciplines deleted.", 'ccat' ),
|
||||
);
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
// Add a top-level menu for the 'discipline' taxonomy in the admin menu
|
||||
add_action( 'admin_menu', 'ccat_discripline_admin_menu' );
|
||||
function ccat_discripline_admin_menu() {
|
||||
add_menu_page(
|
||||
'Disciplines',
|
||||
'Disciplines',
|
||||
'manage_options',
|
||||
'edit-tags.php?taxonomy=discipline',
|
||||
'',
|
||||
'dashicons-microphone',
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
// Set the 'discipline' taxonomy menu as active in the admin menu
|
||||
add_filter( 'parent_file', 'ccat_discipline_parent_file' );
|
||||
function ccat_discipline_parent_file( $parent_file ) {
|
||||
global $current_screen;
|
||||
if ( isset( $current_screen->taxonomy ) && $current_screen->taxonomy === 'discipline' ) {
|
||||
$parent_file = 'edit-tags.php?taxonomy=discipline';
|
||||
}
|
||||
return $parent_file;
|
||||
}
|
||||
Reference in New Issue
Block a user