module-performance-connector.php
1 month ago
module-performance-functions.php
1 month ago
module-performance-ui.php
3 years ago
module-performance-ultra-fields.php
2 years ago
module-performance-ultra-revisions.php
1 month ago
module-performance-ultra.php
1 month ago
module-performance-upgrades.php
2 years ago
module-performance.php
1 month ago
module-performance-ultra-fields.php
89 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')){ |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | if(!class_exists('acfe_performance_ultra_fields')): |
| 8 | |
| 9 | class acfe_performance_ultra_fields{ |
| 10 | |
| 11 | /** |
| 12 | * construct |
| 13 | */ |
| 14 | function __construct(){ |
| 15 | |
| 16 | add_action('acf/render_field_settings', array($this, 'render_field_settings')); |
| 17 | add_filter('acf/validate_field', array($this, 'validate_field'), 20); |
| 18 | |
| 19 | } |
| 20 | |
| 21 | |
| 22 | /** |
| 23 | * render_field_settings |
| 24 | * |
| 25 | * @param $field |
| 26 | */ |
| 27 | function render_field_settings($field){ |
| 28 | |
| 29 | // validate |
| 30 | if(!acfe_is_performance_enabled() || acfe_get_performance_config('engine') !== 'ultra'){ |
| 31 | return; |
| 32 | } |
| 33 | |
| 34 | // vars |
| 35 | $exclude = array('acfe_button', 'acfe_column', 'acfe_recaptcha', 'acfe_dynamic_render', 'accordion', 'message', 'tab'); |
| 36 | |
| 37 | // check if excluded |
| 38 | if(in_array($field['type'], $exclude)){ |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | // settings |
| 43 | acf_render_field_setting($field, array( |
| 44 | 'label' => __('Save as individual meta'), |
| 45 | 'key' => 'acfe_save_meta', |
| 46 | 'name' => 'acfe_save_meta', |
| 47 | 'instructions' => __('Save the field as an individual meta.'), |
| 48 | 'type' => 'true_false', |
| 49 | 'required' => false, |
| 50 | 'conditional_logic' => false, |
| 51 | 'wrapper' => array( |
| 52 | 'width' => '', |
| 53 | 'class' => '', |
| 54 | 'id' => '', |
| 55 | ), |
| 56 | 'message' => '', |
| 57 | 'default_value' => false, |
| 58 | 'ui' => true, |
| 59 | 'ui_on_text' => '', |
| 60 | 'ui_off_text' => '', |
| 61 | )); |
| 62 | |
| 63 | } |
| 64 | |
| 65 | |
| 66 | /** |
| 67 | * validate_field |
| 68 | * |
| 69 | * @param $field |
| 70 | * |
| 71 | * @return mixed |
| 72 | */ |
| 73 | function validate_field($field){ |
| 74 | |
| 75 | // cleanup setting if set and empty |
| 76 | if(isset($field['acfe_save_meta']) && empty($field['acfe_save_meta'])){ |
| 77 | unset($field['acfe_save_meta']); |
| 78 | } |
| 79 | |
| 80 | return $field; |
| 81 | |
| 82 | } |
| 83 | |
| 84 | |
| 85 | } |
| 86 | |
| 87 | acf_new_instance('acfe_performance_ultra_fields'); |
| 88 | |
| 89 | endif; |