| 1 |
<?php |
| 2 |
/* |
| 3 |
* Plugin Name: Disable Everything |
| 4 |
* Description: Disable all unnecessary WordPress features and speed up your website. |
| 5 |
* Version: 0.4.1 |
| 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 |
// Application Passwords |
| 277 |
if (disable_everything_check_option ( 'applicationpasswords' )) { |
| 278 |
|
| 279 |
// completely disable the new Application Passwords functionality |
| 280 |
add_filter('wp_is_application_passwords_available', '__return_false'); |
| 281 |
} |
| 282 |
|
| 283 |
//TODO: Filters and Actions |
| 284 |
// Core Privacy Tools |
| 285 |
if (disable_everything_check_option ( 'coreprivacytools' )) { |
| 286 |
|
| 287 |
// disable the Core Privacy Tools |
| 288 |
// Removes required user's capabilities for core privacy tools by adding the `do_not_allow` capability. |
| 289 |
add_filter( 'map_meta_cap', 'disable_everything_disable_core_privacy_tools', 10, 2 ); |
| 290 |
|
| 291 |
/** |
| 292 |
* Short circuits the option for the privacy policy page to always return 0. |
| 293 |
* |
| 294 |
* The option is used by get_privacy_policy_url() among others. |
| 295 |
*/ |
| 296 |
add_filter( 'pre_option_wp_page_for_privacy_policy', '__return_zero' ); |
| 297 |
|
| 298 |
/** |
| 299 |
* Removes the default scheduled event used to delete old export files. |
| 300 |
*/ |
| 301 |
remove_action( 'init', 'wp_schedule_delete_old_privacy_export_files' ); |
| 302 |
|
| 303 |
/** |
| 304 |
* Removes the hook attached to the default scheduled event for removing |
| 305 |
* old export files. |
| 306 |
*/ |
| 307 |
remove_action( 'wp_privacy_delete_old_export_files', 'wp_privacy_delete_old_export_files' ); |
| 308 |
|
| 309 |
} |
| 310 |
// Disable Site Health |
| 311 |
if (disable_everything_check_option ( 'sitehealth' )) { |
| 312 |
|
| 313 |
// completely disable the Site Health |
| 314 |
|
| 315 |
// disable the admin menu |
| 316 |
add_action( 'admin_menu', 'disable_everything_remove_site_health_menu' ); |
| 317 |
|
| 318 |
// block site health page screen |
| 319 |
add_action( 'current_screen', 'disable_everything_block_site_health_access' ); |
| 320 |
|
| 321 |
} |
| 322 |
// adjacent_posts |
| 323 |
if (disable_everything_check_option ( 'adjacentposts' )) { |
| 324 |
|
| 325 |
// remove the next and previous post links. |
| 326 |
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); |
| 327 |
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); |
| 328 |
|
| 329 |
} |
| 330 |
// Version |
| 331 |
if (disable_everything_check_option ( 'version' )) { |
| 332 |
|
| 333 |
// Remove WordPress version var (?ver=) after styles and scripts. |
| 334 |
|
| 335 |
// remove ver= after style and script links. |
| 336 |
add_filter( |
| 337 |
'style_loader_src', |
| 338 |
function ( $src ) { |
| 339 |
if ( strpos( $src, 'ver=' ) ) { |
| 340 |
$src = remove_query_arg( 'ver', $src ); |
| 341 |
} |
| 342 |
return $src; |
| 343 |
}, |
| 344 |
9999 |
| 345 |
); |
| 346 |
add_filter( |
| 347 |
'script_loader_src', |
| 348 |
function ( $src ) { |
| 349 |
if ( strpos( $src, 'ver=' ) ) { |
| 350 |
$src = remove_query_arg( 'ver', $src ); |
| 351 |
} |
| 352 |
return $src; |
| 353 |
}, |
| 354 |
9999 |
| 355 |
); |
| 356 |
|
| 357 |
} |
| 358 |
// dns-prefetch |
| 359 |
if (disable_everything_check_option ( 'dnsprefetch' )) { |
| 360 |
|
| 361 |
// remove s.w.org dns-prefetch. |
| 362 |
remove_action( 'wp_head', 'wp_resource_hints', 2 ); |
| 363 |
|
| 364 |
} |
| 365 |
// PDF Thumbnails |
| 366 |
if (disable_everything_check_option ( 'pdfthumbnails' )) { |
| 367 |
|
| 368 |
// completely disable the PDF Thumbnails functionality |
| 369 |
add_filter( |
| 370 |
'fallback_intermediate_image_sizes', |
| 371 |
function() { |
| 372 |
return array(); |
| 373 |
} |
| 374 |
); |
| 375 |
|
| 376 |
} |
| 377 |
// Empty Trash |
| 378 |
if (disable_everything_check_option ( 'emptytrash' )) { |
| 379 |
|
| 380 |
// Empty trash sooner. |
| 381 |
if ( ! defined( 'EMPTY_TRASH_DAYS' ) ) { |
| 382 |
define( 'EMPTY_TRASH_DAYS', 7 ); |
| 383 |
} |
| 384 |
|
| 385 |
} |
| 386 |
// Plugin and Theme Editor |
| 387 |
if (disable_everything_check_option ( 'pluginandthemeeditor' )) { |
| 388 |
|
| 389 |
// disable the Plugin and Theme Editor |
| 390 |
if ( ! defined( 'DISALLOW_FILE_EDIT' ) ) { |
| 391 |
define( 'DISALLOW_FILE_EDIT', true ); // phpcs:ignore |
| 392 |
} |
| 393 |
|
| 394 |
} |
| 395 |
// oEmbed |
| 396 |
if (disable_everything_check_option ( 'oembed' )) { |
| 397 |
|
| 398 |
// Remove oEmbed Scripts |
| 399 |
// 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. |
| 400 |
wp_deregister_script( 'wp-embed' ); |
| 401 |
|
| 402 |
} |
| 403 |
// Remote Block Patterns |
| 404 |
if (disable_everything_check_option ( 'remoteblockpatterns' )) { |
| 405 |
|
| 406 |
// Disable Remote Block Patterns |
| 407 |
add_filter( 'should_load_remote_block_patterns', 'disable_everything_disable_remote_patterns_filter' ); |
| 408 |
} |
| 409 |
} |
| 410 |
add_action ( 'init', 'disable_everything_init' ); |
| 411 |
function disable_everything_wp_enqueue_scripts() { |
| 412 |
// Dashicons |
| 413 |
if (disable_everything_check_option ( 'dashicons' ) && ! is_user_logged_in ()) { |
| 414 |
wp_dequeue_style ( 'dashicons' ); |
| 415 |
wp_deregister_style ( 'dashicons' ); |
| 416 |
} |
| 417 |
|
| 418 |
// Heartbeat |
| 419 |
if (disable_everything_check_option ( 'heartbeat' )) { |
| 420 |
global $pagenow; |
| 421 |
if ($pagenow !== 'post.php' && $pagenow !== 'post-new.php') { |
| 422 |
wp_deregister_script ( 'heartbeat' ); |
| 423 |
} |
| 424 |
} |
| 425 |
} |
| 426 |
add_action ( 'wp_enqueue_scripts', 'disable_everything_wp_enqueue_scripts' ); |
| 427 |
|
| 428 |
/* Settings */ |
| 429 |
|
| 430 |
// check checkbox setting |
| 431 |
function disable_everything_check_option($suffix) { |
| 432 |
$settings = get_option ( 'disable_everything_settings' ); |
| 433 |
return (isset ( $settings ['disable-everything-options-' . $suffix] ) && $settings ['disable-everything-options-' . $suffix] === "YES"); |
| 434 |
} |
| 435 |
|
| 436 |
// check checkbox setting |
| 437 |
function disable_everything_check_other_setting($suffix) { |
| 438 |
$settings = get_option ( 'disable_everything_settings' ); |
| 439 |
return (isset ( $settings ['disable-everything-' . $suffix] ) && $settings ['disable-everything-' . $suffix] === "YES"); |
| 440 |
} |
| 441 |
|
| 442 |
// add settings page |
| 443 |
function disable_everything_menus() { |
| 444 |
add_options_page ( __ ( 'Disable Everything', 'disable-everything' ), __ ( 'Disable Everything', 'disable-everything' ), 'manage_options', 'disable-everything', 'disable_everything_options' ); |
| 445 |
} |
| 446 |
|
| 447 |
// add the settings |
| 448 |
function disable_everything_settings() { |
| 449 |
register_setting ( 'disable-everything', 'disable_everything_settings' ); |
| 450 |
|
| 451 |
add_settings_section ( 'disable-everything-section-options', __ ( 'Options', 'disable-everything' ), 'disable_everything_settings_section', 'disable-everything' ); |
| 452 |
|
| 453 |
/* TODO - Placeholder Settings */ |
| 454 |
/** |
| 455 |
* When pro is not activated |
| 456 |
*/ |
| 457 |
if (! function_exists ( 'disable_everything_pro_activated' )) { |
| 458 |
|
| 459 |
$pro_options = array ( |
| 460 |
array ( |
| 461 |
'Comments', |
| 462 |
'Disable Comments on Frontend and Admin' |
| 463 |
), |
| 464 |
array ( |
| 465 |
'WP Updates', |
| 466 |
'Disables all WordPress updates (core, plugins and themes) and removes update notifications in admin' |
| 467 |
), |
| 468 |
array ( |
| 469 |
'Auto-update Email Notifications for Themes and Plugins', |
| 470 |
'Disable auto-update Email Notifications for Themes and Plugins updates Only' |
| 471 |
), |
| 472 |
array ( |
| 473 |
'Post Revisions', |
| 474 |
'Disable Post Revisions (for All Post Types)' |
| 475 |
), |
| 476 |
array ( |
| 477 |
'Search', |
| 478 |
'Disable WordPress Search on Frontend only' |
| 479 |
), |
| 480 |
array ( |
| 481 |
'WP Login Logo and Favicon', |
| 482 |
'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)' |
| 483 |
), |
| 484 |
array ( |
| 485 |
'Administration Email Verification Prompt', |
| 486 |
'Disables the administration email verification prompt introduced in WordPress 5.3' |
| 487 |
), |
| 488 |
array ( |
| 489 |
'Lazy Loading', |
| 490 |
'Disable Lazy Loading (introduced in WP version 5.5)' |
| 491 |
), |
| 492 |
array ( |
| 493 |
'Yoast SEO Bloat', |
| 494 |
'Disable Yoast SEO Bloat' |
| 495 |
), |
| 496 |
array ( |
| 497 |
'WooCommerce Bloat', |
| 498 |
'Disable WooCommerce Bloat' |
| 499 |
), |
| 500 |
array ( |
| 501 |
'Right Click', |
| 502 |
'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)' |
| 503 |
), |
| 504 |
array ( |
| 505 |
'Admin Footer', |
| 506 |
'Disable the admin footer text' |
| 507 |
), |
| 508 |
array ( |
| 509 |
'Elementor Bloat', |
| 510 |
'Disable JS and CSS Bloat and Dashboard Notifications for both Elementor and Essential Addons for Elementor plugins. Following are Disabled in Elementor: Google Fonts, Elementor Frontend JS, Elementor Dialog, Swipper, Elementor Waypoints, Font Awesome icons by Elementor.' |
| 511 |
), |
| 512 |
array ( |
| 513 |
'Jetpack Promotions', |
| 514 |
'Disable all Jetpack related notices that promote services like the backup services VaultPress, WordPress Apps or Blaze.' |
| 515 |
), |
| 516 |
array ( |
| 517 |
'Contact Form 7 Bloat', |
| 518 |
'Remove CF7 scripts and styles from all pages and posts where CF7 is not used' |
| 519 |
), |
| 520 |
array ( |
| 521 |
'Autoptimize Toolbar', |
| 522 |
'Disables the Autoptimize Toolbar from the Top Bar in Dashboard' |
| 523 |
), |
| 524 |
array ( |
| 525 |
'W3 Total Cache HTML Footer Comments', |
| 526 |
'Disables HTML comments from footer generated by W3 Total Cache plugin' |
| 527 |
) |
| 528 |
); |
| 529 |
|
| 530 |
$pro_options_cnt = 0; |
| 531 |
$pro_options_cnt = count ( $pro_options ); |
| 532 |
|
| 533 |
for($i = 0; $i < $pro_options_cnt; $i ++) { |
| 534 |
|
| 535 |
add_settings_field ( 'disable-everything-options-placeholder' . $i, __ ( $pro_options [$i] [0], 'disable-everything' ), 'disable_everything_placeholder', 'disable-everything', 'disable-everything-section-options', array ( |
| 536 |
'placeholderlabel' => $pro_options [$i] [1], |
| 537 |
'placeholderid' => $i |
| 538 |
) ); |
| 539 |
} |
| 540 |
} |
| 541 |
|
| 542 |
add_settings_field ( 'disable-everything-options-blockuserenumeration', __ ( 'User-Enumeration', 'disable-everything' ), 'disable_everything_blockuserenumeration', 'disable-everything', 'disable-everything-section-options' ); |
| 543 |
add_settings_field ( 'disable-everything-options-disableauthorarchives', __ ( 'Author Archives', 'disable-everything' ), 'disable_everything_disableauthorarchives', 'disable-everything', 'disable-everything-section-options' ); |
| 544 |
add_settings_field ( 'disable-everything-options-removecapitalpdangit', __ ( 'capital_P_dangit', 'disable-everything' ), 'disable_everything_removecapitalpdangit', 'disable-everything', 'disable-everything-section-options' ); |
| 545 |
add_settings_field ( 'disable-everything-options-removescreenoptions', __ ( 'Screen options and help', 'disable-everything' ), 'disable_everything_removescreenoptions', 'disable-everything', 'disable-everything-section-options' ); |
| 546 |
add_settings_field ( 'disable-everything-options-removehowdy', __ ( 'Howdy in adminbar', 'disable-everything' ), 'disable_everything_removehowdy', 'disable-everything', 'disable-everything-section-options' ); |
| 547 |
add_settings_field ( 'disable-everything-options-removeitemsadminbar', __ ( 'Navigation items in adminbar', 'disable-everything' ), 'disable_everything_removeitemsadminbar', 'disable-everything', 'disable-everything-section-options' ); |
| 548 |
add_settings_field ( 'disable-everything-options-cleandashboard', __ ( 'Clean Dashboard', 'disable-everything' ), 'disable_everything_cleandashboard', 'disable-everything', 'disable-everything-section-options' ); |
| 549 |
add_settings_field ( 'disable-everything-options-emojis', __ ( 'Emojis', 'disable-everything' ), 'disable_everything_emojis', 'disable-everything', 'disable-everything-section-options' ); |
| 550 |
add_settings_field ( 'disable-everything-options-embed', __ ( 'Embed Objects', 'disable-everything' ), 'disable_everything_embed', 'disable-everything', 'disable-everything-section-options' ); |
| 551 |
add_settings_field ( 'disable-everything-options-dashicons', __ ( 'Dashicons', 'disable-everything' ), 'disable_everything_dashicons', 'disable-everything', 'disable-everything-section-options' ); |
| 552 |
add_settings_field ( 'disable-everything-options-heartbeat', __ ( 'Heartbeat', 'disable-everything' ), 'disable_everything_heartbeat', 'disable-everything', 'disable-everything-section-options' ); |
| 553 |
add_settings_field ( 'disable-everything-options-xmlrpc', __ ( 'XML-RPC + Pingback', 'disable-everything' ), 'disable_everything_xmlrpc', 'disable-everything', 'disable-everything-section-options' ); |
| 554 |
add_settings_field ( 'disable-everything-options-generator', __ ( 'Generator', 'disable-everything' ), 'disable_everything_generator', 'disable-everything', 'disable-everything-section-options' ); |
| 555 |
add_settings_field ( 'disable-everything-options-manifest', __ ( 'WLW Manifest', 'disable-everything' ), 'disable_everything_manifest', 'disable-everything', 'disable-everything-section-options' ); |
| 556 |
add_settings_field ( 'disable-everything-options-rsdlink', __ ( 'Really Simple Discovery', 'disable-everything' ), 'disable_everything_rsdlink', 'disable-everything', 'disable-everything-section-options' ); |
| 557 |
add_settings_field ( 'disable-everything-options-shortlink', __ ( 'Short Link', 'disable-everything' ), 'disable_everything_shortlink', 'disable-everything', 'disable-everything-section-options' ); |
| 558 |
add_settings_field ( 'disable-everything-options-rssfeeds', __ ( 'RSS Feeds', 'disable-everything' ), 'disable_everything_rssfeeds', 'disable-everything', 'disable-everything-section-options' ); |
| 559 |
add_settings_field ( 'disable-everything-options-restapi', __ ( 'REST API', 'disable-everything' ), 'disable_everything_restapi', 'disable-everything', 'disable-everything-section-options' ); |
| 560 |
add_settings_field ( 'disable-everything-options-blocks', __ ( 'Block Library', 'disable-everything' ), 'disable_everything_blocks', 'disable-everything', 'disable-everything-section-options' ); |
| 561 |
add_settings_field ( 'disable-everything-options-applicationpasswords', __ ( 'Application Passwords', 'disable-everything' ), 'disable_everything_applicationpasswords', 'disable-everything', 'disable-everything-section-options' ); |
| 562 |
//TODO: Settings Field |
| 563 |
add_settings_field ( 'disable-everything-options-coreprivacytools', __ ( 'Core Privacy Tools', 'disable-everything' ), 'disable_everything_coreprivacytools', 'disable-everything', 'disable-everything-section-options' ); |
| 564 |
add_settings_field ( 'disable-everything-options-sitehealth', __ ( 'Site Health', 'disable-everything' ), 'disable_everything_sitehealth', 'disable-everything', 'disable-everything-section-options' ); |
| 565 |
add_settings_field ( 'disable-everything-options-adjacentposts', __ ( 'adjacent_posts', 'disable-everything' ), 'disable_everything_adjacentposts', 'disable-everything', 'disable-everything-section-options' ); |
| 566 |
add_settings_field ( 'disable-everything-options-version', __ ( 'Version', 'disable-everything' ), 'disable_everything_version', 'disable-everything', 'disable-everything-section-options' ); |
| 567 |
add_settings_field ( 'disable-everything-options-pdfthumbnails', __ ( 'PDF Thumbnails', 'disable-everything' ), 'disable_everything_pdfthumbnails', 'disable-everything', 'disable-everything-section-options' ); |
| 568 |
add_settings_field ( 'disable-everything-options-emptytrash', __ ( 'Empty Trash', 'disable-everything' ), 'disable_everything_emptytrash', 'disable-everything', 'disable-everything-section-options' ); |
| 569 |
add_settings_field ( 'disable-everything-options-pluginandthemeeditor', __ ( 'Plugin and Theme Editor', 'disable-everything' ), 'disable_everything_pluginandthemeeditor', 'disable-everything', 'disable-everything-section-options' ); |
| 570 |
add_settings_field ( 'disable-everything-options-oembed', __ ( 'oEmbed', 'disable-everything' ), 'disable_everything_oembed', 'disable-everything', 'disable-everything-section-options' ); |
| 571 |
add_settings_field ( 'disable-everything-options-remoteblockpatterns', __ ( 'Remote Block Patterns', 'disable-everything' ), 'disable_everything_remoteblockpatterns', 'disable-everything', 'disable-everything-section-options' ); |
| 572 |
} |
| 573 |
|
| 574 |
// allow the settings to be stored |
| 575 |
add_filter ( 'whitelist_options', function ($whitelist_options) { |
| 576 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-blockuserenumeration'; |
| 577 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-disableauthorarchives'; |
| 578 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-removecapitalpdangit'; |
| 579 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-removescreenoptions'; |
| 580 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-removehowdy'; |
| 581 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-removeitemsadminbar'; |
| 582 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-cleandashboard'; |
| 583 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-emojis'; |
| 584 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-embed'; |
| 585 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-dashicons'; |
| 586 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-heartbeat'; |
| 587 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-generator'; |
| 588 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-xmlrpc'; |
| 589 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-manifest'; |
| 590 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-rsdlink'; |
| 591 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-shortlink'; |
| 592 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-rssfeeds'; |
| 593 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-restapi'; |
| 594 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-blocks'; |
| 595 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-applicationpasswords'; |
| 596 |
//TODO: Storing Settings |
| 597 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-coreprivacytools'; |
| 598 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-sitehealth'; |
| 599 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-adjacentposts'; |
| 600 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-dnsprefetch'; |
| 601 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-pdfthumbnails'; |
| 602 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-emptytrash'; |
| 603 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-pluginandthemeeditor'; |
| 604 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-oembed'; |
| 605 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-remoteblockpatterns'; |
| 606 |
|
| 607 |
return $whitelist_options; |
| 608 |
} ); |
| 609 |
|
| 610 |
// define output for settings page |
| 611 |
function disable_everything_options() { |
| 612 |
echo '<style>#disable-everything-tabs h2{display:none}</style>'; |
| 613 |
echo '<div class="widefat">'; |
| 614 |
|
| 615 |
//Banner |
| 616 |
if (! function_exists ( 'disable_everything_pro_activated' )) { |
| 617 |
echo '<div class="wrap">'; |
| 618 |
echo '<a href="https://syncpostsbetweensites.dessky.info" target="_blank"><img src="' . esc_url( plugins_url( 'assets/img/sync-posts-between-sites.jpg', __FILE__ ) ) . '" /></a>'; |
| 619 |
echo '</div>'; |
| 620 |
} |
| 621 |
|
| 622 |
echo '<div class="wrap disable-everything-panel"> |
| 623 |
<h1>' . __ ( 'Disable Everything', 'disable-everything' ) . '</h1>'; |
| 624 |
|
| 625 |
echo '<hr>'; |
| 626 |
echo ' <p class="description">'; |
| 627 |
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' ); |
| 628 |
echo ' <br>'; |
| 629 |
echo __ ( 'This is NOT a caching plugin, but should play well with any caching plugin you decide to use.', 'disable-everything' ); |
| 630 |
echo ' </p>'; |
| 631 |
|
| 632 |
echo '<hr>'; |
| 633 |
echo '<h2>' . __ ( 'Server Requirements Check', 'disable-everything' ) . '</h2> |
| 634 |
<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>'; |
| 635 |
echo ' <div style="margin:0 0 24px 0;">'; |
| 636 |
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>'; |
| 637 |
|
| 638 |
$dbtype = null; |
| 639 |
$dbversion = null; |
| 640 |
$badge_mysql = null; |
| 641 |
$badge_maria = null; |
| 642 |
|
| 643 |
$dbtype = disable_everything_dbtype (); |
| 644 |
|
| 645 |
$dbversion = disable_everything_dbversion (); |
| 646 |
|
| 647 |
$badge_mysql = disable_everything_badge_mysql (); |
| 648 |
|
| 649 |
$badge_maria = disable_everything_badge_maria (); |
| 650 |
|
| 651 |
if ($dbtype === 'MYSQL') { |
| 652 |
echo ' <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>'; |
| 653 |
} else { |
| 654 |
echo ' <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>'; |
| 655 |
} |
| 656 |
echo ' </div>'; |
| 657 |
echo '<hr>'; |
| 658 |
?> |
| 659 |
|
| 660 |
<select id="opt-all-none" style="width: 80px; height: 32px;"> |
| 661 |
<option value="all"><?php _e( 'All', 'disable-everything' ); ?></option> |
| 662 |
<option value="none"><?php _e( 'None', 'disable-everything' ); ?></option> |
| 663 |
</select> |
| 664 |
<button id="btn-all-none" class="button button-secondary" |
| 665 |
style="width: 80px; height: 32px;"><?php _e( 'Select', 'disable-everything' ); ?></button> |
| 666 |
|
| 667 |
<?php |
| 668 |
echo '<hr>'; |
| 669 |
echo ' <form action="options.php" method="post">'; |
| 670 |
|
| 671 |
settings_fields ( 'disable-everything' ); |
| 672 |
|
| 673 |
do_settings_sections ( 'disable-everything' ); |
| 674 |
echo '<hr>'; |
| 675 |
submit_button (); |
| 676 |
echo ' </form>'; |
| 677 |
|
| 678 |
?> |
| 679 |
<script> |
| 680 |
|
| 681 |
/** |
| 682 |
* The select all/none functionality. |
| 683 |
*/ |
| 684 |
let btn = document.getElementById('btn-all-none'); |
| 685 |
let opt = document.getElementById('opt-all-none'); |
| 686 |
let checkboxes = document.querySelectorAll('.disable-everything-panel input[type="checkbox"]'); |
| 687 |
btn.addEventListener('click', function() { |
| 688 |
if (opt.value === 'all') { |
| 689 |
for (let i = 0; i <= checkboxes.length; i += 1) { |
| 690 |
|
| 691 |
if(checkboxes[i] !== undefined){ |
| 692 |
checkboxes[i].checked = true; |
| 693 |
} |
| 694 |
} |
| 695 |
} else { |
| 696 |
for (let i = 0; i <= checkboxes.length; i += 1) { |
| 697 |
|
| 698 |
if(checkboxes[i] !== undefined){ |
| 699 |
checkboxes[i].checked = false; |
| 700 |
} |
| 701 |
} |
| 702 |
} |
| 703 |
}); |
| 704 |
|
| 705 |
</script> |
| 706 |
<?php |
| 707 |
|
| 708 |
// estimated savings |
| 709 |
$reqs = 0; |
| 710 |
$size = 0; |
| 711 |
$tags = 0; |
| 712 |
if (disable_everything_check_option ( 'emojis' )) { |
| 713 |
$reqs += 2; |
| 714 |
$size += 16; |
| 715 |
$tags += 2; |
| 716 |
} |
| 717 |
if (disable_everything_check_option ( 'embed' )) { |
| 718 |
$reqs += 1; |
| 719 |
$size += 6; |
| 720 |
$tags += 1; |
| 721 |
} |
| 722 |
if (disable_everything_check_option ( 'dashicons' )) { |
| 723 |
$reqs += 1; |
| 724 |
$size += 46; |
| 725 |
$tags += 1; |
| 726 |
} |
| 727 |
if (disable_everything_check_option ( 'heartbeat' )) { |
| 728 |
$reqs += 1; |
| 729 |
$size += 6; |
| 730 |
$tags += 1; |
| 731 |
} |
| 732 |
if (disable_everything_check_option ( 'generator' )) { |
| 733 |
$tags += 1; |
| 734 |
} |
| 735 |
if (disable_everything_check_option ( 'xmlrpc' )) { |
| 736 |
$tags += 1; |
| 737 |
} |
| 738 |
if (disable_everything_check_option ( 'manifest' )) { |
| 739 |
$tags += 1; |
| 740 |
} |
| 741 |
if (disable_everything_check_option ( 'rsdlink' )) { |
| 742 |
$tags += 1; |
| 743 |
} |
| 744 |
if (disable_everything_check_option ( 'shortlink' )) { |
| 745 |
$tags += 1; |
| 746 |
} |
| 747 |
if (disable_everything_check_option ( 'rssfeeds' )) { |
| 748 |
$tags += 2; |
| 749 |
} |
| 750 |
if (disable_everything_check_option ( 'restapi' )) { |
| 751 |
$tags += 1; |
| 752 |
} |
| 753 |
if (disable_everything_check_option ( 'blocks' )) { |
| 754 |
$reqs += 1; |
| 755 |
$size += 29; |
| 756 |
$tags += 1; |
| 757 |
} |
| 758 |
echo '<hr>'; |
| 759 |
echo ' <h2>' . __ ( 'Estimated Savings', 'disable-everything' ) . '</h2>'; |
| 760 |
echo ' <table class="form-table">'; |
| 761 |
echo ' <tbody>'; |
| 762 |
echo ' <tr>'; |
| 763 |
echo ' <th scope="row">' . __ ( 'File Requests', 'disable-everything' ) . '</th>'; |
| 764 |
echo ' <td>' . esc_html ( $reqs ) . '</td>'; |
| 765 |
echo ' </tr>'; |
| 766 |
echo ' <tr>'; |
| 767 |
echo ' <th scope="row">' . __ ( 'File Size', 'disable-everything' ) . '</th>'; |
| 768 |
echo ' <td>' . esc_html ( ($size >= 1024 ? (number_format ( $size / 1024, 1 )) . 'Mb' : $size . 'kb') ) . '</td>'; |
| 769 |
echo ' </tr>'; |
| 770 |
echo ' <tr>'; |
| 771 |
echo ' <th scope="row">' . __ ( 'HTML Tags', 'disable-everything' ) . '</th>'; |
| 772 |
echo ' <td>' . esc_html ( $tags ) . '</td>'; |
| 773 |
echo ' </tr>'; |
| 774 |
echo ' </tbody>'; |
| 775 |
echo ' </table>'; |
| 776 |
echo '</div>'; |
| 777 |
} |
| 778 |
function disable_everything_badge_php() { |
| 779 |
$ver = disable_everything_phpversion (); |
| 780 |
$col = "error"; |
| 781 |
if (version_compare ( $ver, '7.2', '>=' )) { |
| 782 |
$col = "warning"; |
| 783 |
} |
| 784 |
if (version_compare ( $ver, '7.3', '>=' )) { |
| 785 |
$col = "info"; |
| 786 |
} |
| 787 |
return $col; |
| 788 |
} |
| 789 |
function disable_everything_phpversion() { |
| 790 |
return explode ( '-', phpversion () ) [0]; // trim any extra information |
| 791 |
} |
| 792 |
function disable_everything_dbtype_transient() { |
| 793 |
$dbtype = get_transient ( 'disable_everything_dbtype' ); |
| 794 |
|
| 795 |
if (false === $dbtype) { |
| 796 |
|
| 797 |
global $wpdb; |
| 798 |
$vers = $wpdb->get_var ( "SELECT VERSION() as mysql_version" ); |
| 799 |
if (stripos ( $vers, 'MARIA' ) !== false) { |
| 800 |
$dbtype = 'MARIA'; |
| 801 |
} |
| 802 |
$dbtype = 'MYSQL'; |
| 803 |
|
| 804 |
set_transient ( 'disable_everything_dbtype', $dbtype, 604800 ); // expire after 1 week |
| 805 |
|
| 806 |
return $dbtype; |
| 807 |
} else { |
| 808 |
return $dbtype; |
| 809 |
} |
| 810 |
} |
| 811 |
function disable_everything_dbversion_transient() { |
| 812 |
$dbversion = get_transient ( 'disable_everything_dbversion' ); |
| 813 |
|
| 814 |
if (false === $dbversion) { |
| 815 |
|
| 816 |
global $wpdb; |
| 817 |
$vers = $wpdb->get_var ( "SELECT VERSION() as mysql_version" ); |
| 818 |
$vers_transient = explode ( '-', $vers ) [0]; // trim any extra information |
| 819 |
|
| 820 |
set_transient ( 'disable_everything_dbversion', $vers_transient, 604800 ); // expire after 1 week |
| 821 |
|
| 822 |
return $vers_transient; |
| 823 |
} else { |
| 824 |
return $dbversion; |
| 825 |
} |
| 826 |
} |
| 827 |
function disable_everything_dbtype() { |
| 828 |
return disable_everything_dbtype_transient (); |
| 829 |
} |
| 830 |
function disable_everything_dbversion() { |
| 831 |
return disable_everything_dbversion_transient (); |
| 832 |
} |
| 833 |
function disable_everything_badge_mysql() { |
| 834 |
$ver = disable_everything_dbversion (); |
| 835 |
$col = "error"; |
| 836 |
if (version_compare ( $ver, '5.6', '>=' )) { |
| 837 |
$col = "warning"; |
| 838 |
} |
| 839 |
if (version_compare ( $ver, '5.7', '>=' )) { |
| 840 |
$col = "info"; |
| 841 |
} |
| 842 |
return $col; |
| 843 |
} |
| 844 |
function disable_everything_badge_maria() { |
| 845 |
$ver = disable_everything_dbversion (); |
| 846 |
$col = "error"; |
| 847 |
if (version_compare ( $ver, '10.0', '>=' )) { |
| 848 |
$col = "warning"; |
| 849 |
} |
| 850 |
if (version_compare ( $ver, '10.1', '>=' )) { |
| 851 |
$col = "info"; |
| 852 |
} |
| 853 |
return $col; |
| 854 |
} |
| 855 |
|
| 856 |
/* Help Tab */ |
| 857 |
function disable_everything_remove_help_tabs() { |
| 858 |
if (is_admin ()) { |
| 859 |
$screen = get_current_screen (); |
| 860 |
$screen->remove_help_tabs (); |
| 861 |
} |
| 862 |
} |
| 863 |
|
| 864 |
/** |
| 865 |
* Footer text |
| 866 |
* |
| 867 |
* @since 1.0 |
| 868 |
*/ |
| 869 |
function disable_everything_footer_text($text) { |
| 870 |
global $current_screen; |
| 871 |
if (! empty ( $current_screen->id ) && strpos ( $current_screen->id, 'disable-everything' ) !== false) { |
| 872 |
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">★★★★★</a> rating to help us spread the word. A huge thanks in advance!'; |
| 873 |
} |
| 874 |
|
| 875 |
return $text; |
| 876 |
} |
| 877 |
add_filter ( 'admin_footer_text', 'disable_everything_footer_text' ); |
| 878 |
|
| 879 |
/** |
| 880 |
* Plugin Text - meta links |
| 881 |
*/ |
| 882 |
if (! function_exists ( 'disable_everything_pro_activated' )) { |
| 883 |
function disable_everything_row_meta($input, $page) { |
| 884 |
|
| 885 |
// check permissions |
| 886 |
if ($page != plugin_basename ( DISABLEEVERYTHING_FILE )) { |
| 887 |
return $input; |
| 888 |
} |
| 889 |
|
| 890 |
return array_merge ( $input, array ( |
| 891 |
'<a href="https://dessky.com/plugin/disable-everything/" target="_blank" style="font-weight:700;">Order PRO version</a>' |
| 892 |
) ); |
| 893 |
} |
| 894 |
add_filter ( 'plugin_row_meta', 'disable_everything_row_meta', 10, 2 ); |
| 895 |
} |
| 896 |
|
| 897 |
// define output for settings section |
| 898 |
function disable_everything_settings_section() { |
| 899 |
// nothing to output |
| 900 |
} |
| 901 |
|
| 902 |
/* TODO - Placeholder Checkboxes */ |
| 903 |
// defined output for settings if PRO is not active |
| 904 |
function disable_everything_placeholder($args) { |
| 905 |
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">'; |
| 906 |
echo __ ( $args ['placeholderlabel'], 'disable-everything' ); |
| 907 |
echo '</span> '; |
| 908 |
|
| 909 |
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>'; |
| 910 |
} |
| 911 |
|
| 912 |
// defined output for settings |
| 913 |
function disable_everything_blockuserenumeration() { |
| 914 |
$checked = ""; |
| 915 |
if (disable_everything_check_option ( 'blockuserenumeration' )) { |
| 916 |
$checked = " checked"; |
| 917 |
} |
| 918 |
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' ); |
| 919 |
} |
| 920 |
function disable_everything_disableauthorarchives() { |
| 921 |
$checked = ""; |
| 922 |
if (disable_everything_check_option ( 'disableauthorarchives' )) { |
| 923 |
$checked = " checked"; |
| 924 |
} |
| 925 |
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' ); |
| 926 |
} |
| 927 |
function disable_everything_removecapitalpdangit() { |
| 928 |
$checked = ""; |
| 929 |
if (disable_everything_check_option ( 'removecapitalpdangit' )) { |
| 930 |
$checked = " checked"; |
| 931 |
} |
| 932 |
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' ); |
| 933 |
} |
| 934 |
function disable_everything_removescreenoptions() { |
| 935 |
$checked = ""; |
| 936 |
if (disable_everything_check_option ( 'removescreenoptions' )) { |
| 937 |
$checked = " checked"; |
| 938 |
} |
| 939 |
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' ); |
| 940 |
} |
| 941 |
function disable_everything_removehowdy() { |
| 942 |
$checked = ""; |
| 943 |
if (disable_everything_check_option ( 'removehowdy' )) { |
| 944 |
$checked = " checked"; |
| 945 |
} |
| 946 |
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' ); |
| 947 |
} |
| 948 |
function disable_everything_removeitemsadminbar() { |
| 949 |
$checked = ""; |
| 950 |
if (disable_everything_check_option ( 'removeitemsadminbar' )) { |
| 951 |
$checked = " checked"; |
| 952 |
} |
| 953 |
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' ); |
| 954 |
} |
| 955 |
function disable_everything_cleandashboard() { |
| 956 |
$checked = ""; |
| 957 |
if (disable_everything_check_option ( 'cleandashboard' )) { |
| 958 |
$checked = " checked"; |
| 959 |
} |
| 960 |
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' ); |
| 961 |
} |
| 962 |
function disable_everything_emojis() { |
| 963 |
$checked = ""; |
| 964 |
if (disable_everything_check_option ( 'emojis' )) { |
| 965 |
$checked = " checked"; |
| 966 |
} |
| 967 |
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' ); |
| 968 |
} |
| 969 |
function disable_everything_embed() { |
| 970 |
$checked = ""; |
| 971 |
if (disable_everything_check_option ( 'embed' )) { |
| 972 |
$checked = " checked"; |
| 973 |
} |
| 974 |
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' ); |
| 975 |
} |
| 976 |
function disable_everything_dashicons() { |
| 977 |
$checked = ""; |
| 978 |
if (disable_everything_check_option ( 'dashicons' )) { |
| 979 |
$checked = " checked"; |
| 980 |
} |
| 981 |
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' ); |
| 982 |
} |
| 983 |
function disable_everything_heartbeat() { |
| 984 |
$checked = ""; |
| 985 |
if (disable_everything_check_option ( 'heartbeat' )) { |
| 986 |
$checked = " checked"; |
| 987 |
} |
| 988 |
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' ); |
| 989 |
} |
| 990 |
function disable_everything_xmlrpc() { |
| 991 |
$checked = ""; |
| 992 |
if (disable_everything_check_option ( 'xmlrpc' )) { |
| 993 |
$checked = " checked"; |
| 994 |
} |
| 995 |
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' ); |
| 996 |
} |
| 997 |
function disable_everything_generator() { |
| 998 |
$checked = ""; |
| 999 |
if (disable_everything_check_option ( 'generator' )) { |
| 1000 |
$checked = " checked"; |
| 1001 |
} |
| 1002 |
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' ); |
| 1003 |
} |
| 1004 |
function disable_everything_manifest() { |
| 1005 |
$checked = ""; |
| 1006 |
if (disable_everything_check_option ( 'manifest' )) { |
| 1007 |
$checked = " checked"; |
| 1008 |
} |
| 1009 |
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' ); |
| 1010 |
} |
| 1011 |
function disable_everything_rsdlink() { |
| 1012 |
$checked = ""; |
| 1013 |
if (disable_everything_check_option ( 'rsdlink' )) { |
| 1014 |
$checked = " checked"; |
| 1015 |
} |
| 1016 |
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' ); |
| 1017 |
} |
| 1018 |
function disable_everything_shortlink() { |
| 1019 |
$checked = ""; |
| 1020 |
if (disable_everything_check_option ( 'shortlink' )) { |
| 1021 |
$checked = " checked"; |
| 1022 |
} |
| 1023 |
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' ); |
| 1024 |
} |
| 1025 |
function disable_everything_rssfeeds() { |
| 1026 |
$checked = ""; |
| 1027 |
if (disable_everything_check_option ( 'rssfeeds' )) { |
| 1028 |
$checked = " checked"; |
| 1029 |
} |
| 1030 |
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' ); |
| 1031 |
} |
| 1032 |
function disable_everything_restapi() { |
| 1033 |
$checked = ""; |
| 1034 |
if (disable_everything_check_option ( 'restapi' )) { |
| 1035 |
$checked = " checked"; |
| 1036 |
} |
| 1037 |
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' ); |
| 1038 |
} |
| 1039 |
function disable_everything_blocks() { |
| 1040 |
$checked = ""; |
| 1041 |
if (disable_everything_check_option ( 'blocks' )) { |
| 1042 |
$checked = " checked"; |
| 1043 |
} |
| 1044 |
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' ); |
| 1045 |
} |
| 1046 |
function disable_everything_applicationpasswords() { |
| 1047 |
$checked = ""; |
| 1048 |
if (disable_everything_check_option ( 'applicationpasswords' )) { |
| 1049 |
$checked = " checked"; |
| 1050 |
} |
| 1051 |
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' ); |
| 1052 |
} |
| 1053 |
//TODO: Custom Function |
| 1054 |
/** |
| 1055 |
* Removes required user's capabilities for core privacy tools by adding the |
| 1056 |
* `do_not_allow` capability. |
| 1057 |
* |
| 1058 |
* - Disables the feature pointer. |
| 1059 |
* - Removes the Privacy and Export/Erase Personal Data admin menu items. |
| 1060 |
* - Disables the privacy policy guide and update bubbles. |
| 1061 |
* |
| 1062 |
* @param string[] $caps Array of the user's capabilities. |
| 1063 |
* @param string $cap Capability name. |
| 1064 |
* @return string[] Array of the user's capabilities. |
| 1065 |
*/ |
| 1066 |
function disable_everything_disable_core_privacy_tools( $caps, $cap ) { |
| 1067 |
switch ( $cap ) { |
| 1068 |
case 'export_others_personal_data': |
| 1069 |
case 'erase_others_personal_data': |
| 1070 |
case 'manage_privacy_options': |
| 1071 |
$caps[] = 'do_not_allow'; |
| 1072 |
break; |
| 1073 |
} |
| 1074 |
|
| 1075 |
return $caps; |
| 1076 |
} |
| 1077 |
|
| 1078 |
// disable the admin menu |
| 1079 |
function disable_everything_remove_site_health_menu() { |
| 1080 |
|
| 1081 |
remove_submenu_page( 'tools.php', 'site-health.php' ); |
| 1082 |
|
| 1083 |
} |
| 1084 |
|
| 1085 |
// block site health page screen |
| 1086 |
function disable_everything_block_site_health_access() { |
| 1087 |
|
| 1088 |
if ( is_admin() ) { |
| 1089 |
|
| 1090 |
$screen = get_current_screen(); |
| 1091 |
|
| 1092 |
// if screen id is site health |
| 1093 |
if ( 'site-health' == $screen->id ) { |
| 1094 |
wp_redirect( admin_url() ); |
| 1095 |
exit; |
| 1096 |
} |
| 1097 |
|
| 1098 |
} |
| 1099 |
|
| 1100 |
} |
| 1101 |
|
| 1102 |
// Disable Remote Block Patterns |
| 1103 |
function disable_everything_disable_remote_patterns_filter() { |
| 1104 |
return false; |
| 1105 |
} |
| 1106 |
|
| 1107 |
//TODO: Check Field Function |
| 1108 |
function disable_everything_coreprivacytools() { |
| 1109 |
$checked = ""; |
| 1110 |
if (disable_everything_check_option ( 'coreprivacytools' )) { |
| 1111 |
$checked = " checked"; |
| 1112 |
} |
| 1113 |
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' ); |
| 1114 |
} |
| 1115 |
function disable_everything_sitehealth() { |
| 1116 |
$checked = ""; |
| 1117 |
if (disable_everything_check_option ( 'sitehealth' )) { |
| 1118 |
$checked = " checked"; |
| 1119 |
} |
| 1120 |
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' ); |
| 1121 |
} |
| 1122 |
function disable_everything_adjacentposts() { |
| 1123 |
$checked = ""; |
| 1124 |
if (disable_everything_check_option ( 'adjacentposts' )) { |
| 1125 |
$checked = " checked"; |
| 1126 |
} |
| 1127 |
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' ); |
| 1128 |
} |
| 1129 |
function disable_everything_version() { |
| 1130 |
$checked = ""; |
| 1131 |
if (disable_everything_check_option ( 'version' )) { |
| 1132 |
$checked = " checked"; |
| 1133 |
} |
| 1134 |
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' ); |
| 1135 |
} |
| 1136 |
function disable_everything_dnsprefetch() { |
| 1137 |
$checked = ""; |
| 1138 |
if (disable_everything_check_option ( 'dnsprefetch' )) { |
| 1139 |
$checked = " checked"; |
| 1140 |
} |
| 1141 |
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' ); |
| 1142 |
} |
| 1143 |
function disable_everything_pdfthumbnails() { |
| 1144 |
$checked = ""; |
| 1145 |
if (disable_everything_check_option ( 'pdfthumbnails' )) { |
| 1146 |
$checked = " checked"; |
| 1147 |
} |
| 1148 |
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' ); |
| 1149 |
} |
| 1150 |
function disable_everything_emptytrash() { |
| 1151 |
$checked = ""; |
| 1152 |
if (disable_everything_check_option ( 'emptytrash' )) { |
| 1153 |
$checked = " checked"; |
| 1154 |
} |
| 1155 |
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' ); |
| 1156 |
} |
| 1157 |
function disable_everything_pluginandthemeeditor() { |
| 1158 |
$checked = ""; |
| 1159 |
if (disable_everything_check_option ( 'pluginandthemeeditor' )) { |
| 1160 |
$checked = " checked"; |
| 1161 |
} |
| 1162 |
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' ); |
| 1163 |
} |
| 1164 |
function disable_everything_oembed() { |
| 1165 |
$checked = ""; |
| 1166 |
if (disable_everything_check_option ( 'oembed' )) { |
| 1167 |
$checked = " checked"; |
| 1168 |
} |
| 1169 |
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' ); |
| 1170 |
} |
| 1171 |
function disable_everything_remoteblockpatterns() { |
| 1172 |
$checked = ""; |
| 1173 |
if (disable_everything_check_option ( 'remoteblockpatterns' )) { |
| 1174 |
$checked = " checked"; |
| 1175 |
} |
| 1176 |
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' ); |
| 1177 |
} |
| 1178 |
|
| 1179 |
// add actions |
| 1180 |
if (is_admin ()) { |
| 1181 |
add_action ( 'admin_menu', 'disable_everything_menus' ); |
| 1182 |
add_action ( 'admin_init', 'disable_everything_settings' ); |
| 1183 |
} |
| 1184 |
|
| 1185 |
/* Add links to plugins page */ |
| 1186 |
|
| 1187 |
// show settings link |
| 1188 |
function disable_everything_links($links) { |
| 1189 |
$links [] = sprintf ( '<a href="%s">%s</a>', admin_url ( 'options-general.php?page=disable-everything' ), __ ( 'Settings', 'disable-everything' ) ); |
| 1190 |
return $links; |
| 1191 |
} |
| 1192 |
|
| 1193 |
// add actions |
| 1194 |
if (is_admin ()) { |
| 1195 |
add_filter ( 'plugin_action_links_' . plugin_basename ( __FILE__ ), 'disable_everything_links' ); |
| 1196 |
} |
| 1197 |
|