Add Mobile Detect #65
7 changed files with 2771 additions and 1192 deletions
79
.gitignore
vendored
79
.gitignore
vendored
|
@ -1,2 +1,81 @@
|
|||
vendor
|
||||
composer.lock
|
||||
### Example user template template
|
||||
### Example user template
|
||||
|
||||
# IntelliJ project files
|
||||
.idea
|
||||
*.iml
|
||||
out
|
||||
gen### OSX template
|
||||
*.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/dictionaries
|
||||
.idea/vcs.xml
|
||||
.idea/jsLibraryMappings.xml
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/dataSources.ids
|
||||
.idea/dataSources.xml
|
||||
.idea/dataSources.local.xml
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
.idea/gradle.xml
|
||||
.idea/libraries
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
.idea/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ Many thanks for donations, contributors, supporters, testers & bug reporters:
|
|||
* 7th Veil, LLC
|
||||
* Julia Harsch
|
||||
* Grant Berntsen
|
||||
* [Glaydston Veloso](https://github.com/glaydston)
|
||||
|
||||
== Installation ==
|
||||
|
||||
|
@ -135,6 +136,12 @@ Version numbering logic:
|
|||
* every .B version indicates new features.
|
||||
* every ..C indicates bugfixes for A.B version.
|
||||
|
||||
= 1.12.0 =
|
||||
*2016-11-09*
|
||||
|
||||
* Add new class to detect mobile devices
|
||||
* Create a cache to mobile and desktop version
|
||||
|
||||
= 1.11.1 =
|
||||
*2016-04-21*
|
||||
|
1453
backends/mobile-detect.php
Normal file
1453
backends/mobile-detect.php
Normal file
File diff suppressed because one or more lines are too long
|
@ -227,7 +227,7 @@ abstract class WP_FFPC_ABSTRACT {
|
|||
* callback function to add settings link to plugins page
|
||||
*
|
||||
* @param array $links Current links to add ours to
|
||||
*
|
||||
* @return array $links Current links
|
||||
*/
|
||||
public function plugin_settings_link ( $links ) {
|
||||
$settings_link = '<a href="' . $this->settings_link . '">' . __translate__( 'Settings', 'wp-ffpc') . '</a>';
|
||||
|
@ -359,7 +359,7 @@ abstract class WP_FFPC_ABSTRACT {
|
|||
*
|
||||
* @param mixed $var Variable to dump
|
||||
* @param boolean $ret Return text instead of printing if true
|
||||
*
|
||||
* @return mixed $var Variable to dump
|
||||
*/
|
||||
protected function print_var ( $var , $ret = false ) {
|
||||
if ( @is_array ( $var ) || @is_object( $var ) || @is_bool( $var ) )
|
||||
|
@ -401,7 +401,7 @@ abstract class WP_FFPC_ABSTRACT {
|
|||
* @param $print
|
||||
* boolean: is true, the options will be printed, otherwise the string will be returned
|
||||
*
|
||||
* @return
|
||||
* @return mixed
|
||||
* prints or returns the options string
|
||||
*
|
||||
*/
|
||||
|
@ -594,9 +594,9 @@ abstract class WP_FFPC_ABSTRACT {
|
|||
* display formatted alert message
|
||||
*
|
||||
* @param string $msg Error message
|
||||
* @param string $error "level" of error
|
||||
* @param mixed $level "level" of error
|
||||
* @param boolean $network WordPress network or not, DEPRECATED
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
static public function alert ( $msg, $level=LOG_WARNING, $network=false ) {
|
||||
if ( empty($msg)) return false;
|
||||
|
|
|
@ -145,7 +145,21 @@ if ( $wp_ffpc_backend->status() === false ) {
|
|||
}
|
||||
|
||||
/* try to get data & meta keys for current page */
|
||||
$wp_ffpc_keys = array ( 'meta' => $wp_ffpc_config['prefix_meta'], 'data' => $wp_ffpc_config['prefix_data'] );
|
||||
|
||||
/* include the mobile detect */
|
||||
include_once ('backends/mobile-detect.php');
|
||||
$mobile_detect = new Mobile_Detect;
|
||||
$wp_ffpc_keys = array();
|
||||
|
||||
/* verify if mobile device (phones or tablets). */
|
||||
if($mobile_detect->isMobile()){
|
||||
__wp_ffpc_debug__('Set the ffpc keys to the mobile version');
|
||||
$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_debug__ ( "Trying to fetch entries");
|
||||
|
@ -259,7 +273,7 @@ if ( isset($wp_ffpc_config['generate_time']) && $wp_ffpc_config['generate_time']
|
|||
$mtime = explode ( " ", microtime() );
|
||||
$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>' );
|
||||
|
||||
$wp_ffpc_values['data'] = substr_replace( $wp_ffpc_values['data'], $insertion, $index, 0);
|
||||
|
@ -309,6 +323,8 @@ function wp_ffpc_callback( $buffer ) {
|
|||
global $wp_ffpc_backend;
|
||||
/* check is it's a redirect */
|
||||
global $wp_ffpc_redirect;
|
||||
/* check is it's a mobile version*/
|
||||
global $mobile_detect;
|
||||
|
||||
/* no is_home = error, WordPress functions are not availabe */
|
||||
if (!function_exists('is_home'))
|
||||
|
@ -458,10 +474,15 @@ function wp_ffpc_callback( $buffer ) {
|
|||
/* add generation info is option is set, but only to HTML */
|
||||
if ( $wp_ffpc_config['generate_time'] == '1' && stripos($buffer, '</body>') ) {
|
||||
global $wp_ffpc_gentime;
|
||||
|
||||
/* verify the device type to output into the generation stats */
|
||||
$device_type = $mobile_detect -> isMobile() ? 'mobile': 'desktop';
|
||||
__wp_ffpc_debug__('The device type is: ' . $device_type);
|
||||
|
||||
$mtime = explode ( " ", microtime() );
|
||||
$wp_ffpc_gentime = ( $mtime[1] + $mtime[0] )- $wp_ffpc_gentime;
|
||||
|
||||
$insertion = "\n<!-- WP-FFPC cache generation stats" . "\n\tgeneration time: ". round( $wp_ffpc_gentime, 3 ) ." seconds\n\tgeneraton UNIX timestamp: ". time() . "\n\tgeneraton date: ". date( 'c' ) . "\n\tgenerator server: ". $_SERVER['SERVER_ADDR'] . " -->\n";
|
||||
$insertion = "\n<!-- WP-FFPC cache generation stats" . "\n\tgeneration time: ". round( $wp_ffpc_gentime, 3 ) ." seconds\n\tgeneraton UNIX timestamp: ". time() . "\n\tgeneraton date: ". date( 'c' ) . "\n\tDevice Type: " . $device_type . "\n\tgenerator server: ". $_SERVER['SERVER_ADDR'] . " -->\n";
|
||||
$index = stripos( $buffer , '</body>' );
|
||||
|
||||
$to_store = substr_replace( $buffer, $insertion, $index, 0);
|
||||
|
@ -480,10 +501,10 @@ function wp_ffpc_callback( $buffer ) {
|
|||
*/
|
||||
$to_store = apply_filters( 'wp-ffpc-to-store', $to_store );
|
||||
|
||||
$prefix_meta = $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_meta'] );
|
||||
$prefix_meta = ($mobile_detect -> isMobile())? $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_meta_mobile'] ): $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_meta'] );
|
||||
$wp_ffpc_backend->set ( $prefix_meta, $meta );
|
||||
|
||||
$prefix_data = $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_data'] );
|
||||
$prefix_data = ($mobile_detect -> isMobile())? $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_data_mobile'] ): $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_data'] );
|
||||
$wp_ffpc_backend->set ( $prefix_data , $to_store );
|
||||
|
||||
if ( !empty( $meta['status'] ) && $meta['status'] == 404 ) {
|
||||
|
|
2369
wp-ffpc-class.php
2369
wp-ffpc-class.php
File diff suppressed because it is too large
Load diff
|
@ -3,7 +3,7 @@
|
|||
Plugin Name: WP-FFPC
|
||||
Plugin URI: https://github.com/petermolnar/wp-ffpc
|
||||
Description: WordPress in-memory full page cache plugin
|
||||
Version: 1.11.1
|
||||
Version: 1.12.0
|
||||
Author: Peter Molnar <hello@petermolnar.eu>
|
||||
Author URI: http://petermolnar.eu/
|
||||
License: GPLv3
|
||||
|
@ -44,7 +44,9 @@ $wp_ffpc_defaults = array (
|
|||
'expire_taxonomy' => 300,
|
||||
'invalidation_method' => 0,
|
||||
'prefix_meta' => 'meta-',
|
||||
'prefix_meta_mobile' => 'meta-mobile-',
|
||||
'prefix_data' => 'data-',
|
||||
'prefix_data_mobile' => 'data-mobile-',
|
||||
'charset' => 'utf-8',
|
||||
'log' => true,
|
||||
'cache_type' => 'memcached',
|
||||
|
@ -69,4 +71,4 @@ $wp_ffpc_defaults = array (
|
|||
'hashkey' => false,
|
||||
);
|
||||
|
||||
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.11.2', 'WP-FFPC', $wp_ffpc_defaults, 'PeterMolnar_WordPressPlugins_wp-ffpc_HU' , 'WP-FFPC' , 'FA3NT7XDVHPWU' );
|
||||
$wp_ffpc = new WP_FFPC ( 'wp-ffpc', '1.12.0', 'WP-FFPC', $wp_ffpc_defaults, 'PeterMolnar_WordPressPlugins_wp-ffpc_HU' , 'WP-FFPC' , 'FA3NT7XDVHPWU' );
|
||||
|
|
Loading…
Reference in a new issue