Plugin Directory

Changeset 1700943


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

ok good

File:
1 edited

Legend:

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

    r1700941 r1700943  
    1 <?php
     1<?php
    22/*
    33Plugin Name: Disables unnecessary functionality
     
    2929
    3030/* --------------------------------------------------------------------------
    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* -------------------------------------------------------------------------- */
    4333
    4434// Отключаем сам REST API
     
    111101 * Отключаем Emojii
    112102 * -------------------------------------------------------------------------- */
    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 }
     103function 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}
     114add_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 */
     122function 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 */
     137function 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
    128148/* --------------------------------------------------------------------------
    129149 * Отключаем Emojii
     
    143163/* --------------------------------------------------------------------------
    144164*  Удаляем стили 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"
     176remove_action( 'wp_head', 'wp_generator' );
     177 
     178// Удаляем link rel="canonical" // Этот тег лучше выводить с помощью плагина Yoast SEO или All In One SEO Pack
     179remove_action( 'wp_head', 'rel_canonical' );
     180 
     181// Удаляем link rel="shortlink" - короткую ссылку на текущую страницу
     182remove_action( 'wp_head', 'wp_shortlink_wp_head' );
     183 
     184// Удаляем link rel="EditURI" type="application/rsd+xml" title="RSD"
     185// Используется для сервиса Really Simple Discovery
     186remove_action( 'wp_head', 'rsd_link' );
     187 
     188// Удаляем link rel="wlwmanifest" type="application/wlwmanifest+xml"
     189// Используется Windows Live Writer
     190remove_action( 'wp_head', 'wlwmanifest_link' );
     191 
     192// Удаляем различные ссылки link rel
     193// на главную страницу
     194remove_action( 'wp_head', 'index_rel_link' );
     195// на первую запись
     196remove_action( 'wp_head', 'start_post_rel_link', 10 ); 
     197// на предыдущую запись
     198remove_action( 'wp_head', 'parent_post_rel_link', 10 );
     199// на следующую запись
     200remove_action( 'wp_head', 'adjacent_posts_rel_link', 10 );
     201 
     202// Удаляем связь с родительской записью
     203remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );
     204 
     205// Удаляем вывод /feed/
     206remove_action( 'wp_head', 'feed_links', 2 );
     207// Удаляем вывод /feed/ для записей, категорий, тегов и подобного
     208remove_action( 'wp_head', 'feed_links_extra', 3 );
     209 
     210// Удаляем ненужный css плагина WP-PageNavi
     211remove_action( 'wp_head', 'pagenavi_css' );
     212
     213/* --------------------------------------------------------------------------
     214*  pingback, canonical, meta generator, wlwmanifest, EditURI, shortlink, prev,
     215*  next, RSS, feed, profile из заголовков head
    145216* -------------------------------------------------------------------------- */
    146217
Note: See TracChangeset for help on using the changeset viewer.