Changeset 1700943
- Timestamp:
- 07/23/2017 06:36:54 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
disable-unnecessary-functionality/trunk/disable-unnecessary-functionality.php
r1700941 r1700943 1 <?php1 <?php 2 2 /* 3 3 Plugin Name: Disables unnecessary functionality … … 29 29 30 30 /* -------------------------------------------------------------------------- 31 * Отключаем wp-json и др 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'); 31 * Отключаем wp-json 32 * -------------------------------------------------------------------------- */ 43 33 44 34 // Отключаем сам REST API … … 111 101 * Отключаем Emojii 112 102 * -------------------------------------------------------------------------- */ 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 } 127 } 103 function disable_emojis() { 104 remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 105 remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); 106 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 107 remove_action( 'admin_print_styles', 'print_emoji_styles' ); 108 remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); 109 remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); 110 remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); 111 add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); 112 add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 ); 113 } 114 add_action( 'init', 'disable_emojis' ); 115 116 /** 117 * Filter function used to remove the tinymce emoji plugin. 118 * 119 * @param array $plugins 120 * @return array Difference betwen the two arrays 121 */ 122 function disable_emojis_tinymce( $plugins ) { 123 if ( is_array( $plugins ) ) { 124 return array_diff( $plugins, array( 'wpemoji' ) ); 125 } else { 126 return array(); 127 } 128 } 129 130 /** 131 * Remove emoji CDN hostname from DNS prefetching hints. 132 * 133 * @param array $urls URLs to print for resource hints. 134 * @param string $relation_type The relation type the URLs are printed for. 135 * @return array Difference betwen the two arrays. 136 */ 137 function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) { 138 if ( 'dns-prefetch' == $relation_type ) { 139 /** This filter is documented in wp-includes/formatting.php */ 140 $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2.2.1/svg/' ); 141 142 $urls = array_diff( $urls, array( $emoji_svg_url ) ); 143 } 144 145 return $urls; 146 } 147 128 148 /* -------------------------------------------------------------------------- 129 149 * Отключаем Emojii … … 143 163 /* -------------------------------------------------------------------------- 144 164 * Удаляем стили css-класса .recentcomments 165 * -------------------------------------------------------------------------- */ 166 167 168 169 170 /* -------------------------------------------------------------------------- 171 * pingback, canonical, meta generator, wlwmanifest, EditURI, shortlink, prev, 172 * next, RSS, feed, profile из заголовков head 173 * -------------------------------------------------------------------------- */ 174 175 // Удаляем код meta name="generator" 176 remove_action( 'wp_head', 'wp_generator' ); 177 178 // Удаляем link rel="canonical" // Этот тег лучше выводить с помощью плагина Yoast SEO или All In One SEO Pack 179 remove_action( 'wp_head', 'rel_canonical' ); 180 181 // Удаляем link rel="shortlink" - короткую ссылку на текущую страницу 182 remove_action( 'wp_head', 'wp_shortlink_wp_head' ); 183 184 // Удаляем link rel="EditURI" type="application/rsd+xml" title="RSD" 185 // Используется для сервиса Really Simple Discovery 186 remove_action( 'wp_head', 'rsd_link' ); 187 188 // Удаляем link rel="wlwmanifest" type="application/wlwmanifest+xml" 189 // Используется Windows Live Writer 190 remove_action( 'wp_head', 'wlwmanifest_link' ); 191 192 // Удаляем различные ссылки link rel 193 // на главную страницу 194 remove_action( 'wp_head', 'index_rel_link' ); 195 // на первую запись 196 remove_action( 'wp_head', 'start_post_rel_link', 10 ); 197 // на предыдущую запись 198 remove_action( 'wp_head', 'parent_post_rel_link', 10 ); 199 // на следующую запись 200 remove_action( 'wp_head', 'adjacent_posts_rel_link', 10 ); 201 202 // Удаляем связь с родительской записью 203 remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 ); 204 205 // Удаляем вывод /feed/ 206 remove_action( 'wp_head', 'feed_links', 2 ); 207 // Удаляем вывод /feed/ для записей, категорий, тегов и подобного 208 remove_action( 'wp_head', 'feed_links_extra', 3 ); 209 210 // Удаляем ненужный css плагина WP-PageNavi 211 remove_action( 'wp_head', 'pagenavi_css' ); 212 213 /* -------------------------------------------------------------------------- 214 * pingback, canonical, meta generator, wlwmanifest, EditURI, shortlink, prev, 215 * next, RSS, feed, profile из заголовков head 145 216 * -------------------------------------------------------------------------- */ 146 217
Note: See TracChangeset
for help on using the changeset viewer.