function generate_custom_css_precompiled() { if ($this->is_plugin_deactivated_on()) { return; } $cache_key = "essb-precompiled"; $cached_data = ESSBPrecompiledResources::get_resource($cache_key, 'css'); if ($cached_data != '') { echo "<link rel='stylesheet' id='essb-compiled-css' href='" . $cached_data . "' type='text/css' media='all' />"; return; } // generation of all styles $this->add_css(ESSBResourceBuilderSnippets::css_build_customizer(), 'essb-customcss-header'); $this->add_css(ESSBResourceBuilderSnippets::css_build_footer_css(), 'essb-footer-css', 'footer'); $static_content = array(); $styles = array(); if (count($this->css_head) > 0) { $css_code = implode(" ", $this->css_head); $css_code = trim(preg_replace('/\\s+/', ' ', $css_code)); $styles[] = $css_code; } if (count($this->css_footer) > 0) { $css_code = implode(" ", $this->css_footer); $css_code = trim(preg_replace('/\\s+/', ' ', $css_code)); $styles[] = $css_code; } // parsing inlinde enqueue styles $current_site_url = get_site_url(); foreach ($this->precompiled_css_queue as $key => $file) { $relative_path = ESSBPrecompiledResources::get_asset_relative_path($current_site_url, $file); $css_code = file_get_contents(ABSPATH . $relative_path); $css_code = trim(preg_replace('/\\s+/', ' ', $css_code)); if ($key == "essb-social-image-share") { $css_code = str_replace('../', ESSB3_PLUGIN_URL . '/lib/modules/social-image-share/assets/', $css_code); } if ($key == "easy-social-share-buttons-profiles") { $css_code = str_replace('../', ESSB3_PLUGIN_URL . '/assets/', $css_code); } if ($key == "essb-social-followers-counter") { $css_code = str_replace('../', ESSB3_PLUGIN_URL . '/lib/modules/social-followers-counter/assets/', $css_code); } $styles[] = $css_code; $static_content[$key] = $file; } foreach ($this->css_static_footer as $key => $file) { $relative_path = ESSBPrecompiledResources::get_asset_relative_path($current_site_url, $file); $css_code = file_get_contents(ABSPATH . $relative_path); $css_code = trim(preg_replace('/\\s+/', ' ', $css_code)); if ($key == "essb-social-image-share") { $css_code = str_replace('../', ESSB3_PLUGIN_URL . '/lib/modules/social-image-share/assets/', $css_code); } if ($key == "easy-social-share-buttons-profiles") { $css_code = str_replace('../', ESSB3_PLUGIN_URL . '/assets/', $css_code); } if ($key == "essb-social-followers-counter") { $css_code = str_replace('../', ESSB3_PLUGIN_URL . '/lib/modules/social-followers-counter/assets/', $css_code); } $styles[] = $css_code; $static_content[$key] = $file; } $toc = array(); foreach ($static_content as $handle => $item_content) { $toc[] = sprintf(' - %s', $handle . '-' . $item_content); } $styles[] = sprintf("\n\n\n/* TOC:\n%s\n*/", implode("\n", $toc)); ESSBPrecompiledResources::put_resource($cache_key, implode(' ', $styles), 'css'); $cached_data = ESSBPrecompiledResources::get_resource($cache_key, 'css'); if ($cached_data != '') { echo "<link rel='stylesheet' id='essb-compiled-css' href='" . $cached_data . "' type='text/css' media='all' />"; return; } }
/** * generate_custom_css */ function generate_custom_css() { global $post; if ($this->is_plugin_deactivated_on()) { return; } $this->add_css(ESSBResourceBuilderSnippets::css_build_customizer(), 'essb-customcss-header'); $cache_slug = "essb-css-head"; if (isset($post)) { if (defined('ESSB3_CACHE_ACTIVE_RESOURCE')) { $cache_key = $cache_slug . $post->ID; $cached_data = ESSBDynamicCache::get_resource($cache_key, 'css'); if ($cached_data != '') { echo "<link rel='stylesheet' id='essb-cache-css-head' href='" . $cached_data . "' type='text/css' media='all' />"; return; } } } if (count($this->css_head) > 0) { $css_code = implode(" ", $this->css_head); $css_code = trim(preg_replace('/\\s+/', ' ', $css_code)); if (isset($post)) { if (defined('ESSB3_CACHE_ACTIVE_RESOURCE')) { $cache_key = $cache_slug . $post->ID; ESSBDynamicCache::put_resource($cache_key, $css_code, 'css'); $cached_data = ESSBDynamicCache::get_resource($cache_key, 'css'); if ($cached_data != '') { echo "<link rel='stylesheet' id='essb-cache-css-head' href='" . $cached_data . "' type='text/css' media='all' />"; return; } } } echo '<style type="text/css">'; echo $css_code; echo '</style>'; } }