Add upstream plugins

Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
2019-10-25 22:42:20 +02:00
parent 5d3c2ec184
commit 290736650a
1186 changed files with 302577 additions and 0 deletions

View File

@@ -0,0 +1,424 @@
<?php
/**
* The Disable Google Fonts Plugin
*
* Disable enqueuing of fonts from Google used by WordPress core, default themes, Gutenberg, and many more
*
* @package Disable_Google_Fonts
* @subpackage Main
*/
/**
* Plugin Name: Disable Google Fonts
* Plugin URI: https://milandinic.com/wordpress/plugins/disable-google-fonts/
* Description: Disable enqueuing of fonts from Google used by WordPress core, default themes, Gutenberg, and many more.
* Author: Milan Dinić
* Author URI: https://milandinic.com/
* Version: 2.0
* Text Domain: disable-google-fonts
* Domain Path: /languages/
* License: GPL
*/
/* Exit if accessed directly */
if ( ! defined( 'ABSPATH' ) ) exit;
class Disable_Google_Fonts {
/**
* Hook actions and filters.
*
* @since 1.0
* @access public
*/
public function __construct() {
add_filter( 'gettext_with_context', array( $this, 'disable_google_fonts' ), 888, 4 );
}
/**
* Add action links to plugins page.
*
* @since 1.2
* @deprecated 1.3
* @access public
*
* @param array $links Plugin's action links.
* @param string $plugin_file Path to the plugin file.
* @return array $links Plugin's action links.
*/
public function action_links( $links, $plugin_file ) {
_deprecated_function( __METHOD__, '1.3' );
return $links;
}
/**
* Force 'off' as a result of font toggler string translation.
*
* @since 2.0
* @access public
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string $translations Translated text.
*/
public function disable_google_fonts( $translations, $text, $context, $domain ) {
switch ( $text ) {
case 'on':
// Pass for most cases.
if ( $this->is_ending_with_font_toggler( $context ) || in_array( $context, $this->get_font_toggler_variants() ) ) {
$translations = 'off';
}
break;
case 'Noto Serif:400,400i,700,700i':
if ( 'Google Font Name and Variants' === $context ) {
$translations = 'off';
}
break;
}
return $translations;
}
/**
* Check if text is ending with variation of 'font(s):( )on or off'.
*
* For most strings that are used as font togglers, context is ending
* with this text. This method checks if that is the case.
*
* @since 2.0
* @access public
*
* @param string $text Text to check.
* @return bool Whether text is ending with phrase or not.
*/
public function is_ending_with_font_toggler( $text ) {
if ( preg_match( '/font[s]?:\s?on or off$/i', $text ) ) {
return true;
} else {
return false;
}
}
/**
* Get context variants that cannot be detected with string font toggler checker.
*
* @since 2.0
*
* @return array
*/
public function get_font_toggler_variants() {
return array(
'arimo:on or off',
'Assistant:on or off',
'Atma: on or off',
'Crimson Text: on or off',
'Dancing Script: on or off',
'Droid sans: on or off',
'Google font: on',
'Google Font for body text: on or off',
'Google Font for heading text: on or off',
'Google Font for menu text: on or off',
'Google fonts: "on" or "off"',
'Great Vibes:on or off',
'greatvibes:on or off',
'Hind: on or off',
'Indie Flower: on or off',
'Josefin Sans: on or off',
'Lato: on or off',
'Lato:on or off',
'Lato : on or off',
'Lobster:on or off',
'Lora: on or off',
'Merriweather: on or off',
'Merriweather:on or off',
'montserrat:on or off',
'Muli: on or off',
'Nunito Sans: on or off',
'Open Sans',
'Open Sans:on or off',
'Open Sans: on or off',
'opensans:on or off',
'Open Sans : on or off',
'Oswald:on or off',
'oswald:on or off',
'Oxygen: on or off',
'Pacifico: on or off',
'Pacifico:on or off',
'pacifico:on or off',
'Poppins: on or off',
'playball:on or off',
'Playfair Display: on or off',
'Product Sans: on or off',
'pt_sans:on or off',
'Raleway: on or off',
'Roboto',
'Roboto: on or off',
'roboto:on or off',
'Roboto:on or off',
'Roboto : on or off',
'Roboto Condensed',
'Roboto Condensed:on or off',
'roboto_condensed:on or off',
'robotocondensed:on or off',
'Roboto Slab:on or off',
'Sail:on or off',
'Scada:on or off',
'scada:on or off',
'Shadows Into Light: on or off',
);
}
/**
* Force 'off' as a result of Open Sans font toggler string translation.
*
* @since 1.0
* @access public
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string $translations Translated text.
*/
public function disable_open_sans( $translations, $text, $context, $domain ) {
if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
/**
* Force 'off' as a result of Lato font toggler string translation.
*
* @since 1.0
* @access public
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string $translations Translated text.
*/
public function disable_lato( $translations, $text, $context, $domain ) {
if ( 'Lato font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
/**
* Force 'off' as a result of Source Sans Pro font toggler string translation.
*
* @since 1.0
* @access public
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string $translations Translated text.
*/
public function disable_source_sans_pro( $translations, $text, $context, $domain ) {
if ( 'Source Sans Pro font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
/**
* Force 'off' as a result of Bitter font toggler string translation.
*
* @since 1.0
* @access public
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string $translations Translated text.
*/
public function disable_bitter( $translations, $text, $context, $domain ) {
if ( 'Bitter font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
/**
* Force 'off' as a result of Noto Sans font toggler string translation.
*
* @since 1.1
* @access public
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string $translations Translated text.
*/
public function disable_noto_sans( $translations, $text, $context, $domain ) {
if ( 'Noto Sans font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
/**
* Force 'off' as a result of Noto Serif font toggler string translation.
*
* @since 1.1
* @access public
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string $translations Translated text.
*/
public function disable_noto_serif( $translations, $text, $context, $domain ) {
if ( 'Noto Serif font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
/**
* Force 'off' as a result of Inconsolata font toggler string translation.
*
* @since 1.1
* @access public
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string $translations Translated text.
*/
public function disable_inconsolata( $translations, $text, $context, $domain ) {
if ( 'Inconsolata font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
/**
* Force 'off' as a result of Merriweather font toggler string translation.
*
* @since 1.2
* @access public
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string $translations Translated text.
*/
public function disable_merriweather( $translations, $text, $context, $domain ) {
if ( 'Merriweather font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
/**
* Force 'off' as a result of Montserrat font toggler string translation.
*
* @since 1.2
* @access public
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string $translations Translated text.
*/
public function disable_montserrat( $translations, $text, $context, $domain ) {
if ( 'Montserrat font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
/**
* Force 'off' as a result of Libre Franklin font toggler string translation.
*
* @since 1.3
* @access public
*
* @param string $translations Translated text.
* @param string $text Text to translate.
* @param string $context Context information for the translators.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
* @return string $translations Translated text.
*/
public function disable_libre_franklin( $translations, $text, $context, $domain ) {
if ( 'Libre Franklin font: on or off' == $context && 'on' == $text ) {
$translations = 'off';
}
return $translations;
}
/**
* Register filters that disable fonts for bundled themes.
*
* This filters can be directly hooked as Disable_Google_Fonts::disable_open_sans()
* but that would mean that comparison is done on each string
* for each font which creates performance issues.
*
* Instead we check active template's name very late and just once
* and hook appropriate filters.
*
* Note that Open Sans disabler is used for both WordPress core
* and for Twenty Twelve theme.
*
* @since 1.0
* @access public
*
* @uses get_template() To get name of the active parent theme.
* @uses add_filter() To hook theme specific fonts disablers.
*/
public function register_theme_fonts_disabler() {
$template = get_template();
switch ( $template ) {
case 'twentyseventeen' :
add_filter( 'gettext_with_context', array( $this, 'disable_libre_franklin' ), 888, 4 );
break;
case 'twentysixteen' :
add_filter( 'gettext_with_context', array( $this, 'disable_merriweather' ), 888, 4 );
add_filter( 'gettext_with_context', array( $this, 'disable_montserrat' ), 888, 4 );
add_filter( 'gettext_with_context', array( $this, 'disable_inconsolata' ), 888, 4 );
break;
case 'twentyfifteen' :
add_filter( 'gettext_with_context', array( $this, 'disable_noto_sans' ), 888, 4 );
add_filter( 'gettext_with_context', array( $this, 'disable_noto_serif' ), 888, 4 );
add_filter( 'gettext_with_context', array( $this, 'disable_inconsolata' ), 888, 4 );
break;
case 'twentyfourteen' :
add_filter( 'gettext_with_context', array( $this, 'disable_lato' ), 888, 4 );
break;
case 'twentythirteen' :
add_filter( 'gettext_with_context', array( $this, 'disable_source_sans_pro' ), 888, 4 );
add_filter( 'gettext_with_context', array( $this, 'disable_bitter' ), 888, 4 );
break;
}
}
}
/* Although it would be preferred to do this on hook,
* load early to make sure Open Sans is removed
*/
$disable_google_fonts = new Disable_Google_Fonts;

View File

@@ -0,0 +1,51 @@
=== Disable Google Fonts ===
Contributors: dimadin
Donate link: https://milandinic.com/donate/
Tags: Open Sans, Google Fonts, Google Web Fonts
Requires at least: 3.5
Tested up to: 5.1
Requires PHP: 5.2.4
Stable tag: 2.0
Disable enqueuing of fonts from Google used by WordPress core, default themes, Gutenberg, and many more.
== Description ==
[Plugin homepage](https://milandinic.com/wordpress/plugins/disable-google-fonts/) | [Plugin author](https://milandinic.com/) | [Donate](https://milandinic.com/donate/)
This plugin stops loading of fonts from Google Fonts used by WordPress core, Gutenberg plugin, bundled themes (Twenty Twelve, Twenty Thirteen, Twenty Fourteen, Twenty Fifteen, Twenty Sixteen, Twenty Seventeen), and most other themes. If theme or plugin (whose name is not listed here) uses fonts from Google Fonts, those fonts still might be loaded if that theme or plugin loads fonts from Google in a way that is incompatible with this plugin.
Reasons for not using Google Fonts might be privacy and security, local development or production, blocking of Google's servers, characters not supported by font, performance.
Disable Google Fonts is a very lightweight, it has no settings, just activate it and it works immediately.
And it's on [GitHub](https://github.com/dimadin/disable-google-fonts).
== Installation ==
1. Upload `disable-google-fonts` folder to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
== Changelog ==
= 2.0 =
* Released on 23rd December 2018
* Change logic when disabling font via string translation filter.
* Change plugin description to better explain in which situations it works.
* Add support for WordPress 5.0, latest version of Gutenberg plugin, and most of the themes in WordPress.org Themes Repository.
= 1.4 =
* Released on 28th September 2018
* Remove fonts used in Gutenberg.
= 1.3 =
* Released on 12th December 2016
* Remove fonts used in Twenty Seventeen.
= 1.2 =
* Released on 9th December 2015
* Remove fonts used in Twenty Sixteen.
= 1.1 =
* Released on 29th December 2014
* Remove fonts used in Twenty Fifteen.