<?php // Personalizzazione Backend // richiamata da function.php // require get_template_directory() . '/lib/ez_adminimize.php'; // ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- // // ----- ----- MENU - Rinomino NEWS e PRESS ----- ----- // // La menu label di Articoli la cambio in News function ez_cambia_menu_da_articoli_in_news() { global $menu; global $submenu; $menu[5][0] = 'News e Press'; $submenu['edit.php'][5][0] = 'Tutte le News'; $submenu['edit.php'][10][0] = 'Nuova News'; $submenu['edit.php'][15][0] = 'Categorie News'; unset($submenu['edit.php'][16]); //Rimuove il submenu 'Tag' } add_action( 'admin_menu', 'ez_cambia_menu_da_articoli_in_news' ); // ----- ----- MENU - Rinomino Label NEWS e PRESS----- ----- // // Modifico tutte le label di Articoli la cambio in News function ez_cambia_label_da_articoli_in_news() { global $wp_post_types; $labels = &$wp_post_types['post']->labels; $labels->name = 'News e Press'; $labels->singular_name = 'News'; $labels->add_new = 'Nuova News'; $labels->add_new_item = 'News'; $labels->edit_item = 'Modifica News'; $labels->new_item = 'Nuova News'; $labels->view_item = 'Visualizza News'; $labels->search_items = 'Cerca tra le News'; $labels->not_found = 'Nessuna News trovata'; $labels->not_found_in_trash = 'Nessuna News trovata nel Cestino'; } add_action( 'admin_menu', 'ez_cambia_label_da_articoli_in_news' ); // ----- ----- MENU - Aggiunge item al Menu----- ----- // //Aggiunge le pagine al Admin Menu - !!! Se aggiungo un nuovo menu item, ricordarsi di farlo visualizzare dalla funzione ez_admin_menu_da_conservare if ( !function_exists( 'ez_admin_add_menu_item' ) ) { function ez_admin_add_menu_item(){ $ez_capability = 'edit_theme_options'; //La capability necessaria per visualizzare il menu personalizzato //Posizione 110 è per cpt_vini per come definito nella registrazione del type cpt_vini //Posizione 111 è preso da Types plugin che prende il primo disponibile dopo cpt_vini add_menu_page( 'HomePage', 'HomePage', $ez_capability , 'post.php?post=2&action=edit', '', 'dashicons-admin-page', 112 ); add_menu_page( 'Azienda', 'Azienda', $ez_capability, 'post.php?post=14&action=edit', '', 'dashicons-admin-page', 113 ); add_menu_page( 'Lifestyle', 'Lifestyle', $ez_capability, 'post.php?post=16&action=edit', '', 'dashicons-admin-page', 114 ); add_menu_page( 'Contatti', 'Contatti', $ez_capability, 'post.php?post=18&action=edit', '', 'dashicons-admin-page', 115 ); add_menu_page( 'Menu', 'Menu', $ez_capability, 'nav-menus.php', '', 'dashicons-menu', 116 ); } // function add_action( 'admin_menu', 'ez_admin_add_menu_item' ); } // exists // ----- ----- MENU - Elimina qualsiasi menu item non desiderato ----- ----- // // Creo il menu tenendo solo gli elementi che mi interessano if ( !function_exists( 'ez_admin_menu_da_conservare' ) ) { if( ! current_user_can( 'manage_options' ) ) { //tranne che per gli Amministratori function ez_admin_menu_da_conservare(){ //elementi del menu da conservare $menus_to_stay = array( 'edit.php', //Articoli (NEWS e PRESS) 'upload.php', //Media 'post.php?post=2&action=edit', //Home 'post.php?post=14&action=edit', //Azienda 'edit.php?post_type=cpt_vini', //Vini 'post.php?post=16&action=edit', //Lifestyle 'post.php?post=18&action=edit', //Contatti 'nav-menus.php', //Menu ); foreach ($GLOBALS['menu'] as $key => $value) { if (!in_array($value[2], $menus_to_stay)) remove_menu_page($value[2]); } // foreach } // function add_action('admin_init', 'ez_admin_menu_da_conservare'); } } // exists // ----- ----- TOOLBAR - Elimina item non desiderati ----- ----- // // Render toolbar personalizzato, elimino menu e nodi che non mi interessano if ( ! function_exists( 'ez_admin_toolbar_item_remove' ) ) { function ez_admin_toolbar_item_remove() { if( ! current_user_can( 'manage_options' ) ) { //tranne che per gli Amministratori global $wp_admin_bar; $wp_admin_bar->remove_menu('comments'); $wp_admin_bar->remove_menu('dashboard'); $wp_admin_bar->remove_menu('view-site'); $wp_admin_bar->remove_node( 'wp-logo' ); $wp_admin_bar->remove_node( 'new-content' ); $wp_admin_bar->remove_node( 'view' ); $wp_admin_bar->remove_node( 'edit' ); } } // function add_action( 'wp_before_admin_bar_render', 'ez_admin_toolbar_item_remove' ); } // exist // ----- ----- TOOLBAR - Aggiunge item personalizzati ----- ----- // if ( ! function_exists( 'ez_toolbar_item_add' ) ) { function ez_toolbar_item_add() { global $wp_admin_bar; $args = array( 'title' => 'News e Press', 'href' => admin_url() . 'edit.php?&cat=1', ); $wp_admin_bar->add_menu( $args ); $args = array( 'title' => 'Media', 'href' => admin_url() . 'upload.php', ); $wp_admin_bar->add_menu( $args ); $args = array( 'title' => 'Vini', 'href' => admin_url() . 'edit.php?post_type=cpt_vini', ); $wp_admin_bar->add_menu( $args ); $args = array( 'title' => 'HomePage', 'href' => admin_url() . 'post.php?post=2&action=edit', ); $wp_admin_bar->add_menu( $args ); $args = array( 'title' => 'Azienda', 'href' => admin_url() . 'post.php?post=14&action=edit', ); $wp_admin_bar->add_menu( $args ); $args = array( 'title' => 'Lifestyle', 'href' => admin_url() . 'post.php?post=16&action=edit', ); $wp_admin_bar->add_menu( $args ); $args = array( 'title' => 'Contatti', 'href' => admin_url() . 'post.php?post=18&action=edit', ); $wp_admin_bar->add_menu( $args ); $args = array( 'title' => 'Menu', 'href' => admin_url() . 'nav-menus.php', ); $wp_admin_bar->add_menu( $args ); } // function add_action( 'wp_before_admin_bar_render', 'ez_toolbar_item_add', 999 ); } // exist // ----- ----- METABOX ----- ----- // // Nella creazione di un nuovo post, anziché nascondere il meta box, rimuove direttamente il supporto alle caratteristiche superflue. if ( ! function_exists( 'ez_remove_metabox_post_type_support' ) ) { function ez_remove_metabox_post_type_support() { if( ! current_user_can( 'manage_options' ) ) { //tranne che per gli Amministratori foreach ( get_post_types() as $post_type ) { // per qualsiasi tipo di post (articoli, pagine e custom type) remove_post_type_support( $post_type, 'custom-fields' ); remove_post_type_support( $post_type, 'comments' ); remove_post_type_support( $post_type, 'author' ); remove_post_type_support( $post_type, 'trackbacks' ); remove_post_type_support( $post_type, 'excerpt' ); remove_post_type_support( $post_type, 'page-attributes' ); //template e gerarchia di pagina remove_post_type_support( $post_type, 'post-formats' ); // non implementato in gorghi_tema_wp } // Inoltre, solo per le pagine, elimina il WYSIWYG perchè l'ho sostituito con cruppi di Custom Field dedicati per template di pagina remove_post_type_support( 'page', 'editor' ); //rimuovo il metabox WYSIWYG di base dalle pagine remove_post_type_support( 'page', 'thumbnail' ); //rimuovo il metabox immagine featured di base dalle pagine remove_post_type_support( 'post', 'thumbnail' ); //rimuovo il metabox immagine featured di base dai post } } //function add_action( 'admin_init', 'ez_remove_metabox_post_type_support' ); } //exist // ----- ----- METABOX ----- ----- // // Rimuovo i meta box non desiderati dai qualsiasi post type if ( ! function_exists( 'ez_remove_meta_box_all_post_type' ) ) { function ez_remove_meta_box_all_post_type() { if( ! current_user_can( 'manage_options' ) ) { //tranne che per gli Amministratori foreach ( get_post_types() as $post_type ) { // per qualsiasi tipo di post (articoli, pagine e custom type) remove_meta_box( 'tagsdiv-post_tag','post','normal' ); // Metabox Tags //remove_meta_box( 'categorydiv','post','normal' ); // Metabox Categorie //remove_meta_box( 'wpcf-marketing','post','normal' ); // Pubblicità di Types } } } //function add_action('admin_menu','ez_remove_meta_box_all_post_type'); } //exist // ----- ----- Rimuove Impostazioni Schermata ----- ----- // // Rimuove la linguetta impostazioni schermata - Ricordarsi che per l'utente cliente va settato per ogni admin scree e poi attivato qui function ez_remove_screen_options(){ __return_false;} if( ! current_user_can( 'manage_options' ) ) { //tranne che per gli Amministratori add_filter('screen_options_show_screen', 'ez_remove_screen_options'); } // ----- ----- LOGIN LOGO ----- ----- // //Cambia il logo nella schermata di login al backend function ez_login_logo() { ?> <style type="text/css"> .login #login h1 a { background-image: url( "<?php echo get_template_directory_uri();?>/images/logo_gorghi.png" ); background-size: 165px auto; width: 320px; height: 80px; } </style> <?php } add_action( 'login_enqueue_scripts', 'ez_login_logo' ); // ----- ----- NEWS E PRESS ----- ----- // // Rimuove la colonna TAG dalla lista di di tutte le News function ez_remove_posts_listing_tags( $columns ) { unset( $columns[ 'tags' ] ); return $columns; } add_action( 'manage_posts_columns', 'ez_remove_posts_listing_tags' ); // ----- ----- Admin Footer Credit ----- ----- // //Cambia l'admin footer text credits function ez_admin_footer_text () { echo 'Realizzato da <a href="http://tamaco.it">tamaco.it</a>'; } //add_filter( 'admin_footer_text', 'ez_admin_footer_text' ); // ----- ----- DEBUG ----- ----- // // Visualizza l'array Global $menu e $submenu if (!function_exists('ez_debug_admin_menus')): function ez_debug_admin_menus() { if ( !is_admin()) return; global $submenu, $menu, $pagenow; if ( current_user_can('manage_options') ) { // ONLY DO THIS FOR ADMIN if( $pagenow == 'index.php' ) { // PRINTS ON DASHBOARD echo '---GLOBAL MENU---<pre>'; print_r( $menu ); echo '</pre>'; // TOP LEVEL MENUS echo '---GLOBAL SUBMENU---<pre>'; print_r( $submenu ); echo '</pre>'; // SUBMENUS } } } //add_action( 'admin_notices', 'ez_debug_admin_menus' ); endif; ?>