/**
  * Returns true if we can minify
  *
  * @param string  $buffer
  * @return string
  */
 function can_minify2($buffer)
 {
     /**
      * Check for database error
      */
     if (Util_Content::is_database_error($buffer)) {
         $this->minify_reject_reason = 'Database Error occurred';
         return false;
     }
     /**
      * Check for DONOTMINIFY constant
      */
     if (defined('DONOTMINIFY') && DONOTMINIFY) {
         $this->minify_reject_reason = 'DONOTMINIFY constant is defined';
         return false;
     }
     /**
      * Check feed minify
      */
     if ($this->_config->get_boolean('minify.html.reject.feed') && function_exists('is_feed') && is_feed()) {
         $this->minify_reject_reason = 'Feed is rejected';
         return false;
     }
     return true;
 }
 /**
  * Output buffering callback
  *
  * @param string  $buffer
  * @return string
  */
 function ob_callback($buffer)
 {
     global $wpdb;
     global $w3_late_caching_succeeded;
     if ($w3_late_caching_succeeded) {
         return $buffer;
     }
     if (Util_Content::is_database_error($buffer)) {
         status_header(503);
     } else {
         if (Util_Content::can_print_comment($buffer)) {
             /**
              * Add footer comment
              */
             $date = date_i18n('Y-m-d H:i:s');
             $host = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost';
             if (Util_Environment::is_preview_mode()) {
                 $buffer .= "\r\n<!-- W3 Total Cache used in preview mode -->";
             }
             if ($this->_config->get_string('common.support') != '' || $this->_config->get_boolean('common.tweeted')) {
                 $buffer .= sprintf("\r\n<!-- Served from: %s @ %s by W3 Total Cache -->", Util_Content::escape_comment($host), $date);
             } else {
                 $strings = array();
                 $strings = apply_filters('w3tc_footer_comment', $strings);
                 $buffer .= "\r\n<!-- Performance optimized by W3 Total Cache. Learn more: https://www.w3-edge.com/products/\r\n";
                 if (count($strings)) {
                     $buffer .= "\r\n" . Util_Content::escape_comment(implode("\r\n", $strings)) . "\r\n";
                 }
                 $buffer .= sprintf("\r\n Served from: %s @ %s by W3 Total Cache -->", Util_Content::escape_comment($host), $date);
             }
         }
         $buffer = Util_Bus::do_ob_callbacks(array('minify', 'newrelic', 'cdn', 'browsercache', 'pagecache'), $buffer);
     }
     return $buffer;
 }
Beispiel #3
0
 /**
  * Returns true if we can do CDN logic
  *
  * @param unknown $buffer
  * @return string
  */
 function can_cdn2($buffer)
 {
     /**
      * Check for database error
      */
     if (Util_Content::is_database_error($buffer)) {
         $this->cdn_reject_reason = 'Database Error occurred';
         return false;
     }
     /**
      * Check for DONOTCDN constant
      */
     if (defined('DONOTCDN') && DONOTCDN) {
         $this->cdn_reject_reason = 'DONOTCDN constant is defined';
         return false;
     }
     /**
      * Check logged users roles
      */
     if ($this->_config->get_boolean('cdn.reject.logged_roles') && !$this->_check_logged_in_role_allowed()) {
         $this->cdn_reject_reason = 'logged in role is rejected';
         return false;
     }
     return true;
 }
 /**
  * Checks if can we do cache logic
  *
  * @param string  $buffer
  * @return boolean
  */
 function _can_cache2($buffer)
 {
     /**
      * Skip if caching is disabled
      */
     if (!$this->_caching) {
         return false;
     }
     /**
      * Check for database error
      */
     if (Util_Content::is_database_error($buffer)) {
         $this->cache_reject_reason = 'Database error occurred';
         return false;
     }
     /**
      * Check for DONOTCACHEPAGE constant
      */
     if (defined('DONOTCACHEPAGE') && DONOTCACHEPAGE) {
         $this->cache_reject_reason = 'DONOTCACHEPAGE constant is defined';
         return false;
     }
     /**
      * Don't cache 404 pages
      */
     if (!$this->_config->get_boolean('pgcache.cache.404') && function_exists('is_404') && is_404()) {
         $this->cache_reject_reason = 'Page is 404';
         return false;
     }
     /**
      * Don't cache homepage
      */
     if (!$this->_config->get_boolean('pgcache.cache.home') && function_exists('is_home') && is_home()) {
         $this->cache_reject_reason = is_front_page() && is_home() ? 'Page is front page' : 'Page is posts page';
         return false;
     }
     /**
      * Don't cache front page
      */
     if ($this->_config->get_boolean('pgcache.reject.front_page') && function_exists('is_front_page') && is_front_page() && !is_home()) {
         $this->cache_reject_reason = 'Page is front page';
         return false;
     }
     /**
      * Don't cache feed
      */
     if (!$this->_config->get_boolean('pgcache.cache.feed') && function_exists('is_feed') && is_feed()) {
         $this->cache_reject_reason = 'Page is feed';
         return false;
     }
     /**
      * Check if page contains dynamic tags
      */
     if ($this->_enhanced_mode && $this->_has_dynamic($buffer)) {
         $this->cache_reject_reason = 'Page contains dynamic tags (mfunc or mclude) can not be cached in enhanced mode';
         return false;
     }
     return true;
 }