Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * REGISTER THE TAXONOMY
- */
- //
- function cardinalpm_contacts_register_taxonomy()
- {
- $args = array(
- 'label' => esc_html__('Contacts', 'text-domain'),
- 'labels' => array(
- 'menu_name' => esc_html__('Contacts', 'text-domain'),
- 'all_items' => esc_html__('All Contacts', 'text-domain'),
- 'edit_item' => esc_html__('Edit Contact', 'text-domain'),
- 'view_item' => esc_html__('View Contact', 'text-domain'),
- 'update_item' => esc_html__('Update Contact', 'text-domain'),
- 'add_new_item' => esc_html__('Add new Contact', 'text-domain'),
- 'new_item_name' => esc_html__('New Contact', 'text-domain'),
- 'parent_item' => esc_html__('Parent Contact', 'text-domain'),
- 'parent_item_colon' => esc_html__('Parent Contact:', 'text-domain'),
- 'search_items' => esc_html__('Search Contacts', 'text-domain'),
- 'popular_items' => esc_html__('Popular Contacts', 'text-domain'),
- 'separate_items_with_commas' => esc_html__('Separate Contacts with commas', 'text-domain'),
- 'add_or_remove_items' => esc_html__('Add or remove Contacts', 'text-domain'),
- 'choose_from_most_used' => esc_html__('Choose most used Contacts', 'text-domain'),
- 'not_found' => esc_html__('No Contacts found', 'text-domain'),
- 'name' => esc_html__('Contacts', 'text-domain'),
- 'singular_name' => esc_html__('Contact', 'text-domain'),
- ),
- 'public' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'show_in_nav_menus' => true,
- 'show_tagcloud' => false,
- 'show_in_quick_edit' => true,
- 'show_admin_column' => true,
- 'show_in_rest' => true,
- 'hierarchical' => false,
- 'query_var' => true,
- 'sort' => false,
- 'rewrite_no_front' => false,
- 'rewrite_hierarchical' => false,
- 'rewrite' => true,
- );
- register_taxonomy('contact', array('cardinal-job'), $args);
- }
- add_action('init', 'cardinalpm_contacts_register_taxonomy', 0);
- /*
- * DEFINE CUSTOM TABLE
- */
- add_action('init', 'create_table_for_contacts');
- function create_table_for_contacts()
- {
- if (!class_exists('MB_Custom_Table_API')) {
- return;
- }
- MB_Custom_Table_API::create('cardinal_contacts', array(
- 'contact_email' => 'VARCHAR(240) NOT NULL',
- 'contact_phone' => 'TEXT NOT NULL',
- 'related_customer' => 'INT(11) NOT NULL',
- 'contact_notes' => 'TEXT NOT NULL',
- ));
- }
- /*
- * THE ACTUAL META BOXES
- */
- //
- add_filter('rwmb_meta_boxes', 'contactdetails_register_meta_boxes');
- function contactdetails_register_meta_boxes($meta_boxes)
- {
- $prefix = '';
- $meta_boxes[] = array(
- 'title' => esc_html__('Contact Details', 'text-domain'),
- 'id' => 'contact-details',
- 'storage_type' => 'custom_table',
- 'table' => 'cardinal_contacts',
- 'fields' => array(
- array(
- 'id' => 'contact_email',
- 'name' => esc_html__('Email', 'text-domain'),
- 'type' => 'email',
- 'class' => 'wide',
- ),
- array(
- 'id' => 'contact_phone',
- 'type' => 'text',
- 'name' => esc_html__('Phone', 'text-domain'),
- 'class' => 'wide',
- ),
- array(
- 'id' => 'related_customer',
- 'type' => 'taxonomy_advanced',
- 'name' => esc_html__('Company', 'text-domain'),
- 'taxonomy' => 'customer',
- 'field_type' => 'select_advanced',
- 'add_new' => true,
- ),
- array(
- 'id' => 'contact_notes',
- 'type' => 'textarea',
- 'name' => esc_html__('Notes', 'text-domain'),
- ),
- ),
- 'taxonomies' => 'contact',
- 'autocomplete' => 'off',
- );
- return $meta_boxes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement