Current Path: > home > codekrsu > > ameliagraphics.com > wp-content > plugins > essential-blocks > includes > Core
Operation : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 Software : Apache Server IP : 162.0.232.56 | Your IP: 216.73.216.111 Domains : 1034 Domain(s) Permission : [ 0755 ]
Name | Type | Size | Last Modified | Actions |
---|---|---|---|---|
Block.php | File | 5567 bytes | June 01 2025 14:07:44. | |
Blocks.php | File | 4806 bytes | June 01 2025 14:07:44. | |
BlocksPatterns.php | File | 5464 bytes | February 18 2025 14:31:10. | |
FaqSchema.php | File | 7041 bytes | January 12 2025 17:13:54. | |
FontLoader.php | File | 4900 bytes | June 05 2024 11:39:46. | |
Maintenance.php | File | 4530 bytes | May 08 2025 15:01:12. | |
ModifyWPCore.php | File | 761 bytes | August 09 2023 14:57:00. | |
PageTemplates.php | File | 4982 bytes | December 24 2024 15:38:54. | |
PostMeta.php | File | 637 bytes | August 09 2023 14:57:00. | |
Scripts.php | File | 30191 bytes | July 27 2025 13:25:28. |
<?php namespace EssentialBlocks\Core; use EssentialBlocks\Utils\Helper; use EssentialBlocks\Traits\HasSingletone; /** * Load google fonts. */ // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } class FontLoader { use HasSingletone; /** * Google fonts to enqueue * * @access public * @var array */ public static $gfonts = [ ]; private static $block_name = [ ]; /** * The Constructor. */ public function __construct( $block_name ) { self::$block_name = $block_name; // Get font from each block loaded in page add_filter( 'render_block', [ $this, 'get_fonts_on_render_block' ], 10, 2 ); // add_filter( 'wp_enqueue_scripts', [$this, 'eb_enqueue_fonts'], 15 ); add_action( 'wp_footer', [ $this, 'eb_enqueue_fonts' ], 15 ); // add_action( 'init', [ $this, 'get_google_font_list' ] ); } // public function get_google_font_list() // { // // Google Fonts API URL // $api_url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyA98gjHVZcX_FQzgqhn3VRSlzi0hJd_PNc'; // // Fetch data from Google Fonts API // $response = wp_remote_get( $api_url ); // // Check if the request was successful // if ( is_wp_error( $response ) ) { // echo 'Error fetching Google Fonts data: ' . $response->get_error_message(); // } else { // // Decode the JSON response // $fonts_data = json_decode( wp_remote_retrieve_body( $response ), true ); // // Output the fonts data in the desired format // $output = [ ]; // foreach ( $fonts_data[ 'items' ] as $font ) { // $family_key = str_replace( ' ', '-', $font[ 'family' ] ); // $variations = [ ]; // foreach ( $font[ 'variants' ] as $variant ) { // // Replace "regular" with "400" // if ( $variant === "regular" ) { // $variant = "400"; // } else { // // Remove alphabets from other strings // $variant = preg_replace( "/[a-zA-Z]/", "", $variant ); // } // $variations[ ] = $variant; // } // $output[ $family_key ] = [ // 'family' => $font[ 'family' ], // 'category' => $font[ 'category' ], // 'variants' => $font[ 'variants' ] // ]; // } // // Output the formatted data // // echo json_encode( $output, JSON_PRETTY_PRINT ); // error_log( print_r( json_encode( $output, JSON_PRETTY_PRINT ), 1 ) ); // } // } /** * Run font loader after all block render * * @since 4.0.2 * @access public */ public function eb_enqueue_fonts() { $this->fonts_loader(); } /** * Get Attributes on block render * * @since 4.0.2 * @access public */ public function get_fonts_on_render_block( $block_content, $block ) { if ( isset( $block[ 'attrs' ] ) ) { if ( 'essential-blocks' === self::$block_name || $block[ 'blockName' ] === self::$block_name ) { $fonts = self::get_fonts_family( $block[ 'attrs' ] ); self::$gfonts = array_unique( array_merge( self::$gfonts, $fonts ) ); } } return $block_content; } /** * Generate Font family from Attributes * * @since 4.0.0 * @access public */ public static function get_fonts_family( $attributes ) { $keys = preg_grep( '/^(\w+)FontFamily/i', array_keys( $attributes ), 0 ); $googleFontFamily = [ ]; foreach ( $keys as $key ) { $googleFontFamily[ $attributes[ $key ] ] = $attributes[ $key ]; } return $googleFontFamily; } /** * Load fonts. * * @since 4.0.0 * @access public */ public function fonts_loader( $handle_name = 'eb-block-fonts' ) { $googleFont = true; if ( 'essential-blocks' === self::$block_name ) { $eb_settings = get_option( 'eb_settings', [ ] ); $googleFont = ! empty( $eb_settings[ 'googleFont' ] ) ? $eb_settings[ 'googleFont' ] : 'true'; } if ( 'false' !== $googleFont ) { $fonts = self::$gfonts; // $default_fonts = [ // "Default", // "Arial", // "Helvetica", // "Times New Roman", // "Georgia" // ]; // $fonts = array_diff( $fonts, $default_fonts ); Helper::load_google_font( $fonts, $handle_name ); } } }
SILENT KILLER Tool