PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.1.3
Adminify – White Label, Admin Menu Editor, Login Customizer v4.1.3
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Admin / Options / Performance.php

Performance.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.1.3, at Inc/Admin/Options/Performance.php

410 lines 17.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc\Admin\Options;
4
5 use WPAdminify\Inc\Utils;
6 use WPAdminify\Inc\Admin\AdminSettingsModel;
7
8
9 if (!defined('ABSPATH')) {
10 die;
11 } // Cannot access directly.
12
13 if (!class_exists('Performance')) {
14 class Performance extends AdminSettingsModel
15 {
16
17 public $defaults = [];
18
19 public function __construct()
20 {
21 $this->optimization_settings();
22 }
23
24 protected function get_defaults()
25 {
26 return [
27 'performance' => [
28 'performance_enable' => true,
29 'performance_data' => [
30 'version_strings',
31 'emoji',
32 ]
33 ],
34 'disable_embeds' => false, // Gutenberg
35 // Gutenberg
36 'disable_gutenberg' => [
37 'disable_gutenberg_enable' => false,
38 'disable_for' => []
39 ],
40 'heartbeat_api' => [
41 'enabled' => false,
42 'backend' => 'default',
43 'backend_modify' => 60,
44 'on_post_create' => 'default',
45 'on_post_create_modify' => 15,
46 'on_frontend' => 'default',
47 'on_frontend_modify' => 60
48 ],
49 'adminify_assets' => [],
50 'revisions' => [
51 'revisions_enable' => false,
52 'limit' => 30,
53 'post_types' => '',
54 ]
55 ];
56 }
57
58 /**
59 * Gutenberg Settings
60 */
61
62 public function gutenberg_settings(&$fields)
63 {
64 // Disable Gutenberg
65 $disable_gutenberg_for = [
66 'block_editor' => __('Remove Backend Gutenberg Block Editor & Scripts for Entire Site. i.e. - Post/Page/Custom Post Types', 'adminify'),
67 'remove_gutenberg_scripts' => __('Remove Frontend Gutenberg Styles & Scripts', 'adminify'),
68 // 'scripts' => __('Remove Gutenberg Scripts', 'adminify'),
69 // 'sidebar_widgets' => __('Disable Gutenberg for Sidebar Widgets', 'adminify'),
70 ];
71
72
73 $disable_gutenberg_fields = [
74 [
75 'id' => 'disable_gutenberg_enable',
76 'type' => 'switcher',
77 'class' => 'adminify-pl-0 adminify-pt-0',
78 'title' => __('', 'adminify'),
79 'text_on' => __('Show', 'adminify'),
80 'text_off' => __('Hide', 'adminify'),
81 'text_width' => 80,
82 // 'default' => $this->get_default_field('disable_gutenberg')['disable_gutenberg_enable'],
83 ],
84 [
85 'id' => 'disable_for',
86 'type' => 'checkbox',
87 'title' => __('', 'adminify'),
88 'class' => 'adminify-one-col',
89 'options' => $disable_gutenberg_for,
90 // 'default' => $this->get_default_field('disable_gutenberg')['disable_for'],
91 'dependency' => ['disable_gutenberg_enable', '==', 'true', true],
92 ]
93 ];
94
95 $fields[] = [
96 'id' => 'disable_gutenberg',
97 'type' => 'fieldset',
98 'title' => __('Disable Gutenberg for', 'adminify'),
99 'subtitle' => __('Cleanup Gutenberg Form and Gutenberg Template', 'adminify'),
100 'fields' => $disable_gutenberg_fields,
101 'default' => $this->get_default_field('disable_gutenberg'),
102 ];
103 }
104
105
106 /**
107 * Admin Notices: Settings
108 */
109 public function performances(&$fields)
110 {
111 $performance_data = [
112 'dashicons' => __('Remove Dashicons from front-end for Public Visitors', 'adminify'),
113 'version_strings' => __('Remove Versions from Styles/Scripts', 'adminify'),
114 'gravatar_query_strings' => __('Remove Gravatar Query Strings', 'adminify'),
115 'emoji' => __('Remove All Emoji styles and scripts from head section', 'adminify'),
116 'jquery_migrate_front' => __('Remove front end jQuery Migrate script.', 'adminify'),
117 'jquery_migrate_back' => __('Remove back end jQuery Migrate script. Note: It might break functionality', 'adminify'),
118 'defer_parsing_js_footer' => __('Enable Defer Parsing JS to Footer', 'adminify'),
119 'cache_gzip_compression' => __('Enable Browser Cache Expires & GZIP Compression', 'adminify'),
120 ];
121
122 $performance_fields = [
123 [
124 'id' => 'performance_enable',
125 'type' => 'switcher',
126 'class' => 'adminify-pl-0 adminify-pt-0',
127 'title' => __('', 'adminify'),
128 'text_on' => __('Show', 'adminify'),
129 'text_off' => __('Hide', 'adminify'),
130 'text_width' => 80
131 ],
132 [
133 'id' => 'performance_data',
134 'type' => 'checkbox',
135 'title' => __('', 'adminify'),
136 'class' => 'adminify-one-col',
137 'options' => $performance_data,
138 'dependency' => ['performance_enable', '==', 'true', true],
139 ]
140 ];
141
142 $fields[] = array(
143 'id' => 'performance',
144 'type' => 'fieldset',
145 'title' => __('Performance Enhancements', 'adminify'),
146 'subtitle' => __('Enhance Performances', 'adminify'),
147 'fields' => $performance_fields,
148 'default' => $this->get_default_field('performance'),
149 );
150 }
151
152
153
154
155 /**
156 * Security: Disable All Embeds
157 *
158 * @param [type] $security_feed
159 *
160 * @return void
161 */
162 public function disable_embeds(&$disable_embeds)
163 {
164 $disable_embeds[] = [
165 'id' => 'performance_subheading',
166 'type' => 'subheading',
167 'content' => Utils::adminfiy_help_urls(
168 '<span></span>',
169 'https://wpadminify.com/docs/adminify/performance/disable-embeds',
170 'https://www.youtube.com/watch?v=xALg4WWZ_bE',
171 'https://www.facebook.com/groups/jeweltheme',
172 \WPAdminify\Inc\Admin\AdminSettings::support_url()
173 ),
174 ];
175
176 $disable_embeds[] = [
177 'id' => 'disable_embeds',
178 'type' => 'switcher',
179 'class' => 'adminify-pro-fieldset adminify-pro-notice',
180 'title' => sprintf(__('Disable Embeds %s', 'adminify'), Utils::adminify_upgrade_pro_badge()),
181 'subtitle' => __('Disable all Embeds from everywhere like - REST API, Head Tag, Tinymce Editor, Remote results etc.', 'adminify'),
182 'text_on' => __('Yes', 'adminify'),
183 'text_off' => __('No', 'adminify'),
184 'text_width' => 80,
185 'default' => $this->get_default_field('disable_embeds'),
186 ];
187 }
188
189 public function control_heartbit_api_settings(&$fields){
190 $fields[] = [
191 'id' => 'enabled',
192 'type' => 'switcher',
193 'class' => 'adminify-pt-0 adminify-pl-0',
194 'title' => __('', 'adminify'),
195 'text_on' => __('Show', 'adminify'),
196 'text_off' => __('Hide', 'adminify'),
197 'text_width' => 80,
198 'default' => $this->get_default_field('heartbeat_api')['enabled'],
199 ];
200 $fields[] = [
201 'id' => 'backend',
202 'type' => 'radio',
203 'inline' => true,
204 'class' => Utils::upgrade_pro_class(),
205 'title' => __('WordPress Dashboard', 'adminify'),
206 'subtitle' => __('Backend Post Types', 'adminify'),
207 'options' => [
208 'default' => __('Default', 'adminify'),
209 'modify' => __('Modify', 'adminify'),
210 'disable' => __('Disable', 'adminify'),
211 ],
212 'default' => $this->get_default_field('heartbeat_api')['backend'],
213 'dependency' => ['enabled', '==', 'true', 'true'],
214 ];
215 $fields[] = [
216 'id' => 'backend_modify',
217 'type' => 'select',
218 'title' => __('Set interval to once every', 'adminify'),
219 'subtitle' => __('Default: 1 Minute', 'adminify'),
220 'options' => array(
221 '15' => __('15 seconds', 'adminify'),
222 '30' => __('30 seconds', 'adminify'),
223 '60' => __('1 Minute', 'adminify'),
224 '120' => __('2 Minute', 'adminify'),
225 '180' => __('3 Minute', 'adminify'),
226 '300' => __('5 Minute', 'adminify'),
227 '600' => __('10 Minute', 'adminify'),
228 ),
229 'default' => $this->get_default_field('heartbeat_api')['backend_modify'],
230 'dependency' => ['enabled|backend', '==|==', 'true|modify', 'true'],
231 ];
232
233 $fields[] = [
234 'id' => 'on_post_create',
235 'type' => 'radio',
236 'class' => Utils::upgrade_pro_class(),
237 'inline' => true,
238 'title' => __('Create Post Editor', 'adminify'),
239 'subtitle' => __('On post creation and edit screens', 'adminify'),
240 'options' => [
241 'default' => __('Default', 'adminify'),
242 'modify' => __('Modify', 'adminify'),
243 'disable' => __('Disable', 'adminify'),
244 ],
245 'default' => $this->get_default_field('heartbeat_api')['on_post_create'],
246 'dependency' => ['enabled', '==', 'true', 'true'],
247 ];
248
249 $fields[] = [
250 'id' => 'on_post_create_modify',
251 'type' => 'select',
252 'title' => __('Set interval to once every', 'adminify'),
253 'subtitle' => __('Default: 15 seconds', 'adminify'),
254 'options' => array(
255 '15' => __('15 seconds', 'adminify'),
256 '30' => __('30 seconds', 'adminify'),
257 '60' => __('1 Minute', 'adminify'),
258 '120' => __('2 Minute', 'adminify'),
259 '180' => __('3 Minute', 'adminify'),
260 '300' => __('5 Minute', 'adminify'),
261 '600' => __('10 Minute', 'adminify'),
262 ),
263 'default' => $this->get_default_field('heartbeat_api')['on_post_create_modify'],
264 'dependency' => ['enabled|on_post_create', '==|==', 'true|modify', 'true'],
265 ];
266
267 $fields[] = [
268 'id' => 'on_frontend',
269 'type' => 'radio',
270 'class' => Utils::upgrade_pro_class(),
271 'inline' => true,
272 'title' => __('Frontend', 'adminify'),
273 'subtitle' => __('Frontend Heartbits', 'adminify'),
274 'options' => [
275 'default' => __('Default', 'adminify'),
276 'modify' => __('Modify', 'adminify'),
277 'disable' => __('Disable', 'adminify'),
278 ],
279 'default' => $this->get_default_field('heartbeat_api')['on_frontend'],
280 'dependency' => ['enabled', '==', 'true', 'true'],
281 ];
282
283 $fields[] = [
284 'id' => 'on_frontend_modify',
285 'type' => 'select',
286 'title' => __('Set interval to once every', 'adminify'),
287 'subtitle' => __('Default: 1 Minute', 'adminify'),
288 'options' => array(
289 '15' => __('15 seconds', 'adminify'),
290 '30' => __('30 seconds', 'adminify'),
291 '60' => __('1 Minute', 'adminify'),
292 '120' => __('2 Minute', 'adminify'),
293 '180' => __('3 Minute', 'adminify'),
294 '300' => __('5 Minute', 'adminify'),
295 '600' => __('10 Minute', 'adminify'),
296 ),
297 'default' => $this->get_default_field('heartbeat_api')['on_frontend_modify'],
298 'dependency' => ['enabled|on_frontend', '==|==', 'true|modify', 'true'],
299 ];
300 }
301
302
303 /**
304 * Control Heartbit API
305 */
306 public function control_heartbit_api(&$fields){
307 $heartbeat_settings = [];
308 $this->control_heartbit_api_settings($heartbeat_settings);
309
310 $fields[] = array(
311 'id' => 'heartbeat_api',
312 'type' => 'fieldset',
313 'class' => 'adminify-nopadding',
314 'title' => sprintf(__('Control Heartbeat API %s', 'adminify'), Utils::adminify_upgrade_pro_badge()),
315 'class' => 'adminify-pro-fieldset',
316 'subtitle' => __('Modify the interval of the WordPress Heartbeat API or disable it on admin pages, post creation/edit screens, and the frontend to reduce CPU load on the server', 'adminify'),
317 'fields' => $heartbeat_settings
318 );
319 }
320
321
322 /**
323 * Revisions Settings
324 *
325 * @return void
326 */
327 public function control_revisions_settings( &$revisions_settings ){
328 $revisions_settings[] = [
329 'id' => 'revisions_enable',
330 'type' => 'switcher',
331 'class' => 'adminify-p-0 adminify-pro-feature',
332 'title' => __('', 'adminify'),
333 'text_on' => __('Show', 'adminify'),
334 'text_off' => __('Hide', 'adminify'),
335 'text_width' => 80,
336
337 'default' => $this->get_default_field('revisions')['revisions_enable'],
338 ];
339 $revisions_settings[] = [
340 'id' => 'limit',
341 'type' => 'number',
342 'title' => __( 'Limit of Revisions', 'adminify' ),
343 'subtitle' => __('Number of Revisions to show', 'adminify'),
344 'class' => 'adminify-pro-feature adminify-pro-notice',
345 'default' => $this->get_default_field('revisions')['limit'],
346 'dependency' => ['revisions_enable', '==', 'true', 'true'],
347 ];
348
349 $revisions_settings[] = [
350 'id' => 'post_types',
351 'type' => 'checkbox',
352 'title' => __('Apply for Post Types', 'adminify'),
353 'class' => 'adminify-pro-feature adminify-pro-notice',
354 'subtitle' => __('Disable all Embeds from everywhere like - REST API, Head Tag, Tinymce Editor, Remote results etc.', 'adminify'),
355 'options' => 'WPAdminify\Inc\Admin\Options\Productivity::get_all_post_types',
356 'default' => $this->get_default_field('revisions')['post_types'],
357 'dependency' => ['revisions_enable', '==', 'true', 'true'],
358 ];
359
360 }
361
362 /**
363 * Control Revisions
364 */
365 public function control_revisions(&$fields){
366 $revisions_settings = [];
367 $this->control_revisions_settings($revisions_settings);
368
369 $fields[] = array(
370 'id' => 'revisions',
371 'type' => 'fieldset',
372 'title' => sprintf(__('Control Revisions %s', 'adminify'), Utils::adminify_upgrade_pro_badge()),
373 'subtitle' => __('Limit the number of revisions kept for post types supporting revisions to prevent database bloat.', 'adminify'),
374 'fields' => $revisions_settings,
375 'default' => $this->get_default_field('revisions'),
376 );
377 }
378
379
380 public function optimization_settings()
381 {
382 if (!class_exists('ADMINIFY')) {
383 return;
384 }
385
386 $fields = [];
387
388 $this->disable_embeds( $fields );
389 $this->control_heartbit_api( $fields );
390 // $this->control_revisions( $fields );
391 $this->performances( $fields );
392 $this->gutenberg_settings($fields);
393
394
395 $fields = apply_filters('adminify_settings/performance', $fields, $this);
396
397 // Optimization Section
398 \ADMINIFY::createSection(
399 $this->prefix,
400 [
401 'title' => __('Performance', 'adminify'),
402 'id' => 'performance',
403 'icon' => 'fas fa-chart-bar',
404 'fields' => $fields,
405 ]
406 );
407 }
408 }
409 }
410