Disable WordPress REST API for visitors

add_filter( ‘rest_authentication_errors’, function( $result ) { if ( ! empty( $result ) ) { return $result; } if ( ! is_user_logged_in() ) { return new WP_Error( ‘rest_disabled’, __( ‘The WordPress REST API has been disabled.’ ), array( ‘status’ => 401…Continue reading

Completely Disable Comments

add_action(‘admin_init’, function () { // Redirect any user trying to access comments page global $pagenow; if ($pagenow === ‘edit-comments.php’) { wp_safe_redirect(admin_url()); exit; } // Remove comments metabox from dashboard remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘normal’); // Disable support for comments and trackbacks in…Continue reading

Completely Disable Comments (copy)

add_action(‘admin_init’, function () { // Redirect any user trying to access comments page global $pagenow; if ($pagenow === ‘edit-comments.php’) { wp_safe_redirect(admin_url()); exit; } // Remove comments metabox from dashboard remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘normal’); // Disable support for comments and trackbacks in…Continue reading

Disable Embeds (copy)

/** * Disable all embeds in WordPress. */ add_action( ‘init’, function () { // Remove the REST API endpoint. remove_action( ‘rest_api_init’, ‘wp_oembed_register_route’ ); // Turn off oEmbed auto discovery. add_filter( ’embed_oembed_discover’, ‘__return_false’ ); // Don’t filter oEmbed results. remove_filter( ‘oembed_dataparse’,…Continue reading

Disable Thumbnail Image Sizes

add_filter( ‘intermediate_image_sizes_advanced’, function( $sizes ) { // Disable specific thumbnail sizes, uncomment the ones you want to disable. // unset( $sizes[‘thumbnail’] ); // 150px x 150px // unset( $sizes[‘medium’] ); // 300px x 300px // unset( $sizes[‘medium_large’] ); // 768px…Continue reading