field-group-fields.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. //phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- template include file
  3. $field_groups = acf_get_field_groups();
  4. $num_field_groups = 0;
  5. if ( is_array( $field_groups ) ) {
  6. $num_field_groups = count( $field_groups );
  7. }
  8. $is_subfield = ! empty( $is_subfield );
  9. $wrapper_class = '';
  10. if ( $is_subfield ) {
  11. $wrapper_class = ' acf-is-subfields';
  12. if ( ! $fields ) {
  13. $wrapper_class .= ' -empty';
  14. }
  15. } elseif ( ! $fields && ! $parent ) {
  16. $wrapper_class = ' acf-auto-add-field';
  17. }
  18. ?>
  19. <?php if ( $parent || $is_subfield ) { ?>
  20. <div class="acf-sub-field-list-header">
  21. <h3 class="acf-sub-field-list-title"><?php _e( 'Fields', 'acf' ); ?></h3>
  22. <a href="#" class="acf-btn acf-btn-secondary add-field"><i class="acf-icon acf-icon-plus"></i><?php _e( 'Add Field', 'acf' ); ?></a>
  23. </div>
  24. <?php } ?>
  25. <?php //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- fixed string output ?>
  26. <div class="acf-field-list-wrap<?php echo $wrapper_class; ?>">
  27. <ul class="acf-hl acf-thead">
  28. <li class="li-field-order">
  29. <?php
  30. /* translators: A symbol (or text, if not available in your locale) meaning "Order Number", in terms of positional placement. */
  31. _e( '#', 'acf' );
  32. ?>
  33. <span class="acf-hidden">
  34. <?php
  35. /* translators: Hidden accessibility text for the positional order number of the field. */
  36. _e( 'Order', 'acf' );
  37. ?>
  38. </span>
  39. </li>
  40. <li class="li-field-label"><?php _e( 'Label', 'acf' ); ?></li>
  41. <li class="li-field-name"><?php _e( 'Name', 'acf' ); ?></li>
  42. <li class="li-field-key"><?php _e( 'Key', 'acf' ); ?></li>
  43. <li class="li-field-type"><?php _e( 'Type', 'acf' ); ?></li>
  44. </ul>
  45. <?php //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- fixed string output ?>
  46. <div class="acf-field-list<?php echo $wrapper_class; ?>">
  47. <div class="no-fields-message">
  48. <div class="no-fields-message-inner">
  49. <img src="<?php echo acf_get_url( 'assets/images/empty-group.svg' ); ?>" />
  50. <h2><?php _e( 'Add Your First Field', 'acf' ); ?></h2>
  51. <p><?php _e( 'Get started creating new custom fields for your posts, pages, custom post types and other WordPress content.', 'acf' ); ?></p>
  52. <a href="#" class="acf-btn acf-btn-primary add-field add-first-field
  53. "><i class="acf-icon acf-icon-plus"></i> <?php _e( 'Add Field', 'acf' ); ?></a>
  54. <p class="acf-small">
  55. <?php
  56. printf(
  57. /* translators: %s url to field types list */
  58. __( 'Choose from over 30 field types. <a href="%s" target="_blank">Learn more</a>.', 'acf' ),
  59. acf_add_url_utm_tags( 'https://www.advancedcustomfields.com/resources/', 'docs', 'empty-field-group', 'field-types' )
  60. );
  61. ?>
  62. </p>
  63. </div>
  64. </div>
  65. <?php
  66. if ( $fields ) :
  67. foreach ( $fields as $i => $field ) :
  68. acf_get_view(
  69. 'field-group-field',
  70. array(
  71. 'field' => $field,
  72. 'i' => $i,
  73. 'num_field_groups' => $num_field_groups,
  74. )
  75. );
  76. endforeach;
  77. endif;
  78. ?>
  79. </div>
  80. <ul class="acf-hl acf-tfoot">
  81. <li class="acf-fr">
  82. <a href="#" class="acf-btn acf-btn-secondary add-field"><i class="acf-icon acf-icon-plus"></i><?php _e( 'Add Field', 'acf' ); ?></a>
  83. </li>
  84. </ul>
  85. <?php
  86. if ( ! $parent ) :
  87. // get clone
  88. $clone = acf_get_valid_field(
  89. array(
  90. 'ID' => 'acfcloneindex',
  91. 'key' => 'acfcloneindex',
  92. 'label' => __( 'New Field', 'acf' ),
  93. 'name' => 'new_field',
  94. 'type' => 'text',
  95. )
  96. );
  97. ?>
  98. <script type="text/html" id="tmpl-acf-field">
  99. <?php
  100. acf_get_view(
  101. 'field-group-field',
  102. array(
  103. 'field' => $clone,
  104. 'i' => 0,
  105. 'num_field_groups' => $num_field_groups,
  106. )
  107. );
  108. ?>
  109. </script>
  110. <?php endif; ?>
  111. </div>