field-group-options.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?php
  2. // global
  3. global $field_group;
  4. // UI needs at lease 1 location rule
  5. if ( empty( $field_group['location'] ) ) {
  6. $field_group['location'] = array(
  7. // group 0
  8. array(
  9. // rule 0
  10. array(
  11. 'param' => 'post_type',
  12. 'operator' => '==',
  13. 'value' => 'post',
  14. ),
  15. ),
  16. );
  17. }
  18. acf_render_field_wrap(
  19. array(
  20. 'type' => 'tab',
  21. 'label' => __( 'Location Rules', 'acf' ),
  22. 'key' => 'acf_field_group_settings_tabs',
  23. )
  24. );
  25. echo '<div class="field-group-locations field-group-settings-tab">';
  26. acf_get_view( 'field-group-locations' );
  27. echo '</div>';
  28. acf_render_field_wrap(
  29. array(
  30. 'type' => 'tab',
  31. 'label' => __( 'Presentation', 'acf' ),
  32. 'key' => 'acf_field_group_settings_tabs',
  33. )
  34. );
  35. echo '<div class="field-group-setting-split-container field-group-settings-tab">';
  36. echo '<div class="field-group-setting-split">';
  37. // style
  38. acf_render_field_wrap(
  39. array(
  40. 'label' => __( 'Style', 'acf' ),
  41. 'instructions' => '',
  42. 'type' => 'button_group',
  43. 'name' => 'style',
  44. 'prefix' => 'acf_field_group',
  45. 'value' => $field_group['style'],
  46. 'choices' => array(
  47. 'default' => __( 'Standard (WP metabox)', 'acf' ),
  48. 'seamless' => __( 'Seamless (no metabox)', 'acf' ),
  49. ),
  50. )
  51. );
  52. // position
  53. acf_render_field_wrap(
  54. array(
  55. 'label' => __( 'Position', 'acf' ),
  56. 'instructions' => '',
  57. 'type' => 'button_group',
  58. 'name' => 'position',
  59. 'prefix' => 'acf_field_group',
  60. 'value' => $field_group['position'],
  61. 'choices' => array(
  62. 'acf_after_title' => __( 'High (after title)', 'acf' ),
  63. 'normal' => __( 'Normal (after content)', 'acf' ),
  64. 'side' => __( 'Side', 'acf' ),
  65. ),
  66. 'default_value' => 'normal',
  67. )
  68. );
  69. // label_placement
  70. acf_render_field_wrap(
  71. array(
  72. 'label' => __( 'Label placement', 'acf' ),
  73. 'instructions' => '',
  74. 'type' => 'button_group',
  75. 'name' => 'label_placement',
  76. 'prefix' => 'acf_field_group',
  77. 'value' => $field_group['label_placement'],
  78. 'choices' => array(
  79. 'top' => __( 'Top aligned', 'acf' ),
  80. 'left' => __( 'Left aligned', 'acf' ),
  81. ),
  82. )
  83. );
  84. // instruction_placement
  85. acf_render_field_wrap(
  86. array(
  87. 'label' => __( 'Instruction placement', 'acf' ),
  88. 'instructions' => '',
  89. 'type' => 'button_group',
  90. 'name' => 'instruction_placement',
  91. 'prefix' => 'acf_field_group',
  92. 'value' => $field_group['instruction_placement'],
  93. 'choices' => array(
  94. 'label' => __( 'Below labels', 'acf' ),
  95. 'field' => __( 'Below fields', 'acf' ),
  96. ),
  97. )
  98. );
  99. // menu_order
  100. acf_render_field_wrap(
  101. array(
  102. 'label' => __( 'Order No.', 'acf' ),
  103. 'instructions' => __( 'Field groups with a lower order will appear first', 'acf' ),
  104. 'type' => 'number',
  105. 'name' => 'menu_order',
  106. 'prefix' => 'acf_field_group',
  107. 'value' => $field_group['menu_order'],
  108. ),
  109. 'div',
  110. 'field'
  111. );
  112. echo '</div>';
  113. echo '<div class="field-group-setting-split">';
  114. // hide on screen
  115. $choices = array(
  116. 'permalink' => __( 'Permalink', 'acf' ),
  117. 'the_content' => __( 'Content Editor', 'acf' ),
  118. 'excerpt' => __( 'Excerpt', 'acf' ),
  119. 'custom_fields' => __( 'Custom Fields', 'acf' ),
  120. 'discussion' => __( 'Discussion', 'acf' ),
  121. 'comments' => __( 'Comments', 'acf' ),
  122. 'revisions' => __( 'Revisions', 'acf' ),
  123. 'slug' => __( 'Slug', 'acf' ),
  124. 'author' => __( 'Author', 'acf' ),
  125. 'format' => __( 'Format', 'acf' ),
  126. 'page_attributes' => __( 'Page Attributes', 'acf' ),
  127. 'featured_image' => __( 'Featured Image', 'acf' ),
  128. 'categories' => __( 'Categories', 'acf' ),
  129. 'tags' => __( 'Tags', 'acf' ),
  130. 'send-trackbacks' => __( 'Send Trackbacks', 'acf' ),
  131. );
  132. if ( acf_get_setting( 'remove_wp_meta_box' ) ) {
  133. unset( $choices['custom_fields'] );
  134. }
  135. acf_render_field_wrap(
  136. array(
  137. 'label' => __( 'Hide on screen', 'acf' ),
  138. 'instructions' => __( '<b>Select</b> items to <b>hide</b> them from the edit screen.', 'acf' ) . '<br /><br />' . __( "If multiple field groups appear on an edit screen, the first field group's options will be used (the one with the lowest order number)", 'acf' ),
  139. 'type' => 'checkbox',
  140. 'name' => 'hide_on_screen',
  141. 'prefix' => 'acf_field_group',
  142. 'value' => $field_group['hide_on_screen'],
  143. 'toggle' => true,
  144. 'choices' => $choices,
  145. ),
  146. 'div',
  147. 'label',
  148. true
  149. );
  150. echo '</div>';
  151. echo '</div>';
  152. acf_render_field_wrap(
  153. array(
  154. 'type' => 'tab',
  155. 'label' => __( 'Group Settings', 'acf' ),
  156. 'key' => 'acf_field_group_settings_tabs',
  157. )
  158. );
  159. echo '<div class="field-group-settings field-group-settings-tab">';
  160. // active
  161. acf_render_field_wrap(
  162. array(
  163. 'label' => __( 'Active', 'acf' ),
  164. 'instructions' => '',
  165. 'type' => 'true_false',
  166. 'name' => 'active',
  167. 'prefix' => 'acf_field_group',
  168. 'value' => $field_group['active'],
  169. 'ui' => 1,
  170. // 'ui_on_text' => __('Active', 'acf'),
  171. // 'ui_off_text' => __('Inactive', 'acf'),
  172. )
  173. );
  174. // Show fields in REST API.
  175. if ( acf_get_setting( 'rest_api_enabled' ) ) {
  176. acf_render_field_wrap(
  177. array(
  178. 'label' => __( 'Show in REST API', 'acf' ),
  179. 'instructions' => '',
  180. 'type' => 'true_false',
  181. 'name' => 'show_in_rest',
  182. 'prefix' => 'acf_field_group',
  183. 'value' => $field_group['show_in_rest'],
  184. 'ui' => 1,
  185. // 'ui_on_text' => __('Active', 'acf'),
  186. // 'ui_off_text' => __('Inactive', 'acf'),
  187. )
  188. );
  189. }
  190. // description
  191. acf_render_field_wrap(
  192. array(
  193. 'label' => __( 'Description', 'acf' ),
  194. 'instructions' => __( 'Shown in field group list', 'acf' ),
  195. 'type' => 'text',
  196. 'name' => 'description',
  197. 'prefix' => 'acf_field_group',
  198. 'value' => $field_group['description'],
  199. ),
  200. 'div',
  201. 'field'
  202. );
  203. // 3rd party settings
  204. do_action( 'acf/render_field_group_settings', $field_group );
  205. /* translators: 1: Post creation date 2: Post creation time */
  206. $acf_created_on = sprintf( __( 'Created on %1$s at %2$s', 'acf' ), get_the_date(), get_the_time() );
  207. ?>
  208. <div class="acf-field-group-settings-footer">
  209. <span class="acf-created-on"><?php echo esc_html( $acf_created_on ); ?></span>
  210. <a href="<?php echo get_delete_post_link(); ?>" class="acf-btn acf-btn-tertiary acf-delete-field-group">
  211. <i class="acf-icon acf-icon-trash"></i>
  212. <?php esc_html_e( 'Delete Field Group', 'acf' ); ?>
  213. </a>
  214. </div>
  215. </div>
  216. <div class="acf-hidden">
  217. <input type="hidden" name="acf_field_group[key]" value="<?php echo $field_group['key']; ?>" />
  218. </div>
  219. <script type="text/javascript">
  220. if( typeof acf !== 'undefined' ) {
  221. acf.newPostbox({
  222. 'id': 'acf-field-group-options',
  223. 'label': 'top'
  224. });
  225. }
  226. </script>