Nikita___007 0 Posted March 19, 2016 Report Share Posted March 19, 2016 В общем то вопрос в теме, код прописывал, пробовал плагины ставить, но как-то не очень то и помогло. Как лечить то это? Link to post Share on other sites
Модератор files 2843 Posted March 19, 2016 Модератор Report Share Posted March 19, 2016 Нужно полностью отключить REST API, код для functions.php такой: add_filter('rest_enabled', '__return_false'); remove_action( 'init', 'rest_api_init' ); remove_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 ); remove_action( 'parse_request', 'rest_api_loaded' ); remove_action( 'rest_api_init', 'wp_oembed_register_route' ); remove_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); remove_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); remove_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_expired', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_valid', 'rest_cookie_collect_status' ); remove_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 ); P.S. Если мусор попал в поиск, можете прописать редирект: add_action( 'template_redirect', function() { if ( preg_match( '#^/wp-json/?$#i', $_SERVER['REQUEST_URI'] ) ) { wp_redirect( get_option( 'siteurl' ), 301 ); die(); } } ); campusboy 1 Link to post Share on other sites
Alex Bang 156 Posted March 19, 2016 Report Share Posted March 19, 2016 Нужно полностью отключить REST API, код для functions.php такой: add_filter('rest_enabled', '__return_false'); remove_action( 'init', 'rest_api_init' ); remove_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 ); remove_action( 'parse_request', 'rest_api_loaded' ); remove_action( 'rest_api_init', 'wp_oembed_register_route' ); remove_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); remove_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); remove_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_expired', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_valid', 'rest_cookie_collect_status' ); remove_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 ); P.S. Если мусор попал в поиск, можете прописать редирект: add_action( 'template_redirect', function() { if ( preg_match( '#^/wp-json/?$#i', $_SERVER['REQUEST_URI'] ) ) { wp_redirect( get_option( 'siteurl' ), 301 ); die(); } } ); а что повлечет за собой отключение REST API? Link to post Share on other sites
Модератор files 2843 Posted March 19, 2016 Модератор Report Share Posted March 19, 2016 а что повлечет за собой отключение REST API? Отключение REST API повлечет за собой... отключение REST API Это инструменты для вебразработки, для 99% владельцев сайтов эти инструменты - пятое колесо. Link to post Share on other sites
VIP vituson 675 Posted March 19, 2016 VIP Report Share Posted March 19, 2016 Если стоит все время одна тема, то можно прописать коды, но в новой теме можно забыть это сделать. Думаю, плагин в этом случае - более универсальное решение. https_://ru.wordpress.org/plugins/disable-json-api/ Alex Bang 1 Link to post Share on other sites
Nikita___007 0 Posted March 19, 2016 Author Report Share Posted March 19, 2016 Нужно полностью отключить REST API, код для functions.php такой: add_filter('rest_enabled', '__return_false'); remove_action( 'init', 'rest_api_init' ); remove_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 ); remove_action( 'parse_request', 'rest_api_loaded' ); remove_action( 'rest_api_init', 'wp_oembed_register_route' ); remove_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); remove_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); remove_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_expired', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_valid', 'rest_cookie_collect_status' ); remove_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 ); P.S. Если мусор попал в поиск, можете прописать редирект: add_action( 'template_redirect', function() { if ( preg_match( '#^/wp-json/?$#i', $_SERVER['REQUEST_URI'] ) ) { wp_redirect( get_option( 'siteurl' ), 301 ); die(); } } ); спасибо) а куда прописать именно? или можно в любое место этот код воткнуть? Link to post Share on other sites
VIP campusboy 912 Posted March 19, 2016 VIP Report Share Posted March 19, 2016 Использую самопальный плагин, код такой: <?php /* Plugin Name: Убиратель херни Description: Плагин убирает из фрон-энда лишний код, генерируемый движком и некоторыми плагинами. */ require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); function remove_item_admin_bar() { global $wp_admin_bar; $wp_admin_bar->remove_menu('wp-logo'); # Если убрать лого WP, то about/wporg/documentation/support-forums/feedback отключатся автоматически //$wp_admin_bar->remove_menu('about'); # О WordPress //$wp_admin_bar->remove_menu('wporg'); # WordPress.org //$wp_admin_bar->remove_menu('documentation'); # Документация //$wp_admin_bar->remove_menu('support-forums'); # Форумы поддержки //$wp_admin_bar->remove_menu('feedback'); # Обратная связь $wp_admin_bar->remove_menu('view-site'); # Перейти на сайт $wp_admin_bar->remove_menu('customize'); # Настроить $wp_admin_bar->remove_menu('comments'); # Значок комметариев } add_action( 'wp_before_admin_bar_render', 'remove_item_admin_bar' ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); remove_action( 'wp_head', 'rest_output_link_wp_head' ); remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); add_filter('rest_enabled', '__return_false'); remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); remove_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 ); remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); remove_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_expired', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_valid', 'rest_cookie_collect_status' ); remove_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 ); remove_action( 'init', 'rest_api_init' ); remove_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 ); remove_action( 'parse_request', 'rest_api_loaded' ); remove_action( 'rest_api_init', 'wp_oembed_register_route' ); remove_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); // Плагин All in One SEO Pack if ( is_plugin_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ) ) { /* Ссылки с атрибутами prev и next */ function mayak_remove_prev_link( $data ) {return false;} add_filter( 'aioseop_prev_link', 'mayak_remove_prev_link' ); add_filter( 'aioseop_next_link', 'mayak_remove_prev_link' ); } remove_filter('comment_text', 'make_clickable', 9); remove_action( 'wp_head', 'feed_links_extra', 3 ); remove_action( 'wp_head', 'feed_links', 2 ); remove_action( 'wp_head', 'rsd_link' ); remove_action( 'wp_head', 'wlwmanifest_link' ); remove_action( 'wp_head', 'index_rel_link' ); remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); remove_action( 'wp_head', 'wp_generator' ); remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); add_filter('xmlrpc_enabled', '__return_false'); remove_action( "wp_head", "rel_canonical" ); function remove_more_tags($link) { $offset = strpos($link, '#more-'); if ($offset) { $end = strpos($link, '"',$offset); } if ($end) { $link = substr_replace($link, '', $offset, $end-$offset); } return $link; } add_filter('the_content_more_link', 'remove_more_tags'); // Remove Canonical Link Added By Yoast WordPress SEO Plugin function at_remove_dup_canonical_link() {return false;} add_filter( 'wpseo_canonical', 'at_remove_dup_canonical_link' ); // Плагин Yoast SEO if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) ) { // Убираем ссылки с атрибутами prev и next function wpseo_disable_rel( $link ) { if ( is_home() ) { return false; } } add_filter( 'wpseo_prev_rel_link', 'wpseo_disable_rel' ); add_filter( 'wpseo_next_rel_link', 'wpseo_disable_rel' ); // Убираем <script type='application/ld+json'> function remove_json_ld_output( $data ) { $data = array(); return $data; } add_filter('wpseo_json_ld_output', 'remove_json_ld_output', 10, 1); } ?> В зависимости от проекта комментирую ту или иную строчку, если это нужно. Link to post Share on other sites
Nikita___007 0 Posted March 19, 2016 Author Report Share Posted March 19, 2016 Использую самопальный плагин, код такой: <?php /* Plugin Name: Убиратель херни Description: Плагин убирает из фрон-энда лишний код, генерируемый движком и некоторыми плагинами. */ require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); function remove_item_admin_bar() { global $wp_admin_bar; $wp_admin_bar->remove_menu('wp-logo'); # Если убрать лого WP, то about/wporg/documentation/support-forums/feedback отключатся автоматически //$wp_admin_bar->remove_menu('about'); # О WordPress //$wp_admin_bar->remove_menu('wporg'); # WordPress.org //$wp_admin_bar->remove_menu('documentation'); # Документация //$wp_admin_bar->remove_menu('support-forums'); # Форумы поддержки //$wp_admin_bar->remove_menu('feedback'); # Обратная связь $wp_admin_bar->remove_menu('view-site'); # Перейти на сайт $wp_admin_bar->remove_menu('customize'); # Настроить $wp_admin_bar->remove_menu('comments'); # Значок комметариев } add_action( 'wp_before_admin_bar_render', 'remove_item_admin_bar' ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); remove_action( 'wp_head', 'rest_output_link_wp_head' ); remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); add_filter('rest_enabled', '__return_false'); remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' ); remove_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 ); remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 ); remove_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_expired', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' ); remove_action( 'auth_cookie_valid', 'rest_cookie_collect_status' ); remove_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 ); remove_action( 'init', 'rest_api_init' ); remove_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 ); remove_action( 'parse_request', 'rest_api_loaded' ); remove_action( 'rest_api_init', 'wp_oembed_register_route' ); remove_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); // Плагин All in One SEO Pack if ( is_plugin_active( 'all-in-one-seo-pack/all_in_one_seo_pack.php' ) ) { /* Ссылки с атрибутами prev и next */ function mayak_remove_prev_link( $data ) {return false;} add_filter( 'aioseop_prev_link', 'mayak_remove_prev_link' ); add_filter( 'aioseop_next_link', 'mayak_remove_prev_link' ); } remove_filter('comment_text', 'make_clickable', 9); remove_action( 'wp_head', 'feed_links_extra', 3 ); remove_action( 'wp_head', 'feed_links', 2 ); remove_action( 'wp_head', 'rsd_link' ); remove_action( 'wp_head', 'wlwmanifest_link' ); remove_action( 'wp_head', 'index_rel_link' ); remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); remove_action( 'wp_head', 'wp_generator' ); remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); remove_action( 'admin_print_styles', 'print_emoji_styles' ); remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); add_filter('xmlrpc_enabled', '__return_false'); remove_action( "wp_head", "rel_canonical" ); function remove_more_tags($link) { $offset = strpos($link, '#more-'); if ($offset) { $end = strpos($link, '"',$offset); } if ($end) { $link = substr_replace($link, '', $offset, $end-$offset); } return $link; } add_filter('the_content_more_link', 'remove_more_tags'); // Remove Canonical Link Added By Yoast WordPress SEO Plugin function at_remove_dup_canonical_link() {return false;} add_filter( 'wpseo_canonical', 'at_remove_dup_canonical_link' ); // Плагин Yoast SEO if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) ) { // Убираем ссылки с атрибутами prev и next function wpseo_disable_rel( $link ) { if ( is_home() ) { return false; } } add_filter( 'wpseo_prev_rel_link', 'wpseo_disable_rel' ); add_filter( 'wpseo_next_rel_link', 'wpseo_disable_rel' ); // Убираем <script type='application/ld+json'> function remove_json_ld_output( $data ) { $data = array(); return $data; } add_filter('wpseo_json_ld_output', 'remove_json_ld_output', 10, 1); } ?> В зависимости от проекта комментирую ту или иную строчку, если это нужно. спасибо) а куда прописывать то? Link to post Share on other sites
Модератор files 2843 Posted March 19, 2016 Модератор Report Share Posted March 19, 2016 Мой код пишите вверху functions.php. Код campusboy в отдельный файл и в папку с плагинами, подключить как плагин в админке. Link to post Share on other sites
Nikita___007 0 Posted March 19, 2016 Author Report Share Posted March 19, 2016 Мой код пишите вверху functions.php. Код campusboy в отдельный файл и в папку с плагинами, подключить как плагин в админке. я вот прописывал в верху, дак он на главной странице сайта у меня вылез Link to post Share on other sites
Модератор files 2843 Posted March 19, 2016 Модератор Report Share Posted March 19, 2016 я вот прописывал в верху, дак он на главной странице сайта у меня вылез желательно после <?php Link to post Share on other sites
Nikita___007 0 Posted March 19, 2016 Author Report Share Posted March 19, 2016 желательно после <?php угадал? Link to post Share on other sites
Модератор files 2843 Posted March 19, 2016 Модератор Report Share Posted March 19, 2016 да, все верно. Link to post Share on other sites
Nikita___007 0 Posted March 20, 2016 Author Report Share Posted March 20, 2016 да, все верно. блин не помогает не пропадает wp-json Link to post Share on other sites
Модератор files 2843 Posted March 20, 2016 Модератор Report Share Posted March 20, 2016 блин не помогает не пропадает wp-json А кеш выключили? Link to post Share on other sites
Alex Bang 156 Posted March 20, 2016 Report Share Posted March 20, 2016 Если стоит все время одна тема, то можно прописать коды, но в новой теме можно забыть это сделать. Думаю, плагин в этом случае - более универсальное решение. https_://ru.wordpress.org/plugins/disable-json-api/ зачем вот пробел ставить? ну нормальный же ресурс и ссылка полезная. нет блин надо поставить пробел или точку в ссылке чтобы я (или кто-то другой) мучались Link to post Share on other sites
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now