Current Path: > home > codekrsu > > ameliagraphics.com > wp-content > plugins > essential-blocks > includes > Utils
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 |
---|---|---|---|---|
CSSParser.php | File | 9219 bytes | November 07 2024 12:12:30. | |
Enqueue.php | File | 4677 bytes | February 26 2025 16:22:10. | |
Helper.php | File | 25527 bytes | January 12 2025 17:13:54. | |
HttpRequest.php | File | 2147 bytes | August 09 2023 14:57:00. | |
Installer.php | File | 3341 bytes | January 12 2025 17:13:54. | |
Migrator.php | File | 743 bytes | August 09 2023 14:57:00. | |
QueryHelper.php | File | 7360 bytes | October 02 2024 10:36:24. | |
Settings.php | File | 3368 bytes | May 08 2025 15:01:12. | |
SvgSanitizer.php | File | 2525 bytes | May 19 2025 15:07:08. | |
TemplateHelpers.php | File | 2160 bytes | August 29 2023 10:12:00. |
<?php namespace EssentialBlocks\Utils; class CSSParser { private static $instance; public static function init() { if ( null === self::$instance ) { self::$instance = new self; } return self::$instance; } /** * Get Responsive Breakpoints */ public static function get_responsive_breakpoints( $size = 'mobile' ) { $settings = get_option( 'eb_settings', [ ] ); $settingsData = [ ]; if ( array_key_exists( 'responsiveBreakpoints', $settings ) ) { $settingsData = $settings[ 'responsiveBreakpoints' ]; if ( gettype( $settingsData ) === 'string' && strlen( $settingsData ) > 0 ) { $settingsData = (array) json_decode( html_entity_decode( stripslashes( $settingsData ) ) ); } } else { $settings[ 'responsiveBreakpoints' ] = [ 'tablet' => 1024, 'mobile' => 767 ]; update_option( 'eb_settings', $settings ); $settingsData = $settings[ 'responsiveBreakpoints' ]; } return $settingsData[ $size ]; } /** * Recursive function for parsing blocks */ public static function eb_block_style_recursive( $block, &$eb_blocks, &$blocknames ) { if ( count( $block ) > 0 ) { foreach ( $block as $item ) { $attributes = $item[ 'attrs' ]; $isCustomCssError = isset( $attributes[ 'isCustomCssError' ] ) ? $attributes[ 'isCustomCssError' ] : false; $blockId = ""; if ( isset( $attributes[ 'blockId' ] ) && ! empty( $attributes[ 'blockId' ] ) ) { $blockId = $attributes[ 'blockId' ]; if ( isset( $item[ 'blockName' ] ) ) { $blocknames[ ] = $item[ 'blockName' ]; } } $blockMeta = ""; if ( isset( $attributes[ 'blockMeta' ] ) && ! empty( $attributes[ 'blockMeta' ] ) ) { $blockMeta = $attributes[ 'blockMeta' ]; } $commonStyles = ""; if ( isset( $attributes[ 'commonStyles' ] ) && ! empty( $attributes[ 'commonStyles' ] ) ) { $commonStyles = $attributes[ 'commonStyles' ]; } $customCss = ""; if ( ! $isCustomCssError && isset( $attributes[ 'customCss' ] ) && ! empty( $attributes[ 'customCss' ] ) ) { // $customCss = $attributes[ 'customCss' ]; $customCss = str_replace( 'eb_selector', "." . $blockId, $attributes[ 'customCss' ] ); } if ( isset( $attributes[ 'ref' ] ) && ! empty( $attributes[ 'ref' ] ) && $item[ "blockName" ] === "core/block" ) { $reusable_block = get_post( $attributes[ 'ref' ] ); $reusable_content = ! empty( $reusable_block ) ? parse_blocks( $reusable_block->post_content ) : [ ]; $reusable_blocks = [ ]; $eb_blocks[ "reusableBlocks" ][ $attributes[ 'ref' ] ] = self::eb_block_style_recursive( $reusable_content, $reusable_blocks, $blocknames ); } else { if ( isset( $item[ "innerBlocks" ] ) && count( $item[ "innerBlocks" ] ) > 0 ) { self::eb_block_style_recursive( $item[ 'innerBlocks' ], $eb_blocks, $blocknames ); if ( isset( $attributes[ 'blockMeta' ] ) && ! empty( $attributes[ 'blockMeta' ] ) ) { $eb_blocks[ $blockId ] = [ 'blockMeta' => $blockMeta, 'commonStyles' => $commonStyles, 'customCss' => $customCss ]; } } else if ( isset( $attributes[ 'blockMeta' ] ) && ! empty( $attributes[ 'blockMeta' ] ) ) { $eb_blocks[ $blockId ] = [ 'blockMeta' => $blockMeta, 'commonStyles' => $commonStyles, 'customCss' => $customCss ]; } } } } return $eb_blocks; } /** * Blockarray to Style Array Function */ public static function blocks_to_style_array( $blocks, $styles = [ ] ) { if ( is_array( $blocks ) && count( $blocks ) > 0 ) { foreach ( $blocks as $blockId => $block ) { if ( 'reusableBlocks' === $blockId ) { if ( is_array( $block ) && count( $block ) > 0 ) { foreach ( $block as $reusableId => $reusableBlock ) { self::blocks_to_style_array( $reusableBlock, $styles ); } } } else { $styles[ $blockId ] = [ 'desktop' => "", 'tab' => "", 'mobile' => "", 'customCss' => "" ]; if ( is_array( $block ) && count( $block ) > 0 ) { foreach ( $block as $value ) { if ( is_array( $value ) && count( $value ) > 0 ) { if ( isset( $value[ "desktop" ] ) ) { $styles[ $blockId ][ "desktop" ] .= $value[ "desktop" ]; } if ( isset( $value[ "tab" ] ) ) { $styles[ $blockId ][ "tab" ] .= $value[ "tab" ]; } if ( isset( $value[ "mobile" ] ) ) { $styles[ $blockId ][ "mobile" ] .= $value[ "mobile" ]; } } else if ( isset( $block[ 'customCss' ] ) && is_string( $block[ 'customCss' ] ) && strlen( $block[ 'customCss' ] ) > 0 ) { $styles[ $blockId ][ "customCss" ] .= $block[ 'customCss' ]; } } } } } } return $styles; } /** * Enqueue frontend css for post if have one * * @param array * * @return string * @since 1.0.2 */ public static function build_css( $style_object ) { $block_styles = $style_object; $css = ''; foreach ( $block_styles as $block_style_key => $block_style ) { if ( ! empty( $block_css = (array) $block_style ) ) { $css .= sprintf( '/* %1$s Starts */', $block_style_key ); foreach ( $block_css as $media => $style ) { switch ( $media ) { case "desktop": $css .= preg_replace( '/\s+/', ' ', $style ); break; case "tab": $css .= ' @media(max-width: ' . self::get_responsive_breakpoints( 'tablet' ) . 'px){'; $css .= preg_replace( '/\s+/', ' ', $style ); $css .= '}'; break; case "mobile": $css .= ' @media(max-width: ' . self::get_responsive_breakpoints( 'mobile' ) . 'px){'; $css .= preg_replace( '/\s+/', ' ', $style ); $css .= '}'; break; case "customCss": $css .= preg_replace( '/\s+/', ' ', $style ); break; } } $css .= sprintf( '/* =%1$s= Ends */', $block_style_key ); } } return trim( $css ); } /** * Helper function to get string between 2 string * @since 3.3.0 */ public static function get_between_data( $string, $start, $end ) { $pos_string = stripos( $string, $start ); $substr_data = substr( $string, $pos_string ); $string_two = substr( $substr_data, strlen( $start ) ); $second_pos = stripos( $string_two, $end ); $string_three = substr( $string_two, 0, $second_pos ); // remove whitespaces from result $result_unit = trim( $string_three ); // return result_unit return $result_unit; } /** * Is Gutenberg Editor */ public static function eb_stylehandler_is_gutenberg_editor( $pagenow, $param ) { if ( $pagenow == 'post-new.php' || $pagenow == 'post.php' || $pagenow == 'site-editor.php' ) { return true; } if ( $pagenow == 'themes.php' && ! empty( $param ) && str_contains( $param, 'gutenberg-edit-site' ) ) { return true; } return false; } }
SILENT KILLER Tool