| 1 |
<?php |
| 2 |
|
| 3 |
namespace FlyWP\Optimizations; |
| 4 |
|
| 5 |
class Header extends Base { |
| 6 |
|
| 7 |
/** |
| 8 |
* Group name |
| 9 |
* |
| 10 |
* @var string |
| 11 |
*/ |
| 12 |
protected $group = 'header'; |
| 13 |
|
| 14 |
/** |
| 15 |
* Features to remove. |
| 16 |
* |
| 17 |
* @var array |
| 18 |
*/ |
| 19 |
protected $features = [ |
| 20 |
'feed_links' => 'remove_feed_links', |
| 21 |
'rsd_link' => 'remove_rsd_link', |
| 22 |
'generator' => 'remove_generator', |
| 23 |
'rest_api' => 'remove_rest_api', |
| 24 |
'shortlink' => 'remove_shortlink', |
| 25 |
'oembed' => 'remove_oembed', |
| 26 |
]; |
| 27 |
|
| 28 |
/** |
| 29 |
* Remove feed links. |
| 30 |
* |
| 31 |
* @return void |
| 32 |
*/ |
| 33 |
public function remove_feed_links() { |
| 34 |
remove_action( 'wp_head', 'feed_links', 2 ); |
| 35 |
remove_action( 'wp_head', 'feed_links_extra', 3 ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Remove RSD link. |
| 40 |
* |
| 41 |
* @return void |
| 42 |
*/ |
| 43 |
public function remove_rsd_link() { |
| 44 |
remove_action( 'wp_head', 'rsd_link' ); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Remove generator. |
| 49 |
* |
| 50 |
* @return void |
| 51 |
*/ |
| 52 |
public function remove_generator() { |
| 53 |
remove_action( 'wp_head', 'wp_generator' ); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Remove REST API links. |
| 58 |
* |
| 59 |
* @return void |
| 60 |
*/ |
| 61 |
public function remove_rest_api() { |
| 62 |
remove_action( 'wp_head', 'rest_output_link_wp_head' ); |
| 63 |
remove_action( 'template_redirect', 'rest_output_link_header', 11 ); |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Remove shortlink. |
| 68 |
* |
| 69 |
* @return void |
| 70 |
*/ |
| 71 |
public function remove_shortlink() { |
| 72 |
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Remove oEmbed discovery links. |
| 77 |
* |
| 78 |
* @return void |
| 79 |
*/ |
| 80 |
public function remove_oembed() { |
| 81 |
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); |
| 82 |
} |
| 83 |
} |
| 84 |
|