默認(rèn)從WordPress5.0開始會自帶API和JSON功能,可以用于外部第三方的接口管理WP站點(diǎn)。但是如果不用的盡量的屏蔽掉,防止被外部入侵調(diào)用。
//屏蔽 REST API http://bjj.org.cn/disable-rest-api.html add_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'); // 移除頭部 wp-json 標(biāo)簽和 HTTP header 中的 link remove_action('wp_head', 'rest_output_link_wp_head', 10 ); remove_action('template_redirect', 'rest_output_link_header', 11 );
這樣我們就可以屏蔽掉JSON和API,實(shí)現(xiàn)不擔(dān)心外部的調(diào)用,如果有需要用到接口的那就再開啟。
評論