| 1 |
<?php |
| 2 |
/* |
| 3 |
* Plugin Name: Disable Everything |
| 4 |
* Description: Disable all unnecessary WordPress features and speed up your website. |
| 5 |
* Version: 0.2.0 |
| 6 |
* Author: Dessky |
| 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 |
add_action ( 'init', 'disable_everything_init' ); |
| 285 |
function disable_everything_wp_enqueue_scripts() { |
| 286 |
// Dashicons |
| 287 |
if (disable_everything_check_option ( 'dashicons' ) && ! is_user_logged_in ()) { |
| 288 |
wp_dequeue_style ( 'dashicons' ); |
| 289 |
wp_deregister_style ( 'dashicons' ); |
| 290 |
} |
| 291 |
|
| 292 |
// Heartbeat |
| 293 |
if (disable_everything_check_option ( 'heartbeat' )) { |
| 294 |
global $pagenow; |
| 295 |
if ($pagenow !== 'post.php' && $pagenow !== 'post-new.php') { |
| 296 |
wp_deregister_script ( 'heartbeat' ); |
| 297 |
} |
| 298 |
} |
| 299 |
} |
| 300 |
add_action ( 'wp_enqueue_scripts', 'disable_everything_wp_enqueue_scripts' ); |
| 301 |
|
| 302 |
/* Settings */ |
| 303 |
|
| 304 |
// check checkbox setting |
| 305 |
function disable_everything_check_option($suffix) { |
| 306 |
$settings = get_option ( 'disable_everything_settings' ); |
| 307 |
return (isset ( $settings ['disable-everything-options-' . $suffix] ) && $settings ['disable-everything-options-' . $suffix] === "YES"); |
| 308 |
} |
| 309 |
|
| 310 |
// check checkbox setting |
| 311 |
function disable_everything_check_other_setting($suffix) { |
| 312 |
$settings = get_option ( 'disable_everything_settings' ); |
| 313 |
return (isset ( $settings ['disable-everything-' . $suffix] ) && $settings ['disable-everything-' . $suffix] === "YES"); |
| 314 |
} |
| 315 |
|
| 316 |
// add settings page |
| 317 |
function disable_everything_menus() { |
| 318 |
add_options_page ( __ ( 'Disable Everything', 'disable-everything' ), __ ( 'Disable Everything', 'disable-everything' ), 'manage_options', 'disable-everything', 'disable_everything_options' ); |
| 319 |
} |
| 320 |
|
| 321 |
// add the settings |
| 322 |
function disable_everything_settings() { |
| 323 |
register_setting ( 'disable-everything', 'disable_everything_settings' ); |
| 324 |
|
| 325 |
add_settings_section ( 'disable-everything-section-options', __ ( 'Options', 'disable-everything' ), 'disable_everything_settings_section', 'disable-everything' ); |
| 326 |
|
| 327 |
/* TODO - Placeholder Settings */ |
| 328 |
/** |
| 329 |
* When pro is not activated |
| 330 |
*/ |
| 331 |
if (! function_exists ( 'disable_everything_pro_activated' )) { |
| 332 |
|
| 333 |
$pro_options = array ( |
| 334 |
array ( |
| 335 |
'Comments', |
| 336 |
'Disable Comments on Frontent and Admin' |
| 337 |
), |
| 338 |
array ( |
| 339 |
'WP Updates', |
| 340 |
'Disables all WordPress updates (core, plugins and themes) and removes update notifications in admin' |
| 341 |
), |
| 342 |
array ( |
| 343 |
'Auto-update Email Notifications for Themes and Plugins', |
| 344 |
'Disable auto-update Email Notifications for Themes and Plugins updates Only' |
| 345 |
), |
| 346 |
array ( |
| 347 |
'Post Revisions', |
| 348 |
'Disable Post Revisions (for All Post Types)' |
| 349 |
), |
| 350 |
array ( |
| 351 |
'Search', |
| 352 |
'Disable WordPress Search on Frontend only' |
| 353 |
), |
| 354 |
array ( |
| 355 |
'WP Login Logo and Favicon', |
| 356 |
'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)' |
| 357 |
), |
| 358 |
array ( |
| 359 |
'Administration Email Verification Prompt', |
| 360 |
'Disables the administration email verification prompt introduced in WordPress 5.3' |
| 361 |
), |
| 362 |
array ( |
| 363 |
'Lazy Loading', |
| 364 |
'Disable Lazy Loading (introduced in WP version 5.5)' |
| 365 |
), |
| 366 |
array ( |
| 367 |
'Yoast SEO Bloat', |
| 368 |
'Disable Yoast SEO Bloat' |
| 369 |
), |
| 370 |
array ( |
| 371 |
'WooCommerce Bloat', |
| 372 |
'Disable WooCommerce Bloat' |
| 373 |
) |
| 374 |
); |
| 375 |
|
| 376 |
$pro_options_cnt = 0; |
| 377 |
$pro_options_cnt = count ( $pro_options ); |
| 378 |
|
| 379 |
for($i = 0; $i < $pro_options_cnt; $i ++) { |
| 380 |
|
| 381 |
add_settings_field ( 'disable-everything-options-placeholder' . $i, __ ( $pro_options [$i] [0], 'disable-everything' ), 'disable_everything_placeholder', 'disable-everything', 'disable-everything-section-options', array ( |
| 382 |
'placeholderlabel' => $pro_options [$i] [1], |
| 383 |
'placeholderid' => $i |
| 384 |
) ); |
| 385 |
} |
| 386 |
} |
| 387 |
|
| 388 |
add_settings_field ( 'disable-everything-options-blockuserenumeration', __ ( 'User-Enumeration', 'disable-everything' ), 'disable_everything_blockuserenumeration', 'disable-everything', 'disable-everything-section-options' ); |
| 389 |
add_settings_field ( 'disable-everything-options-disableauthorarchives', __ ( 'Author Archives', 'disable-everything' ), 'disable_everything_disableauthorarchives', 'disable-everything', 'disable-everything-section-options' ); |
| 390 |
add_settings_field ( 'disable-everything-options-removecapitalpdangit', __ ( 'capital_P_dangit', 'disable-everything' ), 'disable_everything_removecapitalpdangit', 'disable-everything', 'disable-everything-section-options' ); |
| 391 |
add_settings_field ( 'disable-everything-options-removescreenoptions', __ ( 'Screen options and help', 'disable-everything' ), 'disable_everything_removescreenoptions', 'disable-everything', 'disable-everything-section-options' ); |
| 392 |
add_settings_field ( 'disable-everything-options-removehowdy', __ ( 'Howdy in adminbar', 'disable-everything' ), 'disable_everything_removehowdy', 'disable-everything', 'disable-everything-section-options' ); |
| 393 |
add_settings_field ( 'disable-everything-options-removeitemsadminbar', __ ( 'Navigation items in adminbar', 'disable-everything' ), 'disable_everything_removeitemsadminbar', 'disable-everything', 'disable-everything-section-options' ); |
| 394 |
add_settings_field ( 'disable-everything-options-cleandashboard', __ ( 'Clean Dashboard', 'disable-everything' ), 'disable_everything_cleandashboard', 'disable-everything', 'disable-everything-section-options' ); |
| 395 |
add_settings_field ( 'disable-everything-options-emojis', __ ( 'Emojis', 'disable-everything' ), 'disable_everything_emojis', 'disable-everything', 'disable-everything-section-options' ); |
| 396 |
add_settings_field ( 'disable-everything-options-embed', __ ( 'Embed Objects', 'disable-everything' ), 'disable_everything_embed', 'disable-everything', 'disable-everything-section-options' ); |
| 397 |
add_settings_field ( 'disable-everything-options-dashicons', __ ( 'Dashicons', 'disable-everything' ), 'disable_everything_dashicons', 'disable-everything', 'disable-everything-section-options' ); |
| 398 |
add_settings_field ( 'disable-everything-options-heartbeat', __ ( 'Heartbeat', 'disable-everything' ), 'disable_everything_heartbeat', 'disable-everything', 'disable-everything-section-options' ); |
| 399 |
add_settings_field ( 'disable-everything-options-xmlrpc', __ ( 'XML-RPC + Pingback', 'disable-everything' ), 'disable_everything_xmlrpc', 'disable-everything', 'disable-everything-section-options' ); |
| 400 |
add_settings_field ( 'disable-everything-options-generator', __ ( 'Generator', 'disable-everything' ), 'disable_everything_generator', 'disable-everything', 'disable-everything-section-options' ); |
| 401 |
add_settings_field ( 'disable-everything-options-manifest', __ ( 'WLW Manifest', 'disable-everything' ), 'disable_everything_manifest', 'disable-everything', 'disable-everything-section-options' ); |
| 402 |
add_settings_field ( 'disable-everything-options-rsdlink', __ ( 'Really Simple Discovery', 'disable-everything' ), 'disable_everything_rsdlink', 'disable-everything', 'disable-everything-section-options' ); |
| 403 |
add_settings_field ( 'disable-everything-options-shortlink', __ ( 'Short Link', 'disable-everything' ), 'disable_everything_shortlink', 'disable-everything', 'disable-everything-section-options' ); |
| 404 |
add_settings_field ( 'disable-everything-options-rssfeeds', __ ( 'RSS Feeds', 'disable-everything' ), 'disable_everything_rssfeeds', 'disable-everything', 'disable-everything-section-options' ); |
| 405 |
add_settings_field ( 'disable-everything-options-restapi', __ ( 'REST API', 'disable-everything' ), 'disable_everything_restapi', 'disable-everything', 'disable-everything-section-options' ); |
| 406 |
add_settings_field ( 'disable-everything-options-blocks', __ ( 'Block Library', 'disable-everything' ), 'disable_everything_blocks', 'disable-everything', 'disable-everything-section-options' ); |
| 407 |
add_settings_field ( 'disable-everything-options-adminfooter', __ ( 'Admin Footer', 'disable-everything' ), 'disable_everything_adminfooter', 'disable-everything', 'disable-everything-section-options' ); |
| 408 |
} |
| 409 |
|
| 410 |
// allow the settings to be stored |
| 411 |
add_filter ( 'whitelist_options', function ($whitelist_options) { |
| 412 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-blockuserenumeration'; |
| 413 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-disableauthorarchives'; |
| 414 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-removecapitalpdangit'; |
| 415 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-removescreenoptions'; |
| 416 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-removehowdy'; |
| 417 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-removeitemsadminbar'; |
| 418 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-cleandashboard'; |
| 419 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-emojis'; |
| 420 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-embed'; |
| 421 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-dashicons'; |
| 422 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-heartbeat'; |
| 423 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-generator'; |
| 424 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-xmlrpc'; |
| 425 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-manifest'; |
| 426 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-rsdlink'; |
| 427 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-shortlink'; |
| 428 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-rssfeeds'; |
| 429 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-restapi'; |
| 430 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-blocks'; |
| 431 |
$whitelist_options ['disable-everything'] [] = 'disable-everything-options-adminfooter'; |
| 432 |
return $whitelist_options; |
| 433 |
} ); |
| 434 |
|
| 435 |
// define output for settings page |
| 436 |
function disable_everything_options() { |
| 437 |
echo '<style>#disable-everything-tabs h2{display:none}</style>'; |
| 438 |
echo '<div class="widefat">'; |
| 439 |
echo '<div class="wrap disable-everything-panel"> |
| 440 |
<h1>' . __ ( 'Disable Everything', 'disable-everything' ) . '</h1>'; |
| 441 |
|
| 442 |
echo '<hr>'; |
| 443 |
echo ' <p class="description">'; |
| 444 |
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' ); |
| 445 |
echo ' <br>'; |
| 446 |
echo __ ( 'This is NOT a caching plugin, but should play well with any caching plugin you decide to use.', 'disable-everything' ); |
| 447 |
echo ' </p>'; |
| 448 |
|
| 449 |
echo '<hr>'; |
| 450 |
echo '<h2>' . __ ( 'Server Requirements Check', 'disable-everything' ) . '</h2> |
| 451 |
<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>'; |
| 452 |
echo ' <div style="margin:0 0 24px 0;">'; |
| 453 |
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>'; |
| 454 |
|
| 455 |
$dbtype = null; |
| 456 |
$dbversion = null; |
| 457 |
$badge_mysql = null; |
| 458 |
$badge_maria = null; |
| 459 |
|
| 460 |
$dbtype = disable_everything_dbtype (); |
| 461 |
|
| 462 |
$dbversion = disable_everything_dbversion (); |
| 463 |
|
| 464 |
$badge_mysql = disable_everything_badge_mysql (); |
| 465 |
|
| 466 |
$badge_maria = disable_everything_badge_maria (); |
| 467 |
|
| 468 |
if ($dbtype === 'MYSQL') { |
| 469 |
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>'; |
| 470 |
} else { |
| 471 |
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>'; |
| 472 |
} |
| 473 |
echo ' </div>'; |
| 474 |
echo '<hr>'; |
| 475 |
?> |
| 476 |
|
| 477 |
<select id="opt-all-none" style="width: 80px; height: 32px;"> |
| 478 |
<option value="all"><?php _e( 'All', 'disable-everything' ); ?></option> |
| 479 |
<option value="none"><?php _e( 'None', 'disable-everything' ); ?></option> |
| 480 |
</select> |
| 481 |
<button id="btn-all-none" class="button button-secondary" |
| 482 |
style="width: 80px; height: 32px;"><?php _e( 'Select', 'disable-everything' ); ?></button> |
| 483 |
|
| 484 |
<?php |
| 485 |
echo '<hr>'; |
| 486 |
echo ' <form action="options.php" method="post">'; |
| 487 |
|
| 488 |
settings_fields ( 'disable-everything' ); |
| 489 |
|
| 490 |
do_settings_sections ( 'disable-everything' ); |
| 491 |
echo '<hr>'; |
| 492 |
submit_button (); |
| 493 |
echo ' </form>'; |
| 494 |
|
| 495 |
?> |
| 496 |
<script> |
| 497 |
|
| 498 |
/** |
| 499 |
* The select all/none functionality. |
| 500 |
*/ |
| 501 |
let btn = document.getElementById('btn-all-none'); |
| 502 |
let opt = document.getElementById('opt-all-none'); |
| 503 |
let checkboxes = document.querySelectorAll('.disable-everything-panel input[type="checkbox"]'); |
| 504 |
btn.addEventListener('click', function() { |
| 505 |
if (opt.value === 'all') { |
| 506 |
for (let i = 0; i <= checkboxes.length; i += 1) { |
| 507 |
|
| 508 |
if(checkboxes[i] !== undefined){ |
| 509 |
checkboxes[i].checked = true; |
| 510 |
} |
| 511 |
} |
| 512 |
} else { |
| 513 |
for (let i = 0; i <= checkboxes.length; i += 1) { |
| 514 |
|
| 515 |
if(checkboxes[i] !== undefined){ |
| 516 |
checkboxes[i].checked = false; |
| 517 |
} |
| 518 |
} |
| 519 |
} |
| 520 |
}); |
| 521 |
|
| 522 |
</script> |
| 523 |
<?php |
| 524 |
|
| 525 |
// estimated savings |
| 526 |
$reqs = 0; |
| 527 |
$size = 0; |
| 528 |
$tags = 0; |
| 529 |
if (disable_everything_check_option ( 'emojis' )) { |
| 530 |
$reqs += 2; |
| 531 |
$size += 16; |
| 532 |
$tags += 2; |
| 533 |
} |
| 534 |
if (disable_everything_check_option ( 'embed' )) { |
| 535 |
$reqs += 1; |
| 536 |
$size += 6; |
| 537 |
$tags += 1; |
| 538 |
} |
| 539 |
if (disable_everything_check_option ( 'dashicons' )) { |
| 540 |
$reqs += 1; |
| 541 |
$size += 46; |
| 542 |
$tags += 1; |
| 543 |
} |
| 544 |
if (disable_everything_check_option ( 'heartbeat' )) { |
| 545 |
$reqs += 1; |
| 546 |
$size += 6; |
| 547 |
$tags += 1; |
| 548 |
} |
| 549 |
if (disable_everything_check_option ( 'generator' )) { |
| 550 |
$tags += 1; |
| 551 |
} |
| 552 |
if (disable_everything_check_option ( 'xmlrpc' )) { |
| 553 |
$tags += 1; |
| 554 |
} |
| 555 |
if (disable_everything_check_option ( 'manifest' )) { |
| 556 |
$tags += 1; |
| 557 |
} |
| 558 |
if (disable_everything_check_option ( 'rsdlink' )) { |
| 559 |
$tags += 1; |
| 560 |
} |
| 561 |
if (disable_everything_check_option ( 'shortlink' )) { |
| 562 |
$tags += 1; |
| 563 |
} |
| 564 |
if (disable_everything_check_option ( 'rssfeeds' )) { |
| 565 |
$tags += 2; |
| 566 |
} |
| 567 |
if (disable_everything_check_option ( 'restapi' )) { |
| 568 |
$tags += 1; |
| 569 |
} |
| 570 |
if (disable_everything_check_option ( 'blocks' )) { |
| 571 |
$reqs += 1; |
| 572 |
$size += 29; |
| 573 |
$tags += 1; |
| 574 |
} |
| 575 |
echo '<hr>'; |
| 576 |
echo ' <h2>' . __ ( 'Estimated Savings', 'disable-everything' ) . '</h2>'; |
| 577 |
echo ' <table class="form-table">'; |
| 578 |
echo ' <tbody>'; |
| 579 |
echo ' <tr>'; |
| 580 |
echo ' <th scope="row">' . __ ( 'File Requests', 'disable-everything' ) . '</th>'; |
| 581 |
echo ' <td>' . esc_html ( $reqs ) . '</td>'; |
| 582 |
echo ' </tr>'; |
| 583 |
echo ' <tr>'; |
| 584 |
echo ' <th scope="row">' . __ ( 'File Size', 'disable-everything' ) . '</th>'; |
| 585 |
echo ' <td>' . esc_html ( ($size >= 1024 ? (number_format ( $size / 1024, 1 )) . 'Mb' : $size . 'kb') ) . '</td>'; |
| 586 |
echo ' </tr>'; |
| 587 |
echo ' <tr>'; |
| 588 |
echo ' <th scope="row">' . __ ( 'HTML Tags', 'disable-everything' ) . '</th>'; |
| 589 |
echo ' <td>' . esc_html ( $tags ) . '</td>'; |
| 590 |
echo ' </tr>'; |
| 591 |
echo ' </tbody>'; |
| 592 |
echo ' </table>'; |
| 593 |
echo '</div>'; |
| 594 |
} |
| 595 |
function disable_everything_badge_php() { |
| 596 |
$ver = disable_everything_phpversion (); |
| 597 |
$col = "error"; |
| 598 |
if (version_compare ( $ver, '7.2', '>=' )) { |
| 599 |
$col = "warning"; |
| 600 |
} |
| 601 |
if (version_compare ( $ver, '7.3', '>=' )) { |
| 602 |
$col = "info"; |
| 603 |
} |
| 604 |
return $col; |
| 605 |
} |
| 606 |
function disable_everything_phpversion() { |
| 607 |
return explode ( '-', phpversion () ) [0]; // trim any extra information |
| 608 |
} |
| 609 |
function disable_everything_dbtype_transient() { |
| 610 |
$dbtype = get_transient ( 'disable_everything_dbtype' ); |
| 611 |
|
| 612 |
if (false === $dbtype) { |
| 613 |
|
| 614 |
global $wpdb; |
| 615 |
$vers = $wpdb->get_var ( "SELECT VERSION() as mysql_version" ); |
| 616 |
if (stripos ( $vers, 'MARIA' ) !== false) { |
| 617 |
$dbtype = 'MARIA'; |
| 618 |
} |
| 619 |
$dbtype = 'MYSQL'; |
| 620 |
|
| 621 |
set_transient ( 'disable_everything_dbtype', $dbtype, 604800 ); // expire after 1 week |
| 622 |
|
| 623 |
return $dbtype; |
| 624 |
} else { |
| 625 |
return $dbtype; |
| 626 |
} |
| 627 |
} |
| 628 |
function disable_everything_dbversion_transient() { |
| 629 |
$dbversion = get_transient ( 'disable_everything_dbversion' ); |
| 630 |
|
| 631 |
if (false === $dbversion) { |
| 632 |
|
| 633 |
global $wpdb; |
| 634 |
$vers = $wpdb->get_var ( "SELECT VERSION() as mysql_version" ); |
| 635 |
$vers_transient = explode ( '-', $vers ) [0]; // trim any extra information |
| 636 |
|
| 637 |
set_transient ( 'disable_everything_dbversion', $vers_transient, 604800 ); // expire after 1 week |
| 638 |
|
| 639 |
return $vers_transient; |
| 640 |
} else { |
| 641 |
return $dbversion; |
| 642 |
} |
| 643 |
} |
| 644 |
function disable_everything_dbtype() { |
| 645 |
return disable_everything_dbtype_transient (); |
| 646 |
} |
| 647 |
function disable_everything_dbversion() { |
| 648 |
return disable_everything_dbversion_transient (); |
| 649 |
} |
| 650 |
function disable_everything_badge_mysql() { |
| 651 |
$ver = disable_everything_dbversion (); |
| 652 |
$col = "error"; |
| 653 |
if (version_compare ( $ver, '5.6', '>=' )) { |
| 654 |
$col = "warning"; |
| 655 |
} |
| 656 |
if (version_compare ( $ver, '5.7', '>=' )) { |
| 657 |
$col = "info"; |
| 658 |
} |
| 659 |
return $col; |
| 660 |
} |
| 661 |
function disable_everything_badge_maria() { |
| 662 |
$ver = disable_everything_dbversion (); |
| 663 |
$col = "error"; |
| 664 |
if (version_compare ( $ver, '10.0', '>=' )) { |
| 665 |
$col = "warning"; |
| 666 |
} |
| 667 |
if (version_compare ( $ver, '10.1', '>=' )) { |
| 668 |
$col = "info"; |
| 669 |
} |
| 670 |
return $col; |
| 671 |
} |
| 672 |
|
| 673 |
/* Help Tab */ |
| 674 |
function disable_everything_remove_help_tabs() { |
| 675 |
if (is_admin ()) { |
| 676 |
$screen = get_current_screen (); |
| 677 |
$screen->remove_help_tabs (); |
| 678 |
} |
| 679 |
} |
| 680 |
|
| 681 |
/** |
| 682 |
* Footer text |
| 683 |
* |
| 684 |
* @since 1.0 |
| 685 |
*/ |
| 686 |
function disable_everything_footer_text($text) { |
| 687 |
global $current_screen; |
| 688 |
if (! empty ( $current_screen->id ) && strpos ( $current_screen->id, 'disable-everything' ) !== false) { |
| 689 |
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!'; |
| 690 |
} |
| 691 |
|
| 692 |
return $text; |
| 693 |
} |
| 694 |
add_filter ( 'admin_footer_text', 'disable_everything_footer_text' ); |
| 695 |
|
| 696 |
/** |
| 697 |
* Plugin Text - meta links |
| 698 |
*/ |
| 699 |
if (! function_exists ( 'disable_everything_pro_activated' )) { |
| 700 |
function disable_everything_row_meta($input, $page) { |
| 701 |
|
| 702 |
// check permissions |
| 703 |
if ($page != plugin_basename ( DISABLEEVERYTHING_FILE )) { |
| 704 |
return $input; |
| 705 |
} |
| 706 |
|
| 707 |
return array_merge ( $input, array ( |
| 708 |
'<a href="https://dessky.com/plugin/disable-everything/" target="_blank" style="font-weight:700;">Order PRO version</a>' |
| 709 |
) ); |
| 710 |
} |
| 711 |
add_filter ( 'plugin_row_meta', 'disable_everything_row_meta', 10, 2 ); |
| 712 |
} |
| 713 |
|
| 714 |
// define output for settings section |
| 715 |
function disable_everything_settings_section() { |
| 716 |
// nothing to output |
| 717 |
} |
| 718 |
|
| 719 |
/* TODO - Placeholder checkboxes */ |
| 720 |
// defined output for settings if PRO is not active |
| 721 |
function disable_everything_placeholder($args) { |
| 722 |
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">'; |
| 723 |
echo __ ( $args ['placeholderlabel'], 'disable-everything' ); |
| 724 |
echo '</span> '; |
| 725 |
|
| 726 |
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</a></small>'; |
| 727 |
} |
| 728 |
|
| 729 |
// defined output for settings |
| 730 |
function disable_everything_blockuserenumeration() { |
| 731 |
$checked = ""; |
| 732 |
if (disable_everything_check_option ( 'blockuserenumeration' )) { |
| 733 |
$checked = " checked"; |
| 734 |
} |
| 735 |
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' ); |
| 736 |
} |
| 737 |
function disable_everything_disableauthorarchives() { |
| 738 |
$checked = ""; |
| 739 |
if (disable_everything_check_option ( 'disableauthorarchives' )) { |
| 740 |
$checked = " checked"; |
| 741 |
} |
| 742 |
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' ); |
| 743 |
} |
| 744 |
function disable_everything_removecapitalpdangit() { |
| 745 |
$checked = ""; |
| 746 |
if (disable_everything_check_option ( 'removecapitalpdangit' )) { |
| 747 |
$checked = " checked"; |
| 748 |
} |
| 749 |
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' ); |
| 750 |
} |
| 751 |
function disable_everything_removescreenoptions() { |
| 752 |
$checked = ""; |
| 753 |
if (disable_everything_check_option ( 'removescreenoptions' )) { |
| 754 |
$checked = " checked"; |
| 755 |
} |
| 756 |
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' ); |
| 757 |
} |
| 758 |
function disable_everything_removehowdy() { |
| 759 |
$checked = ""; |
| 760 |
if (disable_everything_check_option ( 'removehowdy' )) { |
| 761 |
$checked = " checked"; |
| 762 |
} |
| 763 |
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' ); |
| 764 |
} |
| 765 |
function disable_everything_removeitemsadminbar() { |
| 766 |
$checked = ""; |
| 767 |
if (disable_everything_check_option ( 'removeitemsadminbar' )) { |
| 768 |
$checked = " checked"; |
| 769 |
} |
| 770 |
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' ); |
| 771 |
} |
| 772 |
function disable_everything_cleandashboard() { |
| 773 |
$checked = ""; |
| 774 |
if (disable_everything_check_option ( 'cleandashboard' )) { |
| 775 |
$checked = " checked"; |
| 776 |
} |
| 777 |
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' ); |
| 778 |
} |
| 779 |
function disable_everything_emojis() { |
| 780 |
$checked = ""; |
| 781 |
if (disable_everything_check_option ( 'emojis' )) { |
| 782 |
$checked = " checked"; |
| 783 |
} |
| 784 |
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' ); |
| 785 |
} |
| 786 |
function disable_everything_embed() { |
| 787 |
$checked = ""; |
| 788 |
if (disable_everything_check_option ( 'embed' )) { |
| 789 |
$checked = " checked"; |
| 790 |
} |
| 791 |
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' ); |
| 792 |
} |
| 793 |
function disable_everything_dashicons() { |
| 794 |
$checked = ""; |
| 795 |
if (disable_everything_check_option ( 'dashicons' )) { |
| 796 |
$checked = " checked"; |
| 797 |
} |
| 798 |
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' ); |
| 799 |
} |
| 800 |
function disable_everything_heartbeat() { |
| 801 |
$checked = ""; |
| 802 |
if (disable_everything_check_option ( 'heartbeat' )) { |
| 803 |
$checked = " checked"; |
| 804 |
} |
| 805 |
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' ); |
| 806 |
} |
| 807 |
function disable_everything_xmlrpc() { |
| 808 |
$checked = ""; |
| 809 |
if (disable_everything_check_option ( 'xmlrpc' )) { |
| 810 |
$checked = " checked"; |
| 811 |
} |
| 812 |
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' ); |
| 813 |
} |
| 814 |
function disable_everything_generator() { |
| 815 |
$checked = ""; |
| 816 |
if (disable_everything_check_option ( 'generator' )) { |
| 817 |
$checked = " checked"; |
| 818 |
} |
| 819 |
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' ); |
| 820 |
} |
| 821 |
function disable_everything_manifest() { |
| 822 |
$checked = ""; |
| 823 |
if (disable_everything_check_option ( 'manifest' )) { |
| 824 |
$checked = " checked"; |
| 825 |
} |
| 826 |
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' ); |
| 827 |
} |
| 828 |
function disable_everything_rsdlink() { |
| 829 |
$checked = ""; |
| 830 |
if (disable_everything_check_option ( 'rsdlink' )) { |
| 831 |
$checked = " checked"; |
| 832 |
} |
| 833 |
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' ); |
| 834 |
} |
| 835 |
function disable_everything_shortlink() { |
| 836 |
$checked = ""; |
| 837 |
if (disable_everything_check_option ( 'shortlink' )) { |
| 838 |
$checked = " checked"; |
| 839 |
} |
| 840 |
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' ); |
| 841 |
} |
| 842 |
function disable_everything_rssfeeds() { |
| 843 |
$checked = ""; |
| 844 |
if (disable_everything_check_option ( 'rssfeeds' )) { |
| 845 |
$checked = " checked"; |
| 846 |
} |
| 847 |
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' ); |
| 848 |
} |
| 849 |
function disable_everything_restapi() { |
| 850 |
$checked = ""; |
| 851 |
if (disable_everything_check_option ( 'restapi' )) { |
| 852 |
$checked = " checked"; |
| 853 |
} |
| 854 |
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' ); |
| 855 |
} |
| 856 |
function disable_everything_blocks() { |
| 857 |
$checked = ""; |
| 858 |
if (disable_everything_check_option ( 'blocks' )) { |
| 859 |
$checked = " checked"; |
| 860 |
} |
| 861 |
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' ); |
| 862 |
} |
| 863 |
function disable_everything_adminfooter() { |
| 864 |
$checked = ""; |
| 865 |
if (disable_everything_check_option ( 'adminfooter' )) { |
| 866 |
$checked = " checked"; |
| 867 |
} |
| 868 |
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' ); |
| 869 |
} |
| 870 |
|
| 871 |
// add actions |
| 872 |
if (is_admin ()) { |
| 873 |
add_action ( 'admin_menu', 'disable_everything_menus' ); |
| 874 |
add_action ( 'admin_init', 'disable_everything_settings' ); |
| 875 |
} |
| 876 |
|
| 877 |
/* Add links to plugins page */ |
| 878 |
|
| 879 |
// show settings link |
| 880 |
function disable_everything_links($links) { |
| 881 |
$links [] = sprintf ( '<a href="%s">%s</a>', admin_url ( 'options-general.php?page=disable-everything' ), __ ( 'Settings', 'disable-everything' ) ); |
| 882 |
return $links; |
| 883 |
} |
| 884 |
|
| 885 |
// add actions |
| 886 |
if (is_admin ()) { |
| 887 |
add_filter ( 'plugin_action_links_' . plugin_basename ( __FILE__ ), 'disable_everything_links' ); |
| 888 |
} |
| 889 |
|