PluginProbe
Advanced Custom Fields: Extended / 0.9.1
Advanced Custom Fields: Extended v0.9.1
0.9.2.7 0.9.2.6 0.9.2.5 0.8.6 0.8.6.1 0.8.6.3 0.8.6.5 0.8.6.6 0.8.6.7 0.8.6.8 0.8.6.9 0.8.7 0.8.7.1 0.8.7.2 0.8.7.3 0.8.7.4 0.8.7.5 0.8.7.6 0.8.8 0.8.8.1 0.8.8.10 0.8.8.11 0.8.8.2 0.8.8.3 0.8.8.4 All 92 releases
acf-extended / includes / fields-settings / instructions.php
instructions.php
84 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_instructions')):
8
9 class acfe_instructions{
10
11 function __construct(){
12
13 add_action('acfe/pre_render_field_group', array($this, 'pre_render_field_group'), 10, 3);
14 add_filter('acf/field_wrapper_attributes', array($this, 'field_wrapper_attributes'), 10, 2);
15
16 }
17
18
19 /**
20 * pre_render_field_group
21 *
22 * @param $field_group
23 * @param $fields
24 * @param $post_id
25 *
26 * @return void
27 */
28 function pre_render_field_group($field_group, $fields, $post_id){
29
30 // bail early on override (acfe_form)
31 if(acf_is_filter_enabled('acfe/override_instruction')){
32 return;
33 }
34
35 acf_disable_filter('acfe/instruction_tooltip');
36 acf_disable_filter('acfe/instruction_above_field');
37
38 if(acf_maybe_get($field_group, 'instruction_placement') === 'tooltip'){
39
40 acf_enable_filter('acfe/instruction_tooltip');
41
42 }elseif(acf_maybe_get($field_group, 'instruction_placement') === 'above_field'){
43
44 acf_enable_filter('acfe/instruction_above_field');
45
46 }
47
48 }
49
50
51 /**
52 * field_wrapper_attributes
53 *
54 * @param $wrapper
55 * @param $field
56 *
57 * @return mixed
58 */
59 function field_wrapper_attributes($wrapper, $field){
60
61 if(!acf_maybe_get($field, 'label')){
62 $wrapper['class'] .= ' acfe-no-label';
63 }
64
65 if(acf_maybe_get($field, 'instructions')){
66
67 if(acf_is_filter_enabled('acfe/instruction_tooltip')){
68 $wrapper['data-instruction-tooltip'] = acf_esc_html($field['instructions']);
69
70 }elseif(acf_is_filter_enabled('acfe/instruction_above_field')){
71 $wrapper['data-instruction-above-field'] = acf_esc_html($field['instructions']);
72 }
73
74 }
75
76 return $wrapper;
77
78 }
79
80 }
81
82 new acfe_instructions();
83
84 endif;