Skip to content

Instantly share code, notes, and snippets.

@MTphilclothier
Last active Dec 11, 2019
Embed
What would you like to do?
<?php
add_filter('rwmb_meta_boxes', function ($meta_boxes) {
$meta_boxes[] = array(
'title' => 'Customer Details',
'id' => 'customer_customer_details_metabox',
'pages'=> 'customer',
'context' => 'normal',
'priority' => 'high',
'storage_type' => 'custom_table',
'table' => 'pww_customers',
'fields' => array(
array(
'name' => 'Title',
'id' => 'title',
'type' => 'radio',
'inline' => true,
'options' => array(
'mr' => 'Mr',
'mrs' => 'Mrs',
'miss' => 'Miss',
'ms' => 'Ms',
),
),
array(
'name' => 'Forename',
'id' => 'forename',
'type' => 'text',
),
array(
'name' => 'Surname',
'id' => 'surname',
'type' => 'text',
),
array(
'name' => 'Address Line 1',
'id' => 'address_line_1',
'type' => 'text',
'admin_columns' => 'replace date',
),
array(
'name' => 'Town',
'id' => 'town',
'type' => 'text',
'admin_columns' => array(
'sort' => true,
),
),
array(
'name' => 'Postcode',
'id' => 'postcode',
'type' => 'text',
'required' => true,
'admin_columns' => array(
'sort' => true,
),
),
array(
'name' => 'Landline',
'id' => 'telephone',
'type' => 'text',
),
array(
'name' => 'Mobile',
'id' => 'mobile',
'type' => 'text',
),
array(
'name' => '2nd Mobile',
'id' => 'mobile_2',
'type' => 'text',
),
array(
'name' => 'Email',
'id' => 'email',
'type' => 'email',
),
array(
'name' => 'Week',
'id' => 'week',
'type' => 'number',
),
array(
'name' => 'Legacy ID',
'id' => 'legacy_id',
'type' => 'hidden',
'readonly' => true,
'disabled' => true,
),
),
);
return $meta_boxes;
});
<?php
// Register Customer CPT
add_action('init', function () {
$labels = array(
'name' => 'Customers',
'singular_name' => 'Customer',
'menu_name' => 'Customers',
'name_admin_bar' => 'Post Type',
'archives' => 'Item Archives',
'attributes' => 'Item Attributes',
'parent_item_colon' => 'Parent Item:',
'all_items' => 'All Customers',
'add_new_item' => 'Add New Customer',
'add_new' => 'Add Customer',
'new_item' => 'New Customer',
'edit_item' => 'Edit Customer',
'update_item' => 'Update Customer',
'view_item' => 'View Item',
'view_items' => 'View Items',
'search_items' => 'Search Item',
'not_found' => 'Not found',
'not_found_in_trash' => 'Not found in Trash',
'featured_image' => 'Featured Image',
'set_featured_image' => 'Set featured image',
'remove_featured_image' => 'Remove featured image',
'use_featured_image' => 'Use as featured image',
'insert_into_item' => 'Insert into item',
'uploaded_to_this_item' => 'Uploaded to this item',
'items_list' => 'Items list',
'items_list_navigation' => 'Items list navigation',
'filter_items_list' => 'Filter items list',
);
$args = array(
'label' => 'Customers',
'description' => '',
'labels' => $labels,
'supports' => false,
//'taxonomies' => array('question_category'),
'hierarchical' => false,
'public' => false,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 20,
'menu_icon' => 'dashicons-groups',
'show_in_admin_bar' => false,
'show_in_nav_menus' => false,
'can_export' => false,
'has_archive' => false,
'exclude_from_search' => true,
'publicly_queryable' => true,
'rewrite' => false,
'capability_type' => 'page',
'show_in_rest' => false,
);
register_post_type('customer', $args);
}, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment