get_data($handle, 'phast_no_defer')) { return $tag; } return preg_replace('~]*>\s*(/\*.*?\*/)?\s*var\s+SlimStatParams\s*=)~', '$1 data-phast-no-defer$2', $chunk); }, 8192); }); // Don't delay Google Site Kit Analytics. add_filter('wp_print_scripts', function () { wp_scripts()->add_data('google_gtagjs', 'phast_no_defer', true); }); // Don't delay GA Google Analytics script. add_filter('ga_google_analytics_script_atts_ext', function ($atts) { return $atts . ' data-phast-no-defer'; }); add_filter('ga_google_analytics_script_atts', function ($atts) { return $atts . ' data-phast-no-defer'; }); $sdk = phastpress_get_plugin_sdk(); $handler = $sdk->getPhastAPI()->deployOutputBufferForDocument(); // Allow disabling PhastPress with hook. add_filter('template_redirect', function () use ($handler) { if (apply_filters('phastpress_disable', false)) { $handler->cancel(); } }, 100); $plugin_config = $sdk->getPluginConfiguration(); $display_footer = $plugin_config->shouldDisplayFooter(); if ($display_footer) { add_action('wp_head', 'phastpress_render_footer_css', 0, 2); add_action('wp_footer', 'phastpress_render_footer'); } } function phastpress_render_footer_css() { echo << STYLE; } function phastpress_render_footer() { echo ''; }