corefeco_define_constants();
add_action( 'admin_menu', [ $this, 'corefeco_add_settings_page' ] );
add_action( 'admin_init', [ $this, 'corefeco_register_settings' ] );
add_action( 'admin_enqueue_scripts',[ $this, 'corefeco_enqueue_styles' ] );
add_action( 'init', [ $this, 'corefeco_apply_features' ] );
add_action( 'wp_loaded', [ $this, 'corefeco_apply_features_after_load' ] );
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), [ $this, 'corefeco_action_settings_link' ]);
add_action( 'wp_enqueue_scripts', [ $this, 'corefeco_custom_scripts' ] );
}
public function corefeco_custom_scripts(){
$options = get_option( 'corefeco_extended_disable_core_settings', [] );
if ( ! empty( $options['disable_right_click'] ) ) {
wp_register_script( 'disable-right-click', '' );
wp_enqueue_script( 'disable-right-click' );
$inline_script = "
document.addEventListener('contextmenu', event => event.preventDefault());
";
wp_add_inline_script( 'disable-right-click', $inline_script );
}
}
public function corefeco_action_settings_link ( $links ) {
$mylinks = array('Settings',);
return array_merge( $links, $mylinks );
}
public function corefeco_add_settings_page() {
add_options_page(
__( 'Core Feature Control', 'core-feature-control' ),
__( 'Core Feature Control', 'core-feature-control' ),
'manage_options',
'core-feature-control',
[ $this, 'corefeco_render_settings_page' ]
);
}
private function corefeco_define_constants() {
if (!defined('COREFECO_PATH')) define('COREFECO_PATH', plugin_dir_path( __FILE__ ));
if (!defined('COREFECO_URL')) define('COREFECO_URL', plugin_dir_url( __FILE__ ));
}
public function corefeco_register_settings() {
register_setting( 'corefeco_extended_disable_core_settings', 'corefeco_extended_disable_core_settings', 'corefeco_extended_disable_core_sanitize_checkbox' );
add_settings_section(
'disable_features_section',
__( 'Features to Disable', 'core-feature-control' ),
null,
'core-feature-control'
);
$this->corefeco_add_feature_fields();
}
public function corefeco_enqueue_styles( $hook_suffix ) {
$options = get_option( 'corefeco_extended_disable_core_settings', [] );
if ( ! empty( $options['disable_howdy_admin'] ) ) {
wp_register_script( 'disable-howdy-admin', '' );
wp_enqueue_script( 'disable-howdy-admin' );
$inline_script = "
document.addEventListener('DOMContentLoaded', function() {
var accountMenu = document.querySelector('#wp-admin-bar-my-account > a.ab-item');
if (accountMenu) {
accountMenu.innerHTML = accountMenu.innerHTML.replace('Howdy,', 'Welcome,');
}
});
";
wp_add_inline_script( 'disable-howdy-admin', $inline_script );
}
if ( ! empty( $options['disable_screen_options'] ) ) {
add_filter( 'screen_options_show_screen', '__return_false' );
// Register and enqueue a dummy style handle
wp_register_style( 'corefeco-inline-custom-style', false );
wp_enqueue_style( 'corefeco-inline-custom-style' );
$custom_css = '#contextual-help-link-wrap { display: none !important; }';
wp_add_inline_style( 'corefeco-inline-custom-style', $custom_css );
}
if($hook_suffix == 'settings_page_core-feature-control'){
wp_register_script( 'corefeco-custom-script-check-uncheck', '' );
wp_enqueue_script( 'corefeco-custom-script-check-uncheck' );
$inline_custom_script = "
document.addEventListener('DOMContentLoaded', function () {
const checkAll = document.getElementById('check-all');
const checkboxes = document.querySelectorAll('input[type=\"checkbox\"][name^=\"corefeco_extended_disable_core_settings\"]');
checkAll.addEventListener('change', function () {
checkboxes.forEach(function (checkbox) {
checkbox.checked = checkAll.checked;
});
});
});
";
wp_add_inline_script( 'corefeco-custom-script-check-uncheck', $inline_custom_script );
}
// Enqueue custom style for admin
wp_enqueue_style( 'core-feature-control-style', COREFECO_URL . 'assets/css/core-feature-control.css', array(), '1.0');
}
public function corefeco_extended_disable_core_sanitize_checkbox($input) {
return isset($input) && $input ? 1 : 0;
}
private function corefeco_add_feature_fields() {
$features = $this->corefeco_get_features_list();
foreach ( $features as $id => $feature ) {
add_settings_field(
$id,
$feature['label'],
[ $this, 'corefeco_render_checkbox_field' ],
'core-feature-control',
'disable_features_section',
[
'id' => $id,
'description' => $feature['description'],
]
);
}
}
public function corefeco_render_checkbox_field( $args ) {
$options = get_option( 'corefeco_extended_disable_core_settings', [] );
$value = isset( $options[ $args['id'] ] ) ? $options[ $args['id'] ] : '';
?>
/>
Here's a link to the demo and documentation for the plugin. This will help you learn more about its features and how to use it.
For any feedback or queries regarding this plugin, please contact our Support team.
[
'label' => __( 'Disable User Enumeration', 'core-feature-control' ),
'description' => __( 'Prevents attackers from enumerating user IDs via REST API or query parameters.', 'core-feature-control' ),
],
'disable_author_archives' => [
'label' => __( 'Disable Author Archives', 'core-feature-control' ),
'description' => __( 'Removes author archive pages to enhance privacy.', 'core-feature-control' ),
],
'disable_capital_p_dangit' => [
'label' => __( 'Disable Capital P Dangit', 'core-feature-control' ),
'description' => __( 'Disables forced capitalization of WordPress.', 'core-feature-control' ),
],
'disable_screen_options' => [
'label' => __( 'Disable Screen Options and Help', 'core-feature-control' ),
'description' => __( 'Removes "Screen Options" and "Help" tabs from the admin interface.', 'core-feature-control' ),
],
'disable_howdy_admin' => [
'label' => __( 'Disable Howdy in Admin Bar', 'core-feature-control' ),
'description' => __( 'Replaces or removes the "Howdy" greeting in the admin bar.', 'core-feature-control' ),
],
'disable_emojis' => [
'label' => __( 'Disable Emojis', 'core-feature-control' ),
'description' => __( 'Prevents the loading of WordPress emoji scripts.', 'core-feature-control' ),
],
'disable_embed_objects' => [
'label' => __( 'Disable Embed Objects', 'core-feature-control' ),
'description' => __( 'Removes oEmbed functionality and related scripts.', 'core-feature-control' ),
],
'disable_heartbeat' => [
'label' => __( 'Disable Heartbeat', 'core-feature-control' ),
'description' => __( 'Stops the WordPress Heartbeat API to save server resources.', 'core-feature-control' ),
],
'disable_rest_api' => [
'label' => __( 'Disable REST API', 'core-feature-control' ),
'description' => __( 'Blocks access to the REST API for unauthorized users.', 'core-feature-control' ),
],
'disable_block_library' => [
'label' => __( 'Disable Block Library', 'core-feature-control' ),
'description' => __( 'Prevents loading the Block Library CSS.', 'core-feature-control' ),
],
'disable_app_passwords' => [
'label' => __( 'Disable Application Passwords', 'core-feature-control' ),
'description' => __( 'Disables the application passwords feature for REST API.', 'core-feature-control' ),
],
'disable_privacy_tools' => [
'label' => __( 'Disable Privacy Tools', 'core-feature-control' ),
'description' => __( 'Removes WordPress privacy tools from the admin interface.', 'core-feature-control' ),
],
'disable_site_health' => [
'label' => __( 'Disable Site Health', 'core-feature-control' ),
'description' => __( 'Disables the Site Health feature.', 'core-feature-control' ),
],
'disable_adjacent_posts_links' => [
'label' => __( 'Disable Adjacent Posts Links', 'core-feature-control' ),
'description' => __( 'Prevents adding adjacent post links in the header.', 'core-feature-control' ),
],
'disable_version_query_strings' => [
'label' => __( 'Disable Version Query Strings', 'core-feature-control' ),
'description' => __( 'Removes version numbers from assets.', 'core-feature-control' ),
],
'disable_pdf_thumbnails' => [
'label' => __( 'Disable PDF Thumbnails', 'core-feature-control' ),
'description' => __( 'Stops WordPress from generating PDF thumbnails.', 'core-feature-control' ),
],
'disable_empty_trash' => [
'label' => __( 'Disable Empty Trash', 'core-feature-control' ),
'description' => __( 'Disables automatic emptying of trash.', 'core-feature-control' ),
],
'disable_plugin_theme_editor' => [
'label' => __( 'Disable Plugin and Theme Editor', 'core-feature-control' ),
'description' => __( 'Prevents the usage of the plugin and theme editor in the admin panel.', 'core-feature-control' ),
],
'disable_oembed' => [
'label' => __( 'Disable oEmbed', 'core-feature-control' ),
'description' => __( 'Disables oEmbed functionality and related scripts.', 'core-feature-control' ),
],
'disable_remote_block_patterns' => [
'label' => __( 'Disable Remote Block Patterns', 'core-feature-control' ),
'description' => __( 'Prevents fetching remote block patterns.', 'core-feature-control' ),
],
'disable_comments' => [
'label' => __( 'Disable Comments', 'core-feature-control' ),
'description' => __( 'Disables the comments functionality site-wide.', 'core-feature-control' ),
],
'disable_wp_updates' => [
'label' => __( 'Disable WordPress Updates', 'core-feature-control' ),
'description' => __( 'Stops all WordPress updates.', 'core-feature-control' ),
],
'disable_auto_update_emails' => [
'label' => __( 'Disable Auto Update Emails', 'core-feature-control' ),
'description' => __( 'Prevents email notifications for automatic updates.', 'core-feature-control' ),
],
'disable_post_revisions' => [
'label' => __( 'Disable Post Revisions', 'core-feature-control' ),
'description' => __( 'Disables the post revisions feature.', 'core-feature-control' ),
],
'disable_search' => [
'label' => __( 'Disable Search', 'core-feature-control' ),
'description' => __( 'Disables the site-wide search functionality.', 'core-feature-control' ),
],
'disable_login_logo_favicon' => [
'label' => __( 'Disable Login Logo and Favicon', 'core-feature-control' ),
'description' => __( 'Removes the login page logo and favicon.', 'core-feature-control' ),
],
'disable_email_verification' => [
'label' => __( 'Disable Email Verification', 'core-feature-control' ),
'description' => __( 'Prevents WordPress from verifying admin email addresses.', 'core-feature-control' ),
],
'disable_lazy_loading' => [
'label' => __( 'Disable Lazy Loading', 'core-feature-control' ),
'description' => __( 'Disables lazy loading of images.', 'core-feature-control' ),
],
'disable_yoast_bloat' => [
'label' => __( 'Disable Yoast Bloat', 'core-feature-control' ),
'description' => __( 'Removes unnecessary Yoast SEO features.', 'core-feature-control' ),
],
'disable_woocommerce_bloat' => [
'label' => __( 'Disable WooCommerce Bloat', 'core-feature-control' ),
'description' => __( 'Removes unnecessary WooCommerce features.', 'core-feature-control' ),
],
'disable_right_click' => [
'label' => __( 'Disable Right Click', 'core-feature-control' ),
'description' => __( 'Prevents right-click actions site-wide.', 'core-feature-control' ),
],
'disable_admin_footer' => [
'label' => __( 'Disable Admin Footer', 'core-feature-control' ),
'description' => __( 'Removes the footer text from the admin area.', 'core-feature-control' ),
],
'disable_elementor_bloat' => [
'label' => __( 'Disable Elementor Bloat', 'core-feature-control' ),
'description' => __( 'Removes unnecessary Elementor features.', 'core-feature-control' ),
],
'disable_jetpack_promotions' => [
'label' => __( 'Disable Jetpack Promotions', 'core-feature-control' ),
'description' => __( 'Removes Jetpack promotion notifications.', 'core-feature-control' ),
],
'disable_contact_form7_bloat' => [
'label' => __( 'Disable Contact Form 7 Bloat', 'core-feature-control' ),
'description' => __( 'Prevents unnecessary Contact Form 7 scripts.', 'core-feature-control' ),
],
'disable_autoptimize_toolbar' => [
'label' => __( 'Disable Autoptimize Toolbar', 'core-feature-control' ),
'description' => __( 'Removes Autoptimize toolbar options.', 'core-feature-control' ),
],
'disable_w3_footer_comments' => [
'label' => __( 'Disable W3 Footer Comments', 'core-feature-control' ),
'description' => __( 'Removes W3 Total Cache footer comments.', 'core-feature-control' ),
],
// Add other features as required...
];
}
/**
* Applies the features based on the settings.
*/
public function corefeco_apply_features() {
$options = get_option( 'corefeco_extended_disable_core_settings', [] );
if ( ! empty( $options['disable_user_enumeration'] ) ) {
add_filter( 'rest_endpoints', function ( $endpoints ) {
unset( $endpoints['/wp/v2/users'] );
return $endpoints;
});
}
if ( ! empty( $options['disable_author_archives'] ) ) {
add_action( 'template_redirect', function () {
if ( is_author() ) {
wp_redirect( home_url(), 301 );
exit;
}
});
}
if ( ! empty( $options['disable_capital_p_dangit'] ) ) {
remove_filter( 'the_content', 'capital_P_dangit', 11 );
remove_filter( 'the_title', 'capital_P_dangit', 11 );
remove_filter( 'wp_title', 'capital_P_dangit', 11 );
}
if ( ! empty( $options['disable_emojis'] ) ) {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
}
if ( ! empty( $options['disable_embed_objects'] ) ) {
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
add_filter( 'embed_oembed_discover', '__return_false' );
}
if ( ! empty( $options['disable_heartbeat'] ) ) {
add_action( 'init', function () {
wp_deregister_script( 'heartbeat' );
});
}
if ( ! empty( $options['disable_rest_api'] ) ) {
add_filter( 'rest_authentication_errors', function ( $result ) {
if ( ! is_user_logged_in() ) {
return new WP_Error( 'rest_disabled', __( 'REST API disabled.', 'core-feature-control' ), [ 'status' => 401 ] );
}
return $result;
});
}
if ( ! empty( $options['disable_block_library'] ) ) {
add_action( 'wp_enqueue_scripts', function () {
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'wc-block-style' ); // WooCommerce block styles
}, 100 );
}
if ( ! empty( $options['disable_app_passwords'] ) ) {
add_filter( 'wp_is_application_passwords_available', '__return_false' );
}
if ( ! empty( $options['disable_privacy_tools'] ) ) {
add_action( 'admin_menu', function () {
remove_submenu_page( 'tools.php', 'export_personal_data' );
remove_submenu_page( 'tools.php', 'erase_personal_data' );
} );
}
if ( ! empty( $options['disable_site_health'] ) ) {
add_action( 'admin_menu', function () {
remove_submenu_page( 'tools.php', 'site-health.php' );
} );
}
if ( ! empty( $options['disable_adjacent_posts_links'] ) ) {
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );
}
if ( ! empty( $options['disable_version_query_strings'] ) ) {
add_filter( 'style_loader_src', [ $this, 'corefeco_remove_version_query' ], 10, 2 );
add_filter( 'script_loader_src', [ $this, 'corefeco_remove_version_query' ], 10, 2 );
}
if ( ! empty( $options['disable_pdf_thumbnails'] ) ) {
add_filter( 'fallback_intermediate_image_sizes', function ( $sizes ) {
return array_diff( $sizes, [ 'full' ] );
} );
}
if ( ! empty( $options['disable_empty_trash'] ) ) {
add_filter( 'trash_empty_days', '__return_zero' );
}
if ( ! empty( $options['disable_plugin_theme_editor'] ) ) {
define( 'DISALLOW_FILE_EDIT', true );
}
if ( ! empty( $options['disable_oembed'] ) ) {
remove_action( 'rest_api_init', 'wp_oembed_register_route' );
remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
add_filter( 'embed_oembed_discover', '__return_false' );
}
if ( ! empty( $options['disable_remote_block_patterns'] ) ) {
remove_action( 'init', 'gutenberg_load_remote_block_patterns' );
remove_action( 'init', 'wp_initialize_site_patterns' );
}
if ( ! empty( $options['disable_comments'] ) ) {
add_action( 'init', function () {
remove_post_type_support( 'post', 'comments' );
remove_post_type_support( 'page', 'comments' );
update_option( 'default_comment_status', 'closed' );
} );
}
if ( ! empty( $options['disable_wp_updates'] ) ) {
add_action( 'admin_notices', function () {
echo '';
echo '
' . esc_html( 'Update notifications are enabled. Ensure compatibility before updating plugins.', 'core-feature-control' ) . '
';
echo '
';
});
if ( get_option( 'disable_auto_updates', false ) ) {
add_filter( 'automatic_updates_is_vcs_checkout', '__return_true', 1 );
}
}
if ( ! empty( $options['disable_auto_update_emails'] ) ) {
add_filter( 'auto_core_update_send_email', '__return_false' );
add_filter( 'send_core_update_notification_email', '__return_false' );
}
if ( ! empty( $options['disable_post_revisions'] ) && !defined('WP_POST_REVISIONS') ) {
define( 'WP_POST_REVISIONS', false );
}
if ( ! empty( $options['disable_search'] ) ) {
add_action( 'template_redirect', function () {
if ( is_search() && ! is_admin() ) {
wp_redirect( home_url() );
exit;
}
} );
}
if ( ! empty( $options['disable_login_logo_favicon'] ) ) {
add_action( 'login_enqueue_scripts', function() {
// Enqueue the default login stylesheet handle
wp_enqueue_style( 'login' );
// Add inline CSS to hide the login logo link
$custom_css = '.login h1 a { display: none !important; }';
wp_add_inline_style( 'login', $custom_css );
});
}
if ( ! empty( $options['disable_email_verification'] ) ) {
remove_filter( 'authenticate', 'wp_authenticate_email_password', 20 );
}
if ( ! empty( $options['disable_lazy_loading'] ) ) {
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
}
if ( ! empty( $options['disable_yoast_bloat'] ) ) {
add_action( 'admin_init', function () {
remove_action( 'admin_notices', [ 'Yoast_Notification_Center', 'display_notifications' ] );
add_filter( 'wpseo_automatic_updates', '__return_false' );
} );
}
if ( ! empty( $options['disable_woocommerce_bloat'] ) ) {
add_action( 'wp_enqueue_scripts', function () {
wp_dequeue_style( 'wc-block-style' );
} );
add_action( 'admin_enqueue_scripts', function () {
wp_dequeue_style( 'woocommerce_admin_styles' );
wp_dequeue_script( 'woocommerce_admin' );
} );
}
if ( ! empty( $options['disable_admin_footer'] ) ) {
add_filter( 'admin_footer_text', '__return_empty_string' );
}
if ( ! empty( $options['disable_elementor_bloat'] ) ) {
add_action( 'elementor/editor/after_enqueue_styles', function () {
wp_dequeue_style( 'elementor-icons' );
} );
}
if ( ! empty( $options['disable_jetpack_promotions'] ) ) {
add_action( 'admin_init', function () {
remove_action( 'admin_notices', [ 'Jetpack_Admin', 'jetpack_admin_notices' ] );
} );
}
if ( ! empty( $options['disable_contact_form7_bloat'] ) ) {
add_action( 'wp_enqueue_scripts', function () {
wp_dequeue_script( 'contact-form-7' );
wp_dequeue_style( 'contact-form-7' );
} );
}
if ( ! empty( $options['disable_autoptimize_toolbar'] ) ) {
add_action( 'admin_bar_menu', function ( $wp_admin_bar ) {
$wp_admin_bar->remove_node( 'autoptimize' );
}, 999 );
}
if ( ! empty( $options['disable_w3_footer_comments'] ) ) {
add_filter( 'w3tc_footer_comment', '__return_false' );
}
// Add logic for other features...
}
/**
* Applies features that need to load after all plugins.
*/
public function corefeco_apply_features_after_load() {
$options = get_option( 'corefeco_extended_disable_core_settings', [] );
// Example: Remove admin bar items if navigation features are disabled.
if ( ! empty( $options['disable_howdy_admin'] ) ) {
add_action( 'wp_before_admin_bar_render', function () {
global $wp_admin_bar;
$wp_admin_bar->remove_node( 'search' );
});
}
if ( ! empty( $options['disable_user_enumeration'] ) ) {
add_filter( 'rest_endpoints', function ( $endpoints ) {
unset( $endpoints['/wp/v2/users'] );
return $endpoints;
});
}
// Additional after-load implementations can be added here.
}
public function corefeco_remove_version_query( $src ) {
return remove_query_arg( 'ver', $src );
}
}
// Initialize the plugin.
new Core_Feature_Control();