Advertisement
Guest User

Untitled

a guest
May 6th, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.77 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' => __( 'command-form', 'your-text-domain' ),
  9. 'id' => 'command-form',
  10. 'post_types' => ['commande-en-ligne'],
  11. 'fields' => [
  12. [
  13. 'name' => __( 'Votre Nom', 'your-text-domain' ),
  14. 'id' => $prefix . 'name',
  15. 'type' => 'text',
  16. 'required' => 1,
  17. 'admin_columns' => [
  18. 'position' => 'replace title',
  19. 'title' => 'De:',
  20. ],
  21. 'columns' => 4,
  22. ],
  23. [
  24. 'name' => __( 'Téléphone', 'your-text-domain' ),
  25. 'id' => $prefix . 'telephone',
  26. 'type' => 'text',
  27. 'required' => 1,
  28. 'columns' => 4,
  29. 'save_field' => 1,
  30. ],
  31. [
  32. 'name' => __( 'Courriel', 'your-text-domain' ),
  33. 'id' => $prefix . 'courriel',
  34. 'type' => 'text',
  35. 'required' => 1,
  36. 'admin_columns' => [
  37. 'position' => 'after name',
  38. 'title' => 'Courriel',
  39. ],
  40. 'columns' => 8,
  41. 'save_field' => 1,
  42. ],
  43. [
  44. 'name' => __( 'Commande', 'your-text-domain' ),
  45. 'id' => $prefix . 'commande',
  46. 'type' => 'group',
  47. 'clone' => 1,
  48. 'add_button' => __( 'Ajouter +', 'your-text-domain' ),
  49. 'save_field' => 1,
  50. 'fields' => [
  51. [
  52. 'name' => __( 'Item', 'your-text-domain' ),
  53. 'id' => $prefix . 'item',
  54. 'type' => 'text',
  55. 'required' => 1,
  56. 'columns' => 4,
  57. 'class' => 'pile-up',
  58. 'save_field' => 1,
  59. ],
  60. [
  61. 'name' => __( 'Quantité', 'your-text-domain' ),
  62. 'id' => $prefix . 'qty',
  63. 'type' => 'number',
  64. 'min' => 1,
  65. 'std' => 1,
  66. 'required' => 1,
  67. 'columns' => 2,
  68. 'save_field' => 1,
  69. ],
  70. [
  71. 'name' => __( 'Code BMR', 'your-text-domain' ),
  72. 'id' => $prefix . 'code_bmr',
  73. 'type' => 'text',
  74. 'columns' => 2,
  75. 'save_field' => 1,
  76. ],
  77. ],
  78. ],
  79. [
  80. 'name' => __( 'Réception', 'your-text-domain' ),
  81. 'id' => $prefix . 'reception',
  82. 'type' => 'radio',
  83. 'options' => [
  84. 'cueillette' => __( 'Cueillette', 'your-text-domain' ),
  85. 'livraison' => __( 'Livraison', 'your-text-domain' ),
  86. ],
  87. 'required' => 1,
  88. 'admin_columns' => [
  89. 'position' => 'after courriel',
  90. 'title' => 'Réception',
  91. ],
  92. 'save_field' => 1,
  93. 'inline' => false,
  94. ],
  95. [
  96. 'name' => __( 'Destination', 'your-text-domain' ),
  97. 'id' => $prefix . 'destination',
  98. 'type' => 'group',
  99. 'save_field' => 1,
  100. 'fields' => [
  101. [
  102. 'name' => __( 'Adresse', 'your-text-domain' ),
  103. 'id' => $prefix . 'adresse',
  104. 'type' => 'text',
  105. 'columns' => 8,
  106. 'save_field' => 1,
  107. ],
  108. [
  109. 'name' => __( 'Ville', 'your-text-domain' ),
  110. 'id' => $prefix . 'ville',
  111. 'type' => 'text',
  112. 'columns' => 5,
  113. 'save_field' => 1,
  114. ],
  115. [
  116. 'name' => __( 'Code postal', 'your-text-domain' ),
  117. 'id' => $prefix . 'code_postal',
  118. 'type' => 'text',
  119. 'columns' => 3,
  120. 'save_field' => 1,
  121. ],
  122. ],
  123. 'hidden' => [
  124. 'when' => [['reception', '!=', 'livraison']],
  125. 'relation' => 'or',
  126. ],
  127. ],
  128. [
  129. 'name' => __( 'Méthode de Paiement', 'your-text-domain' ),
  130. 'id' => $prefix . 'paiement',
  131. 'type' => 'checkbox_list',
  132. 'options' => [
  133. 'comptant' => __( 'Comptant', 'your-text-domain' ),
  134. 'credit' => __( 'Crédit', 'your-text-domain' ),
  135. 'telephone' => __( 'Téléphone (crédit)', 'your-text-domain' ),
  136. ],
  137. 'save_field' => 1,
  138. ],
  139. ],
  140. ];
  141.  
  142. return $meta_boxes;
  143. }`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement