mirror of
https://git.sindominio.net/estibadores/wordpress.git
synced 2024-11-23 02:51:06 +01:00
56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Disable/Remove Google Fonts
|
|
* Plugin URI: https://wordpress.org/plugins/disable-remove-google-fonts/
|
|
* Description: Improve frontend performance by disabling Google Fonts.
|
|
* Author: Fonts Plugin
|
|
* Author URI: https://fontsplugin.com
|
|
* Version: 1.1.3
|
|
* License: GPLv2 or later
|
|
* License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
|
*
|
|
* @package disable-remove-google-fonts
|
|
*/
|
|
|
|
// Exit if accessed directly.
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Dequeue Google Fonts based on URL.
|
|
*/
|
|
function drgf_dequeueu_fonts() {
|
|
global $wp_styles;
|
|
|
|
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
|
|
return;
|
|
}
|
|
|
|
$allowed = apply_filters(
|
|
'drgf_exceptions',
|
|
[ 'olympus-google-fonts' ]
|
|
);
|
|
|
|
foreach ( $wp_styles->registered as $style ) {
|
|
$handle = $style->handle;
|
|
$src = $style->src;
|
|
$gfonts = strpos( $src, 'fonts.googleapis' );
|
|
|
|
if ( false !== $gfonts ) {
|
|
if ( ! array_key_exists( $handle, array_flip( $allowed ) ) ) {
|
|
wp_dequeue_style( $handle );
|
|
}
|
|
}
|
|
}
|
|
// Dequeue Google Fonts loaded by Revolution Slider.
|
|
remove_action( 'wp_footer', array( 'RevSliderFront', 'load_google_fonts' ) );
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'drgf_dequeueu_fonts', 9999 );
|
|
add_action( 'wp_print_styles', 'drgf_dequeueu_fonts', 9999 );
|
|
|
|
/**
|
|
* Dequeue Google Fonts loaded by Elementor.
|
|
*/
|
|
add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );
|