Add logs to the mobile detect
This commit is contained in:
parent
65b7f20ed2
commit
cd968726fb
3 changed files with 1213 additions and 1206 deletions
|
@ -70,7 +70,7 @@ else {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no cache for WooCommerce URL patterns */
|
/* no cache for WooCommerce URL patterns */
|
||||||
if ( isset($wp_ffpc_config['nocache_woocommerce']) && !empty($wp_ffpc_config['nocache_woocommerce']) &&
|
if ( isset($wp_ffpc_config['nocache_woocommerce']) && !empty($wp_ffpc_config['nocache_woocommerce']) &&
|
||||||
isset($wp_ffpc_config['nocache_woocommerce_url']) && trim($wp_ffpc_config['nocache_woocommerce_url']) ) {
|
isset($wp_ffpc_config['nocache_woocommerce_url']) && trim($wp_ffpc_config['nocache_woocommerce_url']) ) {
|
||||||
$pattern = sprintf('#%s#', trim($wp_ffpc_config['nocache_woocommerce_url']));
|
$pattern = sprintf('#%s#', trim($wp_ffpc_config['nocache_woocommerce_url']));
|
||||||
if ( preg_match($pattern, $wp_ffpc_uri) ) {
|
if ( preg_match($pattern, $wp_ffpc_uri) ) {
|
||||||
|
@ -149,10 +149,16 @@ if ( $wp_ffpc_backend->status() === false ) {
|
||||||
/* include the mobile detect */
|
/* include the mobile detect */
|
||||||
include_once ('backends/mobile-detect.php');
|
include_once ('backends/mobile-detect.php');
|
||||||
$mobile_detect = new Mobile_Detect;
|
$mobile_detect = new Mobile_Detect;
|
||||||
|
$wp_ffpc_keys = array();
|
||||||
|
|
||||||
/* verify if mobile device (phones or tablets). */
|
/* verify if mobile device (phones or tablets). */
|
||||||
$wp_ffpc_keys = $mobile_detect->isMobile() ?
|
if($mobile_detect->isMobile()){
|
||||||
array ( 'meta' => $wp_ffpc_config['prefix_meta_mobile'], 'data' => $wp_ffpc_config['prefix_data_mobile'] ) :
|
__wp_ffpc_debug__('Set the ffpc keys to the mobile version');
|
||||||
array ( 'meta' => $wp_ffpc_config['prefix_meta'], 'data' => $wp_ffpc_config['prefix_data']);
|
$wp_ffpc_keys = array ( 'meta' => $wp_ffpc_config['prefix_meta_mobile'], 'data' => $wp_ffpc_config['prefix_data_mobile'] );
|
||||||
|
} else {
|
||||||
|
__wp_ffpc_debug__('Set the ffpc keys to the desktop version');
|
||||||
|
$wp_ffpc_keys = array( 'meta' => $wp_ffpc_config['prefix_meta'], 'data' => $wp_ffpc_config['prefix_data'] );
|
||||||
|
}
|
||||||
|
|
||||||
$wp_ffpc_values = array();
|
$wp_ffpc_values = array();
|
||||||
|
|
||||||
|
@ -267,7 +273,7 @@ if ( isset($wp_ffpc_config['generate_time']) && $wp_ffpc_config['generate_time']
|
||||||
$mtime = explode ( " ", microtime() );
|
$mtime = explode ( " ", microtime() );
|
||||||
$wp_ffpc_gentime = ( $mtime[1] + $mtime[0] ) - $wp_ffpc_gentime;
|
$wp_ffpc_gentime = ( $mtime[1] + $mtime[0] ) - $wp_ffpc_gentime;
|
||||||
|
|
||||||
$insertion = "\n<!-- WP-FFPC cache output stats\n\tcache engine: ". $wp_ffpc_config['cache_type'] ."\n\tUNIX timestamp: ". time() . "\n\tdate: ". date( 'c' ) . "\n\tfrom server: ". $_SERVER['SERVER_ADDR'] . " -->\n";
|
$insertion = "\n<!-- \n\tCache Engine: ". $wp_ffpc_config['cache_type'] ."\n\tDate: ". date( 'c' ) . " -->\n";
|
||||||
$index = stripos( $wp_ffpc_values['data'] , '</body>' );
|
$index = stripos( $wp_ffpc_values['data'] , '</body>' );
|
||||||
|
|
||||||
$wp_ffpc_values['data'] = substr_replace( $wp_ffpc_values['data'], $insertion, $index, 0);
|
$wp_ffpc_values['data'] = substr_replace( $wp_ffpc_values['data'], $insertion, $index, 0);
|
||||||
|
@ -317,8 +323,8 @@ function wp_ffpc_callback( $buffer ) {
|
||||||
global $wp_ffpc_backend;
|
global $wp_ffpc_backend;
|
||||||
/* check is it's a redirect */
|
/* check is it's a redirect */
|
||||||
global $wp_ffpc_redirect;
|
global $wp_ffpc_redirect;
|
||||||
/* check is it's a mobile version*/
|
/* check is it's a mobile version*/
|
||||||
global $mobile_detect;
|
global $mobile_detect;
|
||||||
|
|
||||||
/* no is_home = error, WordPress functions are not availabe */
|
/* no is_home = error, WordPress functions are not availabe */
|
||||||
if (!function_exists('is_home'))
|
if (!function_exists('is_home'))
|
||||||
|
@ -469,8 +475,9 @@ function wp_ffpc_callback( $buffer ) {
|
||||||
if ( $wp_ffpc_config['generate_time'] == '1' && stripos($buffer, '</body>') ) {
|
if ( $wp_ffpc_config['generate_time'] == '1' && stripos($buffer, '</body>') ) {
|
||||||
global $wp_ffpc_gentime;
|
global $wp_ffpc_gentime;
|
||||||
|
|
||||||
/* verify the device type to output into the generation stats */
|
/* verify the device type to output into the generation stats */
|
||||||
$device_type = $mobile_detect -> isMobile() ? 'mobile': 'desktop';
|
$device_type = $mobile_detect -> isMobile() ? 'mobile': 'desktop';
|
||||||
|
__wp_ffpc_debug__('The device type is: ' . $device_type);
|
||||||
|
|
||||||
$mtime = explode ( " ", microtime() );
|
$mtime = explode ( " ", microtime() );
|
||||||
$wp_ffpc_gentime = ( $mtime[1] + $mtime[0] )- $wp_ffpc_gentime;
|
$wp_ffpc_gentime = ( $mtime[1] + $mtime[0] )- $wp_ffpc_gentime;
|
||||||
|
|
2388
wp-ffpc-class.php
2388
wp-ffpc-class.php
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
||||||
Plugin Name: WP-FFPC
|
Plugin Name: WP-FFPC
|
||||||
Plugin URI: https://github.com/petermolnar/wp-ffpc
|
Plugin URI: https://github.com/petermolnar/wp-ffpc
|
||||||
Description: WordPress in-memory full page cache plugin
|
Description: WordPress in-memory full page cache plugin
|
||||||
Version: 1.11.1
|
Version: 1.12.0
|
||||||
Author: Peter Molnar <hello@petermolnar.eu>
|
Author: Peter Molnar <hello@petermolnar.eu>
|
||||||
Author URI: http://petermolnar.eu/
|
Author URI: http://petermolnar.eu/
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
|
@ -44,9 +44,9 @@ $wp_ffpc_defaults = array (
|
||||||
'expire_taxonomy' => 300,
|
'expire_taxonomy' => 300,
|
||||||
'invalidation_method' => 0,
|
'invalidation_method' => 0,
|
||||||
'prefix_meta' => 'meta-',
|
'prefix_meta' => 'meta-',
|
||||||
'prefix_meta_mobile' => 'meta-mobile-',
|
'prefix_meta_mobile' => 'meta-mobile-',
|
||||||
'prefix_data' => 'data-',
|
'prefix_data' => 'data-',
|
||||||
'prefix_data_mobile' => 'data-mobile-',
|
'prefix_data_mobile' => 'data-mobile-',
|
||||||
'charset' => 'utf-8',
|
'charset' => 'utf-8',
|
||||||
'log' => true,
|
'log' => true,
|
||||||
'cache_type' => 'memcached',
|
'cache_type' => 'memcached',
|
||||||
|
|
Loading…
Reference in a new issue