39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
/***
|
|
* Remove unnecessary functionnalities from Wordpress
|
|
*/
|
|
|
|
// Hook on init to remove some supports and functionalities
|
|
add_action( 'init',function(){
|
|
// Disable global styles
|
|
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
|
|
remove_action( 'wp_footer', 'wp_enqueue_global_styles', 1 );
|
|
remove_action( 'wp_body_open', 'wp_global_styles_render_svg_filters' );
|
|
|
|
// Remove tag for posts
|
|
unregister_taxonomy_for_object_type( 'post_tag', 'post' );
|
|
});
|
|
|
|
// Remove posts unnecessary support
|
|
remove_post_type_support('post', 'author');
|
|
remove_post_type_support('post', 'custom-fields');
|
|
remove_post_type_support('post', 'post-formats');
|
|
|
|
remove_theme_support( 'core-block-patterns' );
|
|
|
|
// Remove search feature
|
|
function matt_filter_query( $query, $error = true ) {
|
|
if ( is_search() ) {
|
|
$query->is_search = false;
|
|
$query->query_vars['s'] = false;
|
|
$query->query['s'] = false;
|
|
if ( $error )
|
|
$query->is_404 = true;
|
|
}
|
|
}
|
|
add_action( 'parse_query', 'matt_filter_query' );
|
|
add_filter( 'get_search_form', function () { return null; } );
|
|
function remove_search_widget(): void {
|
|
unregister_widget('WP_Widget_Search');
|
|
}
|
|
add_action( 'widgets_init', 'remove_search_widget' ); |