Plugin Directory

Changeset 1700936


Ignore:
Timestamp:
07/23/2017 06:07:05 AM (9 years ago)
Author:
dreamerklim
Message:

bug :с

Location:
disable-unnecessary-functionality
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • disable-unnecessary-functionality/trunk/disable-unnecessary-functionality.php

    r1700599 r1700936  
    22/*
    33Plugin Name: Disables unnecessary functionality
    4 Plugin URI: https://pupi-boy.ru/wordpress/wordpress-otklyuchaem-wp-json-emoji-xml-rpc-head.html
     4Plugin URI: http://pupi-boy.ru/
    55Description: 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.2
     6Version: 1.3
    77Author: DreamerKlim
    8 Author URI: https://pupi-boy.ru/
     8Author URI: https://pupi-boy.ru/avtor-ivanov-klim
    99License: GPL2
    1010*/
     
    5858// если собираетесь выводить вставки из других сайтов на своем, то закомментируйте след. строку.
    5959remove_action( 'wp_head',                'wp_oembed_add_host_js'                 );
     60
    6061/* --------------------------------------------------------------------------
    6162*  Отключаем wp-json
     
    9899 
    99100 
    100 /* --------------------------------------------------------------------------
    101  * Отключаем Emoji
    102  * -------------------------------------------------------------------------- */
    103 add_action( 'init', 'sheensay_disable_emojis' );
    104  
    105 function sheensay_disable_emojis() {
    106   remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
    107   remove_action( 'wp_print_styles', 'print_emoji_styles' );
    108   remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
    109   remove_action( 'admin_print_styles', 'print_emoji_styles' );
    110   remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
    111   remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
    112   remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
    113  
    114   add_filter( 'tiny_mce_plugins', 'sheensay_disable_emojis_tinymce' );
    115   add_filter( 'wp_resource_hints', 'sheensay_disable_emojis_remove_dns_prefetch', 10, 2 );
    116 }
    117  
    118 function sheensay_disable_emojis_tinymce( $plugins ) {
    119   if ( is_array( $plugins ) ) {
    120     return array_diff( $plugins, array( 'wpemoji' ) );
    121   } else {
    122     return array();
    123   }
    124 }
    125  
    126 function sheensay_disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
    127   if ( 'dns-prefetch' == $relation_type ) {
    128     /** This filter is documented in wp-includes/formatting.php */
    129     $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2.2.1/svg/' );
    130  
    131     $urls = array_diff( $urls, array( $emoji_svg_url ) );
    132   }
    133  
    134   return $urls;
    135 }
    136 /* --------------------------------------------------------------------------
    137  * Отключаем Emoji
    138  * -------------------------------------------------------------------------- */
    139 
    140 
     101 
     102/* --------------------------------------------------------------------------
     103 * Отключаем Emojii
     104 * -------------------------------------------------------------------------- */
     105
     106function disable_emojis() {
     107    remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
     108    remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
     109    remove_action( 'wp_print_styles', 'print_emoji_styles' );
     110    remove_action( 'admin_print_styles', 'print_emoji_styles' );   
     111    remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
     112    remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); 
     113    remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
     114    add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
     115    add_filter( 'wp_resource_hints', 'disable_emojis_remove_dns_prefetch', 10, 2 );
     116}
     117add_action( 'init', 'disable_emojis' );
     118
     119/**
     120 * Filter function used to remove the tinymce emoji plugin.
     121 *
     122 * @param    array  $plugins 
     123 * @return   array             Difference betwen the two arrays
     124 */
     125function disable_emojis_tinymce( $plugins ) {
     126    if ( is_array( $plugins ) ) {
     127        return array_diff( $plugins, array( 'wpemoji' ) );
     128    } else {
     129        return array();
     130    }
     131}
     132
     133/**
     134 * Remove emoji CDN hostname from DNS prefetching hints.
     135 *
     136 * @param  array  $urls          URLs to print for resource hints.
     137 * @param  string $relation_type The relation type the URLs are printed for.
     138 * @return array                 Difference betwen the two arrays.
     139 */
     140function disable_emojis_remove_dns_prefetch( $urls, $relation_type ) {
     141    if ( 'dns-prefetch' == $relation_type ) {
     142        /** This filter is documented in wp-includes/formatting.php */
     143        $emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2.2.1/svg/' );
     144
     145        $urls = array_diff( $urls, array( $emoji_svg_url ) );
     146    }
     147
     148    return $urls;
     149}
     150
     151/* --------------------------------------------------------------------------
     152 * Отключаем Emojii
     153 * -------------------------------------------------------------------------- */
     154
     155 
     156 
    141157 
    142158/* --------------------------------------------------------------------------
     
    176192* -------------------------------------------------------------------------- */
    177193
    178 
    179 
    180 /* --------------------------------------------------------------------------
    181 *  pingback, canonical, meta generator, wlwmanifest, EditURI, shortlink, prev,
    182 *  next, RSS, feed, profile из заголовков head
    183 * -------------------------------------------------------------------------- */
    184 
    185 // Удаляем код meta name="generator"
     194add_filter('xmlrpc_enabled', '__return_false');
     195remove_action('wp_head', 'wp_shortlink_wp_head');
     196remove_action( 'wp_head', 'rsd_link' );
     197remove_action( 'wp_head', 'wlwmanifest_link' );
    186198remove_action( 'wp_head', 'wp_generator' );
    187  
    188 // Удаляем link rel="canonical" // Этот тег лучше выводить с помощью плагина Yoast SEO или All In One SEO Pack
    189 remove_action( 'wp_head', 'rel_canonical' );
    190  
    191 // Удаляем link rel="shortlink" - короткую ссылку на текущую страницу
    192 remove_action( 'wp_head', 'wp_shortlink_wp_head' );
    193  
    194 // Удаляем link rel="EditURI" type="application/rsd+xml" title="RSD"
    195 // Используется для сервиса Really Simple Discovery
    196 remove_action( 'wp_head', 'rsd_link' );
    197  
    198 // Удаляем link rel="wlwmanifest" type="application/wlwmanifest+xml"
    199 // Используется Windows Live Writer
    200 remove_action( 'wp_head', 'wlwmanifest_link' );
    201  
    202 // Удаляем различные ссылки link rel
    203 // на главную страницу
    204 remove_action( 'wp_head', 'index_rel_link' );
    205 // на первую запись
    206 remove_action( 'wp_head', 'start_post_rel_link', 10 ); 
    207 // на предыдущую запись
    208 remove_action( 'wp_head', 'parent_post_rel_link', 10 );
    209 // на следующую запись
    210 remove_action( 'wp_head', 'adjacent_posts_rel_link', 10 );
    211  
    212 // Удаляем связь с родительской записью
    213 remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );
    214  
    215 // Удаляем вывод /feed/
     199remove_action( 'wp_head', 'feed_links_extra', 3 );
    216200remove_action( 'wp_head', 'feed_links', 2 );
    217 // Удаляем вывод /feed/ для записей, категорий, тегов и подобного
    218 remove_action( 'wp_head', 'feed_links_extra', 3 );
    219  
    220 // Удаляем ненужный css плагина WP-PageNavi
    221 remove_action( 'wp_head', 'pagenavi_css' );
    222 
    223 /* --------------------------------------------------------------------------
    224 *  pingback, canonical, meta generator, wlwmanifest, EditURI, shortlink, prev,
    225 *  next, RSS, feed, profile из заголовков head
    226 * -------------------------------------------------------------------------- */
     201remove_action( 'wp_head', 'index_rel_link' );
     202remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head');
    227203
    228204
Note: See TracChangeset for help on using the changeset viewer.