1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
<?php
namespace SIW;
use SIW\Properties;
use SIW\HTML;
class Head {
public static function init() {
$self = new self();
add_action( 'wp_head', [ $self, 'add_favicons' ] );
add_filter( 'wp_resource_hints', [ $self, 'add_resource_hints' ], 10 , 2 );
add_filter( 'the_generator', '__return_false' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 );
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'template_redirect', 'rest_output_link_header', 11 ) ;
}
public function add_favicons() {
$favicons = siw_get_data( 'favicons' );
?>
<!-- Start favicons -->
<?php
foreach ( $favicons as $favicon ) {
HTML::render_tag( $favicon['tag'], $favicon['attributes'] );
}
?>
<!-- Einde favicons -->
<?php
}
public function add_resource_hints( array $urls, string $relation_type ) {
$preconnect_urls = apply_filters( 'siw_preconnect_urls', [] );
if ( 'preconnect' === $relation_type || 'dns-prefetch' === $relation_type ) {
foreach ( $preconnect_urls as $preconnect_url ) {
$urls[] = $preconnect_url;
}
}
return $urls;
}
}