Advertisement
madanpraba

Metabox Custom Field

Jun 16th, 2021 (edited)
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 21.53 KB | None | 0 0
  1. <?php
  2. add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
  3.  
  4. function your_prefix_function_name( $meta_boxes ) {
  5.     $prefix = '';
  6.  
  7.     $meta_boxes[] = [
  8.         'title'        => __( 'Job Details Custom Table', 'your-text-domain' ),
  9.         'id'           => 'job-details-custom-table',
  10.         'post_types'   => ['job'],
  11.         'storage_type' => 'custom_table',
  12.         'table'        => 'wp_1p_my_jobmeta',
  13.         'validation'   => [
  14.             'rules'    => [
  15.                 $prefix . 'job_ct_inquiry_email' => [
  16.                     'email' => true,
  17.                 ],
  18.             ],
  19.             'messages' => [
  20.                 $prefix . 'job_ct_inquiry_email' => [
  21.                     'email' => 'Please enter a valid email',
  22.                 ],
  23.             ],
  24.         ],
  25.         'tabs'         => [
  26.             'job_taxonomies'        => [
  27.                 'label' => 'Job Taxonomies',
  28.                 'icon'  => 'admin-tools',
  29.             ],
  30.             'general_details'       => [
  31.                 'label' => 'General Details',
  32.                 'icon'  => 'admin-network',
  33.             ],
  34.             'salary'                => [
  35.                 'label' => 'Salary',
  36.                 'icon'  => 'tickets-alt',
  37.             ],
  38.             'hiring_organization'   => [
  39.                 'label' => 'Hiring Organization',
  40.                 'icon'  => 'id-alt',
  41.             ],
  42.             'application_details'   => [
  43.                 'label' => 'Application Details',
  44.                 'icon'  => 'megaphone',
  45.             ],
  46.             'main_details'          => [
  47.                 'label' => 'Main Details',
  48.                 'icon'  => 'admin-post',
  49.             ],
  50.             'contact_details'       => [
  51.                 'label' => 'Contact Details',
  52.                 'icon'  => 'phone',
  53.             ],
  54.             'advertisement_details' => [
  55.                 'label' => 'Advertisement Details',
  56.                 'icon'  => 'megaphone',
  57.             ],
  58.         ],
  59.         'fields'       => [
  60.             [
  61.                 'name'           => __( 'Job Category Position', 'your-text-domain' ),
  62.                 'id'             => $prefix . 'job_category_position',
  63.                 'type'           => 'taxonomy',
  64.                 'taxonomy'       => ['position'],
  65.                 'field_type'     => 'checkbox_tree',
  66.                 'remove_default' => true,
  67.                 'columns'        => 3,
  68.                 'tab'            => 'job_taxonomies',
  69.             ],
  70.             [
  71.                 'name'           => __( 'Job Category Status', 'your-text-domain' ),
  72.                 'id'             => $prefix . 'job_category_status',
  73.                 'type'           => 'taxonomy',
  74.                 'desc'           => __( 'Select \'ongoing\' for all the Job', 'your-text-domain' ),
  75.                 'taxonomy'       => ['category'],
  76.                 'field_type'     => 'checkbox_list',
  77.                 'remove_default' => true,
  78.                 'columns'        => 3,
  79.                 'tab'            => 'job_taxonomies',
  80.             ],
  81.             [
  82.                 'name'           => __( 'Job Category Country', 'your-text-domain' ),
  83.                 'id'             => $prefix . 'job_category_country',
  84.                 'type'           => 'taxonomy',
  85.                 'taxonomy'       => ['country'],
  86.                 'field_type'     => 'select_advanced',
  87.                 'remove_default' => true,
  88.                 'columns'        => 3,
  89.                 'tab'            => 'job_taxonomies',
  90.             ],
  91.             [
  92.                 'name'           => __( 'Job Category Field', 'your-text-domain' ),
  93.                 'id'             => $prefix . 'job_category_field',
  94.                 'type'           => 'taxonomy',
  95.                 'taxonomy'       => ['job-field'],
  96.                 'field_type'     => 'checkbox_tree',
  97.                 'remove_default' => true,
  98.                 'columns'        => 3,
  99.                 'tab'            => 'job_taxonomies',
  100.             ],
  101.             [
  102.                 'name'           => __( 'Research Subjects', 'your-text-domain' ),
  103.                 'id'             => $prefix . 'research_subjects',
  104.                 'type'           => 'taxonomy',
  105.                 'desc'           => __( 'Type the research subjects to select the content', 'your-text-domain' ),
  106.                 'taxonomy'       => ['post_tag'],
  107.                 'field_type'     => 'select_advanced',
  108.                 'add_new'        => true,
  109.                 'remove_default' => true,
  110.                 'multiple'       => true,
  111.                 'columns'        => 3,
  112.                 'tab'            => 'job_taxonomies',
  113.             ],
  114.             [
  115.                 'name' => __( 'Position Name', 'your-text-domain' ),
  116.                 'id'   => $prefix . 'job_position_name',
  117.                 'type' => 'text',
  118.                 'desc' => __( 'Enter the given position name in the advertisement', 'your-text-domain' ),
  119.                 'size' => 7,
  120.                 'tab'  => 'general_details',
  121.             ],
  122.             [
  123.                 'name'    => __( 'Job Type', 'your-text-domain' ),
  124.                 'id'      => $prefix . 'job_type',
  125.                 'type'    => 'select',
  126.                 'desc'    => __( 'Select Full Time / Part Time', 'your-text-domain' ),
  127.                 'options' => [
  128.                     'Full-Time' => __( 'Full-Time', 'your-text-domain' ),
  129.                     'Part-Time' => __( 'Part-Time', 'your-text-domain' ),
  130.                     'Contract'  => __( 'Contract', 'your-text-domain' ),
  131.                     'Temporary' => __( 'Temporary', 'your-text-domain' ),
  132.                     'Intern'    => __( 'Intern', 'your-text-domain' ),
  133.                     'Other'     => __( 'Other', 'your-text-domain' ),
  134.                 ],
  135.                 'tab'     => 'general_details',
  136.             ],
  137.             [
  138.                 'name' => __( 'No of Positions', 'your-text-domain' ),
  139.                 'id'   => $prefix . 'job_no_positions',
  140.                 'type' => 'text',
  141.                 'desc' => __( 'Mention One/Two/More/Few/100', 'your-text-domain' ),
  142.                 'std'  => 'One',
  143.                 'size' => 6,
  144.                 'tab'  => 'general_details',
  145.             ],
  146.             [
  147.                 'name' => __( 'Deadline Date Time', 'your-text-domain' ),
  148.                 'id'   => $prefix . 'job_deadline_date_time',
  149.                 'type' => 'datetime',
  150.                 'desc' => __( 'Select the date and time as given in the advertisement', 'your-text-domain' ),
  151.                 'size' => 6,
  152.                 'tab'  => 'general_details',
  153.             ],
  154.             [
  155.                 'name'     => __( 'Deadline Time Zone', 'your-text-domain' ),
  156.                 'id'       => $prefix . 'job_deadline_timezone',
  157.                 'type'     => 'text',
  158.                 'desc'     => __( 'Select the Time Zone GMT', 'your-text-domain' ),
  159.                 'size'     => -1,
  160.                 'datalist' => [
  161.                     'id'      => '60c9b644a57ca',
  162.                     'options' => [
  163.                         '(GMT +1)
  164. ',
  165.                         '(GMT +2)
  166. ',
  167.                         '(GMT +3)
  168. ',
  169.                         '(GMT +3:30)
  170. ',
  171.                         '(GMT +4)
  172. ',
  173.                         '(GMT +5)
  174. ',
  175.                         '(GMT +5:30)
  176. ',
  177.                         '(GMT +6)
  178. ',
  179.                         '(GMT +7)
  180. ',
  181.                         '(GMT +8)
  182. ',
  183.                         '(GMT +9)
  184. ',
  185.                         '(GMT +9:30)
  186. ',
  187.                         '(GMT +10)
  188. ',
  189.                         '(GMT +11)
  190. ',
  191.                         '(GMT +12)
  192. ',
  193.                         '(GMT -1)
  194. ',
  195.                         '(GMT -3)
  196. ',
  197.                         '(GMT -3:30)
  198. ',
  199.                         '(GMT -4)
  200. ',
  201.                         '(GMT -5)
  202. ',
  203.                         '(GMT -6)
  204. ',
  205.                         '(GMT -7)
  206. ',
  207.                         '(GMT -8)
  208. ',
  209.                         '(GMT -9)
  210. ',
  211.                         '(GMT -10)
  212. ',
  213.                         '(GMT-11)',
  214.                     ],
  215.                 ],
  216.                 'tab'      => 'general_details',
  217.             ],
  218.             [
  219.                 'name'        => __( 'Joining Date', 'your-text-domain' ),
  220.                 'id'          => $prefix . 'job_joining_date',
  221.                 'type'        => 'text',
  222.                 'desc'        => __( 'Mention the joining date as given in the advertisement', 'your-text-domain' ),
  223.                 'placeholder' => __( 'Sep 01, 2021 or ASAP', 'your-text-domain' ),
  224.                 'size'        => 6,
  225.                 'tab'         => 'general_details',
  226.             ],
  227.             [
  228.                 'name' => __( 'Contract Period', 'your-text-domain' ),
  229.                 'id'   => $prefix . 'job_contract_period',
  230.                 'type' => 'text',
  231.                 'desc' => __( 'Mention the years/month. If not available, Leave it for default value', 'your-text-domain' ),
  232.                 'std'  => 'Not Mentioned',
  233.                 'size' => 3,
  234.                 'tab'  => 'general_details',
  235.             ],
  236.             [
  237.                 'name'              => __( 'Schema Currency', 'your-text-domain' ),
  238.                 'id'                => $prefix . 'job_currency',
  239.                 'type'              => 'select',
  240.                 'label_description' => __( 'This is for Schema', 'your-text-domain' ),
  241.                 'desc'              => __( 'Select the Currency name (USD)', 'your-text-domain' ),
  242.                 'options'           => [
  243.                     'EURO' => __( 'EURO', 'your-text-domain' ),
  244.                     'DKK'  => __( 'DKK (Denmark)', 'your-text-domain' ),
  245.                     'USD'  => __( 'USD (America)', 'your-text-domain' ),
  246.                     'KRW'  => __( 'KRW (South Korea)', 'your-text-domain' ),
  247.                     'INR'  => __( 'INR (India)', 'your-text-domain' ),
  248.                     'GBP'  => __( 'GBP (England)', 'your-text-domain' ),
  249.                 ],
  250.                 'columns'           => 3,
  251.                 'tab'               => 'salary',
  252.             ],
  253.             [
  254.                 'name'              => __( 'Schema Value', 'your-text-domain' ),
  255.                 'id'                => $prefix . 'job_value',
  256.                 'type'              => 'text',
  257.                 'label_description' => __( 'This is for Schema', 'your-text-domain' ),
  258.                 'desc'              => __( 'Mention the salary value (40,000)', 'your-text-domain' ),
  259.                 'size'              => 3,
  260.                 'columns'           => 3,
  261.                 'tab'               => 'salary',
  262.             ],
  263.             [
  264.                 'name'              => __( 'Schema Payroll', 'your-text-domain' ),
  265.                 'id'                => $prefix . 'job_payroll',
  266.                 'type'              => 'select',
  267.                 'label_description' => __( 'This is for Schema', 'your-text-domain' ),
  268.                 'desc'              => __( 'Mention Salary for Year/Month/Week', 'your-text-domain' ),
  269.                 'options'           => [
  270.                     'YEAR'  => __( 'Year', 'your-text-domain' ),
  271.                     'MONTH' => __( 'Month', 'your-text-domain' ),
  272.                     'WEEK'  => __( 'Week', 'your-text-domain' ),
  273.                     'DAY'   => __( 'Day', 'your-text-domain' ),
  274.                     'HOUR'  => __( 'Hour', 'your-text-domain' ),
  275.                 ],
  276.                 'columns'           => 3,
  277.                 'tab'               => 'salary',
  278.             ],
  279.             [
  280.                 'name'              => __( 'Actual Salary', 'your-text-domain' ),
  281.                 'id'                => $prefix . 'job_salary',
  282.                 'type'              => 'text',
  283.                 'label_description' => __( 'Mentioned Salary in the Advertisement', 'your-text-domain' ),
  284.                 'desc'              => __( 'Mention as 5,000 USD/Month or leave to default value', 'your-text-domain' ),
  285.                 'std'               => 'According to Standard Norms',
  286.                 'size'              => 6,
  287.                 'columns'           => 3,
  288.                 'tab'               => 'salary',
  289.             ],
  290.             [
  291.                 'name'       => __( 'University Name', 'your-text-domain' ),
  292.                 'id'         => $prefix . 'job_uni_name',
  293.                 'type'       => 'post',
  294.                 'desc'       => __( 'Type the Name of the University', 'your-text-domain' ),
  295.                 'post_type'  => ['emp'],
  296.                 'field_type' => 'select',
  297.                 'columns'    => 3,
  298.                 'tab'        => 'hiring_organization',
  299.             ],
  300.             [
  301.                 'name'              => __( 'University URL', 'your-text-domain' ),
  302.                 'id'                => $prefix . 'job_uni_url',
  303.                 'type'              => 'text',
  304.                 'label_description' => __( 'Select the University name to link the URL', 'your-text-domain' ),
  305.                 'desc'              => __( 'If not in the list, paste the University URL without https://', 'your-text-domain' ),
  306.                 'columns'           => 3,
  307.                 'tab'               => 'hiring_organization',
  308.             ],
  309.             [
  310.                 'name'        => __( 'University Section', 'your-text-domain' ),
  311.                 'id'          => $prefix . 'job_uni_section',
  312.                 'type'        => 'text',
  313.                 'placeholder' => __( 'Type the Section name/Department', 'your-text-domain' ),
  314.                 'size'        => 6,
  315.                 'columns'     => 3,
  316.                 'tab'         => 'hiring_organization',
  317.             ],
  318.             [
  319.                 'name'        => __( 'University Department', 'your-text-domain' ),
  320.                 'id'          => $prefix . 'job_uni_dept',
  321.                 'type'        => 'text',
  322.                 'placeholder' => __( 'Type the Department/School name/Locality', 'your-text-domain' ),
  323.                 'required'    => true,
  324.                 'columns'     => 3,
  325.                 'tab'         => 'hiring_organization',
  326.             ],
  327.             [
  328.                 'name'    => __( 'University City Name', 'your-text-domain' ),
  329.                 'id'      => $prefix . 'job_uni_city',
  330.                 'type'    => 'text',
  331.                 'desc'    => __( 'City Name', 'your-text-domain' ),
  332.                 'size'    => 6,
  333.                 'columns' => 3,
  334.                 'tab'     => 'hiring_organization',
  335.             ],
  336.             [
  337.                 'name'    => __( 'University Post Code', 'your-text-domain' ),
  338.                 'id'      => $prefix . 'job_uni_post_code',
  339.                 'type'    => 'text',
  340.                 'desc'    => __( 'Pin code of the University Location', 'your-text-domain' ),
  341.                 'size'    => 3,
  342.                 'columns' => 3,
  343.                 'tab'     => 'hiring_organization',
  344.             ],
  345.             [
  346.                 'name'    => __( 'Educational Qualification', 'your-text-domain' ),
  347.                 'id'      => $prefix . 'edu_qualification',
  348.                 'type'    => 'checkbox_list',
  349.                 'options' => [
  350.                     'PhD Degree'          => __( 'PhD Degree', 'your-text-domain' ),
  351.                     'Masters Degree'      => __( 'Masters Degree', 'your-text-domain' ),
  352.                     'Bachelors Degree'    => __( 'Bachelors Degree', 'your-text-domain' ),
  353.                     'Relevant Experience' => __( 'Relevant Experience', 'your-text-domain' ),
  354.                 ],
  355.                 'tab'     => 'application_details',
  356.             ],
  357.             [
  358.                 'name' => __( 'Qualification Details', 'your-text-domain' ),
  359.                 'id'   => $prefix . 'job_qualifi_details',
  360.                 'type' => 'wysiwyg',
  361.                 'desc' => __( 'All qualification related information, if necessary add sub-heading (h3 tag) like preference, attitude,..', 'your-text-domain' ),
  362.                 'tab'  => 'application_details',
  363.             ],
  364.             [
  365.                 'name' => __( 'How to Apply', 'your-text-domain' ),
  366.                 'id'   => $prefix . 'job_how_to_apply',
  367.                 'type' => 'wysiwyg',
  368.                 'tab'  => 'application_details',
  369.             ],
  370.             [
  371.                 'name'              => __( 'Reference Number', 'your-text-domain' ),
  372.                 'id'                => $prefix . 'job_ref_number',
  373.                 'type'              => 'text',
  374.                 'label_description' => __( 'Job Reference Number or Text given in the Post', 'your-text-domain' ),
  375.                 'desc'              => __( 'If nothing available, please use \'-\'', 'your-text-domain' ),
  376.                 'std'               => '-',
  377.                 'columns'           => 3,
  378.                 'tab'               => 'application_details',
  379.             ],
  380.             [
  381.                 'name' => __( 'Documents Required', 'your-text-domain' ),
  382.                 'id'   => $prefix . 'job_doc_req',
  383.                 'type' => 'wysiwyg',
  384.                 'tab'  => 'application_details',
  385.             ],
  386.             [
  387.                 'name' => __( 'Responsibilities', 'your-text-domain' ),
  388.                 'id'   => $prefix . 'job_responsibilities',
  389.                 'type' => 'wysiwyg',
  390.                 'desc' => __( 'Responsibilities or Job description', 'your-text-domain' ),
  391.                 'tab'  => 'main_details',
  392.             ],
  393.             [
  394.                 'name'       => __( 'About Information', 'your-text-domain' ),
  395.                 'id'         => $prefix . 'job_about',
  396.                 'type'       => 'group',
  397.                 'desc'       => __( 'Title of the content (about the project or anything else)', 'your-text-domain' ),
  398.                 'clone'      => true,
  399.                 'sort_clone' => true,
  400.                 'add_button' => __( '+ Add more', 'your-text-domain' ),
  401.                 'fields'     => [
  402.                     [
  403.                         'name'        => __( 'Job CT About Title', 'your-text-domain' ),
  404.                         'id'          => $prefix . 'job_ct_about_title',
  405.                         'type'        => 'text',
  406.                         'placeholder' => __( 'Enter the title of the content', 'your-text-domain' ),
  407.                     ],
  408.                     [
  409.                         'name' => __( 'Job CT About Content', 'your-text-domain' ),
  410.                         'id'   => $prefix . 'job_ct_about_content',
  411.                         'type' => 'wysiwyg',
  412.                     ],
  413.                 ],
  414.                 'tab'        => 'main_details',
  415.             ],
  416.             [
  417.                 'name' => __( 'Note or Other Details', 'your-text-domain' ),
  418.                 'id'   => $prefix . 'job_note',
  419.                 'type' => 'wysiwyg',
  420.                 'desc' => __( 'Type the Notes or other information about the position else leave it', 'your-text-domain' ),
  421.                 'std'  => 'Nothing to mention',
  422.                 'tab'  => 'main_details',
  423.             ],
  424.             [
  425.                 'name'       => __( 'Inquiry Details', 'your-text-domain' ),
  426.                 'id'         => $prefix . 'job_inquiry',
  427.                 'type'       => 'group',
  428.                 'clone'      => true,
  429.                 'add_button' => __( '+ add more', 'your-text-domain' ),
  430.                 'fields'     => [
  431.                     [
  432.                         'name'    => __( 'Name', 'your-text-domain' ),
  433.                         'id'      => $prefix . 'job_ct_inquiry_name',
  434.                         'type'    => 'text',
  435.                         'desc'    => __( 'Name of the person', 'your-text-domain' ),
  436.                         'columns' => 4,
  437.                     ],
  438.                     [
  439.                         'name'    => __( 'Designation', 'your-text-domain' ),
  440.                         'id'      => $prefix . 'job_ct_inquiry_designation',
  441.                         'type'    => 'text',
  442.                         'desc'    => __( 'Designation of the person', 'your-text-domain' ),
  443.                         'std'     => 'Incharge',
  444.                         'columns' => 4,
  445.                     ],
  446.                     [
  447.                         'name'    => __( 'Email', 'your-text-domain' ),
  448.                         'id'      => $prefix . 'job_ct_inquiry_email',
  449.                         'type'    => 'email',
  450.                         'desc'    => __( 'email address', 'your-text-domain' ),
  451.                         'columns' => 4,
  452.                     ],
  453.                     [
  454.                         'name'    => __( 'Phone Number', 'your-text-domain' ),
  455.                         'id'      => $prefix . 'job_ct_inquiry_phone',
  456.                         'type'    => 'tel',
  457.                         'desc'    => __( 'phone number', 'your-text-domain' ),
  458.                         'std'     => '-',
  459.                         'columns' => 4,
  460.                     ],
  461.                 ],
  462.                 'tab'        => 'contact_details',
  463.             ],
  464.             [
  465.                 'name'    => __( 'Job Adv Title', 'your-text-domain' ),
  466.                 'id'      => $prefix . 'job_adv_title',
  467.                 'type'    => 'text',
  468.                 'desc'    => __( 'Paste the title of position given in the advertisement', 'your-text-domain' ),
  469.                 'columns' => 6,
  470.                 'tab'     => 'advertisement_details',
  471.             ],
  472.             [
  473.                 'name'    => __( 'Job Adv URL', 'your-text-domain' ),
  474.                 'id'      => $prefix . 'job_adv_url',
  475.                 'type'    => 'url',
  476.                 'columns' => 6,
  477.                 'tab'     => 'advertisement_details',
  478.             ],
  479.         ],
  480.     ];
  481.  
  482.     return $meta_boxes;
  483. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement