Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'init', 'register_cpt_evento' );
- function register_cpt_evento() {
- $labels = array(
- 'name' => _x( 'Eventos', 'evento' ),
- 'singular_name' => _x( 'Evento', 'evento' ),
- 'add_new' => _x( 'Adicionar novo', 'evento' ),
- 'add_new_item' => _x( 'Adicionar novo evento', 'evento' ),
- 'edit_item' => _x( 'Editar evento', 'evento' ),
- 'new_item' => _x( 'Novo evento', 'evento' ),
- 'view_item' => _x( 'Ver evento', 'evento' ),
- 'search_items' => _x( 'Procurar eventos', 'evento' ),
- 'not_found' => _x( 'Nenhum evento encontrado', 'evento' ),
- 'not_found_in_trash' => _x( 'Nenhum evento encontrado na lixeira', 'evento' ),
- 'parent_item_colon' => _x( 'Evento pai:', 'evento' ),
- 'menu_name' => _x( 'Eventos', 'evento' ),
- );
- $args = array(
- 'labels' => $labels,
- 'hierarchical' => false,
- 'description' => 'Eventos',
- 'supports' => array( 'title', 'editor', 'thumbnail', 'comments' ),
- 'taxonomies' => array( 'colaboradores' ),
- 'public' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'menu_position' => 2,
- 'show_in_nav_menus' => true,
- 'publicly_queryable' => true,
- 'exclude_from_search' => false,
- 'has_archive' => true,
- 'query_var' => true,
- 'can_export' => true,
- 'rewrite' => true,
- 'capabilities' => array(
- 'edit_post' => 'edit_evento',
- 'edit_posts' => 'edit_eventos',
- 'edit_private_posts' => 'edit_private_eventos',
- 'edit_others_posts' => 'edit_other_eventos',
- 'read_post' => 'read_evento',
- 'read_private_posts' => 'read_private_eventos',
- 'publish_posts' => 'publish_eventos',
- 'delete_post' => 'delete_evento',
- 'delete_posts' => 'delete_eventos',
- 'delete_others_posts' => 'delete_others_eventos',
- 'delete_published_posts' => 'delete_published_eventos',
- 'delete_private_posts' => 'delete_private_eventos'
- )
- );
- register_post_type( 'evento', $args );
- $labels_tax = array(
- 'name' => _x( 'Colaboradores', 'taxonomy general name' ),
- 'singular_name' => _x( 'Colaborador', 'taxonomy singular name' ),
- 'search_items' => __( 'Procurar colaboradores' ),
- 'popular_items' => __( 'Mais usados' ),
- 'all_items' => __( 'Todos os colaboradores' ),
- 'parent_item' => null,
- 'parent_item_colon' => null,
- 'edit_item' => __( 'Editar colaborador' ),
- 'update_item' => __( 'Atualizar colaborador' ),
- 'add_new_item' => __( 'Adicionar novo colaborador' ),
- 'new_item_name' => __( 'Novo colaborador' ),
- 'separate_items_with_commas' => __( 'Separar colaboradores com vírgulas' ),
- 'add_or_remove_items' => __( 'Adicionar ou remover colaboradores' ),
- 'choose_from_most_used' => __( 'Escolha entre os colaboradores mais usados' ),
- 'menu_name' => __( 'Colaboradores' ),
- );
- register_taxonomy('colaboradores','evento',array(
- 'hierarchical' => false,
- 'labels' => $labels_tax,
- 'show_ui' => true,
- 'query_var' => true,
- 'rewrite' => array( 'slug' => 'colaboradores' ),
- 'capabilities' => array(
- 'manage_terms'=>'manage_colaboradores',
- 'edit_terms'=>'edit_colaboradores',
- 'delete_terms'=>'delete_colaboradores',
- 'assign_terms'=>'assign_colaboradores'
- )
- ));
- //Get the admin role
- $admin_role = get_role( 'administrator' );
- // Add more capabilities to the admin role only for this plugin.
- $admin_role->add_cap( 'edit_eventos' );
- $admin_role->add_cap( 'edit_evento' );
- $admin_role->add_cap( 'edit_private_eventos' );
- $admin_role->add_cap( 'edit_others_eventos' );
- $admin_role->add_cap( 'read_evento' );
- $admin_role->add_cap( 'read_private_eventos' );
- $admin_role->add_cap( 'publish_eventos' );
- $admin_role->add_cap( 'delete_evento' );
- $admin_role->add_cap( 'delete_eventos' );
- $admin_role->add_cap( 'delete_others_eventos' );
- $admin_role->add_cap( 'delete_published_eventos' );
- $admin_role->add_cap( 'delete_private_eventos' );
- $admin_role->add_cap( 'manage_colaboradores' );
- $admin_role->add_cap( 'edit_colaboradores' );
- $admin_role->add_cap( 'delete_colaboradores' );
- $admin_role->add_cap( 'assign_colaboradores' );
- }
- function cpt_rewrite_flush() {
- register_cpt_evento();
- flush_rewrite_rules();
- }
- register_activation_hook(__FILE__, 'cpt_rewrite_flush');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement