PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.6
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.6
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.2.6, at Inc/Admin/Options/Performance.php

413 lines 17.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PXLBSAdminify\Inc\Admin\Options;
4
5 use PXLBSAdminify\Inc\Utils;
6 use PXLBSAdminify\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' => '',
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' => '',
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' => '',
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' => '',
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::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 \PXLBSAdminify\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 /* translators: %s: pro upgrade badge HTML */
181 'title' => sprintf(__('Disable Embeds %s', 'adminify'), Utils::upgrade_pro_badge()),
182 'subtitle' => __('Disable all Embeds from everywhere like - REST API, Head Tag, Tinymce Editor, Remote results etc.', 'adminify'),
183 'text_on' => __('Yes', 'adminify'),
184 'text_off' => __('No', 'adminify'),
185 'text_width' => 80,
186 'default' => $this->get_default_field('disable_embeds'),
187 ];
188 }
189
190 public function control_heartbit_api_settings(&$fields){
191 $fields[] = [
192 'id' => 'enabled',
193 'type' => 'switcher',
194 'class' => 'adminify-pt-0 adminify-pl-0',
195 'title' => '',
196 'text_on' => __('Show', 'adminify'),
197 'text_off' => __('Hide', 'adminify'),
198 'text_width' => 80,
199 'default' => $this->get_default_field('heartbeat_api')['enabled'],
200 ];
201 $fields[] = [
202 'id' => 'backend',
203 'type' => 'radio',
204 'inline' => true,
205 'class' => Utils::upgrade_pro_notice_class(),
206 'title' => __('WordPress Dashboard', 'adminify'),
207 'subtitle' => __('Backend Post Types', 'adminify'),
208 'options' => [
209 'default' => __('Default', 'adminify'),
210 'modify' => __('Modify', 'adminify'),
211 'disable' => __('Disable', 'adminify'),
212 ],
213 'default' => $this->get_default_field('heartbeat_api')['backend'],
214 'dependency' => ['enabled', '==', 'true', 'true'],
215 ];
216 $fields[] = [
217 'id' => 'backend_modify',
218 'type' => 'select',
219 'title' => __('Set interval to once every', 'adminify'),
220 'subtitle' => __('Default: 1 Minute', 'adminify'),
221 'options' => array(
222 '15' => __('15 seconds', 'adminify'),
223 '30' => __('30 seconds', 'adminify'),
224 '60' => __('1 Minute', 'adminify'),
225 '120' => __('2 Minute', 'adminify'),
226 '180' => __('3 Minute', 'adminify'),
227 '300' => __('5 Minute', 'adminify'),
228 '600' => __('10 Minute', 'adminify'),
229 ),
230 'default' => $this->get_default_field('heartbeat_api')['backend_modify'],
231 'dependency' => ['enabled|backend', '==|==', 'true|modify', 'true'],
232 ];
233
234 $fields[] = [
235 'id' => 'on_post_create',
236 'type' => 'radio',
237 'class' => Utils::upgrade_pro_notice_class(),
238 'inline' => true,
239 'title' => __('Create Post Editor', 'adminify'),
240 'subtitle' => __('On post creation and edit screens', 'adminify'),
241 'options' => [
242 'default' => __('Default', 'adminify'),
243 'modify' => __('Modify', 'adminify'),
244 'disable' => __('Disable', 'adminify'),
245 ],
246 'default' => $this->get_default_field('heartbeat_api')['on_post_create'],
247 'dependency' => ['enabled', '==', 'true', 'true'],
248 ];
249
250 $fields[] = [
251 'id' => 'on_post_create_modify',
252 'type' => 'select',
253 'title' => __('Set interval to once every', 'adminify'),
254 'subtitle' => __('Default: 15 seconds', 'adminify'),
255 'options' => array(
256 '15' => __('15 seconds', 'adminify'),
257 '30' => __('30 seconds', 'adminify'),
258 '60' => __('1 Minute', 'adminify'),
259 '120' => __('2 Minute', 'adminify'),
260 '180' => __('3 Minute', 'adminify'),
261 '300' => __('5 Minute', 'adminify'),
262 '600' => __('10 Minute', 'adminify'),
263 ),
264 'default' => $this->get_default_field('heartbeat_api')['on_post_create_modify'],
265 'dependency' => ['enabled|on_post_create', '==|==', 'true|modify', 'true'],
266 ];
267
268 $fields[] = [
269 'id' => 'on_frontend',
270 'type' => 'radio',
271 'class' => Utils::upgrade_pro_notice_class(),
272 'inline' => true,
273 'title' => __('Frontend', 'adminify'),
274 'subtitle' => __('Frontend Heartbits', 'adminify'),
275 'options' => [
276 'default' => __('Default', 'adminify'),
277 'modify' => __('Modify', 'adminify'),
278 'disable' => __('Disable', 'adminify'),
279 ],
280 'default' => $this->get_default_field('heartbeat_api')['on_frontend'],
281 'dependency' => ['enabled', '==', 'true', 'true'],
282 ];
283
284 $fields[] = [
285 'id' => 'on_frontend_modify',
286 'type' => 'select',
287 'title' => __('Set interval to once every', 'adminify'),
288 'subtitle' => __('Default: 1 Minute', 'adminify'),
289 'options' => array(
290 '15' => __('15 seconds', 'adminify'),
291 '30' => __('30 seconds', 'adminify'),
292 '60' => __('1 Minute', 'adminify'),
293 '120' => __('2 Minute', 'adminify'),
294 '180' => __('3 Minute', 'adminify'),
295 '300' => __('5 Minute', 'adminify'),
296 '600' => __('10 Minute', 'adminify'),
297 ),
298 'default' => $this->get_default_field('heartbeat_api')['on_frontend_modify'],
299 'dependency' => ['enabled|on_frontend', '==|==', 'true|modify', 'true'],
300 ];
301 }
302
303
304 /**
305 * Control Heartbit API
306 */
307 public function control_heartbit_api(&$fields){
308 $heartbeat_settings = [];
309 $this->control_heartbit_api_settings($heartbeat_settings);
310
311 $fields[] = array(
312 'id' => 'heartbeat_api',
313 'type' => 'fieldset',
314 'class' => 'adminify-nopadding',
315 /* translators: %s: pro upgrade badge HTML */
316 'title' => sprintf(__('Control Heartbeat API %s', 'adminify'), Utils::upgrade_pro_badge()),
317 'class' => 'adminify-pro-fieldset',
318 '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'),
319 'fields' => $heartbeat_settings
320 );
321 }
322
323
324 /**
325 * Revisions Settings
326 *
327 * @return void
328 */
329 public function control_revisions_settings( &$revisions_settings ){
330 $revisions_settings[] = [
331 'id' => 'revisions_enable',
332 'type' => 'switcher',
333 'class' => 'adminify-p-0 adminify-pro-feature',
334 'title' => '',
335 'text_on' => __('Show', 'adminify'),
336 'text_off' => __('Hide', 'adminify'),
337 'text_width' => 80,
338
339 'default' => $this->get_default_field('revisions')['revisions_enable'],
340 ];
341 $revisions_settings[] = [
342 'id' => 'limit',
343 'type' => 'number',
344 'title' => __( 'Limit of Revisions', 'adminify' ),
345 'subtitle' => __('Number of Revisions to show', 'adminify'),
346 'class' => 'adminify-pro-feature adminify-pro-notice',
347 'default' => $this->get_default_field('revisions')['limit'],
348 'dependency' => ['revisions_enable', '==', 'true', 'true'],
349 ];
350
351 $revisions_settings[] = [
352 'id' => 'post_types',
353 'type' => 'checkbox',
354 'title' => __('Apply for Post Types', 'adminify'),
355 'class' => 'adminify-pro-feature adminify-pro-notice',
356 'subtitle' => __('Disable all Embeds from everywhere like - REST API, Head Tag, Tinymce Editor, Remote results etc.', 'adminify'),
357 'options' => 'PXLBSAdminify\Inc\Admin\Options\Productivity::get_all_post_types',
358 'default' => $this->get_default_field('revisions')['post_types'],
359 'dependency' => ['revisions_enable', '==', 'true', 'true'],
360 ];
361
362 }
363
364 /**
365 * Control Revisions
366 */
367 public function control_revisions(&$fields){
368 $revisions_settings = [];
369 $this->control_revisions_settings($revisions_settings);
370
371 $fields[] = array(
372 'id' => 'revisions',
373 'type' => 'fieldset',
374 /* translators: %s: pro upgrade badge HTML */
375 'title' => sprintf(__('Control Revisions %s', 'adminify'), Utils::upgrade_pro_badge()),
376 'subtitle' => __('Limit the number of revisions kept for post types supporting revisions to prevent database bloat.', 'adminify'),
377 'fields' => $revisions_settings,
378 'default' => $this->get_default_field('revisions'),
379 );
380 }
381
382
383 public function optimization_settings()
384 {
385 if (!class_exists('ADMINIFY')) {
386 return;
387 }
388
389 $fields = [];
390
391 $this->disable_embeds( $fields );
392 $this->control_heartbit_api( $fields );
393 // $this->control_revisions( $fields );
394 $this->performances( $fields );
395 $this->gutenberg_settings($fields);
396
397
398 $fields = apply_filters('pxlbsadminify_settings/performance', $fields, $this);
399
400 // Optimization Section
401 \ADMINIFY::createSection(
402 $this->prefix,
403 [
404 'title' => __('Performance', 'adminify'),
405 'id' => 'performance',
406 'icon' => 'fas fa-chart-bar',
407 'fields' => $fields,
408 ]
409 );
410 }
411 }
412 }
413