conditional-logic.php
1 year ago
field.php
2 months ago
fields.php
2 months ago
index.php
1 year ago
list-empty.php
8 months ago
location-group.php
1 year ago
location-rule.php
8 months ago
locations.php
8 months ago
options.php
8 months ago
options.php
313 lines
| 1 | <?php |
| 2 | |
| 3 | // global |
| 4 | global $field_group; |
| 5 | |
| 6 | // UI needs at lease 1 location rule |
| 7 | if ( empty( $field_group['location'] ) ) { |
| 8 | $field_group['location'] = array( |
| 9 | // Group 0. |
| 10 | array( |
| 11 | // Rule 0. |
| 12 | array( |
| 13 | 'param' => 'post_type', |
| 14 | 'operator' => '==', |
| 15 | 'value' => 'post', |
| 16 | ), |
| 17 | ), |
| 18 | ); |
| 19 | |
| 20 | $acf_use_post_type = acf_get_post_type_from_request_args( 'add-fields' ); |
| 21 | $acf_use_taxonomy = acf_get_taxonomy_from_request_args( 'add-fields' ); |
| 22 | $acf_use_options_page = acf_get_ui_options_page_from_request_args( 'add-fields' ); |
| 23 | |
| 24 | if ( $acf_use_post_type && ! empty( $acf_use_post_type['post_type'] ) ) { |
| 25 | $field_group['location'] = array( |
| 26 | array( |
| 27 | array( |
| 28 | 'param' => 'post_type', |
| 29 | 'operator' => '==', |
| 30 | 'value' => $acf_use_post_type['post_type'], |
| 31 | ), |
| 32 | ), |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | if ( $acf_use_taxonomy && ! empty( $acf_use_taxonomy['taxonomy'] ) ) { |
| 37 | $field_group['location'] = array( |
| 38 | array( |
| 39 | array( |
| 40 | 'param' => 'taxonomy', |
| 41 | 'operator' => '==', |
| 42 | 'value' => $acf_use_taxonomy['taxonomy'], |
| 43 | ), |
| 44 | ), |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | if ( $acf_use_options_page && ! empty( $acf_use_options_page['menu_slug'] ) ) { |
| 49 | $field_group['location'] = array( |
| 50 | array( |
| 51 | array( |
| 52 | 'param' => 'options_page', |
| 53 | 'operator' => '==', |
| 54 | 'value' => $acf_use_options_page['menu_slug'], |
| 55 | ), |
| 56 | ), |
| 57 | ); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | foreach ( acf_get_combined_field_group_settings_tabs() as $tab_key => $tab_label ) { |
| 62 | acf_render_field_wrap( |
| 63 | array( |
| 64 | 'type' => 'tab', |
| 65 | 'label' => $tab_label, |
| 66 | 'key' => 'acf_field_group_settings_tabs', |
| 67 | 'settings-type' => $tab_key, |
| 68 | ) |
| 69 | ); |
| 70 | |
| 71 | switch ( $tab_key ) { |
| 72 | case 'location_rules': |
| 73 | echo '<div class="field-group-locations field-group-settings-tab">'; |
| 74 | acf_get_view( 'acf-field-group/locations' ); |
| 75 | |
| 76 | do_action( 'acf/field_group/render_additional_location_settings', $field_group ); |
| 77 | echo '</div>'; |
| 78 | break; |
| 79 | case 'presentation': |
| 80 | echo '<div class="field-group-setting-split-container field-group-settings-tab">'; |
| 81 | echo '<div class="field-group-setting-split">'; |
| 82 | |
| 83 | // style |
| 84 | acf_render_field_wrap( |
| 85 | array( |
| 86 | 'label' => __( 'Style', 'secure-custom-fields' ), |
| 87 | 'instructions' => '', |
| 88 | 'type' => 'button_group', |
| 89 | 'name' => 'style', |
| 90 | 'prefix' => 'acf_field_group', |
| 91 | 'value' => $field_group['style'], |
| 92 | 'choices' => array( |
| 93 | 'default' => __( 'Standard (WP metabox)', 'secure-custom-fields' ), |
| 94 | 'seamless' => __( 'Seamless (no metabox)', 'secure-custom-fields' ), |
| 95 | ), |
| 96 | ) |
| 97 | ); |
| 98 | |
| 99 | |
| 100 | // position |
| 101 | acf_render_field_wrap( |
| 102 | array( |
| 103 | 'label' => __( 'Position', 'secure-custom-fields' ), |
| 104 | 'instructions' => __( "'High' position not supported in the Block Editor", 'secure-custom-fields' ), |
| 105 | 'type' => 'button_group', |
| 106 | 'name' => 'position', |
| 107 | 'prefix' => 'acf_field_group', |
| 108 | 'value' => $field_group['position'], |
| 109 | 'choices' => array( |
| 110 | 'acf_after_title' => __( 'High (after title)', 'secure-custom-fields' ), |
| 111 | 'normal' => __( 'Normal (after content)', 'secure-custom-fields' ), |
| 112 | 'side' => __( 'Side', 'secure-custom-fields' ), |
| 113 | ), |
| 114 | 'default_value' => 'normal', |
| 115 | ), |
| 116 | 'div', |
| 117 | 'field' |
| 118 | ); |
| 119 | |
| 120 | |
| 121 | // label_placement |
| 122 | acf_render_field_wrap( |
| 123 | array( |
| 124 | 'label' => __( 'Label Placement', 'secure-custom-fields' ), |
| 125 | 'instructions' => '', |
| 126 | 'type' => 'button_group', |
| 127 | 'name' => 'label_placement', |
| 128 | 'prefix' => 'acf_field_group', |
| 129 | 'value' => $field_group['label_placement'], |
| 130 | 'choices' => array( |
| 131 | 'top' => __( 'Top aligned', 'secure-custom-fields' ), |
| 132 | 'left' => __( 'Left aligned', 'secure-custom-fields' ), |
| 133 | ), |
| 134 | ) |
| 135 | ); |
| 136 | |
| 137 | |
| 138 | // instruction_placement |
| 139 | acf_render_field_wrap( |
| 140 | array( |
| 141 | 'label' => __( 'Instruction Placement', 'secure-custom-fields' ), |
| 142 | 'instructions' => '', |
| 143 | 'type' => 'button_group', |
| 144 | 'name' => 'instruction_placement', |
| 145 | 'prefix' => 'acf_field_group', |
| 146 | 'value' => $field_group['instruction_placement'], |
| 147 | 'choices' => array( |
| 148 | 'label' => __( 'Below labels', 'secure-custom-fields' ), |
| 149 | 'field' => __( 'Below fields', 'secure-custom-fields' ), |
| 150 | ), |
| 151 | ) |
| 152 | ); |
| 153 | |
| 154 | |
| 155 | // menu_order |
| 156 | acf_render_field_wrap( |
| 157 | array( |
| 158 | 'label' => __( 'Order No.', 'secure-custom-fields' ), |
| 159 | 'instructions' => __( 'Field groups with a lower order will appear first', 'secure-custom-fields' ), |
| 160 | 'type' => 'number', |
| 161 | 'name' => 'menu_order', |
| 162 | 'prefix' => 'acf_field_group', |
| 163 | 'value' => $field_group['menu_order'], |
| 164 | ), |
| 165 | 'div', |
| 166 | 'field' |
| 167 | ); |
| 168 | |
| 169 | do_action( 'acf/field_group/render_additional_presentation_settings', $field_group ); |
| 170 | |
| 171 | echo '</div>'; |
| 172 | echo '<div class="field-group-setting-split">'; |
| 173 | |
| 174 | // hide on screen |
| 175 | $choices = array( |
| 176 | 'permalink' => __( 'Permalink', 'secure-custom-fields' ), |
| 177 | 'the_content' => __( 'Content Editor', 'secure-custom-fields' ), |
| 178 | 'excerpt' => __( 'Excerpt', 'secure-custom-fields' ), |
| 179 | 'custom_fields' => __( 'Custom Fields', 'secure-custom-fields' ), |
| 180 | 'discussion' => __( 'Discussion', 'secure-custom-fields' ), |
| 181 | 'comments' => __( 'Comments', 'secure-custom-fields' ), |
| 182 | 'revisions' => __( 'Revisions', 'secure-custom-fields' ), |
| 183 | 'slug' => __( 'Slug', 'secure-custom-fields' ), |
| 184 | 'author' => __( 'Author', 'secure-custom-fields' ), |
| 185 | 'format' => __( 'Format', 'secure-custom-fields' ), |
| 186 | 'page_attributes' => __( 'Page Attributes', 'secure-custom-fields' ), |
| 187 | 'featured_image' => __( 'Featured Image', 'secure-custom-fields' ), |
| 188 | 'categories' => __( 'Categories', 'secure-custom-fields' ), |
| 189 | 'tags' => __( 'Tags', 'secure-custom-fields' ), |
| 190 | 'send-trackbacks' => __( 'Send Trackbacks', 'secure-custom-fields' ), |
| 191 | ); |
| 192 | if ( acf_get_setting( 'remove_wp_meta_box' ) ) { |
| 193 | unset( $choices['custom_fields'] ); |
| 194 | } |
| 195 | |
| 196 | acf_render_field_wrap( |
| 197 | array( |
| 198 | 'label' => __( 'Hide on screen', 'secure-custom-fields' ), |
| 199 | 'instructions' => __( '<b>Select</b> items to <b>hide</b> them from the edit screen.', 'secure-custom-fields' ) . '<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)", 'secure-custom-fields' ), |
| 200 | 'type' => 'checkbox', |
| 201 | 'name' => 'hide_on_screen', |
| 202 | 'prefix' => 'acf_field_group', |
| 203 | 'value' => $field_group['hide_on_screen'], |
| 204 | 'toggle' => true, |
| 205 | 'choices' => $choices, |
| 206 | ), |
| 207 | 'div', |
| 208 | 'label', |
| 209 | true |
| 210 | ); |
| 211 | |
| 212 | echo '</div>'; |
| 213 | echo '</div>'; |
| 214 | break; |
| 215 | case 'group_settings': |
| 216 | echo '<div class="field-group-settings field-group-settings-tab">'; |
| 217 | |
| 218 | // active |
| 219 | acf_render_field_wrap( |
| 220 | array( |
| 221 | 'label' => __( 'Active', 'secure-custom-fields' ), |
| 222 | 'instructions' => '', |
| 223 | 'type' => 'true_false', |
| 224 | 'name' => 'active', |
| 225 | 'prefix' => 'acf_field_group', |
| 226 | 'value' => $field_group['active'], |
| 227 | 'ui' => 1, |
| 228 | ) |
| 229 | ); |
| 230 | |
| 231 | // Show fields in REST API. |
| 232 | if ( acf_get_setting( 'rest_api_enabled' ) ) { |
| 233 | acf_render_field_wrap( |
| 234 | array( |
| 235 | 'label' => __( 'Show in REST API', 'secure-custom-fields' ), |
| 236 | 'instructions' => '', |
| 237 | 'type' => 'true_false', |
| 238 | 'name' => 'show_in_rest', |
| 239 | 'prefix' => 'acf_field_group', |
| 240 | 'value' => $field_group['show_in_rest'], |
| 241 | 'ui' => 1, |
| 242 | ) |
| 243 | ); |
| 244 | } |
| 245 | |
| 246 | // description |
| 247 | acf_render_field_wrap( |
| 248 | array( |
| 249 | 'label' => __( 'Description', 'secure-custom-fields' ), |
| 250 | 'instructions' => __( 'Shown in field group list', 'secure-custom-fields' ), |
| 251 | 'type' => 'text', |
| 252 | 'name' => 'description', |
| 253 | 'prefix' => 'acf_field_group', |
| 254 | 'value' => $field_group['description'], |
| 255 | ), |
| 256 | 'div', |
| 257 | 'field' |
| 258 | ); |
| 259 | |
| 260 | acf_render_field_wrap( |
| 261 | array( |
| 262 | 'label' => __( 'Display Title', 'secure-custom-fields' ), |
| 263 | 'instructions' => __( 'Title shown on the edit screen for the field group meta box to use instead of the field group title', 'secure-custom-fields' ), |
| 264 | 'type' => 'text', |
| 265 | 'name' => 'display_title', |
| 266 | 'prefix' => 'acf_field_group', |
| 267 | 'value' => $field_group['display_title'], |
| 268 | ), |
| 269 | 'div', |
| 270 | 'field' |
| 271 | ); |
| 272 | |
| 273 | do_action( 'acf/field_group/render_additional_group_settings', $field_group ); |
| 274 | |
| 275 | /* translators: 1: Post creation date 2: Post creation time */ |
| 276 | $acf_created_on = sprintf( __( 'Created on %1$s at %2$s', 'secure-custom-fields' ), get_the_date(), get_the_time() ); |
| 277 | ?> |
| 278 | <div class="acf-field-group-settings-footer"> |
| 279 | <span class="acf-created-on"><?php echo esc_html( $acf_created_on ); ?></span> |
| 280 | <a href="<?php echo get_delete_post_link(); ?>" class="acf-btn acf-btn-tertiary acf-delete-field-group"> |
| 281 | <i class="acf-icon acf-icon-trash"></i> |
| 282 | <?php esc_html_e( 'Delete Field Group', 'secure-custom-fields' ); ?> |
| 283 | </a> |
| 284 | </div> |
| 285 | <?php |
| 286 | echo '</div>'; |
| 287 | break; |
| 288 | default: |
| 289 | echo '<div class="field-group-' . esc_attr( $tab_key ) . ' field-group-settings-tab">'; |
| 290 | do_action( 'acf/field_group/render_group_settings_tab/' . $tab_key, $field_group ); |
| 291 | echo '</div>'; |
| 292 | break; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | // 3rd party settings |
| 297 | do_action( 'acf/render_field_group_settings', $field_group ); |
| 298 | ?> |
| 299 | |
| 300 | <div class="acf-hidden"> |
| 301 | <input type="hidden" name="acf_field_group[key]" value="<?php echo esc_attr( $field_group['key'] ); ?>" /> |
| 302 | </div> |
| 303 | <script type="text/javascript"> |
| 304 | if( typeof acf !== 'undefined' ) { |
| 305 | |
| 306 | acf.newPostbox({ |
| 307 | 'id': 'acf-field-group-options', |
| 308 | 'label': 'top' |
| 309 | }); |
| 310 | |
| 311 | } |
| 312 | </script> |
| 313 |