'remove_rest_api_link',
'title' => 'Remove REST API link from header',
'desc' => 'Remove the REST API discovery links from the page head and HTTP headers',
'icon' => 'code',
'risk' => 'safe',
'level' => 'beginner',
'audience' => 'everyone',
'priority' => 4,
'benefit' => 'Removes the pointers to your REST API from each page. The API itself still works at /wp-json/, so this tidies the page head; it does not hide or protect anything.',
'help' => 'WordPress adds and a link to the JSON version of the current page to the page head, and matching Link: HTTP headers. This removes them. Apps that find your API through these links need its address (/wp-json/) instead.',
'before' => ' in the page head',
'after' => 'Removed. The REST API still works.',
'detect' => function () {
return array(
'detected' => true,
'message' => 'Present in page source',
'safe' => true,
'savings' => 'Cleaner HTML',
);
},
'callback' => function () {
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 );},
);