Plugin Directory

Changeset 1700571


Ignore:
Timestamp:
07/21/2017 08:49:11 PM (9 years ago)
Author:
dreamerklim
Message:

pingback, canonical, meta generator, wlwmanifest, EditURI, shortlink, prev, next, RSS, feed

File:
1 edited

Legend:

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

    r1700023 r1700571  
    1 <?php
     1<?php
    22/*
    33Plugin Name: Disables unnecessary functionality
    4 Plugin URI: http://pupi-boy.ru/
     4Plugin URI: https://pupi-boy.ru/wordpress/wordpress-otklyuchaem-wp-json-emoji-xml-rpc-head.html
    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.1
     6Version: 1.2
    77Author: DreamerKlim
    8 Author URI: https://pupi-boy.ru/avtor-ivanov-klim
     8Author URI: https://pupi-boy.ru/
    99License: GPL2
    1010*/
     
    3131*  Отключаем wp-json
    3232* -------------------------------------------------------------------------- */
    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');
    4333
    4434// Отключаем сам REST API
     
    6858// если собираетесь выводить вставки из других сайтов на своем, то закомментируйте след. строку.
    6959remove_action( 'wp_head',                'wp_oembed_add_host_js'                 );
    70 
    7160/* --------------------------------------------------------------------------
    7261*  Отключаем wp-json
     
    111100 * Отключаем Emojii
    112101 * -------------------------------------------------------------------------- */
    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     }
     102add_action( 'init', 'sheensay_disable_emojis' );
     103 
     104function 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 
     117function 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 
     125function 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;
    127134}
    128135/* --------------------------------------------------------------------------
     
    131138
    132139
    133  /* dns-prefetch */
    134 
    135  remove_action( 'wp_head', 'wp_resource_hints', 2);
    136  
    137  /* dns-prefetch */
    138  
    139140 
    140141/* --------------------------------------------------------------------------
     
    173174*  Удаляем опасные методы работы XML-RPC Pingback
    174175* -------------------------------------------------------------------------- */
     176/* --------------------------------------------------------------------------
     177*  pingback, canonical, meta generator, wlwmanifest, EditURI, shortlink, prev,
     178*  next, RSS, feed, profile из заголовков head
     179* -------------------------------------------------------------------------- */
     180
     181// Удаляем код meta name="generator"
     182remove_action( 'wp_head', 'wp_generator' );
     183 
     184// Удаляем link rel="canonical" // Этот тег лучше выводить с помощью плагина Yoast SEO или All In One SEO Pack
     185remove_action( 'wp_head', 'rel_canonical' );
     186 
     187// Удаляем link rel="shortlink" - короткую ссылку на текущую страницу
     188remove_action( 'wp_head', 'wp_shortlink_wp_head' );
     189 
     190// Удаляем link rel="EditURI" type="application/rsd+xml" title="RSD"
     191// Используется для сервиса Really Simple Discovery
     192remove_action( 'wp_head', 'rsd_link' );
     193 
     194// Удаляем link rel="wlwmanifest" type="application/wlwmanifest+xml"
     195// Используется Windows Live Writer
     196remove_action( 'wp_head', 'wlwmanifest_link' );
     197 
     198// Удаляем различные ссылки link rel
     199// на главную страницу
     200remove_action( 'wp_head', 'index_rel_link' );
     201// на первую запись
     202remove_action( 'wp_head', 'start_post_rel_link', 10 ); 
     203// на предыдущую запись
     204remove_action( 'wp_head', 'parent_post_rel_link', 10 );
     205// на следующую запись
     206remove_action( 'wp_head', 'adjacent_posts_rel_link', 10 );
     207 
     208// Удаляем связь с родительской записью
     209remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );
     210 
     211// Удаляем вывод /feed/
     212remove_action( 'wp_head', 'feed_links', 2 );
     213// Удаляем вывод /feed/ для записей, категорий, тегов и подобного
     214remove_action( 'wp_head', 'feed_links_extra', 3 );
     215 
     216// Удаляем ненужный css плагина WP-PageNavi
     217remove_action( 'wp_head', 'pagenavi_css' );
     218
     219/* --------------------------------------------------------------------------
     220*  pingback, canonical, meta generator, wlwmanifest, EditURI, shortlink, prev,
     221*  next, RSS, feed, profile из заголовков head
     222* -------------------------------------------------------------------------- */
     223
    175224?>
Note: See TracChangeset for help on using the changeset viewer.