Changeset 1700571
- Timestamp:
- 07/21/2017 08:49:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
disable-unnecessary-functionality/trunk/disable-unnecessary-functionality.php
r1700023 r1700571 1 <?php1 <?php 2 2 /* 3 3 Plugin Name: Disables unnecessary functionality 4 Plugin URI: http ://pupi-boy.ru/4 Plugin URI: https://pupi-boy.ru/wordpress/wordpress-otklyuchaem-wp-json-emoji-xml-rpc-head.html 5 5 Description: Disables unnecessary functionality: REST API, Emoji, links to the blog-clients, links to the RSS feed version of your WordPress, automatic links in comments and some other functions. 6 Version: 1. 16 Version: 1.2 7 7 Author: DreamerKlim 8 Author URI: https://pupi-boy.ru/ avtor-ivanov-klim8 Author URI: https://pupi-boy.ru/ 9 9 License: GPL2 10 10 */ … … 31 31 * Отключаем wp-json 32 32 * -------------------------------------------------------------------------- */ 33 34 add_filter('xmlrpc_enabled', '__return_false');35 remove_action('wp_head', 'wp_shortlink_wp_head');36 remove_action( 'wp_head', 'rsd_link' );37 remove_action( 'wp_head', 'wlwmanifest_link' );38 remove_action( 'wp_head', 'wp_generator' );39 remove_action( 'wp_head', 'feed_links_extra', 3 );40 remove_action( 'wp_head', 'feed_links', 2 );41 remove_action( 'wp_head', 'index_rel_link' );42 remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head');43 33 44 34 // Отключаем сам REST API … … 68 58 // если собираетесь выводить вставки из других сайтов на своем, то закомментируйте след. строку. 69 59 remove_action( 'wp_head', 'wp_oembed_add_host_js' ); 70 71 60 /* -------------------------------------------------------------------------- 72 61 * Отключаем wp-json … … 111 100 * Отключаем Emojii 112 101 * -------------------------------------------------------------------------- */ 113 remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 114 remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); 115 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 116 remove_action( 'admin_print_styles', 'print_emoji_styles' ); 117 remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); 118 remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); 119 remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); 120 add_filter( 'tiny_mce_plugins', 'disable_wp_emojis_in_tinymce' ); 121 function disable_wp_emojis_in_tinymce( $plugins ) { 122 if ( is_array( $plugins ) ) { 123 return array_diff( $plugins, array( 'wpemoji' ) ); 124 } else { 125 return array(); 126 } 102 add_action( 'init', 'sheensay_disable_emojis' ); 103 104 function sheensay_disable_emojis() { 105 remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 106 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 107 remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); 108 remove_action( 'admin_print_styles', 'print_emoji_styles' ); 109 remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); 110 remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); 111 remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); 112 113 add_filter( 'tiny_mce_plugins', 'sheensay_disable_emojis_tinymce' ); 114 add_filter( 'wp_resource_hints', 'sheensay_disable_emojis_remove_dns_prefetch', 10, 2 ); 115 } 116 117 function sheensay_disable_emojis_tinymce( $plugins ) { 118 if ( is_array( $plugins ) ) { 119 return array_diff( $plugins, array( 'wpemoji' ) ); 120 } else { 121 return array(); 122 } 123 } 124 125 function sheensay_disable_emojis_remove_dns_prefetch( $urls, $relation_type ) { 126 if ( 'dns-prefetch' == $relation_type ) { 127 /** This filter is documented in wp-includes/formatting.php */ 128 $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2.2.1/svg/' ); 129 130 $urls = array_diff( $urls, array( $emoji_svg_url ) ); 131 } 132 133 return $urls; 127 134 } 128 135 /* -------------------------------------------------------------------------- … … 131 138 132 139 133 /* dns-prefetch */134 135 remove_action( 'wp_head', 'wp_resource_hints', 2);136 137 /* dns-prefetch */138 139 140 140 141 /* -------------------------------------------------------------------------- … … 173 174 * Удаляем опасные методы работы XML-RPC Pingback 174 175 * -------------------------------------------------------------------------- */ 176 /* -------------------------------------------------------------------------- 177 * pingback, canonical, meta generator, wlwmanifest, EditURI, shortlink, prev, 178 * next, RSS, feed, profile из заголовков head 179 * -------------------------------------------------------------------------- */ 180 181 // Удаляем код meta name="generator" 182 remove_action( 'wp_head', 'wp_generator' ); 183 184 // Удаляем link rel="canonical" // Этот тег лучше выводить с помощью плагина Yoast SEO или All In One SEO Pack 185 remove_action( 'wp_head', 'rel_canonical' ); 186 187 // Удаляем link rel="shortlink" - короткую ссылку на текущую страницу 188 remove_action( 'wp_head', 'wp_shortlink_wp_head' ); 189 190 // Удаляем link rel="EditURI" type="application/rsd+xml" title="RSD" 191 // Используется для сервиса Really Simple Discovery 192 remove_action( 'wp_head', 'rsd_link' ); 193 194 // Удаляем link rel="wlwmanifest" type="application/wlwmanifest+xml" 195 // Используется Windows Live Writer 196 remove_action( 'wp_head', 'wlwmanifest_link' ); 197 198 // Удаляем различные ссылки link rel 199 // на главную страницу 200 remove_action( 'wp_head', 'index_rel_link' ); 201 // на первую запись 202 remove_action( 'wp_head', 'start_post_rel_link', 10 ); 203 // на предыдущую запись 204 remove_action( 'wp_head', 'parent_post_rel_link', 10 ); 205 // на следующую запись 206 remove_action( 'wp_head', 'adjacent_posts_rel_link', 10 ); 207 208 // Удаляем связь с родительской записью 209 remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 ); 210 211 // Удаляем вывод /feed/ 212 remove_action( 'wp_head', 'feed_links', 2 ); 213 // Удаляем вывод /feed/ для записей, категорий, тегов и подобного 214 remove_action( 'wp_head', 'feed_links_extra', 3 ); 215 216 // Удаляем ненужный css плагина WP-PageNavi 217 remove_action( 'wp_head', 'pagenavi_css' ); 218 219 /* -------------------------------------------------------------------------- 220 * pingback, canonical, meta generator, wlwmanifest, EditURI, shortlink, prev, 221 * next, RSS, feed, profile из заголовков head 222 * -------------------------------------------------------------------------- */ 223 175 224 ?>
Note: See TracChangeset
for help on using the changeset viewer.