Server IP : 104.21.14.48 / Your IP : 18.223.158.14 [ Web Server : Apache System : Linux b70eb322-3aee-0c53-7c82-0db91281f2c6.secureserver.net 6.1.90-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 2 12:09:22 EDT 2024 x86_64 User : root ( 0) PHP Version : 8.0.30.2 Disable Function : NONE Domains : 0 Domains MySQL : ON | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/wp-content/plugins/coblocks/includes/ |
Upload File : |
<?php /** * Load google fonts. * * @package CoBlocks */ // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Load google fonts for our blocks. * * @since 1.6.0 */ class CoBlocks_Font_Loader { /** * This plugin's instance. * * @var CoBlocks_Font_Loader */ private static $instance; /** * Registers the plugin. * * @return CoBlocks_Font_Loader */ public static function register() { if ( null === self::$instance ) { self::$instance = new CoBlocks_Font_Loader(); } return self::$instance; } /** * The Constructor. */ public function __construct() { add_action( 'wp_enqueue_scripts', array( $this, 'fonts_loader' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'fonts_loader' ) ); } /** * Load fonts. * * @access public */ public function fonts_loader() { global $post; if ( $post && isset( $post->ID ) ) { $fonts = get_post_meta( $post->ID, '_coblocks_attr', true ); if ( ! empty( $fonts ) ) { $fonts = array_unique( explode( ',', $fonts ) ); $system = array( 'Arial', 'Tahoma', 'Verdana', 'Helvetica', 'Times New Roman', 'Trebuchet MS', 'Georgia', ); $gfonts = ''; $gfonts_attr = ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic'; foreach ( $fonts as $font ) { if ( ! in_array( $font, $system, true ) && ! empty( $font ) ) { $gfonts .= str_replace( ' ', '+', trim( $font ) ) . $gfonts_attr . '|'; } } if ( ! empty( $gfonts ) ) { $query_args = array( 'family' => $gfonts, ); wp_register_style( 'coblocks-block-fonts', add_query_arg( $query_args, '//fonts.googleapis.com/css' ), array(), COBLOCKS_VERSION ); wp_enqueue_style( 'coblocks-block-fonts' ); } // Reset. $gfonts = ''; } } } } CoBlocks_Font_Loader::register();