Server IP : 104.21.14.103 / Your IP : 3.145.50.124 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/home/giankuin/dietcontrungnhanh.com/wp-content/plugins/perfmatters/inc/classes/ |
Upload File : |
<?php namespace Perfmatters; class Buffer { //initialize buffer class public static function init() { add_action('perfmatters_queue', array('Perfmatters\Buffer', 'queue')); } //queue functions public static function queue() { //buffer is allowed if(!apply_filters('perfmatters_allow_buffer', true)) { return; } //add buffer action add_action('template_redirect', array('Perfmatters\Buffer', 'start'), -9999); } //start buffer public static function start() { if(has_filter('perfmatters_output_buffer_template_redirect')) { //exclude certain requests if(is_embed() || is_feed() || is_preview() || is_customize_preview()) { return; } //don't buffer amp if(function_exists('is_amp_endpoint') && is_amp_endpoint()) { return; } ob_start(function($html) { //check for valid buffer if(!self::is_valid_buffer($html)) { return $html; } //run buffer filters $html = (string) apply_filters('perfmatters_output_buffer_template_redirect', $html); //return processed html return $html; }); } } //make sure buffer content is valid private static function is_valid_buffer($html) { //check for valid/invalid tags if(stripos($html, '<html') === false || stripos($html, '</body>') === false || stripos($html, '<xsl:stylesheet') !== false) { return false; } //check for invalid urls $current_url = home_url($_SERVER['REQUEST_URI']); $matches = apply_filters('perfmatters_buffer_excluded_extensions', array('.xml', '.txt', '.php')); foreach($matches as $match) { if(stripos($current_url, $match) !== false) { return false; } } return true; } }