// header.php <?php if (is_home()) { echo'<h1>'; bloginfo( 'description' ); echo'</h1>'; } else { echo'<h2>'; bloginfo( 'description' ); echo'</h2>'; } ?>
// functions.php wp_deregister_script( 'jquery' ); // On annule l'inscription du jQuery de WP wp_enqueue_script( // On déclare une version plus moderne 'jquery', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js', false, '3.5.1', true ); } add_action( 'wp_enqueue_scripts', 'sp_register_assets' );
// functions.php function sp_clean_body_classes( $classes ) { $allowed_classes = [ 'home', 'page-homepage','homepage', 'page-template-landing-page', 'page-template-home', 'page-template-default', 'singular', 'single', 'page', 'archive', ]; return array_intersect( $classes, $allowed_classes ); } add_filter( 'body_class', 'sp_clean_body_classes', 20 );
// functions.php function dequeue_jquery_migrate( &$scripts ){ if( !is_admin() ) { $scripts->remove( 'jquery'); $scripts->add( 'jquery', false, array( 'jquery-core' ), '1.10.2' ); } } add_filter( 'wp_default_scripts', 'dequeue_jquery_migrate' );
Read : Reasons to dequeue this script
// functions.php function sp_add_slug_body_class( $classes ) { global $post; if ( isset( $post ) ) { $classes[] = $post->post_type . '-' . $post->post_name; } return $classes; } add_filter( 'body_class', 'sp_add_slug_body_class' );;
// functions.php function clean_post_classes( $classes ) { if( ! is_array( $classes ) ) return $classes; $allowed_classes = array( 'hentry', 'type-' . get_post_type(), ); return array_intersect( $classes, $allowed_classes ); } add_filter( 'post_class', 'clean_post_classes', 5 );
// functions.php function clean_nav_menu_classes( $classes ) { if( ! is_array( $classes ) ) return $classes; foreach( $classes as $i => $class ) { // Remove class with menu item id $id = strtok( $class, 'menu-item-' ); if( 0 < intval( $id ) ) unset( $classes[ $i ] ); // Remove menu-item-type-* if( false !== strpos( $class, 'menu-item-type-' ) ) unset( $classes[ $i ] ); // Remove menu-item-object-* if( false !== strpos( $class, 'menu-item-object-' ) ) unset( $classes[ $i ] ); // Change page ancestor to menu ancestor if( 'current-page-ancestor' == $class ) { $classes[] = 'current-menu-ancestor'; unset( $classes[ $i ] ); } } // Remove submenu class if depth is limited if( isset( $args->depth ) && 1 === $args->depth ) { $classes = array_diff( $classes, array( 'menu-item-has-children' ) ); } return $classes; } add_filter( 'nav_menu_css_class', 'clean_nav_menu_classes', 5 );
// functions.php function singular_body_class( $classes ) { if( is_singular() ) $classes[] = 'singular'; return $classes; } add_filter( 'body_class', 'singular_body_class' );
// function.php // Alter dns-prefetch links add_filter('wp_resource_hints', function (array $urls, string $relation): array { // If the relation is different than dns-prefetch, leave the URLs intact if ($relation !== 'dns-prefetch') { return $urls; } // Remove s.w.org entry $urls = array_filter($urls, function (string $url): bool { return strpos($url, 's.w.org') === false; }); return array_merge($urls); }, 10, 2); // Remove infos about WordPress version remove_action('wp_head', 'wp_generator'); // Remove emoji script and styles remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('wp_print_styles', 'print_emoji_styles'); // Remove REST-API link remove_action('wp_head', 'rest_output_link_wp_head'); // Disable XML-RPC add_filter('xmlrpc_enabled', function (): bool { return false; }); // Remove XML-RPC link remove_action('wp_head', 'rsd_link'); // Remove Windows Live Writer manifest remove_action('wp_head', 'wlwmanifest_link'); // Disable RSS feeds by redirecting their URLs to homepage foreach (['do_feed_rss2', 'do_feed_rss2_comments'] as $feedAction) { add_action($feedAction, function (): void { // Redirect permanently to homepage wp_redirect(home_url(), 301); exit; }, 1); } // Remove the feed links remove_action('wp_head', 'feed_links', 2); // Remove unnecessary attributes from style tags add_filter('style_loader_tag', function (string $tag, string $handle): string { // Remove ID attribute $tag = str_replace("id='${handle}-css'", '', $tag); // Change ' to " in attributes: $tag = str_replace('\'', '"', $tag); // Remove trailing slash $tag = str_replace(' />', '>', $tag); // Remove double spaces return str_replace(' ', '', $tag); }, 10, 2);