94 lines
3.1 KiB
PHP
94 lines
3.1 KiB
PHP
<?php
|
|
|
|
// ########## HIDE DEFAULT TAXONOMIES
|
|
function wpsnipp_remove_default_taxonomies()
|
|
{
|
|
global $pagenow;
|
|
|
|
// register_taxonomy('post_tag', array());
|
|
register_taxonomy('category', array());
|
|
|
|
// $tax = array('post_tag', 'category');
|
|
$tax = array('category');
|
|
|
|
if ($pagenow == 'edit-tags.php' && in_array($_GET['taxonomy'], $tax)) {
|
|
wp_die('Invalid taxonomy');
|
|
}
|
|
}
|
|
add_action('init', 'wpsnipp_remove_default_taxonomies');
|
|
|
|
|
|
|
|
// ########## OTHER THAN ADMIN CANNOT CREATE TAGS
|
|
|
|
add_action('create_term', 'undo_create_term', 10, 3);
|
|
|
|
function undo_create_term($term_id, $tt_id, $taxonomy)
|
|
{
|
|
if (!current_user_can('administrator')) {
|
|
if ($taxonomy == 'post_tag') {
|
|
wp_delete_term($term_id, $taxonomy);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
// ########## REGISTER TAXONOMY
|
|
|
|
function add_custom_taxonomies()
|
|
{
|
|
// ————— Thématiques —————
|
|
register_taxonomy('thematiques', ['fiche-questions', 'fiche-conseils'], array(
|
|
// 'hierarchical' => true,
|
|
'labels' => array(
|
|
'name' => _x('Thématiques', 'taxonomy general name'),
|
|
'singular_name' => _x('Thématique', 'taxonomy singular name'),
|
|
'search_items' => __('Chercher une Thématique'),
|
|
'all_items' => __('Toutes les Thématiques'),
|
|
'parent_item' => __('Thématique Parent'),
|
|
'parent_item_colon' => __('Thématique Parent:'),
|
|
'edit_item' => __('Editer la Thématique'),
|
|
'update_item' => __('Mettre à jour la Thématique'),
|
|
'add_new_item' => __('Ajouter une Thématique'),
|
|
'new_item_name' => __('Nom de la nouvelle Thématique'),
|
|
'menu_name' => __('Thématiques'),
|
|
),
|
|
'hierarchical' => true, // This will allow URL's like "/locations/boston/cambridge/"
|
|
'rewrite' => array(
|
|
'slug' => 'thematiques', // This controls the base slug that will display before each term
|
|
// 'with_front' => false, // Don't display the category base before "/locations/"
|
|
),
|
|
));
|
|
|
|
|
|
// ————— —————
|
|
register_taxonomy('thematiques', ['fiche-questions', 'fiche-conseils'], array(
|
|
|
|
// 'hierarchical' => true,
|
|
|
|
// This array of options controls the labels displayed in the WordPress Admin UI
|
|
'labels' => array(
|
|
'name' => _x('Thématiques', 'taxonomy general name'),
|
|
'singular_name' => _x('Thématique', 'taxonomy singular name'),
|
|
'search_items' => __('Chercher une Thématique'),
|
|
'all_items' => __('Toutes les Thématiques'),
|
|
'parent_item' => __('Thématique Parent'),
|
|
'parent_item_colon' => __('Thématique Parent:'),
|
|
'edit_item' => __('Editer la Thématique'),
|
|
'update_item' => __('Mettre à jour la Thématique'),
|
|
'add_new_item' => __('Ajouter une Thématique'),
|
|
'new_item_name' => __('Nom de la nouvelle Thématique'),
|
|
'menu_name' => __('Thématiques'),
|
|
),
|
|
// Control the slugs used for this taxonomy
|
|
'rewrite' => array(
|
|
'slug' => 'thematiques', // This controls the base slug that will display before each term
|
|
// 'with_front' => false, // Don't display the category base before "/locations/"
|
|
'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
|
|
),
|
|
));
|
|
}
|
|
add_action('init', 'add_custom_taxonomies', 0);
|