Nessuna descrizione

field-group-field.php 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <?php
  2. // Define input name prefix using unique identifier.
  3. $input_prefix = 'acf_fields[' . $field['ID'] . ']';
  4. $input_id = acf_idify( $input_prefix );
  5. // Update field props.
  6. $field['prefix'] = $input_prefix;
  7. // Elements.
  8. $div_attrs = array(
  9. 'class' => 'acf-field-object acf-field-object-' . acf_slugify( $field['type'] ),
  10. 'data-id' => $field['ID'],
  11. 'data-key' => $field['key'],
  12. 'data-type' => $field['type'],
  13. );
  14. // Misc template vars.
  15. $field_label = acf_get_field_label( $field, 'admin' );
  16. $field_type_label = acf_get_field_type_label( $field['type'] );
  17. ?>
  18. <div <?php echo acf_esc_attr( $div_attrs ); ?>>
  19. <div class="meta">
  20. <?php
  21. $meta_inputs = array(
  22. 'ID' => $field['ID'],
  23. 'key' => $field['key'],
  24. 'parent' => $field['parent'],
  25. 'menu_order' => $i,
  26. 'save' => '',
  27. );
  28. foreach ( $meta_inputs as $k => $v ) :
  29. acf_hidden_input(
  30. array(
  31. 'name' => $input_prefix . '[' . $k . ']',
  32. 'value' => $v,
  33. 'id' => $input_id . '-' . $k,
  34. )
  35. );
  36. endforeach;
  37. ?>
  38. </div>
  39. <div class="handle">
  40. <ul class="acf-hl acf-tbody">
  41. <li class="li-field-order">
  42. <span class="acf-icon acf-sortable-handle" title="<?php _e( 'Drag to reorder', 'acf' ); ?>"><?php echo ( $i + 1 ); ?></span>
  43. </li>
  44. <li class="li-field-label">
  45. <strong>
  46. <a class="edit-field" title="<?php _e( 'Edit field', 'acf' ); ?>" href="#"><?php echo acf_esc_html( $field_label ); ?></a>
  47. </strong>
  48. <div class="row-options">
  49. <a class="edit-field" title="<?php _e( 'Edit field', 'acf' ); ?>" href="#"><?php _e( 'Edit', 'acf' ); ?></a>
  50. <a class="duplicate-field" title="<?php _e( 'Duplicate field', 'acf' ); ?>" href="#"><?php _e( 'Duplicate', 'acf' ); ?></a>
  51. <a class="move-field" title="<?php _e( 'Move field to another group', 'acf' ); ?>" href="#"><?php _e( 'Move', 'acf' ); ?></a>
  52. <a class="delete-field" title="<?php _e( 'Delete field', 'acf' ); ?>" href="#"><?php _e( 'Delete', 'acf' ); ?></a>
  53. </div>
  54. </li>
  55. <?php // whitespace before field name looks odd but fixes chrome bug selecting all text in row ?>
  56. <li class="li-field-name"> <?php echo esc_html( $field['name'] ); ?></li>
  57. <li class="li-field-key"> <?php echo esc_html( $field['key'] ); ?></li>
  58. <li class="li-field-type"> <?php echo esc_html( $field_type_label ); ?></li>
  59. </ul>
  60. </div>
  61. <div class="settings">
  62. <table class="acf-table">
  63. <tbody class="acf-field-settings">
  64. <?php
  65. // label
  66. acf_render_field_setting(
  67. $field,
  68. array(
  69. 'label' => __( 'Field Label', 'acf' ),
  70. 'instructions' => __( 'This is the name which will appear on the EDIT page', 'acf' ),
  71. 'name' => 'label',
  72. 'type' => 'text',
  73. 'class' => 'field-label',
  74. ),
  75. true
  76. );
  77. // name
  78. acf_render_field_setting(
  79. $field,
  80. array(
  81. 'label' => __( 'Field Name', 'acf' ),
  82. 'instructions' => __( 'Single word, no spaces. Underscores and dashes allowed', 'acf' ),
  83. 'name' => 'name',
  84. 'type' => 'text',
  85. 'class' => 'field-name',
  86. ),
  87. true
  88. );
  89. // type
  90. acf_render_field_setting(
  91. $field,
  92. array(
  93. 'label' => __( 'Field Type', 'acf' ),
  94. 'instructions' => '',
  95. 'type' => 'select',
  96. 'name' => 'type',
  97. 'choices' => acf_get_grouped_field_types(),
  98. 'class' => 'field-type',
  99. ),
  100. true
  101. );
  102. // instructions
  103. acf_render_field_setting(
  104. $field,
  105. array(
  106. 'label' => __( 'Instructions', 'acf' ),
  107. 'instructions' => __( 'Instructions for authors. Shown when submitting data', 'acf' ),
  108. 'type' => 'textarea',
  109. 'name' => 'instructions',
  110. 'rows' => 5,
  111. ),
  112. true
  113. );
  114. // required
  115. acf_render_field_setting(
  116. $field,
  117. array(
  118. 'label' => __( 'Required?', 'acf' ),
  119. 'instructions' => '',
  120. 'type' => 'true_false',
  121. 'name' => 'required',
  122. 'ui' => 1,
  123. 'class' => 'field-required',
  124. ),
  125. true
  126. );
  127. // 3rd party settings
  128. do_action( 'acf/render_field_settings', $field );
  129. // type specific settings
  130. do_action( "acf/render_field_settings/type={$field['type']}", $field );
  131. // conditional logic
  132. acf_get_view( 'field-group-field-conditional-logic', array( 'field' => $field ) );
  133. // wrapper
  134. acf_render_field_wrap(
  135. array(
  136. 'label' => __( 'Wrapper Attributes', 'acf' ),
  137. 'instructions' => '',
  138. 'type' => 'number',
  139. 'name' => 'width',
  140. 'prefix' => $field['prefix'] . '[wrapper]',
  141. 'value' => $field['wrapper']['width'],
  142. 'prepend' => __( 'width', 'acf' ),
  143. 'append' => '%',
  144. 'wrapper' => array(
  145. 'data-name' => 'wrapper',
  146. 'class' => 'acf-field-setting-wrapper',
  147. ),
  148. ),
  149. 'tr'
  150. );
  151. acf_render_field_wrap(
  152. array(
  153. 'label' => '',
  154. 'instructions' => '',
  155. 'type' => 'text',
  156. 'name' => 'class',
  157. 'prefix' => $field['prefix'] . '[wrapper]',
  158. 'value' => $field['wrapper']['class'],
  159. 'prepend' => __( 'class', 'acf' ),
  160. 'wrapper' => array(
  161. 'data-append' => 'wrapper',
  162. ),
  163. ),
  164. 'tr'
  165. );
  166. acf_render_field_wrap(
  167. array(
  168. 'label' => '',
  169. 'instructions' => '',
  170. 'type' => 'text',
  171. 'name' => 'id',
  172. 'prefix' => $field['prefix'] . '[wrapper]',
  173. 'value' => $field['wrapper']['id'],
  174. 'prepend' => __( 'id', 'acf' ),
  175. 'wrapper' => array(
  176. 'data-append' => 'wrapper',
  177. ),
  178. ),
  179. 'tr'
  180. );
  181. ?>
  182. <tr class="acf-field acf-field-save">
  183. <td class="acf-label"></td>
  184. <td class="acf-input">
  185. <ul class="acf-hl">
  186. <li>
  187. <a class="button edit-field" title="<?php _e( 'Close Field', 'acf' ); ?>" href="#"><?php _e( 'Close Field', 'acf' ); ?></a>
  188. </li>
  189. </ul>
  190. </td>
  191. </tr>
  192. </tbody>
  193. </table>
  194. </div>
  195. </div>