PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / trunk
Advanced Custom Fields: Extended vtrunk
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 / admin / admin.php
acf-extended / includes / admin Last commit date
tools 1 month ago views 4 years ago admin.php 1 month ago menu.php 1 month ago plugins.php 1 month ago settings.php 1 month ago
admin.php
283 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_admin')):
8
9 class acfe_admin{
10
11 /**
12 * construct
13 */
14 function __construct(){
15
16 // acf-updates & acf-tools pages
17 add_action('admin_menu', array($this, 'admin_menu'));
18
19 // acf-field-groups (ACF 6.0)
20 add_action('acfe/load_posts/post_type=acf-field-group', array($this, 'load_posts'));
21 add_action('acfe/load_post/post_type=acf-field-group', array($this, 'load_post'));
22
23 // acf-post-type (ACF 6.1)
24 add_action('acfe/load_posts/post_type=acf-post-type', array($this, 'load_posts'));
25 add_action('acfe/load_post/post_type=acf-post-type', array($this, 'load_post'));
26
27 // acf-taxonomy (ACF 6.1)
28 add_action('acfe/load_posts/post_type=acf-taxonomy', array($this, 'load_posts'));
29 add_action('acfe/load_post/post_type=acf-taxonomy', array($this, 'load_post'));
30
31 // acf-ui-options-page (ACF 6.2)
32 add_action('acfe/load_posts/post_type=acf-ui-options-page', array($this, 'load_posts'));
33 add_action('acfe/load_post/post_type=acf-ui-options-page', array($this, 'load_post'));
34
35 // additional hooks
36 add_action('current_screen', array($this, 'current_screen'));
37 add_filter('acf/validate_field', array($this, 'validate_field'));
38
39 }
40
41
42 /**
43 * admin_menu
44 */
45 function admin_menu(){
46
47 // get updates/tools pages
48 $updates = get_plugin_page_hookname('acf-settings-updates', 'edit.php?post_type=acf-field-group');
49 $tools = get_plugin_page_hookname('acf-tools', 'edit.php?post_type=acf-field-group');
50
51 // actions
52 add_action("load-{$updates}", array($this, 'load_acf_page'));
53 add_action("load-{$tools}", array($this, 'load_acf_page'));
54
55 }
56
57
58 /**
59 * load_acf_page
60 */
61 function load_acf_page(){
62
63 // add marker for acfe-admin-input assets
64 if(acfe_is_acf('6.0')){
65 acf_enable_filter('acfe/acf_internal_page');
66 }
67
68 add_filter('admin_body_class', array($this, 'admin_body_class'));
69 }
70
71
72 /**
73 * load_posts
74 */
75 function load_posts(){
76
77 // add marker for acfe-admin-input assets
78 if(acfe_is_acf('6.0')){
79 acf_enable_filter('acfe/acf_internal_page');
80 }
81
82 add_filter('admin_body_class', array($this, 'admin_body_class'));
83 }
84
85
86 /**
87 * load_post
88 */
89 function load_post(){
90
91 // add marker for acfe-admin-input assets
92 if(acfe_is_acf('6.0')){
93 acf_enable_filter('acfe/acf_internal_page');
94 }
95
96 add_filter('admin_body_class', array($this, 'admin_body_class'));
97 add_action('acf/input/admin_head', array($this, 'admin_head'), 20);
98
99 }
100
101
102 /**
103 * admin_body_class
104 *
105 * Adds acfe-acf-6-0 class to body
106 */
107 function admin_body_class($classes){
108
109 // filter
110 $new_class = apply_filters('acfe/acf_admin_body_class', 'acfe-acf-6-0');
111
112 // append class
113 if(!empty($new_class)){
114 $classes .= ' ' . $new_class;
115 }
116
117 // return
118 return $classes;
119 }
120
121
122 /**
123 * admin_head
124 *
125 */
126 function admin_head(){
127
128 // remove forced 1 column on 'screen_layout' options
129 acfe_remove_filter('get_user_option_screen_layout_acf-field-group', array('acf_admin_field_group', 'screen_layout'));
130 acfe_remove_filter('get_user_option_screen_layout_acf-post-type', array('ACF_Admin_Post_type', 'screen_layout'));
131 acfe_remove_filter('get_user_option_screen_layout_acf-taxonomy', array('ACF_Admin_Taxonomy', 'screen_layout'));
132 acfe_remove_filter('get_user_option_screen_layout_acf-ui-options-page', array('ACF_Admin_UI_Options_Page', 'screen_layout'));
133
134 // base url
135 $default_icon = acf_get_url('assets/images/icons/icon-fields.svg');
136
137 // generate default field type missing icon
138 ?>
139 <style>
140 .field-type-icon:before{
141 -webkit-mask-image: url(<?php echo $default_icon; ?>);
142 mask-image: url(<?php echo $default_icon; ?>);
143 }
144 </style>
145 <?php
146
147 }
148
149
150 /**
151 * current_screen
152 *
153 * Remove ACF Title header bar on ACFE modules
154 *
155 * @param $screen
156 */
157 function current_screen($screen){
158
159 // allowed screens
160 $allowed = array(
161 'edit-acf-field-group-category',
162 'edit-acfe-dbt',
163 'acfe-dbt',
164 'edit-acfe-template',
165 'acfe-template',
166 'edit-acfe-form',
167 'acfe-form'
168 );
169
170 // check screen
171 if(acfe_get($screen, 'post_type') === 'acf-field-group' || acf_is_screen($allowed)){
172
173 // add top menu icons
174 add_action('admin_head', array($this, 'admin_head_navigation'));
175
176 // remove the topbar "white banner" with the page title
177 if(acf_is_screen($allowed)){
178 global $acf_page_title;
179 $acf_page_title = '';
180 }
181
182 }
183
184 // acf 6.1 removed topbar for third party submenu
185 // checking $screen[post_type] to avoid adding the global navigation twice (throws: Cannot redeclare acf_print_menu_section())
186 // this fix an issue when visiting custom admin url like: edit-tags.php?taxonomy=acf-field-group-category&post_type=acf-field-group
187 if(acf_is_screen($allowed) && acfe_get($screen, 'post_type') !== 'acf-field-group'){
188 add_action('in_admin_header', array($this, 'in_admin_header'));
189 }
190
191 }
192
193
194 /**
195 * in_admin_header
196 *
197 * @return void
198 */
199 function in_admin_header(){
200
201 // safeguard: bail early in case global navigation is already loaded
202 if(function_exists('acf_print_menu_section')){
203 return;
204 }
205
206 // load view
207 acf_get_view(apply_filters('acfe/acf_admin_navigation_page', 'global/navigation'));
208
209 }
210
211
212 /**
213 * admin_head_navigation
214 *
215 * ACF >= 6.0 && <= 6.1 Add ACF admin head navigation icons to ACFE modules
216 * Starting ACF 6.1, ACF add custom submenus into a "More" menu, which doesn't show icons anymore
217 */
218 function admin_head_navigation(){
219
220 // base url
221 $base_url = acf_get_url('assets/images/');
222
223 // pages rules
224 $pages = array(
225 'categories' => 'field-type-icons/icon-field-taxonomy.svg',
226 'edit-tagsphptaxonomyacf-field-group-category' => 'field-type-icons/icon-field-taxonomy.svg',
227 'block-types' => 'icons/icon-fields.svg',
228 'acfe-dbt' => 'icons/icon-fields.svg',
229 'forms' => 'field-type-icons/icon-field-post-object.svg',
230 'acfe-form' => 'field-type-icons/icon-field-post-object.svg',
231 'options-pages' => 'field-type-icons/icon-field-group.svg',
232 'acfe-dop' => 'field-type-icons/icon-field-group.svg',
233 'settings' => 'icons/icon-settings.svg',
234 'acfe-settings' => 'icons/icon-settings.svg',
235 'templates' => 'field-type-icons/icon-field-wysiwyg.svg',
236 'acfe-template' => 'field-type-icons/icon-field-wysiwyg.svg',
237 );
238
239 // generate css
240 ?>
241 <style>
242 <?php foreach($pages as $page => $icon): ?>
243 .acf-admin-toolbar .acf-header-tab-<?php echo $page; ?> i.acf-icon{
244 display: inline-flex;
245 -webkit-mask-image: url(<?php echo $base_url . $icon; ?>);
246 mask-image: url(<?php echo $base_url . $icon; ?>);
247 }
248 <?php endforeach; ?>
249
250 .acf-icon.acf-icon-plus{
251 -webkit-mask-image: url(<?php echo $base_url; ?>icons/icon-add.svg);
252 mask-image: url(<?php echo $base_url; ?>icons/icon-add.svg);
253 }
254 </style>
255 <?php
256
257 }
258
259 /**
260 * validate_field
261 *
262 * Change instructions to hint for appended field settings
263 *
264 * @param $field
265 *
266 * @return mixed
267 */
268 function validate_field($field){
269
270 if(acfe_get($field, '_appended') && acfe_get($field, 'instructions')){
271 $field['hint'] = $field['instructions'];
272 $field['instructions'] = '';
273 }
274
275 return $field;
276
277 }
278
279 }
280
281 acf_new_instance('acfe_admin');
282
283 endif;