Disable rest API function of WordPress program and remove WP JSON link

There is no doubt that WordPress is currently a relatively easy-to-use PHP program, which can be used in personal blogs, enterprise websites and small business websites. Moreover, the official updates of WordPress and the rich themes of third-party plugins make this program more and more diverse. However, with the continuous upgrading of functions, it will also increase the burden and insecurity of the program.

For example, starting from WordPress 4.4, we add rest API functions, which are not needed for general websites. On the contrary, it will drag down the speed of websites, so we try our best to ban these unnecessary functional requirements. We can see similar link characters in the source code.

<link rel=’ https://api.w.org/ ‘ href=’ https://www.wpfans.org/wp-json/ ‘ />

Here, we will record how to solve this problem. First, he needs to remove this link. Second, he needs to disable rest API functions.

Contents of articleshideFirst, non plugin modeSecond, disable JSON API pluginFirst, non plugin mode

/ / shield rest API < br > fromadd_ filter(‘json_ enabled’, ‘__ return_ false’ );
add_ filter(‘json_ jsonp_ enabled’, ‘__ return_ false’ );
add_ filter(‘rest_ enabled’, ‘__ return_ false’);
add_ filter(‘rest_ jsonp_ enabled’, ‘__ return_ false’);

//Remove the WP JSON tag in the header and the link in the HTTP header < br > fileremove_ action(‘wp_ head’, ‘rest_ output_ link_ wp_ head’, 10 );
remove_ action(‘template_ redirect’, ‘rest_ output_ link_ header’, 11 );

Drop the script to the Functions.php File. However, we will find that the link is removed, but you can still see the output character when you open WP Josn. Then old Chiang Kai Shek used a plugin to solve the problem.

Second, disable JSON API plugin

plug in address: https://wordpress.org/plugins/disable-json-api/

After downloading and starting the plugin, the problem of output characters can be completely solved.

Related Article
WordPress automatically intercepts part of the content of the article as a summary

In the daily release of articles, not every article may have an article summary, so the summary function of WordPress Read more

Implementation of tag inner chain association effect of WordPress program without plug-in

Nowadays, whether it is a large website or a personal blog, what matters is not the weight of the website Read more

Is in WordPress Theme_ Home () and is_ front_ Different usage of page ()

Under normal circumstances, when we use WordPress to build a website, the home page is the default index.php Just call Read more

How to delete the version number tail of WordPress scripts and CSS style sheets

As an excellent website building program, WordPress is undoubtedly the largest user group in the world in terms of user Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image