PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.9.2.7
Advanced Custom Fields: Extended v0.9.2.7
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 0.8.8.5 0.8.8.6 0.8.8.7 0.8.8.8 0.8.8.9 0.8.9 0.8.9.1 0.8.9.2 0.8.9.3 0.8.9.4 0.8.9.5 0.9 0.9.0.1 0.9.0.2 0.9.0.3 0.9.0.4 0.9.0.5 0.9.0.6 0.9.0.7 0.9.0.8 0.9.0.9 0.9.1 0.9.1.1 0.9.2 0.9.2.1 0.9.2.2 0.9.2.3 0.9.2.4 trunk 0.5 0.5.1 0.5.2 0.5.2.1 0.5.2.3 0.5.5 0.5.5.1 0.5.8 0.5.8.1 0.6 0.6.0.1 0.6.0.2 0.6.1 0.6.3 0.6.5 0.6.7 0.6.7.2 0.7 0.7.0.3 0.7.5 0.7.5.5 0.7.8 0.7.9 0.7.9.3 0.7.9.4 0.7.9.9.8 0.7.9.9.9 0.8 0.8.1 0.8.2 0.8.3 0.8.3.1 0.8.4 0.8.4.1 0.8.4.5 0.8.4.6 0.8.5 0.8.5.5
acf-extended / includes / fields / field-flexible-content-popup.php
acf-extended / includes / fields Last commit date
field-advanced-link.php 3 months ago field-button-group.php 1 week ago field-button.php 7 months ago field-checkbox.php 3 months ago field-clone.php 2 years ago field-code-editor.php 3 months ago field-column.php 3 years ago field-dynamic-render.php 3 years ago field-file.php 3 months ago field-flexible-content-actions-title.php 3 months ago field-flexible-content-actions-toggle.php 3 months ago field-flexible-content-actions.php 3 months ago field-flexible-content-async.php 4 months ago field-flexible-content-compatibility.php 3 months ago field-flexible-content-controls.php 9 months ago field-flexible-content-hide.php 3 months ago field-flexible-content-hooks.php 9 months ago field-flexible-content-modal-edit.php 9 months ago field-flexible-content-modal-select.php 3 months ago field-flexible-content-modal-settings.php 3 months ago field-flexible-content-popup.php 3 months ago field-flexible-content-preview.php 3 months ago field-flexible-content-state.php 9 months ago field-flexible-content-thumbnail.php 9 months ago field-flexible-content-wysiwyg.php 9 months ago field-flexible-content.php 3 months ago field-forms.php 3 months ago field-gallery.php 3 months ago field-google-map.php 3 months ago field-group.php 3 months ago field-hidden.php 3 years ago field-image.php 3 months ago field-post-object.php 3 months ago field-post-statuses.php 3 months ago field-post-types.php 3 months ago field-radio.php 3 months ago field-recaptcha.php 3 months ago field-relationship.php 3 months ago field-repeater.php 3 months ago field-select.php 3 months ago field-slug.php 1 year ago field-taxonomies.php 3 months ago field-taxonomy-terms.php 3 months ago field-taxonomy.php 3 months ago field-textarea.php 3 months ago field-user-roles.php 3 months ago field-user.php 3 months ago field-wysiwyg.php 3 months ago
field-flexible-content-popup.php
179 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_field_flexible_content_popup')):
8
9 class acfe_field_flexible_content_popup{
10
11 /**
12 * construct
13 */
14 function __construct(){
15
16 add_action('acfe/flexible/render_popup', array($this, 'render_popup_select'));
17 add_action('acfe/flexible/render_popup', array($this, 'render_popup_actions'));
18 add_action('acfe/flexible/render_popup_select', array($this, 'render_popup_select_content'));
19 add_action('acfe/flexible/render_popup_actions', array($this, 'render_popup_actions_content'));
20
21 }
22
23
24 /**
25 * render_popup_select
26 *
27 * @param $field
28 *
29 * @return void
30 */
31 function render_popup_select($field){
32
33 // select layout
34 echo '<script type="text-html" class="tmpl-popup">';
35 do_action('acfe/flexible/render_popup_select', $field);
36 echo '</script>';
37
38 }
39
40
41 /**
42 * render_popup_actions
43 *
44 * @param $field
45 *
46 * @return void
47 */
48 function render_popup_actions($field){
49
50 // ACF 6.5+ only
51 if(!acfe_is_acf('6.5')){
52 return;
53 }
54
55 // layout more actions
56 echo '<script type="text-html" class="tmpl-more-layout-actions">';
57 do_action('acfe/flexible/render_popup_actions', $field);
58 echo '</script>';
59
60 }
61
62
63 /**
64 * render_popup_select_content
65 *
66 * @param $field
67 *
68 * @return void
69 */
70 function render_popup_select_content($field){
71
72 // vars
73 $name = $field['_name'];
74 $key = $field['key'];
75
76 // wrapper
77 echo '<ul>';
78
79 // loop layouts
80 foreach($field['layouts'] as $layout){
81
82 // vars
83 $l_name = $layout['name'];
84 $atts = array(
85 'href' => '#',
86 'data-layout' => $layout['name'],
87 'data-min' => $layout['min'],
88 'data-max' => $layout['max'],
89 'title' => acf_esc_html($layout['label']),
90 );
91
92 // atts
93 $atts = apply_filters("acfe/flexible/layouts/select_atts", $atts, $layout, $field);
94 $atts = apply_filters("acfe/flexible/layouts/select_atts/name={$name}", $atts, $layout, $field);
95 $atts = apply_filters("acfe/flexible/layouts/select_atts/key={$key}", $atts, $layout, $field);
96 $atts = apply_filters("acfe/flexible/layouts/select_atts/layout={$l_name}", $atts, $layout, $field);
97 $atts = apply_filters("acfe/flexible/layouts/select_atts/name={$name}&layout={$l_name}", $atts, $layout, $field);
98 $atts = apply_filters("acfe/flexible/layouts/select_atts/key={$key}&layout={$l_name}", $atts, $layout, $field);
99
100 // label
101 $label = $layout['label'];
102 $label = apply_filters("acfe/flexible/layouts/select_label", $label, $layout, $field);
103 $label = apply_filters("acfe/flexible/layouts/select_label/name={$name}", $label, $layout, $field);
104 $label = apply_filters("acfe/flexible/layouts/select_label/key={$key}", $label, $layout, $field);
105 $label = apply_filters("acfe/flexible/layouts/select_label/layout={$l_name}", $label, $layout, $field);
106 $label = apply_filters("acfe/flexible/layouts/select_label/name={$name}&layout={$l_name}", $label, $layout, $field);
107 $label = apply_filters("acfe/flexible/layouts/select_label/key={$key}&layout={$l_name}", $label, $layout, $field);
108
109 printf('<li><a %s>%s</a></li>', acf_esc_attrs($atts), acf_esc_html($label));
110
111 }
112
113 echo '</ul>';
114
115 }
116
117
118 /**
119 * render_popup_actions_content
120 *
121 * @param $field
122 *
123 * @return void
124 */
125 function render_popup_actions_content($field){
126
127 // get buttons
128 $buttons = $this->get_popup_actions_buttons($field);
129
130 // bail early
131 if(empty($buttons)){
132 return;
133 }
134
135 // wrapper
136 echo '<ul role="menu" tabindex="-1">';
137
138 // loop buttons
139 foreach($buttons as $button){
140 echo '<li>' . $button . '</li>';
141 }
142
143 echo '</ul>';
144 }
145
146
147 /**
148 * get_popup_actions_buttons
149 *
150 * @param $field
151 *
152 * @return mixed|null
153 */
154 function get_popup_actions_buttons($field){
155
156 // vars
157 $name = $field['_name'];
158 $key = $field['key'];
159
160 // buttons
161 $buttons = array(
162 'rename' => '<a class="acf-rename-layout" data-action="rename-layout" href="#" role="menuitem">' . esc_html__('Rename', 'acf') . '</a>',
163 'disable' => '<a class="acf-toggle-layout disable" data-action="toggle-layout" href="#" role="menuitem">' . esc_html__('Disable', 'acf') . '</a><a class="acf-toggle-layout enable" data-action="toggle-layout" href="#" role="menuitem">' . esc_html__('Enable', 'acf') . '</a>',
164 );
165
166 // filter buttons
167 $buttons = apply_filters("acfe/flexible/layouts/more_action_buttons", $buttons, $field);
168 $buttons = apply_filters("acfe/flexible/layouts/more_action_buttons/name={$name}", $buttons, $field);
169 $buttons = apply_filters("acfe/flexible/layouts/more_action_buttons/key={$key}", $buttons, $field);
170
171 return $buttons;
172
173 }
174
175 }
176
177 acf_new_instance('acfe_field_flexible_content_popup');
178
179 endif;