PluginProbe
Disable Everything / 0.4.0
Disable Everything v0.4.0
trunk 0.1.1 0.2.0 0.2.1 0.3.0 0.4.0 0.4.1
disable-everything / disable-everything.php

disable-everything.php in Disable Everything 0.4.0, at disable-everything.php

1,190 lines 51.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * Plugin Name: Disable Everything
4 * Description: Disable all unnecessary WordPress features and speed up your website.
5 * Version: 0.4.0
6 * Author: Dessky Team
7 * Author URI: https://dessky.com
8 * License: GPL3
9 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10 * Text Domain: disable-everything
11 * Domain Path: /languages
12 */
13
14 // prevent direct access
15 defined ( 'ABSPATH' ) or die ( 'Forbidden' );
16
17 define ( 'DISABLEEVERYTHING_FILE', __FILE__ );
18
19 // debug logging if required
20 function disable_everything_log($message) {
21 if (WP_DEBUG === true) {
22 if (is_array ( $message ) || is_object ( $message )) {
23 error_log ( print_r ( $message, true ) );
24 } else {
25 error_log ( $message );
26 }
27 }
28 }
29
30 /* Remove Options */
31 function disable_everything_init() {
32 // Self Pingbacks
33 add_action ( 'pre_ping', function (&$links) {
34 $home = get_option ( 'home' );
35 foreach ( $links as $l => $link ) {
36 if (strpos ( $link, $home ) === 0) {
37 unset ( $links [$l] );
38 }
39 }
40 } );
41
42 // Block User-Enumeration
43 if (disable_everything_check_option ( 'blockuserenumeration' )) {
44
45 // block user-enumeration
46 if (! is_admin ()) {
47 // default URL format
48 if (preg_match ( '/author=([0-9]*)/i', $_SERVER ['QUERY_STRING'] ))
49 die ();
50 add_filter ( 'redirect_canonical', function ($redirect, $request) {
51 // permalink URL format
52 if (preg_match ( '/\?author=([0-9]*)(\/*)/i', $request ))
53 die ();
54 else
55 return $redirect;
56 }, 10, 2 );
57 }
58 }
59 // Disable Author Archives
60 if (disable_everything_check_option ( 'disableauthorarchives' )) {
61
62 // disable author archives
63 remove_filter ( 'template_redirect', 'redirect_canonical' );
64 add_action ( 'template_redirect', function () {
65 if (is_author ()) {
66 global $wp_query;
67 $wp_query->set_404 ();
68 status_header ( 404 );
69 } else {
70 redirect_canonical ();
71 }
72 } );
73 }
74 // Remove Capital P Dangit
75 if (disable_everything_check_option ( 'removecapitalpdangit' )) {
76
77 remove_filter ( 'the_title', 'capital_P_dangit', 11 );
78 remove_filter ( 'the_content', 'capital_P_dangit', 11 );
79 remove_filter ( 'comment_text', 'capital_P_dangit', 31 );
80 }
81 // Remove screen options and contextual help
82 if (disable_everything_check_option ( 'removescreenoptions' )) {
83 // Remove help tab
84 add_action ( 'admin_head', 'disable_everything_remove_help_tabs' );
85
86 // Remove screen options
87 add_filter ( 'screen_options_show_screen', '__return_false' );
88 }
89 // Remove Howdy
90 if (disable_everything_check_option ( 'removehowdy' )) {
91 // removes howdy "greeting"
92 add_filter ( 'admin_bar_menu', function ($wp_admin_bar) {
93 $my_account = $wp_admin_bar->get_node ( 'my-account' );
94 $newtitle = 'My Profile';
95 $wp_admin_bar->add_node ( array (
96 'id' => 'my-account',
97 'title' => $newtitle
98 ) );
99 } );
100 }
101
102 // Remove items from adminbar
103 if (disable_everything_check_option ( 'removeitemsadminbar' )) {
104
105 // removes redundant items from adminbar
106 add_action ( 'admin_bar_menu', function ($wp_admin_bar) {
107 global $wp_admin_bar;
108
109 /**
110 * * BACKEND **
111 */
112 // remove WP logo and subsequent drop-down menu
113 $wp_admin_bar->remove_node ( 'wp-logo' );
114
115 // remove View Site text
116 $wp_admin_bar->remove_node ( 'view-site' );
117
118 // remove "+ New" drop-down menu
119 $wp_admin_bar->remove_node ( 'new-content' );
120
121 // remove Comments
122 $wp_admin_bar->remove_node ( 'comments' );
123
124 // remove plugin updates count
125 $wp_admin_bar->remove_node ( 'updates' );
126
127 /**
128 * * FRONTEND **
129 */
130 // remove Dashboard link
131 $wp_admin_bar->remove_node ( 'dashboard' );
132
133 // remove Themes, Widgets, Menus, Header links
134 $wp_admin_bar->remove_node ( 'appearance' );
135 }, 99 );
136 }
137
138 // Clean Dashboard
139 if (disable_everything_check_option ( 'cleandashboard' )) {
140
141 add_action ( 'wp_dashboard_setup', function () {
142 remove_meta_box ( 'dashboard_quick_press', 'dashboard', 'side' ); // Quick Press widget
143 remove_meta_box ( 'dashboard_recent_drafts', 'dashboard', 'side' ); // Recent Drafts
144 remove_meta_box ( 'dashboard_primary', 'dashboard', 'side' ); // WordPress.com Blog
145 remove_meta_box ( 'dashboard_secondary', 'dashboard', 'side' ); // Other WordPress News
146 remove_meta_box ( 'dashboard_incoming_links', 'dashboard', 'normal' ); // Incoming Links
147 remove_meta_box ( 'dashboard_plugins', 'dashboard', 'normal' ); // Plugins
148 remove_meta_box ( 'dashboard_right_now', 'dashboard', 'normal' ); // Right Now
149 remove_meta_box ( 'dashboard_activity', 'dashboard', 'normal' ); // Activity
150 remove_meta_box ( 'dashboard_site_health', 'dashboard', 'normal' ); // Site Health
151 remove_meta_box ( 'dashboard_php_nag', 'dashboard', 'normal' ); // PHP nag
152 remove_action ( 'welcome_panel', 'wp_welcome_panel' ); // Remove Welcome Panel
153 } );
154 }
155
156 // Emojis
157 if (disable_everything_check_option ( 'emojis' )) {
158 remove_action ( 'wp_head', 'print_emoji_detection_script', 7 );
159 remove_action ( 'admin_print_scripts', 'print_emoji_detection_script' );
160 remove_action ( 'wp_print_styles', 'print_emoji_styles' );
161 remove_action ( 'admin_print_styles', 'print_emoji_styles' );
162 remove_filter ( 'the_content_feed', 'wp_staticize_emoji' );
163 remove_filter ( 'comment_text_rss', 'wp_staticize_emoji' );
164 remove_filter ( 'wp_mail', 'wp_staticize_emoji_for_email' );
165 add_filter ( 'emoji_svg_url', '__return_false' );
166 add_filter ( 'tiny_mce_plugins', function ($plugins) {
167 return array_diff ( $plugins, array (
168 'wpemoji'
169 ) );
170 } );
171 }
172
173 // Embed
174 if (disable_everything_check_option ( 'embed' )) {
175 global $wp;
176 $wp->public_query_vars = array_diff ( $wp->public_query_vars, array (
177 'embed'
178 ) );
179 remove_action ( 'rest_api_init', 'wp_oembed_register_route' );
180 remove_filter ( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
181 remove_action ( 'wp_head', 'wp_oembed_add_discovery_links' );
182 remove_action ( 'wp_head', 'wp_oembed_add_host_js' );
183 remove_filter ( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );
184 add_filter ( 'embed_oembed_discover', '__return_false' );
185 add_filter ( 'tiny_mce_plugins', function ($plugins) {
186 return array_diff ( $plugins, array (
187 'wpembed'
188 ) );
189 } );
190 add_filter ( 'rewrite_rules_array', function ($rules) {
191 foreach ( $rules as $rule => $rewrite ) {
192 if (strpos ( $rewrite, 'embed=true' ) !== false) {
193 unset ( $rules [$rule] );
194 }
195 }
196 return $rules;
197 } );
198 }
199
200 // XML-RPC
201 if (disable_everything_check_option ( 'xmlrpc' )) {
202 add_filter ( 'xmlrpc_enabled', '__return_false' );
203 add_filter ( 'pings_open', '__return_false', 9999 );
204 add_filter ( 'wp_headers', function ($headers) {
205 unset ( $headers ['X-Pingback'], $headers ['x-pingback'] );
206 return $headers;
207 } );
208 }
209
210 // Generator
211 if (disable_everything_check_option ( 'generator' )) {
212 remove_action ( 'wp_head', 'wp_generator' );
213 add_filter ( 'the_generator', function () {
214 return '';
215 } );
216 }
217
218 // WLW Manifest
219 if (disable_everything_check_option ( 'manifest' )) {
220 remove_action ( 'wp_head', 'wlwmanifest_link' );
221 }
222
223 // RSD Link
224 if (disable_everything_check_option ( 'rsdlink' )) {
225 remove_action ( 'wp_head', 'rsd_link' );
226 }
227
228 // Shortlink
229 if (disable_everything_check_option ( 'shortlink' )) {
230 remove_action ( 'wp_head', 'wp_shortlink_wp_head' );
231 remove_action ( 'template_redirect', 'wp_shortlink_header', 11, 0 );
232 }
233
234 // RSS Feeds
235 if (disable_everything_check_option ( 'rssfeeds' )) {
236 remove_action ( 'wp_head', 'feed_links', 2 );
237 remove_action ( 'wp_head', 'feed_links_extra', 3 );
238 add_action ( 'template_redirect', function () {
239 if (! is_feed () || is_404 ()) {
240 return;
241 }
242 if (isset ( $_GET ['feed'] )) {
243 wp_redirect ( esc_url_raw ( remove_query_arg ( 'feed' ) ), 301 );
244 exit ();
245 }
246 if (get_query_var ( 'feed' ) !== 'old') {
247 set_query_var ( 'feed', '' );
248 }
249 redirect_canonical ();
250 wp_die ( sprintf ( __ ( "RSS Feeds disabled, please visit the <a href='%s'>homepage</a>!" ), esc_url ( home_url ( '/' ) ) ) );
251 }, 1 );
252 }
253
254 // REST API
255 if (disable_everything_check_option ( 'restapi' ) && ! is_admin ()) {
256 remove_action ( 'xmlrpc_rsd_apis', 'rest_output_rsd' );
257 remove_action ( 'wp_head', 'rest_output_link_wp_head' );
258 remove_action ( 'template_redirect', 'rest_output_link_header', 11, 0 );
259 add_filter ( 'rest_authentication_errors', function ($result) {
260 if (empty ( $result ) && ! is_admin ()) {
261 return new WP_Error ( 'rest_authentication_error', __ ( 'Forbidden', 'disable-everything' ), array (
262 'status' => 403
263 ) );
264 }
265 return $result;
266 }, 20 );
267 }
268
269 // Block Library
270 if (disable_everything_check_option ( 'blocks' )) {
271 add_action ( 'wp_print_styles', function () {
272 wp_dequeue_style ( 'wp-block-library' );
273 }, 100 );
274 }
275
276 // Admin Footer
277 if (disable_everything_check_option ( 'adminfooter' )) {
278
279 // Remove admin footer text and WP version
280 add_filter ( 'admin_footer_text', '__return_empty_string', 11 );
281 add_filter ( 'update_footer', '__return_empty_string', 11 );
282 }
283
284 // Application Passwords
285 if (disable_everything_check_option ( 'applicationpasswords' )) {
286
287 // completely disable the new Application Passwords functionality
288 add_filter('wp_is_application_passwords_available', '__return_false');
289 }
290
291 //TODO: Filters and Actions
292 // Core Privacy Tools
293 if (disable_everything_check_option ( 'coreprivacytools' )) {
294
295 // disable the Core Privacy Tools
296 // Removes required user's capabilities for core privacy tools by adding the `do_not_allow` capability.
297 add_filter( 'map_meta_cap', 'disable_everything_disable_core_privacy_tools', 10, 2 );
298
299 /**
300 * Short circuits the option for the privacy policy page to always return 0.
301 *
302 * The option is used by get_privacy_policy_url() among others.
303 */
304 add_filter( 'pre_option_wp_page_for_privacy_policy', '__return_zero' );
305
306 /**
307 * Removes the default scheduled event used to delete old export files.
308 */
309 remove_action( 'init', 'wp_schedule_delete_old_privacy_export_files' );
310
311 /**
312 * Removes the hook attached to the default scheduled event for removing
313 * old export files.
314 */
315 remove_action( 'wp_privacy_delete_old_export_files', 'wp_privacy_delete_old_export_files' );
316
317 }
318 // Disable Site Health
319 if (disable_everything_check_option ( 'sitehealth' )) {
320
321 // completely disable the Site Health
322
323 // disable the admin menu
324 add_action( 'admin_menu', 'disable_everything_remove_site_health_menu' );
325
326 // block site health page screen
327 add_action( 'current_screen', 'disable_everything_block_site_health_access' );
328
329 }
330 // adjacent_posts
331 if (disable_everything_check_option ( 'adjacentposts' )) {
332
333 // remove the next and previous post links.
334 remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
335 remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
336
337 }
338 // Version
339 if (disable_everything_check_option ( 'version' )) {
340
341 // Remove WordPress version var (?ver=) after styles and scripts.
342
343 // remove ver= after style and script links.
344 add_filter(
345 'style_loader_src',
346 function ( $src ) {
347 if ( strpos( $src, 'ver=' ) ) {
348 $src = remove_query_arg( 'ver', $src );
349 }
350 return $src;
351 },
352 9999
353 );
354 add_filter(
355 'script_loader_src',
356 function ( $src ) {
357 if ( strpos( $src, 'ver=' ) ) {
358 $src = remove_query_arg( 'ver', $src );
359 }
360 return $src;
361 },
362 9999
363 );
364
365 }
366 // dns-prefetch
367 if (disable_everything_check_option ( 'dnsprefetch' )) {
368
369 // remove s.w.org dns-prefetch.
370 remove_action( 'wp_head', 'wp_resource_hints', 2 );
371
372 }
373 // PDF Thumbnails
374 if (disable_everything_check_option ( 'pdfthumbnails' )) {
375
376 // completely disable the PDF Thumbnails functionality
377 add_filter(
378 'fallback_intermediate_image_sizes',
379 function() {
380 return array();
381 }
382 );
383
384 }
385 // Empty Trash
386 if (disable_everything_check_option ( 'emptytrash' )) {
387
388 // Empty trash sooner.
389 if ( ! defined( 'EMPTY_TRASH_DAYS' ) ) {
390 define( 'EMPTY_TRASH_DAYS', 7 );
391 }
392
393 }
394 // Plugin and Theme Editor
395 if (disable_everything_check_option ( 'pluginandthemeeditor' )) {
396
397 // disable the Plugin and Theme Editor
398 if ( ! defined( 'DISALLOW_FILE_EDIT' ) ) {
399 define( 'DISALLOW_FILE_EDIT', true ); // phpcs:ignore
400 }
401
402 }
403 // oEmbed
404 if (disable_everything_check_option ( 'oembed' )) {
405
406 // Remove oEmbed Scripts
407 // Since WordPress 4.4, oEmbed is installed and available by default. WordPress assumes you’ll want to easily embed media like tweets and YouTube videos so includes the scripts as standard. If you don’t need oEmbed, you can remove it.
408 wp_deregister_script( 'wp-embed' );
409
410 }
411 // Remote Block Patterns
412 if (disable_everything_check_option ( 'remoteblockpatterns' )) {
413
414 // Disable Remote Block Patterns
415 add_filter( 'should_load_remote_block_patterns', 'disable_everything_disable_remote_patterns_filter' );
416 }
417 }
418 add_action ( 'init', 'disable_everything_init' );
419 function disable_everything_wp_enqueue_scripts() {
420 // Dashicons
421 if (disable_everything_check_option ( 'dashicons' ) && ! is_user_logged_in ()) {
422 wp_dequeue_style ( 'dashicons' );
423 wp_deregister_style ( 'dashicons' );
424 }
425
426 // Heartbeat
427 if (disable_everything_check_option ( 'heartbeat' )) {
428 global $pagenow;
429 if ($pagenow !== 'post.php' && $pagenow !== 'post-new.php') {
430 wp_deregister_script ( 'heartbeat' );
431 }
432 }
433 }
434 add_action ( 'wp_enqueue_scripts', 'disable_everything_wp_enqueue_scripts' );
435
436 /* Settings */
437
438 // check checkbox setting
439 function disable_everything_check_option($suffix) {
440 $settings = get_option ( 'disable_everything_settings' );
441 return (isset ( $settings ['disable-everything-options-' . $suffix] ) && $settings ['disable-everything-options-' . $suffix] === "YES");
442 }
443
444 // check checkbox setting
445 function disable_everything_check_other_setting($suffix) {
446 $settings = get_option ( 'disable_everything_settings' );
447 return (isset ( $settings ['disable-everything-' . $suffix] ) && $settings ['disable-everything-' . $suffix] === "YES");
448 }
449
450 // add settings page
451 function disable_everything_menus() {
452 add_options_page ( __ ( 'Disable Everything', 'disable-everything' ), __ ( 'Disable Everything', 'disable-everything' ), 'manage_options', 'disable-everything', 'disable_everything_options' );
453 }
454
455 // add the settings
456 function disable_everything_settings() {
457 register_setting ( 'disable-everything', 'disable_everything_settings' );
458
459 add_settings_section ( 'disable-everything-section-options', __ ( 'Options', 'disable-everything' ), 'disable_everything_settings_section', 'disable-everything' );
460
461 /* TODO - Placeholder Settings */
462 /**
463 * When pro is not activated
464 */
465 if (! function_exists ( 'disable_everything_pro_activated' )) {
466
467 $pro_options = array (
468 array (
469 'Comments',
470 'Disable Comments on Frontend and Admin'
471 ),
472 array (
473 'WP Updates',
474 'Disables all WordPress updates (core, plugins and themes) and removes update notifications in admin'
475 ),
476 array (
477 'Auto-update Email Notifications for Themes and Plugins',
478 'Disable auto-update Email Notifications for Themes and Plugins updates Only'
479 ),
480 array (
481 'Post Revisions',
482 'Disable Post Revisions (for All Post Types)'
483 ),
484 array (
485 'Search',
486 'Disable WordPress Search on Frontend only'
487 ),
488 array (
489 'WP Login Logo and Favicon',
490 'Disable WordPress logo on the login page and W favicon (logo is replaced with your site\'s name and new favicon can be added in Customizer)'
491 ),
492 array (
493 'Administration Email Verification Prompt',
494 'Disables the administration email verification prompt introduced in WordPress 5.3'
495 ),
496 array (
497 'Lazy Loading',
498 'Disable Lazy Loading (introduced in WP version 5.5)'
499 ),
500 array (
501 'Yoast SEO Bloat',
502 'Disable Yoast SEO Bloat'
503 ),
504 array (
505 'WooCommerce Bloat',
506 'Disable WooCommerce Bloat'
507 ),
508 array (
509 'Right Click',
510 'Disable Right Click (by checking this you will disable right click, view source, cut/copy/paste, text selection, inspect element, image save, image drag & drop. However this will not work if you are logged as Administrator or Editor, in other words you need to be logged out of admin panel in order to see all of these disabled)'
511 )
512 );
513
514 $pro_options_cnt = 0;
515 $pro_options_cnt = count ( $pro_options );
516
517 for($i = 0; $i < $pro_options_cnt; $i ++) {
518
519 add_settings_field ( 'disable-everything-options-placeholder' . $i, __ ( $pro_options [$i] [0], 'disable-everything' ), 'disable_everything_placeholder', 'disable-everything', 'disable-everything-section-options', array (
520 'placeholderlabel' => $pro_options [$i] [1],
521 'placeholderid' => $i
522 ) );
523 }
524 }
525
526 add_settings_field ( 'disable-everything-options-blockuserenumeration', __ ( 'User-Enumeration', 'disable-everything' ), 'disable_everything_blockuserenumeration', 'disable-everything', 'disable-everything-section-options' );
527 add_settings_field ( 'disable-everything-options-disableauthorarchives', __ ( 'Author Archives', 'disable-everything' ), 'disable_everything_disableauthorarchives', 'disable-everything', 'disable-everything-section-options' );
528 add_settings_field ( 'disable-everything-options-removecapitalpdangit', __ ( 'capital_P_dangit', 'disable-everything' ), 'disable_everything_removecapitalpdangit', 'disable-everything', 'disable-everything-section-options' );
529 add_settings_field ( 'disable-everything-options-removescreenoptions', __ ( 'Screen options and help', 'disable-everything' ), 'disable_everything_removescreenoptions', 'disable-everything', 'disable-everything-section-options' );
530 add_settings_field ( 'disable-everything-options-removehowdy', __ ( 'Howdy in adminbar', 'disable-everything' ), 'disable_everything_removehowdy', 'disable-everything', 'disable-everything-section-options' );
531 add_settings_field ( 'disable-everything-options-removeitemsadminbar', __ ( 'Navigation items in adminbar', 'disable-everything' ), 'disable_everything_removeitemsadminbar', 'disable-everything', 'disable-everything-section-options' );
532 add_settings_field ( 'disable-everything-options-cleandashboard', __ ( 'Clean Dashboard', 'disable-everything' ), 'disable_everything_cleandashboard', 'disable-everything', 'disable-everything-section-options' );
533 add_settings_field ( 'disable-everything-options-emojis', __ ( 'Emojis', 'disable-everything' ), 'disable_everything_emojis', 'disable-everything', 'disable-everything-section-options' );
534 add_settings_field ( 'disable-everything-options-embed', __ ( 'Embed Objects', 'disable-everything' ), 'disable_everything_embed', 'disable-everything', 'disable-everything-section-options' );
535 add_settings_field ( 'disable-everything-options-dashicons', __ ( 'Dashicons', 'disable-everything' ), 'disable_everything_dashicons', 'disable-everything', 'disable-everything-section-options' );
536 add_settings_field ( 'disable-everything-options-heartbeat', __ ( 'Heartbeat', 'disable-everything' ), 'disable_everything_heartbeat', 'disable-everything', 'disable-everything-section-options' );
537 add_settings_field ( 'disable-everything-options-xmlrpc', __ ( 'XML-RPC + Pingback', 'disable-everything' ), 'disable_everything_xmlrpc', 'disable-everything', 'disable-everything-section-options' );
538 add_settings_field ( 'disable-everything-options-generator', __ ( 'Generator', 'disable-everything' ), 'disable_everything_generator', 'disable-everything', 'disable-everything-section-options' );
539 add_settings_field ( 'disable-everything-options-manifest', __ ( 'WLW Manifest', 'disable-everything' ), 'disable_everything_manifest', 'disable-everything', 'disable-everything-section-options' );
540 add_settings_field ( 'disable-everything-options-rsdlink', __ ( 'Really Simple Discovery', 'disable-everything' ), 'disable_everything_rsdlink', 'disable-everything', 'disable-everything-section-options' );
541 add_settings_field ( 'disable-everything-options-shortlink', __ ( 'Short Link', 'disable-everything' ), 'disable_everything_shortlink', 'disable-everything', 'disable-everything-section-options' );
542 add_settings_field ( 'disable-everything-options-rssfeeds', __ ( 'RSS Feeds', 'disable-everything' ), 'disable_everything_rssfeeds', 'disable-everything', 'disable-everything-section-options' );
543 add_settings_field ( 'disable-everything-options-restapi', __ ( 'REST API', 'disable-everything' ), 'disable_everything_restapi', 'disable-everything', 'disable-everything-section-options' );
544 add_settings_field ( 'disable-everything-options-blocks', __ ( 'Block Library', 'disable-everything' ), 'disable_everything_blocks', 'disable-everything', 'disable-everything-section-options' );
545 add_settings_field ( 'disable-everything-options-adminfooter', __ ( 'Admin Footer', 'disable-everything' ), 'disable_everything_adminfooter', 'disable-everything', 'disable-everything-section-options' );
546 add_settings_field ( 'disable-everything-options-applicationpasswords', __ ( 'Application Passwords', 'disable-everything' ), 'disable_everything_applicationpasswords', 'disable-everything', 'disable-everything-section-options' );
547 //TODO: Settings Field
548 add_settings_field ( 'disable-everything-options-coreprivacytools', __ ( 'Core Privacy Tools', 'disable-everything' ), 'disable_everything_coreprivacytools', 'disable-everything', 'disable-everything-section-options' );
549 add_settings_field ( 'disable-everything-options-sitehealth', __ ( 'Site Health', 'disable-everything' ), 'disable_everything_sitehealth', 'disable-everything', 'disable-everything-section-options' );
550 add_settings_field ( 'disable-everything-options-adjacentposts', __ ( 'adjacent_posts', 'disable-everything' ), 'disable_everything_adjacentposts', 'disable-everything', 'disable-everything-section-options' );
551 add_settings_field ( 'disable-everything-options-version', __ ( 'Version', 'disable-everything' ), 'disable_everything_version', 'disable-everything', 'disable-everything-section-options' );
552 add_settings_field ( 'disable-everything-options-pdfthumbnails', __ ( 'PDF Thumbnails', 'disable-everything' ), 'disable_everything_pdfthumbnails', 'disable-everything', 'disable-everything-section-options' );
553 add_settings_field ( 'disable-everything-options-emptytrash', __ ( 'Empty Trash', 'disable-everything' ), 'disable_everything_emptytrash', 'disable-everything', 'disable-everything-section-options' );
554 add_settings_field ( 'disable-everything-options-pluginandthemeeditor', __ ( 'Plugin and Theme Editor', 'disable-everything' ), 'disable_everything_pluginandthemeeditor', 'disable-everything', 'disable-everything-section-options' );
555 add_settings_field ( 'disable-everything-options-oembed', __ ( 'oEmbed', 'disable-everything' ), 'disable_everything_oembed', 'disable-everything', 'disable-everything-section-options' );
556 add_settings_field ( 'disable-everything-options-remoteblockpatterns', __ ( 'Remote Block Patterns', 'disable-everything' ), 'disable_everything_remoteblockpatterns', 'disable-everything', 'disable-everything-section-options' );
557 }
558
559 // allow the settings to be stored
560 add_filter ( 'whitelist_options', function ($whitelist_options) {
561 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-blockuserenumeration';
562 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-disableauthorarchives';
563 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-removecapitalpdangit';
564 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-removescreenoptions';
565 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-removehowdy';
566 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-removeitemsadminbar';
567 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-cleandashboard';
568 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-emojis';
569 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-embed';
570 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-dashicons';
571 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-heartbeat';
572 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-generator';
573 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-xmlrpc';
574 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-manifest';
575 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-rsdlink';
576 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-shortlink';
577 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-rssfeeds';
578 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-restapi';
579 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-blocks';
580 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-adminfooter';
581 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-applicationpasswords';
582 //TODO: Storing Settings
583 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-coreprivacytools';
584 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-sitehealth';
585 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-adjacentposts';
586 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-dnsprefetch';
587 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-pdfthumbnails';
588 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-emptytrash';
589 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-pluginandthemeeditor';
590 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-oembed';
591 $whitelist_options ['disable-everything'] [] = 'disable-everything-options-remoteblockpatterns';
592
593 return $whitelist_options;
594 } );
595
596 // define output for settings page
597 function disable_everything_options() {
598 echo '<style>#disable-everything-tabs h2{display:none}</style>';
599 echo '<div class="widefat">';
600
601 //Banner
602 if (! function_exists ( 'disable_everything_pro_activated' )) {
603 echo '<div class="wrap">';
604 echo '<a href="https://syncpostsbetweensites.dessky.info" target="_blank"><img src="' . esc_url( plugins_url( 'assets/img/sync-posts-between-sites.jpg', __FILE__ ) ) . '" /></a>';
605 echo '</div>';
606 }
607
608 echo '<div class="wrap disable-everything-panel">
609 <h1>' . __ ( 'Disable Everything', 'disable-everything' ) . '</h1>';
610
611 echo '<hr>';
612 echo ' <p class="description">';
613 echo __ ( 'This plugin is used to disable all unused options that are slowing down your site. Doing so will improve your website performance.', 'disable-everything' );
614 echo ' <br>';
615 echo __ ( 'This is NOT a caching plugin, but should play well with any caching plugin you decide to use.', 'disable-everything' );
616 echo ' </p>';
617
618 echo '<hr>';
619 echo '<h2>' . __ ( 'Server Requirements Check', 'disable-everything' ) . '</h2>
620 <p class="description menu-settings" style="margin:0 0 24px 0;">To put it short, if both boxes are in blue you are good. If some is in red you should consider upgrading your hosting to get better performance out of your site.</p>';
621 echo ' <div style="margin:0 0 24px 0;">';
622 echo ' <a href="https://www.php.net/supported-versions.php" target="_blank" class="update-message notice inline notice-' . disable_everything_badge_php () . ' notice-alt">PHP ' . disable_everything_phpversion () . '</a>';
623
624 $dbtype = null;
625 $dbversion = null;
626 $badge_mysql = null;
627 $badge_maria = null;
628
629 $dbtype = disable_everything_dbtype ();
630
631 $dbversion = disable_everything_dbversion ();
632
633 $badge_mysql = disable_everything_badge_mysql ();
634
635 $badge_maria = disable_everything_badge_maria ();
636
637 if ($dbtype === 'MYSQL') {
638 echo ' &nbsp; <a href="https://www.fromdual.com/support-for-mysql-from-oracle" target="_blank" class="update-message notice inline notice-' . $badge_mysql . ' notice-alt">' . $dbtype . ' ' . $dbversion . '</a>';
639 } else {
640 echo ' &nbsp; <a href="https://www.fromdual.com/support-for-mysql-from-oracle" target="_blank" class="update-message notice inline notice-' . $badge_maria . ' notice-alt">' . $dbtype . ' ' . $dbversion . '</a>';
641 }
642 echo ' </div>';
643 echo '<hr>';
644 ?>
645
646 <select id="opt-all-none" style="width: 80px; height: 32px;">
647 <option value="all"><?php _e( 'All', 'disable-everything' ); ?></option>
648 <option value="none"><?php _e( 'None', 'disable-everything' ); ?></option>
649 </select>
650 <button id="btn-all-none" class="button button-secondary"
651 style="width: 80px; height: 32px;"><?php _e( 'Select', 'disable-everything' ); ?></button>
652
653 <?php
654 echo '<hr>';
655 echo ' <form action="options.php" method="post">';
656
657 settings_fields ( 'disable-everything' );
658
659 do_settings_sections ( 'disable-everything' );
660 echo '<hr>';
661 submit_button ();
662 echo ' </form>';
663
664 ?>
665 <script>
666
667 /**
668 * The select all/none functionality.
669 */
670 let btn = document.getElementById('btn-all-none');
671 let opt = document.getElementById('opt-all-none');
672 let checkboxes = document.querySelectorAll('.disable-everything-panel input[type="checkbox"]');
673 btn.addEventListener('click', function() {
674 if (opt.value === 'all') {
675 for (let i = 0; i <= checkboxes.length; i += 1) {
676
677 if(checkboxes[i] !== undefined){
678 checkboxes[i].checked = true;
679 }
680 }
681 } else {
682 for (let i = 0; i <= checkboxes.length; i += 1) {
683
684 if(checkboxes[i] !== undefined){
685 checkboxes[i].checked = false;
686 }
687 }
688 }
689 });
690
691 </script>
692 <?php
693
694 // estimated savings
695 $reqs = 0;
696 $size = 0;
697 $tags = 0;
698 if (disable_everything_check_option ( 'emojis' )) {
699 $reqs += 2;
700 $size += 16;
701 $tags += 2;
702 }
703 if (disable_everything_check_option ( 'embed' )) {
704 $reqs += 1;
705 $size += 6;
706 $tags += 1;
707 }
708 if (disable_everything_check_option ( 'dashicons' )) {
709 $reqs += 1;
710 $size += 46;
711 $tags += 1;
712 }
713 if (disable_everything_check_option ( 'heartbeat' )) {
714 $reqs += 1;
715 $size += 6;
716 $tags += 1;
717 }
718 if (disable_everything_check_option ( 'generator' )) {
719 $tags += 1;
720 }
721 if (disable_everything_check_option ( 'xmlrpc' )) {
722 $tags += 1;
723 }
724 if (disable_everything_check_option ( 'manifest' )) {
725 $tags += 1;
726 }
727 if (disable_everything_check_option ( 'rsdlink' )) {
728 $tags += 1;
729 }
730 if (disable_everything_check_option ( 'shortlink' )) {
731 $tags += 1;
732 }
733 if (disable_everything_check_option ( 'rssfeeds' )) {
734 $tags += 2;
735 }
736 if (disable_everything_check_option ( 'restapi' )) {
737 $tags += 1;
738 }
739 if (disable_everything_check_option ( 'blocks' )) {
740 $reqs += 1;
741 $size += 29;
742 $tags += 1;
743 }
744 echo '<hr>';
745 echo ' <h2>' . __ ( 'Estimated Savings', 'disable-everything' ) . '</h2>';
746 echo ' <table class="form-table">';
747 echo ' <tbody>';
748 echo ' <tr>';
749 echo ' <th scope="row">' . __ ( 'File Requests', 'disable-everything' ) . '</th>';
750 echo ' <td>' . esc_html ( $reqs ) . '</td>';
751 echo ' </tr>';
752 echo ' <tr>';
753 echo ' <th scope="row">' . __ ( 'File Size', 'disable-everything' ) . '</th>';
754 echo ' <td>' . esc_html ( ($size >= 1024 ? (number_format ( $size / 1024, 1 )) . 'Mb' : $size . 'kb') ) . '</td>';
755 echo ' </tr>';
756 echo ' <tr>';
757 echo ' <th scope="row">' . __ ( 'HTML Tags', 'disable-everything' ) . '</th>';
758 echo ' <td>' . esc_html ( $tags ) . '</td>';
759 echo ' </tr>';
760 echo ' </tbody>';
761 echo ' </table>';
762 echo '</div>';
763 }
764 function disable_everything_badge_php() {
765 $ver = disable_everything_phpversion ();
766 $col = "error";
767 if (version_compare ( $ver, '7.2', '>=' )) {
768 $col = "warning";
769 }
770 if (version_compare ( $ver, '7.3', '>=' )) {
771 $col = "info";
772 }
773 return $col;
774 }
775 function disable_everything_phpversion() {
776 return explode ( '-', phpversion () ) [0]; // trim any extra information
777 }
778 function disable_everything_dbtype_transient() {
779 $dbtype = get_transient ( 'disable_everything_dbtype' );
780
781 if (false === $dbtype) {
782
783 global $wpdb;
784 $vers = $wpdb->get_var ( "SELECT VERSION() as mysql_version" );
785 if (stripos ( $vers, 'MARIA' ) !== false) {
786 $dbtype = 'MARIA';
787 }
788 $dbtype = 'MYSQL';
789
790 set_transient ( 'disable_everything_dbtype', $dbtype, 604800 ); // expire after 1 week
791
792 return $dbtype;
793 } else {
794 return $dbtype;
795 }
796 }
797 function disable_everything_dbversion_transient() {
798 $dbversion = get_transient ( 'disable_everything_dbversion' );
799
800 if (false === $dbversion) {
801
802 global $wpdb;
803 $vers = $wpdb->get_var ( "SELECT VERSION() as mysql_version" );
804 $vers_transient = explode ( '-', $vers ) [0]; // trim any extra information
805
806 set_transient ( 'disable_everything_dbversion', $vers_transient, 604800 ); // expire after 1 week
807
808 return $vers_transient;
809 } else {
810 return $dbversion;
811 }
812 }
813 function disable_everything_dbtype() {
814 return disable_everything_dbtype_transient ();
815 }
816 function disable_everything_dbversion() {
817 return disable_everything_dbversion_transient ();
818 }
819 function disable_everything_badge_mysql() {
820 $ver = disable_everything_dbversion ();
821 $col = "error";
822 if (version_compare ( $ver, '5.6', '>=' )) {
823 $col = "warning";
824 }
825 if (version_compare ( $ver, '5.7', '>=' )) {
826 $col = "info";
827 }
828 return $col;
829 }
830 function disable_everything_badge_maria() {
831 $ver = disable_everything_dbversion ();
832 $col = "error";
833 if (version_compare ( $ver, '10.0', '>=' )) {
834 $col = "warning";
835 }
836 if (version_compare ( $ver, '10.1', '>=' )) {
837 $col = "info";
838 }
839 return $col;
840 }
841
842 /* Help Tab */
843 function disable_everything_remove_help_tabs() {
844 if (is_admin ()) {
845 $screen = get_current_screen ();
846 $screen->remove_help_tabs ();
847 }
848 }
849
850 /**
851 * Footer text
852 *
853 * @since 1.0
854 */
855 function disable_everything_footer_text($text) {
856 global $current_screen;
857 if (! empty ( $current_screen->id ) && strpos ( $current_screen->id, 'disable-everything' ) !== false) {
858 return 'If you like <strong>Disable Everything</strong> please leave us a <a href="https://wordpress.org/support/plugin/disable-everything/reviews?rate=5#new-post" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a> rating to help us spread the word. A huge thanks in advance!';
859 }
860
861 return $text;
862 }
863 add_filter ( 'admin_footer_text', 'disable_everything_footer_text' );
864
865 /**
866 * Plugin Text - meta links
867 */
868 if (! function_exists ( 'disable_everything_pro_activated' )) {
869 function disable_everything_row_meta($input, $page) {
870
871 // check permissions
872 if ($page != plugin_basename ( DISABLEEVERYTHING_FILE )) {
873 return $input;
874 }
875
876 return array_merge ( $input, array (
877 '<a href="https://dessky.com/plugin/disable-everything/" target="_blank" style="font-weight:700;">Order PRO version</a>'
878 ) );
879 }
880 add_filter ( 'plugin_row_meta', 'disable_everything_row_meta', 10, 2 );
881 }
882
883 // define output for settings section
884 function disable_everything_settings_section() {
885 // nothing to output
886 }
887
888 /* TODO - Placeholder Checkboxes */
889 // defined output for settings if PRO is not active
890 function disable_everything_placeholder($args) {
891 echo '<label><input id="disable-everything-options-placeholder' . $args ['placeholderid'] . '" name="disable_everything_settings[disable-everything-options-placeholder' . $args ['placeholderid'] . ']" type="checkbox" value="" disabled > <span style="color:gray">';
892 echo __ ( $args ['placeholderlabel'], 'disable-everything' );
893 echo '</span> ';
894
895 echo '<small class="update-message notice inline notice-warning notice-alt"><a style="color:orange" href="https://dessky.com/plugin/disable-everything/" target="_blank">Available in PRO version</a></small>';
896 }
897
898 // defined output for settings
899 function disable_everything_blockuserenumeration() {
900 $checked = "";
901 if (disable_everything_check_option ( 'blockuserenumeration' )) {
902 $checked = " checked";
903 }
904 echo '<label><input id="disable-everything-options-blockuserenumeration" name="disable_everything_settings[disable-everything-options-blockuserenumeration]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Block User-Enumeration', 'disable-everything' );
905 }
906 function disable_everything_disableauthorarchives() {
907 $checked = "";
908 if (disable_everything_check_option ( 'disableauthorarchives' )) {
909 $checked = " checked";
910 }
911 echo '<label><input id="disable-everything-options-disableauthorarchives" name="disable_everything_settings[disable-everything-options-disableauthorarchives]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable Author Archives', 'disable-everything' );
912 }
913 function disable_everything_removecapitalpdangit() {
914 $checked = "";
915 if (disable_everything_check_option ( 'removecapitalpdangit' )) {
916 $checked = " checked";
917 }
918 echo '<label><input id="disable-everything-options-removecapitalpdangit" name="disable_everything_settings[disable-everything-options-removecapitalpdangit]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Changes the incorrect capitalization of Wordpress into WordPress. WordPress uses it to filter the content, the title and comment text.', 'disable-everything' );
919 }
920 function disable_everything_removescreenoptions() {
921 $checked = "";
922 if (disable_everything_check_option ( 'removescreenoptions' )) {
923 $checked = " checked";
924 }
925 echo '<label><input id="disable-everything-options-removescreenoptions" name="disable_everything_settings[disable-everything-options-removescreenoptions]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable screen options and contextual help', 'disable-everything' );
926 }
927 function disable_everything_removehowdy() {
928 $checked = "";
929 if (disable_everything_check_option ( 'removehowdy' )) {
930 $checked = " checked";
931 }
932 echo '<label><input id="disable-everything-options-removehowdy" name="disable_everything_settings[disable-everything-options-removehowdy]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Remove Howdy from adminbar', 'disable-everything' );
933 }
934 function disable_everything_removeitemsadminbar() {
935 $checked = "";
936 if (disable_everything_check_option ( 'removeitemsadminbar' )) {
937 $checked = " checked";
938 }
939 echo '<label><input id="disable-everything-options-removeitemsadminbar" name="disable_everything_settings[disable-everything-options-removeitemsadminbar]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Remove reduntant items from adminbar <em>(these items are removed: wp-logo,view-site,new-content,comments,updates,dashboard,appearance)</em>', 'disable-everything' );
940 }
941 function disable_everything_cleandashboard() {
942 $checked = "";
943 if (disable_everything_check_option ( 'cleandashboard' )) {
944 $checked = " checked";
945 }
946 echo '<label><input id="disable-everything-options-cleandashboard" name="disable_everything_settings[disable-everything-options-cleandashboard]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Clean up Dasboard from bloat <em>(improves preformance and saves valuable space)</em>', 'disable-everything' );
947 }
948 function disable_everything_emojis() {
949 $checked = "";
950 if (disable_everything_check_option ( 'emojis' )) {
951 $checked = " checked";
952 }
953 echo '<label><input id="disable-everything-options-emojis" name="disable_everything_settings[disable-everything-options-emojis]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable support for emojis in posts <em>(saves at least 1 file request and ~16kb)</em>', 'disable-everything' );
954 }
955 function disable_everything_embed() {
956 $checked = "";
957 if (disable_everything_check_option ( 'embed' )) {
958 $checked = " checked";
959 }
960 echo '<label><input id="disable-everything-options-embed" name="disable_everything_settings[disable-everything-options-embed]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable support for embedding objects in posts <em>(saves at least 1 file request and ~6kb)</em>', 'disable-everything' );
961 }
962 function disable_everything_dashicons() {
963 $checked = "";
964 if (disable_everything_check_option ( 'dashicons' )) {
965 $checked = " checked";
966 }
967 echo '<label><input id="disable-everything-options-dashicons" name="disable_everything_settings[disable-everything-options-dashicons]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable support for Dashicons <u>when not logged in</u> <em>(saves 1 file request and ~46kb)</em>', 'disable-everything' );
968 }
969 function disable_everything_heartbeat() {
970 $checked = "";
971 if (disable_everything_check_option ( 'heartbeat' )) {
972 $checked = " checked";
973 }
974 echo '<label><input id="disable-everything-options-heartbeat" name="disable_everything_settings[disable-everything-options-heartbeat]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable support for auto-save <u>when not editing a page/post</u> <em>(saves 1 file request and ~6kb)</em>', 'disable-everything' );
975 }
976 function disable_everything_xmlrpc() {
977 $checked = "";
978 if (disable_everything_check_option ( 'xmlrpc' )) {
979 $checked = " checked";
980 }
981 echo '<label><input id="disable-everything-options-xmlrpc" name="disable_everything_settings[disable-everything-options-xmlrpc]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable support for third-party application access <em>(such as mobile apps)</em>', 'disable-everything' );
982 }
983 function disable_everything_generator() {
984 $checked = "";
985 if (disable_everything_check_option ( 'generator' )) {
986 $checked = " checked";
987 }
988 echo '<label><input id="disable-everything-options-generator" name="disable_everything_settings[disable-everything-options-generator]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable the generator tag <em>(includes Wordpress version number)</em>', 'disable-everything' );
989 }
990 function disable_everything_manifest() {
991 $checked = "";
992 if (disable_everything_check_option ( 'manifest' )) {
993 $checked = " checked";
994 }
995 echo '<label><input id="disable-everything-options-manifest" name="disable_everything_settings[disable-everything-options-manifest]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable the Windows Live Writer manifest tag <em>(WLW was discontinued in Jan 2017)</em>', 'disable-everything' );
996 }
997 function disable_everything_rsdlink() {
998 $checked = "";
999 if (disable_everything_check_option ( 'rsdlink' )) {
1000 $checked = " checked";
1001 }
1002 echo '<label><input id="disable-everything-options-rsdlink" name="disable_everything_settings[disable-everything-options-rsdlink]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable the Really Simple Discovery (RSD) tag <em>(this protocol never became popular)</em>', 'disable-everything' );
1003 }
1004 function disable_everything_shortlink() {
1005 $checked = "";
1006 if (disable_everything_check_option ( 'shortlink' )) {
1007 $checked = " checked";
1008 }
1009 echo '<label><input id="disable-everything-options-shortlink" name="disable_everything_settings[disable-everything-options-shortlink]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable the Short Link tag <em>(search engines ignore this tag completely)</em>', 'disable-everything' );
1010 }
1011 function disable_everything_rssfeeds() {
1012 $checked = "";
1013 if (disable_everything_check_option ( 'rssfeeds' )) {
1014 $checked = " checked";
1015 }
1016 echo '<label><input id="disable-everything-options-rssfeeds" name="disable_everything_settings[disable-everything-options-rssfeeds]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable the RSS feed links and disable the feeds <em>(will redirect to the page instead)</em>', 'disable-everything' );
1017 }
1018 function disable_everything_restapi() {
1019 $checked = "";
1020 if (disable_everything_check_option ( 'restapi' )) {
1021 $checked = " checked";
1022 }
1023 echo '<label><input id="disable-everything-options-restapi" name="disable_everything_settings[disable-everything-options-restapi]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable the REST API links and disable the endpoints <u>when not on admin pages</u>', 'disable-everything' );
1024 }
1025 function disable_everything_blocks() {
1026 $checked = "";
1027 if (disable_everything_check_option ( 'blocks' )) {
1028 $checked = " checked";
1029 }
1030 echo '<label><input id="disable-everything-options-blocks" name="disable_everything_settings[disable-everything-options-blocks]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable the Gutenberg blocks library if you are using Classic Editor <em>(saves 1 file request and ~29kb)</em>', 'disable-everything' );
1031 }
1032 function disable_everything_adminfooter() {
1033 $checked = "";
1034 if (disable_everything_check_option ( 'adminfooter' )) {
1035 $checked = " checked";
1036 }
1037 echo '<label><input id="disable-everything-options-adminfooter" name="disable_everything_settings[disable-everything-options-adminfooter]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable the admin footer text', 'disable-everything' );
1038 }
1039 function disable_everything_applicationpasswords() {
1040 $checked = "";
1041 if (disable_everything_check_option ( 'applicationpasswords' )) {
1042 $checked = " checked";
1043 }
1044 echo '<label><input id="disable-everything-options-applicationpasswords" name="disable_everything_settings[disable-everything-options-applicationpasswords]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Completely disable the new Application Passwords functionality (added in WP version 5.6)', 'disable-everything' );
1045 }
1046 //TODO: Custom Function
1047 /**
1048 * Removes required user's capabilities for core privacy tools by adding the
1049 * `do_not_allow` capability.
1050 *
1051 * - Disables the feature pointer.
1052 * - Removes the Privacy and Export/Erase Personal Data admin menu items.
1053 * - Disables the privacy policy guide and update bubbles.
1054 *
1055 * @param string[] $caps Array of the user's capabilities.
1056 * @param string $cap Capability name.
1057 * @return string[] Array of the user's capabilities.
1058 */
1059 function disable_everything_disable_core_privacy_tools( $caps, $cap ) {
1060 switch ( $cap ) {
1061 case 'export_others_personal_data':
1062 case 'erase_others_personal_data':
1063 case 'manage_privacy_options':
1064 $caps[] = 'do_not_allow';
1065 break;
1066 }
1067
1068 return $caps;
1069 }
1070
1071 // disable the admin menu
1072 function disable_everything_remove_site_health_menu() {
1073
1074 remove_submenu_page( 'tools.php', 'site-health.php' );
1075
1076 }
1077
1078 // block site health page screen
1079 function disable_everything_block_site_health_access() {
1080
1081 if ( is_admin() ) {
1082
1083 $screen = get_current_screen();
1084
1085 // if screen id is site health
1086 if ( 'site-health' == $screen->id ) {
1087 wp_redirect( admin_url() );
1088 exit;
1089 }
1090
1091 }
1092
1093 }
1094
1095 // Disable Remote Block Patterns
1096 function disable_everything_disable_remote_patterns_filter() {
1097 return false;
1098 }
1099
1100 //TODO: Check Field Function
1101 function disable_everything_coreprivacytools() {
1102 $checked = "";
1103 if (disable_everything_check_option ( 'coreprivacytools' )) {
1104 $checked = " checked";
1105 }
1106 echo '<label><input id="disable-everything-options-coreprivacytools" name="disable_everything_settings[disable-everything-options-coreprivacytools]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable the Core Privacy Tools', 'disable-everything' );
1107 }
1108 function disable_everything_sitehealth() {
1109 $checked = "";
1110 if (disable_everything_check_option ( 'sitehealth' )) {
1111 $checked = " checked";
1112 }
1113 echo '<label><input id="disable-everything-options-sitehealth" name="disable_everything_settings[disable-everything-options-sitehealth]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable the Site Health page', 'disable-everything' );
1114 }
1115 function disable_everything_adjacentposts() {
1116 $checked = "";
1117 if (disable_everything_check_option ( 'adjacentposts' )) {
1118 $checked = " checked";
1119 }
1120 echo '<label><input id="disable-everything-options-adjacentposts" name="disable_everything_settings[disable-everything-options-adjacentposts]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Remove the next and previous post links from the header', 'disable-everything' );
1121 }
1122 function disable_everything_version() {
1123 $checked = "";
1124 if (disable_everything_check_option ( 'version' )) {
1125 $checked = " checked";
1126 }
1127 echo '<label><input id="disable-everything-options-version" name="disable_everything_settings[disable-everything-options-version]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Remove WordPress version var (?ver=) after styles and scripts.', 'disable-everything' );
1128 }
1129 function disable_everything_dnsprefetch() {
1130 $checked = "";
1131 if (disable_everything_check_option ( 'dnsprefetch' )) {
1132 $checked = " checked";
1133 }
1134 echo '<label><input id="disable-everything-options-dnsprefetch" name="disable_everything_settings[disable-everything-options-dnsprefetch]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Removes dns-prefetch links from the header', 'disable-everything' );
1135 }
1136 function disable_everything_pdfthumbnails() {
1137 $checked = "";
1138 if (disable_everything_check_option ( 'pdfthumbnails' )) {
1139 $checked = " checked";
1140 }
1141 echo '<label><input id="disable-everything-options-pdfthumbnails" name="disable_everything_settings[disable-everything-options-pdfthumbnails]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'This option disables PDF thumbnails.', 'disable-everything' );
1142 }
1143 function disable_everything_emptytrash() {
1144 $checked = "";
1145 if (disable_everything_check_option ( 'emptytrash' )) {
1146 $checked = " checked";
1147 }
1148 echo '<label><input id="disable-everything-options-emptytrash" name="disable_everything_settings[disable-everything-options-emptytrash]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Shorten the time posts are kept in the trash, which is 30 days by default, to 1 week.', 'disable-everything' );
1149 }
1150 function disable_everything_pluginandthemeeditor() {
1151 $checked = "";
1152 if (disable_everything_check_option ( 'pluginandthemeeditor' )) {
1153 $checked = " checked";
1154 }
1155 echo '<label><input id="disable-everything-options-pluginandthemeeditor" name="disable_everything_settings[disable-everything-options-pluginandthemeeditor]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disables the plugins and theme editor.', 'disable-everything' );
1156 }
1157 function disable_everything_oembed() {
1158 $checked = "";
1159 if (disable_everything_check_option ( 'oembed' )) {
1160 $checked = " checked";
1161 }
1162 echo '<label><input id="disable-everything-options-oembed" name="disable_everything_settings[disable-everything-options-oembed]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Remove oEmbed Scripts. Since WordPress 4.4, oEmbed is installed and available by default. If you do not need oEmbed, you can remove it.', 'disable-everything' );
1163 }
1164 function disable_everything_remoteblockpatterns() {
1165 $checked = "";
1166 if (disable_everything_check_option ( 'remoteblockpatterns' )) {
1167 $checked = " checked";
1168 }
1169 echo '<label><input id="disable-everything-options-remoteblockpatterns" name="disable_everything_settings[disable-everything-options-remoteblockpatterns]" type="checkbox" value="YES"' . $checked . '> ' . __ ( 'Disable Remote Block Patterns. Disable it if you want to improve pattern inserter loading performance or you have privacy concerns regarding loading remote asset.', 'disable-everything' );
1170 }
1171
1172 // add actions
1173 if (is_admin ()) {
1174 add_action ( 'admin_menu', 'disable_everything_menus' );
1175 add_action ( 'admin_init', 'disable_everything_settings' );
1176 }
1177
1178 /* Add links to plugins page */
1179
1180 // show settings link
1181 function disable_everything_links($links) {
1182 $links [] = sprintf ( '<a href="%s">%s</a>', admin_url ( 'options-general.php?page=disable-everything' ), __ ( 'Settings', 'disable-everything' ) );
1183 return $links;
1184 }
1185
1186 // add actions
1187 if (is_admin ()) {
1188 add_filter ( 'plugin_action_links_' . plugin_basename ( __FILE__ ), 'disable_everything_links' );
1189 }
1190