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