Cache Enabler – WordPress Cache - Version 1.3.2

Version Description

  • Changed to page specific as new default
  • Added regex setting for analytics tags in get variables
  • Fixed 304 responses
Download this release

Release Info

Developer keycdn
Plugin Icon 128x128 Cache Enabler – WordPress Cache
Version 1.3.2
Comparing to
See all releases

Code changes from version 1.3.1 to 1.3.2

advanced-cache.php CHANGED
@@ -40,9 +40,18 @@ if ( !empty($settings['excl_regexp']) ) {
40
  }
41
  }
42
 
43
- // check if request with query strings
44
- if ( ! empty($_GET) && ! isset( $_GET['utm_source'], $_GET['utm_medium'], $_GET['utm_campaign'] ) ) {
45
- return false;
 
 
 
 
 
 
 
 
 
46
  }
47
 
48
  // check cookie values
@@ -107,7 +116,7 @@ if ( function_exists( 'apache_request_headers' ) ) {
107
  }
108
 
109
  // check modified since with cached file and return 304 if no difference
110
- if ( $http_if_modified_since && ( strtotime( $http_if_modified_since ) <= filemtime( $path_html ) ) ) {
111
  header( $_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified', true, 304 );
112
  exit;
113
  }
40
  }
41
  }
42
 
43
+ // check GET variables
44
+ if ( !empty($_GET) ) {
45
+ // set regex of analytics campaign tags that shall not prevent caching
46
+ if ( !empty($settings['incl_attributes']) ) {
47
+ $attributes_regex = $settings['incl_attributes'];
48
+ } else {
49
+ $attributes_regex = '/^utm_(source|medium|campaign|term|content)$/';
50
+ }
51
+ // prevent cache use if there is any GET variable not covered by the campaign tag regex
52
+ if ( sizeof( preg_grep( $attributes_regex, array_keys( $_GET ), PREG_GREP_INVERT ) ) > 0 ) {
53
+ return false;
54
+ }
55
  }
56
 
57
  // check cookie values
116
  }
117
 
118
  // check modified since with cached file and return 304 if no difference
119
+ if ( $http_if_modified_since && ( strtotime( $http_if_modified_since ) >= filemtime( $path_html ) ) ) {
120
  header( $_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified', true, 304 );
121
  exit;
122
  }
cache-enabler.php CHANGED
@@ -6,7 +6,7 @@ Description: Simple and fast WordPress disk caching plugin.
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
- Version: 1.3.1
10
  */
11
 
12
  /*
6
  Author: KeyCDN
7
  Author URI: https://www.keycdn.com
8
  License: GPLv2 or later
9
+ Version: 1.3.2
10
  */
11
 
12
  /*
inc/cache_enabler.class.php CHANGED
@@ -6,40 +6,40 @@ defined('ABSPATH') OR exit;
6
 
7
 
8
  /**
9
- * Cache_Enabler
10
- *
11
- * @since 1.0.0
12
- */
13
 
14
  final class Cache_Enabler {
15
 
16
 
17
  /**
18
- * plugin options
19
- *
20
- * @since 1.0.0
21
- * @var array
22
- */
23
 
24
  public static $options;
25
 
26
 
27
  /**
28
- * disk cache object
29
- *
30
- * @since 1.0.0
31
- * @var object
32
- */
33
 
34
  private static $disk;
35
 
36
 
37
  /**
38
- * minify default settings
39
- *
40
- * @since 1.0.0
41
- * @var integer
42
- */
43
 
44
  const MINIFY_DISABLED = 0;
45
  const MINIFY_HTML_ONLY = 1;
@@ -47,11 +47,11 @@ final class Cache_Enabler {
47
 
48
 
49
  /**
50
- * constructor wrapper
51
- *
52
- * @since 1.0.0
53
- * @change 1.0.0
54
- */
55
 
56
  public static function instance()
57
  {
@@ -60,14 +60,14 @@ final class Cache_Enabler {
60
 
61
 
62
  /**
63
- * constructor
64
- *
65
- * @since 1.0.0
66
- * @change 1.2.3
67
- *
68
- * @param void
69
- * @return void
70
- */
71
 
72
  public function __construct()
73
  {
@@ -162,6 +162,24 @@ final class Cache_Enabler {
162
  10,
163
  1
164
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
 
166
  // add admin clear link
167
  add_action(
@@ -334,11 +352,11 @@ final class Cache_Enabler {
334
 
335
 
336
  /**
337
- * deactivation hook
338
- *
339
- * @since 1.0.0
340
- * @change 1.1.1
341
- */
342
 
343
  public static function on_deactivation() {
344
  self::clear_total_cache(true);
@@ -354,11 +372,11 @@ final class Cache_Enabler {
354
 
355
 
356
  /**
357
- * activation hook
358
- *
359
- * @since 1.0.0
360
- * @change 1.1.1
361
- */
362
 
363
  public static function on_activation() {
364
 
@@ -427,11 +445,11 @@ final class Cache_Enabler {
427
 
428
 
429
  /**
430
- * install on multisite setup
431
- *
432
- * @since 1.0.0
433
- * @change 1.0.0
434
- */
435
 
436
  public static function install_later($id) {
437
 
@@ -452,11 +470,11 @@ final class Cache_Enabler {
452
 
453
 
454
  /**
455
- * installation options
456
- *
457
- * @since 1.0.0
458
- * @change 1.0.0
459
- */
460
 
461
  private static function _install_backend() {
462
 
@@ -471,11 +489,11 @@ final class Cache_Enabler {
471
 
472
 
473
  /**
474
- * installation WP_CACHE (advanced cache)
475
- *
476
- * @since 1.1.1
477
- * @change 1.1.1
478
- */
479
 
480
  private static function _set_wp_cache($wp_cache_value = true) {
481
  $wp_config_file = ABSPATH . 'wp-config.php';
@@ -518,11 +536,11 @@ final class Cache_Enabler {
518
 
519
 
520
  /**
521
- * uninstall per multisite blog
522
- *
523
- * @since 1.0.0
524
- * @change 1.0.0
525
- */
526
 
527
  public static function on_uninstall() {
528
  global $wpdb;
@@ -550,11 +568,11 @@ final class Cache_Enabler {
550
 
551
 
552
  /**
553
- * uninstall for multisite and network
554
- *
555
- * @since 1.0.0
556
- * @change 1.0.0
557
- */
558
 
559
  public static function uninstall_later($id) {
560
 
@@ -575,11 +593,11 @@ final class Cache_Enabler {
575
 
576
 
577
  /**
578
- * uninstall
579
- *
580
- * @since 1.0.0
581
- * @change 1.0.0
582
- */
583
 
584
  private static function _uninstall_backend() {
585
 
@@ -592,13 +610,13 @@ final class Cache_Enabler {
592
 
593
 
594
  /**
595
- * get blog ids
596
- *
597
- * @since 1.0.0
598
- * @change 1.0.0
599
- *
600
- * @return array blog ids array
601
- */
602
 
603
  private static function _get_blog_ids() {
604
  global $wpdb;
@@ -608,11 +626,11 @@ final class Cache_Enabler {
608
 
609
 
610
  /**
611
- * set default vars
612
- *
613
- * @since 1.0.0
614
- * @change 1.0.0
615
- */
616
 
617
  private static function _set_default_vars() {
618
 
@@ -627,13 +645,13 @@ final class Cache_Enabler {
627
 
628
 
629
  /**
630
- * get options
631
- *
632
- * @since 1.0.0
633
- * @change 1.2.3
634
- *
635
- * @return array options array
636
- */
637
 
638
  private static function _get_options() {
639
 
@@ -659,6 +677,7 @@ final class Cache_Enabler {
659
  'excl_ids' => '',
660
  'excl_regexp' => '',
661
  'excl_cookies' => '',
 
662
  'minify_html' => self::MINIFY_DISABLED,
663
  )
664
  );
@@ -666,36 +685,36 @@ final class Cache_Enabler {
666
 
667
 
668
  /**
669
- * warning if no custom permlinks
670
- *
671
- * @since 1.0.0
672
- * @change 1.0.0
673
- *
674
- * @return array options array
675
- */
676
 
677
  public static function warning_is_permalink() {
678
 
679
- if ( !Cache_Enabler_Disk::is_permalink() AND current_user_can('manage_options') ) { ?>
680
 
681
  <div class="error">
682
  <p><?php printf( __('The <b>%s</b> plugin requires a custom permalink structure to start caching properly. Please go to <a href="%s">Permalink</a> to enable it.', 'cache-enabler'), 'Cache Enabler', admin_url( 'options-permalink.php' ) ); ?></p>
683
  </div>
684
 
685
- <?php
686
  }
687
  }
688
 
689
 
690
  /**
691
- * add action links
692
- *
693
- * @since 1.0.0
694
- * @change 1.0.0
695
- *
696
- * @param array $data existing links
697
- * @return array $data appended links
698
- */
699
 
700
  public static function action_links($data) {
701
 
@@ -723,15 +742,15 @@ final class Cache_Enabler {
723
 
724
 
725
  /**
726
- * cache enabler meta links
727
- *
728
- * @since 1.0.0
729
- * @change 1.0.0
730
- *
731
- * @param array $input existing links
732
- * @param string $page page
733
- * @return array $data appended links
734
- */
735
 
736
  public static function row_meta($input, $page) {
737
 
@@ -750,14 +769,14 @@ final class Cache_Enabler {
750
 
751
 
752
  /**
753
- * add dashboard cache size count
754
- *
755
- * @since 1.0.0
756
- * @change 1.1.0
757
- *
758
- * @param array $items initial array with dashboard items
759
- * @return array $items merged array with dashboard items
760
- */
761
 
762
  public static function add_dashboard_count( $items = array() ) {
763
 
@@ -788,25 +807,25 @@ final class Cache_Enabler {
788
 
789
 
790
  /**
791
- * get cache size
792
- *
793
- * @since 1.0.0
794
- * @change 1.0.0
795
- *
796
- * @param integer $size cache size (bytes)
797
- */
798
 
799
  public static function get_cache_size() {
800
 
801
  if ( ! $size = get_transient('cache_size') ) {
802
 
803
- $size = (int) self::$disk->cache_size(CE_CACHE_DIR);
804
 
805
  // set transient
806
  set_transient(
807
- 'cache_size',
808
- $size,
809
- 60 * 15
810
  );
811
  }
812
 
@@ -815,15 +834,15 @@ final class Cache_Enabler {
815
 
816
 
817
  /**
818
- * add admin links
819
- *
820
- * @since 1.0.0
821
- * @change 1.1.0
822
- *
823
- * @hook mixed
824
- *
825
- * @param object menu properties
826
- */
827
 
828
  public static function add_admin_links($wp_admin_bar) {
829
 
@@ -859,13 +878,13 @@ final class Cache_Enabler {
859
 
860
 
861
  /**
862
- * process clear request
863
- *
864
- * @since 1.0.0
865
- * @change 1.1.0
866
- *
867
- * @param array $data array of metadata
868
- */
869
 
870
  public static function process_clear_request($data) {
871
 
@@ -977,13 +996,13 @@ final class Cache_Enabler {
977
 
978
 
979
  /**
980
- * notification after clear cache
981
- *
982
- * @since 1.0.0
983
- * @change 1.0.0
984
- *
985
- * @hook mixed user_can_clear_cache
986
- */
987
 
988
  public static function clear_notice() {
989
 
@@ -1000,14 +1019,14 @@ final class Cache_Enabler {
1000
 
1001
 
1002
  /**
1003
- * clear cache if post comment
1004
- *
1005
- * @since 1.2.0
1006
- * @change 1.2.0
1007
- *
1008
- * @param integer $id id of the comment
1009
- * @param mixed $approved approval status
1010
- */
1011
 
1012
  public static function comment_post($id, $approved) {
1013
 
@@ -1025,13 +1044,13 @@ final class Cache_Enabler {
1025
 
1026
 
1027
  /**
1028
- * clear cache if edit comment
1029
- *
1030
- * @since 1.0.0
1031
- * @change 1.0.0
1032
- *
1033
- * @param integer $id id of the comment
1034
- */
1035
 
1036
  public static function edit_comment($id) {
1037
 
@@ -1047,15 +1066,15 @@ final class Cache_Enabler {
1047
 
1048
 
1049
  /**
1050
- * clear cache if new comment
1051
- *
1052
- * @since 1.0.0
1053
- * @change 1.0.0
1054
- *
1055
- * @param mixed $approved approval status
1056
- * @param array $comment
1057
- * @return mixed $approved approval status
1058
- */
1059
 
1060
  public static function new_comment($approved, $comment) {
1061
 
@@ -1073,15 +1092,15 @@ final class Cache_Enabler {
1073
 
1074
 
1075
  /**
1076
- * clear cache if comment changes
1077
- *
1078
- * @since 1.0.0
1079
- * @change 1.0.0
1080
- *
1081
- * @param string $after_status
1082
- * @param string $before_status
1083
- * @param object $comment
1084
- */
1085
 
1086
  public static function change_comment($after_status, $before_status, $comment) {
1087
 
@@ -1097,14 +1116,14 @@ final class Cache_Enabler {
1097
 
1098
 
1099
  /**
1100
- * register publish hooks for custom post types
1101
- *
1102
- * @since 1.0.0
1103
- * @since 1.2.3
1104
- *
1105
- * @param void
1106
- * @return void
1107
- */
1108
 
1109
  public static function register_publish_hooks() {
1110
 
@@ -1145,13 +1164,13 @@ final class Cache_Enabler {
1145
 
1146
 
1147
  /**
1148
- * delete post type cache on post updates
1149
- *
1150
- * @since 1.0.0
1151
- * @change 1.0.7
1152
- *
1153
- * @param integer $post_ID Post ID
1154
- */
1155
 
1156
  public static function publish_post_types($post_ID, $post) {
1157
 
@@ -1207,13 +1226,13 @@ final class Cache_Enabler {
1207
 
1208
 
1209
  /**
1210
- * clear page cache by post id
1211
- *
1212
- * @since 1.0.0
1213
- * @change 1.0.0
1214
- *
1215
- * @param integer $post_ID Post ID
1216
- */
1217
 
1218
  public static function clear_page_cache_by_post_id($post_ID) {
1219
 
@@ -1230,13 +1249,13 @@ final class Cache_Enabler {
1230
 
1231
 
1232
  /**
1233
- * clear page cache by url
1234
- *
1235
- * @since 1.0.0
1236
- * @change 1.2.3
1237
- *
1238
- * @param string $url url of a page
1239
- */
1240
 
1241
  public static function clear_page_cache_by_url($url) {
1242
 
@@ -1259,12 +1278,12 @@ final class Cache_Enabler {
1259
 
1260
 
1261
  /**
1262
- * clear home page cache
1263
- *
1264
- * @since 1.0.7
1265
- * @change 1.2.3
1266
- *
1267
- */
1268
 
1269
  public static function clear_home_page_cache() {
1270
 
@@ -1281,13 +1300,13 @@ final class Cache_Enabler {
1281
 
1282
 
1283
  /**
1284
- * check if index.php
1285
- *
1286
- * @since 1.0.0
1287
- * @change 1.0.0
1288
- *
1289
- * @return boolean true if index.php
1290
- */
1291
 
1292
  private static function _is_index() {
1293
  return strtolower(basename($_SERVER['SCRIPT_NAME'])) != 'index.php';
@@ -1295,13 +1314,13 @@ final class Cache_Enabler {
1295
 
1296
 
1297
  /**
1298
- * check if mobile
1299
- *
1300
- * @since 1.0.0
1301
- * @change 1.0.0
1302
- *
1303
- * @return boolean true if mobile
1304
- */
1305
 
1306
  private static function _is_mobile() {
1307
  return ( strpos(TEMPLATEPATH, 'wptouch') OR strpos(TEMPLATEPATH, 'carrington') OR strpos(TEMPLATEPATH, 'jetpack') OR strpos(TEMPLATEPATH, 'handheld') );
@@ -1309,13 +1328,13 @@ final class Cache_Enabler {
1309
 
1310
 
1311
  /**
1312
- * check if logged in
1313
- *
1314
- * @since 1.0.0
1315
- * @change 1.0.0
1316
- *
1317
- * @return boolean true if logged in or cookie set
1318
- */
1319
 
1320
  private static function _is_logged_in() {
1321
 
@@ -1346,13 +1365,13 @@ final class Cache_Enabler {
1346
 
1347
 
1348
  /**
1349
- * check if there are post to be published in the future
1350
- *
1351
- * @since 1.2.3
1352
- *
1353
- * @return void
1354
- *
1355
- */
1356
 
1357
  public static function check_future_posts() {
1358
 
@@ -1370,15 +1389,15 @@ final class Cache_Enabler {
1370
 
1371
 
1372
  /**
1373
- * check to bypass the cache
1374
- *
1375
- * @since 1.0.0
1376
- * @change 1.2.3
1377
- *
1378
- * @return boolean true if exception
1379
- *
1380
- * @hook boolean bypass cache
1381
- */
1382
 
1383
  private static function _bypass_cache() {
1384
 
@@ -1441,16 +1460,16 @@ final class Cache_Enabler {
1441
 
1442
 
1443
  /**
1444
- * minify html
1445
- *
1446
- * @since 1.0.0
1447
- * @change 1.0.0
1448
- *
1449
- * @param string $data minify request data
1450
- * @return string $data minify response data
1451
- *
1452
- * @hook array cache_minify_ignore_tags
1453
- */
1454
 
1455
  private static function _minify_cache($data) {
1456
 
@@ -1509,11 +1528,11 @@ final class Cache_Enabler {
1509
 
1510
 
1511
  /**
1512
- * clear complete cache
1513
- *
1514
- * @since 1.0.0
1515
- * @change 1.2.3
1516
- */
1517
 
1518
  public static function clear_total_cache() {
1519
  // we need this here to update advanced-cache.php for the 1.2.3 upgrade
@@ -1546,14 +1565,14 @@ final class Cache_Enabler {
1546
 
1547
 
1548
  /**
1549
- * set cache
1550
- *
1551
- * @since 1.0.0
1552
- * @change 1.0.0
1553
- *
1554
- * @param string $data content of a page
1555
- * @return string $data content of a page
1556
- */
1557
 
1558
  public static function set_cache($data) {
1559
 
@@ -1578,11 +1597,11 @@ final class Cache_Enabler {
1578
 
1579
 
1580
  /**
1581
- * handle cache
1582
- *
1583
- * @since 1.0.0
1584
- * @change 1.0.1
1585
- */
1586
 
1587
  public static function handle_cache() {
1588
 
@@ -1635,11 +1654,11 @@ final class Cache_Enabler {
1635
 
1636
 
1637
  /**
1638
- * add clear option dropdown on post publish widget
1639
- *
1640
- * @since 1.0.0
1641
- * @change 1.0.0
1642
- */
1643
 
1644
  public static function add_clear_dropdown() {
1645
 
@@ -1666,8 +1685,8 @@ final class Cache_Enabler {
1666
  // init variables
1667
  $dropdown_options = '';
1668
  $available_options = array(
1669
- esc_html__('Completely', 'cache-enabler'),
1670
- esc_html__('Page specific', 'cache-enabler')
1671
  );
1672
 
1673
  // set dropdown options
@@ -1708,16 +1727,16 @@ final class Cache_Enabler {
1708
 
1709
 
1710
  /**
1711
- * enqueue scripts
1712
- *
1713
- * @since 1.0.0
1714
- * @change 1.0.0
1715
- */
1716
 
1717
  public static function add_admin_resources($hook) {
1718
 
1719
  // hook check
1720
- if ( $hook !== 'index.php' AND $hook !== 'post.php' ) {
1721
  return;
1722
  }
1723
 
@@ -1735,20 +1754,20 @@ final class Cache_Enabler {
1735
  $plugin_data['Version'],
1736
  true
1737
  );
1738
- break;
1739
 
1740
  default:
1741
- break;
1742
  }
1743
  }
1744
 
1745
 
1746
  /**
1747
- * add settings page
1748
- *
1749
- * @since 1.0.0
1750
- * @change 1.0.0
1751
- */
1752
 
1753
  public static function add_settings_page() {
1754
 
@@ -1766,13 +1785,13 @@ final class Cache_Enabler {
1766
 
1767
 
1768
  /**
1769
- * minify caching dropdown
1770
- *
1771
- * @since 1.0.0
1772
- * @change 1.0.0
1773
- *
1774
- * @return array Key => value array
1775
- */
1776
 
1777
  private static function _minify_select() {
1778
 
@@ -1785,11 +1804,11 @@ final class Cache_Enabler {
1785
 
1786
 
1787
  /**
1788
- * Check plugin requirements
1789
- *
1790
- * @since 1.1.0
1791
- * @change 1.1.0
1792
- */
1793
 
1794
  public static function requirements_check() {
1795
 
@@ -1844,11 +1863,11 @@ final class Cache_Enabler {
1844
 
1845
 
1846
  /**
1847
- * register textdomain
1848
- *
1849
- * @since 1.0.0
1850
- * @change 1.0.0
1851
- */
1852
 
1853
  public static function register_textdomain() {
1854
 
@@ -1871,7 +1890,7 @@ final class Cache_Enabler {
1871
 
1872
  public static function missing_trailing_slash() {
1873
  if ( ($permalink_structure = get_option('permalink_structure')) &&
1874
- preg_match("/\/$/", $permalink_structure) ) {
1875
 
1876
  // record permalink structure for advanced-cache
1877
  Cache_Enabler_Disk::record_advcache_settings(array(
@@ -1890,11 +1909,11 @@ final class Cache_Enabler {
1890
  }
1891
 
1892
  /**
1893
- * register settings
1894
- *
1895
- * @since 1.0.0
1896
- * @change 1.0.0
1897
- */
1898
 
1899
  public static function register_settings() {
1900
 
@@ -1910,13 +1929,13 @@ final class Cache_Enabler {
1910
 
1911
 
1912
  /**
1913
- * validate regexps
1914
- *
1915
- * @since 1.2.3
1916
- *
1917
- * @param string $re string containing regexps
1918
- * @return string string containing regexps or emty string if input invalid
1919
- */
1920
 
1921
  public static function validate_regexps($re) {
1922
  if ( $re != '' ) {
@@ -1936,14 +1955,14 @@ final class Cache_Enabler {
1936
  }
1937
 
1938
  /**
1939
- * validate settings
1940
- *
1941
- * @since 1.0.0
1942
- * @change 1.2.3
1943
- *
1944
- * @param array $data array form data
1945
- * @return array array form data valid
1946
- */
1947
 
1948
  public static function validate_settings($data) {
1949
 
@@ -1982,6 +2001,14 @@ final class Cache_Enabler {
1982
  Cache_Enabler_Disk::delete_advcache_settings(array("excl_cookies"));
1983
  }
1984
 
 
 
 
 
 
 
 
 
1985
  return array(
1986
  'expires' => (int)$data['expires'],
1987
  'new_post' => (int)(!empty($data['new_post'])),
@@ -1992,29 +2019,30 @@ final class Cache_Enabler {
1992
  'excl_ids' => (string)sanitize_text_field(@$data['excl_ids']),
1993
  'excl_regexp' => (string)self::validate_regexps(@$data['excl_regexp']),
1994
  'excl_cookies' => (string)self::validate_regexps(@$data['excl_cookies']),
 
1995
  'minify_html' => (int)$data['minify_html']
1996
  );
1997
  }
1998
 
1999
 
2000
  /**
2001
- * settings page
2002
- *
2003
- * @since 1.0.0
2004
- * @change 1.2.3
2005
- */
2006
 
2007
  public static function settings_page() {
2008
 
2009
  // wp cache check
2010
  if ( !defined('WP_CACHE') || !WP_CACHE ) {
2011
  echo sprintf(
2012
- '<div class="notice notice-warning"><p>%s</p></div>',
2013
- sprintf(
2014
- __("%s is not set in %s.", 'cache-enabler'),
2015
- "<code>define('WP_CACHE', true);</code>",
2016
- "wp-config.php"
2017
- )
2018
  );
2019
  }
2020
 
@@ -2129,6 +2157,24 @@ final class Cache_Enabler {
2129
  </td>
2130
  </tr>
2131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2132
  <tr valign="top">
2133
  <th scope="row">
2134
  <?php _e("Cache Minification", "cache-enabler") ?>
6
 
7
 
8
  /**
9
+ * Cache_Enabler
10
+ *
11
+ * @since 1.0.0
12
+ */
13
 
14
  final class Cache_Enabler {
15
 
16
 
17
  /**
18
+ * plugin options
19
+ *
20
+ * @since 1.0.0
21
+ * @var array
22
+ */
23
 
24
  public static $options;
25
 
26
 
27
  /**
28
+ * disk cache object
29
+ *
30
+ * @since 1.0.0
31
+ * @var object
32
+ */
33
 
34
  private static $disk;
35
 
36
 
37
  /**
38
+ * minify default settings
39
+ *
40
+ * @since 1.0.0
41
+ * @var integer
42
+ */
43
 
44
  const MINIFY_DISABLED = 0;
45
  const MINIFY_HTML_ONLY = 1;
47
 
48
 
49
  /**
50
+ * constructor wrapper
51
+ *
52
+ * @since 1.0.0
53
+ * @change 1.0.0
54
+ */
55
 
56
  public static function instance()
57
  {
60
 
61
 
62
  /**
63
+ * constructor
64
+ *
65
+ * @since 1.0.0
66
+ * @change 1.2.3
67
+ *
68
+ * @param void
69
+ * @return void
70
+ */
71
 
72
  public function __construct()
73
  {
162
  10,
163
  1
164
  );
165
+ add_action(
166
+ 'woocommerce_variation_set_stock',
167
+ array(
168
+ __CLASS__,
169
+ 'woocommerce_product_set_stock',
170
+ ),
171
+ 10,
172
+ 1
173
+ );
174
+ add_action(
175
+ 'woocommerce_variation_set_stock_status',
176
+ array(
177
+ __CLASS__,
178
+ 'woocommerce_product_set_stock_status',
179
+ ),
180
+ 10,
181
+ 1
182
+ );
183
 
184
  // add admin clear link
185
  add_action(
352
 
353
 
354
  /**
355
+ * deactivation hook
356
+ *
357
+ * @since 1.0.0
358
+ * @change 1.1.1
359
+ */
360
 
361
  public static function on_deactivation() {
362
  self::clear_total_cache(true);
372
 
373
 
374
  /**
375
+ * activation hook
376
+ *
377
+ * @since 1.0.0
378
+ * @change 1.1.1
379
+ */
380
 
381
  public static function on_activation() {
382
 
445
 
446
 
447
  /**
448
+ * install on multisite setup
449
+ *
450
+ * @since 1.0.0
451
+ * @change 1.0.0
452
+ */
453
 
454
  public static function install_later($id) {
455
 
470
 
471
 
472
  /**
473
+ * installation options
474
+ *
475
+ * @since 1.0.0
476
+ * @change 1.0.0
477
+ */
478
 
479
  private static function _install_backend() {
480
 
489
 
490
 
491
  /**
492
+ * installation WP_CACHE (advanced cache)
493
+ *
494
+ * @since 1.1.1
495
+ * @change 1.1.1
496
+ */
497
 
498
  private static function _set_wp_cache($wp_cache_value = true) {
499
  $wp_config_file = ABSPATH . 'wp-config.php';
536
 
537
 
538
  /**
539
+ * uninstall per multisite blog
540
+ *
541
+ * @since 1.0.0
542
+ * @change 1.0.0
543
+ */
544
 
545
  public static function on_uninstall() {
546
  global $wpdb;
568
 
569
 
570
  /**
571
+ * uninstall for multisite and network
572
+ *
573
+ * @since 1.0.0
574
+ * @change 1.0.0
575
+ */
576
 
577
  public static function uninstall_later($id) {
578
 
593
 
594
 
595
  /**
596
+ * uninstall
597
+ *
598
+ * @since 1.0.0
599
+ * @change 1.0.0
600
+ */
601
 
602
  private static function _uninstall_backend() {
603
 
610
 
611
 
612
  /**
613
+ * get blog ids
614
+ *
615
+ * @since 1.0.0
616
+ * @change 1.0.0
617
+ *
618
+ * @return array blog ids array
619
+ */
620
 
621
  private static function _get_blog_ids() {
622
  global $wpdb;
626
 
627
 
628
  /**
629
+ * set default vars
630
+ *
631
+ * @since 1.0.0
632
+ * @change 1.0.0
633
+ */
634
 
635
  private static function _set_default_vars() {
636
 
645
 
646
 
647
  /**
648
+ * get options
649
+ *
650
+ * @since 1.0.0
651
+ * @change 1.2.3
652
+ *
653
+ * @return array options array
654
+ */
655
 
656
  private static function _get_options() {
657
 
677
  'excl_ids' => '',
678
  'excl_regexp' => '',
679
  'excl_cookies' => '',
680
+ 'incl_attributes' => '',
681
  'minify_html' => self::MINIFY_DISABLED,
682
  )
683
  );
685
 
686
 
687
  /**
688
+ * warning if no custom permlinks
689
+ *
690
+ * @since 1.0.0
691
+ * @change 1.0.0
692
+ *
693
+ * @return array options array
694
+ */
695
 
696
  public static function warning_is_permalink() {
697
 
698
+ if ( !Cache_Enabler_Disk::is_permalink() && current_user_can('manage_options') ) { ?>
699
 
700
  <div class="error">
701
  <p><?php printf( __('The <b>%s</b> plugin requires a custom permalink structure to start caching properly. Please go to <a href="%s">Permalink</a> to enable it.', 'cache-enabler'), 'Cache Enabler', admin_url( 'options-permalink.php' ) ); ?></p>
702
  </div>
703
 
704
+ <?php
705
  }
706
  }
707
 
708
 
709
  /**
710
+ * add action links
711
+ *
712
+ * @since 1.0.0
713
+ * @change 1.0.0
714
+ *
715
+ * @param array $data existing links
716
+ * @return array $data appended links
717
+ */
718
 
719
  public static function action_links($data) {
720
 
742
 
743
 
744
  /**
745
+ * cache enabler meta links
746
+ *
747
+ * @since 1.0.0
748
+ * @change 1.0.0
749
+ *
750
+ * @param array $input existing links
751
+ * @param string $page page
752
+ * @return array $data appended links
753
+ */
754
 
755
  public static function row_meta($input, $page) {
756
 
769
 
770
 
771
  /**
772
+ * add dashboard cache size count
773
+ *
774
+ * @since 1.0.0
775
+ * @change 1.1.0
776
+ *
777
+ * @param array $items initial array with dashboard items
778
+ * @return array $items merged array with dashboard items
779
+ */
780
 
781
  public static function add_dashboard_count( $items = array() ) {
782
 
807
 
808
 
809
  /**
810
+ * get cache size
811
+ *
812
+ * @since 1.0.0
813
+ * @change 1.0.0
814
+ *
815
+ * @param integer $size cache size (bytes)
816
+ */
817
 
818
  public static function get_cache_size() {
819
 
820
  if ( ! $size = get_transient('cache_size') ) {
821
 
822
+ $size = is_object( self::$disk ) ? (int) self::$disk->cache_size(CE_CACHE_DIR) : 0;
823
 
824
  // set transient
825
  set_transient(
826
+ 'cache_size',
827
+ $size,
828
+ 60 * 15
829
  );
830
  }
831
 
834
 
835
 
836
  /**
837
+ * add admin links
838
+ *
839
+ * @since 1.0.0
840
+ * @change 1.1.0
841
+ *
842
+ * @hook mixed
843
+ *
844
+ * @param object menu properties
845
+ */
846
 
847
  public static function add_admin_links($wp_admin_bar) {
848
 
878
 
879
 
880
  /**
881
+ * process clear request
882
+ *
883
+ * @since 1.0.0
884
+ * @change 1.1.0
885
+ *
886
+ * @param array $data array of metadata
887
+ */
888
 
889
  public static function process_clear_request($data) {
890
 
996
 
997
 
998
  /**
999
+ * notification after clear cache
1000
+ *
1001
+ * @since 1.0.0
1002
+ * @change 1.0.0
1003
+ *
1004
+ * @hook mixed user_can_clear_cache
1005
+ */
1006
 
1007
  public static function clear_notice() {
1008
 
1019
 
1020
 
1021
  /**
1022
+ * clear cache if post comment
1023
+ *
1024
+ * @since 1.2.0
1025
+ * @change 1.2.0
1026
+ *
1027
+ * @param integer $id id of the comment
1028
+ * @param mixed $approved approval status
1029
+ */
1030
 
1031
  public static function comment_post($id, $approved) {
1032
 
1044
 
1045
 
1046
  /**
1047
+ * clear cache if edit comment
1048
+ *
1049
+ * @since 1.0.0
1050
+ * @change 1.0.0
1051
+ *
1052
+ * @param integer $id id of the comment
1053
+ */
1054
 
1055
  public static function edit_comment($id) {
1056
 
1066
 
1067
 
1068
  /**
1069
+ * clear cache if new comment
1070
+ *
1071
+ * @since 1.0.0
1072
+ * @change 1.0.0
1073
+ *
1074
+ * @param mixed $approved approval status
1075
+ * @param array $comment
1076
+ * @return mixed $approved approval status
1077
+ */
1078
 
1079
  public static function new_comment($approved, $comment) {
1080
 
1092
 
1093
 
1094
  /**
1095
+ * clear cache if comment changes
1096
+ *
1097
+ * @since 1.0.0
1098
+ * @change 1.0.0
1099
+ *
1100
+ * @param string $after_status
1101
+ * @param string $before_status
1102
+ * @param object $comment
1103
+ */
1104
 
1105
  public static function change_comment($after_status, $before_status, $comment) {
1106
 
1116
 
1117
 
1118
  /**
1119
+ * register publish hooks for custom post types
1120
+ *
1121
+ * @since 1.0.0
1122
+ * @since 1.2.3
1123
+ *
1124
+ * @param void
1125
+ * @return void
1126
+ */
1127
 
1128
  public static function register_publish_hooks() {
1129
 
1164
 
1165
 
1166
  /**
1167
+ * delete post type cache on post updates
1168
+ *
1169
+ * @since 1.0.0
1170
+ * @change 1.0.7
1171
+ *
1172
+ * @param integer $post_ID Post ID
1173
+ */
1174
 
1175
  public static function publish_post_types($post_ID, $post) {
1176
 
1226
 
1227
 
1228
  /**
1229
+ * clear page cache by post id
1230
+ *
1231
+ * @since 1.0.0
1232
+ * @change 1.0.0
1233
+ *
1234
+ * @param integer $post_ID Post ID
1235
+ */
1236
 
1237
  public static function clear_page_cache_by_post_id($post_ID) {
1238
 
1249
 
1250
 
1251
  /**
1252
+ * clear page cache by url
1253
+ *
1254
+ * @since 1.0.0
1255
+ * @change 1.2.3
1256
+ *
1257
+ * @param string $url url of a page
1258
+ */
1259
 
1260
  public static function clear_page_cache_by_url($url) {
1261
 
1278
 
1279
 
1280
  /**
1281
+ * clear home page cache
1282
+ *
1283
+ * @since 1.0.7
1284
+ * @change 1.2.3
1285
+ *
1286
+ */
1287
 
1288
  public static function clear_home_page_cache() {
1289
 
1300
 
1301
 
1302
  /**
1303
+ * check if index.php
1304
+ *
1305
+ * @since 1.0.0
1306
+ * @change 1.0.0
1307
+ *
1308
+ * @return boolean true if index.php
1309
+ */
1310
 
1311
  private static function _is_index() {
1312
  return strtolower(basename($_SERVER['SCRIPT_NAME'])) != 'index.php';
1314
 
1315
 
1316
  /**
1317
+ * check if mobile
1318
+ *
1319
+ * @since 1.0.0
1320
+ * @change 1.0.0
1321
+ *
1322
+ * @return boolean true if mobile
1323
+ */
1324
 
1325
  private static function _is_mobile() {
1326
  return ( strpos(TEMPLATEPATH, 'wptouch') OR strpos(TEMPLATEPATH, 'carrington') OR strpos(TEMPLATEPATH, 'jetpack') OR strpos(TEMPLATEPATH, 'handheld') );
1328
 
1329
 
1330
  /**
1331
+ * check if logged in
1332
+ *
1333
+ * @since 1.0.0
1334
+ * @change 1.0.0
1335
+ *
1336
+ * @return boolean true if logged in or cookie set
1337
+ */
1338
 
1339
  private static function _is_logged_in() {
1340
 
1365
 
1366
 
1367
  /**
1368
+ * check if there are post to be published in the future
1369
+ *
1370
+ * @since 1.2.3
1371
+ *
1372
+ * @return void
1373
+ *
1374
+ */
1375
 
1376
  public static function check_future_posts() {
1377
 
1389
 
1390
 
1391
  /**
1392
+ * check to bypass the cache
1393
+ *
1394
+ * @since 1.0.0
1395
+ * @change 1.2.3
1396
+ *
1397
+ * @return boolean true if exception
1398
+ *
1399
+ * @hook boolean bypass cache
1400
+ */
1401
 
1402
  private static function _bypass_cache() {
1403
 
1460
 
1461
 
1462
  /**
1463
+ * minify html
1464
+ *
1465
+ * @since 1.0.0
1466
+ * @change 1.0.0
1467
+ *
1468
+ * @param string $data minify request data
1469
+ * @return string $data minify response data
1470
+ *
1471
+ * @hook array cache_minify_ignore_tags
1472
+ */
1473
 
1474
  private static function _minify_cache($data) {
1475
 
1528
 
1529
 
1530
  /**
1531
+ * clear complete cache
1532
+ *
1533
+ * @since 1.0.0
1534
+ * @change 1.2.3
1535
+ */
1536
 
1537
  public static function clear_total_cache() {
1538
  // we need this here to update advanced-cache.php for the 1.2.3 upgrade
1565
 
1566
 
1567
  /**
1568
+ * set cache
1569
+ *
1570
+ * @since 1.0.0
1571
+ * @change 1.0.0
1572
+ *
1573
+ * @param string $data content of a page
1574
+ * @return string $data content of a page
1575
+ */
1576
 
1577
  public static function set_cache($data) {
1578
 
1597
 
1598
 
1599
  /**
1600
+ * handle cache
1601
+ *
1602
+ * @since 1.0.0
1603
+ * @change 1.0.1
1604
+ */
1605
 
1606
  public static function handle_cache() {
1607
 
1654
 
1655
 
1656
  /**
1657
+ * add clear option dropdown on post publish widget
1658
+ *
1659
+ * @since 1.0.0
1660
+ * @change 1.0.0
1661
+ */
1662
 
1663
  public static function add_clear_dropdown() {
1664
 
1685
  // init variables
1686
  $dropdown_options = '';
1687
  $available_options = array(
1688
+ esc_html__('Page specific', 'cache-enabler'),
1689
+ esc_html__('Completely', 'cache-enabler')
1690
  );
1691
 
1692
  // set dropdown options
1727
 
1728
 
1729
  /**
1730
+ * enqueue scripts
1731
+ *
1732
+ * @since 1.0.0
1733
+ * @change 1.0.0
1734
+ */
1735
 
1736
  public static function add_admin_resources($hook) {
1737
 
1738
  // hook check
1739
+ if ( $hook !== 'index.php' && $hook !== 'post.php' ) {
1740
  return;
1741
  }
1742
 
1754
  $plugin_data['Version'],
1755
  true
1756
  );
1757
+ break;
1758
 
1759
  default:
1760
+ break;
1761
  }
1762
  }
1763
 
1764
 
1765
  /**
1766
+ * add settings page
1767
+ *
1768
+ * @since 1.0.0
1769
+ * @change 1.0.0
1770
+ */
1771
 
1772
  public static function add_settings_page() {
1773
 
1785
 
1786
 
1787
  /**
1788
+ * minify caching dropdown
1789
+ *
1790
+ * @since 1.0.0
1791
+ * @change 1.0.0
1792
+ *
1793
+ * @return array Key => value array
1794
+ */
1795
 
1796
  private static function _minify_select() {
1797
 
1804
 
1805
 
1806
  /**
1807
+ * Check plugin requirements
1808
+ *
1809
+ * @since 1.1.0
1810
+ * @change 1.1.0
1811
+ */
1812
 
1813
  public static function requirements_check() {
1814
 
1863
 
1864
 
1865
  /**
1866
+ * register textdomain
1867
+ *
1868
+ * @since 1.0.0
1869
+ * @change 1.0.0
1870
+ */
1871
 
1872
  public static function register_textdomain() {
1873
 
1890
 
1891
  public static function missing_trailing_slash() {
1892
  if ( ($permalink_structure = get_option('permalink_structure')) &&
1893
+ preg_match("/\/$/", $permalink_structure) ) {
1894
 
1895
  // record permalink structure for advanced-cache
1896
  Cache_Enabler_Disk::record_advcache_settings(array(
1909
  }
1910
 
1911
  /**
1912
+ * register settings
1913
+ *
1914
+ * @since 1.0.0
1915
+ * @change 1.0.0
1916
+ */
1917
 
1918
  public static function register_settings() {
1919
 
1929
 
1930
 
1931
  /**
1932
+ * validate regexps
1933
+ *
1934
+ * @since 1.2.3
1935
+ *
1936
+ * @param string $re string containing regexps
1937
+ * @return string string containing regexps or emty string if input invalid
1938
+ */
1939
 
1940
  public static function validate_regexps($re) {
1941
  if ( $re != '' ) {
1955
  }
1956
 
1957
  /**
1958
+ * validate settings
1959
+ *
1960
+ * @since 1.0.0
1961
+ * @change 1.2.3
1962
+ *
1963
+ * @param array $data array form data
1964
+ * @return array array form data valid
1965
+ */
1966
 
1967
  public static function validate_settings($data) {
1968
 
2001
  Cache_Enabler_Disk::delete_advcache_settings(array("excl_cookies"));
2002
  }
2003
 
2004
+ // custom GET attribute exceptions
2005
+ if ( strlen($data["incl_attributes"]) > 0 ) {
2006
+ Cache_Enabler_Disk::record_advcache_settings(array(
2007
+ "incl_attributes" => $data["incl_attributes"]));
2008
+ } else {
2009
+ Cache_Enabler_Disk::delete_advcache_settings(array("incl_attributes"));
2010
+ }
2011
+
2012
  return array(
2013
  'expires' => (int)$data['expires'],
2014
  'new_post' => (int)(!empty($data['new_post'])),
2019
  'excl_ids' => (string)sanitize_text_field(@$data['excl_ids']),
2020
  'excl_regexp' => (string)self::validate_regexps(@$data['excl_regexp']),
2021
  'excl_cookies' => (string)self::validate_regexps(@$data['excl_cookies']),
2022
+ 'incl_attributes' => (string)self::validate_regexps(@$data['incl_attributes']),
2023
  'minify_html' => (int)$data['minify_html']
2024
  );
2025
  }
2026
 
2027
 
2028
  /**
2029
+ * settings page
2030
+ *
2031
+ * @since 1.0.0
2032
+ * @change 1.2.3
2033
+ */
2034
 
2035
  public static function settings_page() {
2036
 
2037
  // wp cache check
2038
  if ( !defined('WP_CACHE') || !WP_CACHE ) {
2039
  echo sprintf(
2040
+ '<div class="notice notice-warning"><p>%s</p></div>',
2041
+ sprintf(
2042
+ __("%s is not set in %s.", 'cache-enabler'),
2043
+ "<code>define('WP_CACHE', true);</code>",
2044
+ "wp-config.php"
2045
+ )
2046
  );
2047
  }
2048
 
2157
  </td>
2158
  </tr>
2159
 
2160
+ <tr valign="top">
2161
+ <th scope="row">
2162
+ <?php _e("Cache Inclusions", "cache-enabler") ?>
2163
+ </th>
2164
+ <td>
2165
+ <fieldset>
2166
+ <label for="cache_incl_attributes">
2167
+ <input type="text" name="cache-enabler[incl_attributes]" id="cache_incl_attributes" value="<?php echo esc_attr($options['incl_attributes']) ?>" />
2168
+ <p class="description">
2169
+ <?php _e("Regexp matching campaign tracking GET attributes that should not cause the cache to be bypassed.", "cache-enabler"); ?><br>
2170
+ <?php _e("Example:", "cache-enabler"); ?> <code>/^pk_(source|medium|campaign|kwd|content)$/</code><br>
2171
+ <?php _e("Default if unset:", "cache-enabler"); ?> <code>/^utm_(source|medium|campaign|term|content)$/</code>
2172
+ </p>
2173
+ </label>
2174
+ </fieldset>
2175
+ </td>
2176
+ </tr>
2177
+
2178
  <tr valign="top">
2179
  <th scope="row">
2180
  <?php _e("Cache Minification", "cache-enabler") ?>
inc/cache_enabler_disk.class.php CHANGED
@@ -6,22 +6,22 @@ defined('ABSPATH') OR exit;
6
 
7
 
8
  /**
9
- * Cache_Enabler_Disk
10
- *
11
- * @since 1.0.0
12
- */
13
 
14
  final class Cache_Enabler_Disk {
15
 
16
 
17
  /**
18
- * cached filename settings
19
- *
20
- * @since 1.0.7
21
- * @change 1.0.7
22
- *
23
- * @var string
24
- */
25
 
26
  const FILE_HTML = 'index.html';
27
  const FILE_GZIP = 'index.html.gz';
@@ -30,13 +30,13 @@ final class Cache_Enabler_Disk {
30
 
31
 
32
  /**
33
- * permalink check
34
- *
35
- * @since 1.0.0
36
- * @change 1.0.0
37
- *
38
- * @return boolean true if installed
39
- */
40
 
41
  public static function is_permalink() {
42
  return get_option('permalink_structure');
@@ -44,13 +44,13 @@ final class Cache_Enabler_Disk {
44
 
45
 
46
  /**
47
- * store asset
48
- *
49
- * @since 1.0.0
50
- * @change 1.0.0
51
- *
52
- * @param string $data content of the asset
53
- */
54
 
55
  public static function store_asset($data) {
56
 
@@ -68,13 +68,13 @@ final class Cache_Enabler_Disk {
68
 
69
 
70
  /**
71
- * check asset
72
- *
73
- * @since 1.0.0
74
- * @change 1.0.0
75
- *
76
- * @return boolean true if asset exists
77
- */
78
 
79
  public static function check_asset() {
80
  return is_readable(
@@ -84,13 +84,13 @@ final class Cache_Enabler_Disk {
84
 
85
 
86
  /**
87
- * check expiry
88
- *
89
- * @since 1.0.1
90
- * @change 1.0.1
91
- *
92
- * @return boolean true if asset expired
93
- */
94
 
95
  public static function check_expiry() {
96
 
@@ -116,13 +116,13 @@ final class Cache_Enabler_Disk {
116
 
117
 
118
  /**
119
- * delete asset
120
- *
121
- * @since 1.0.0
122
- * @change 1.0.0
123
- *
124
- * @param string $url url of cached asset
125
- */
126
 
127
  public static function delete_asset($url) {
128
 
@@ -139,11 +139,11 @@ final class Cache_Enabler_Disk {
139
 
140
 
141
  /**
142
- * clear cache
143
- *
144
- * @since 1.0.0
145
- * @change 1.0.0
146
- */
147
 
148
  public static function clear_cache() {
149
  self::_clear_dir(
@@ -153,11 +153,11 @@ final class Cache_Enabler_Disk {
153
 
154
 
155
  /**
156
- * clear home cache
157
- *
158
- * @since 1.0.7
159
- * @change 1.0.9
160
- */
161
 
162
  public static function clear_home() {
163
  $path = sprintf(
@@ -176,11 +176,11 @@ final class Cache_Enabler_Disk {
176
 
177
 
178
  /**
179
- * get asset
180
- *
181
- * @since 1.0.0
182
- * @change 1.0.9
183
- */
184
 
185
  public static function get_asset() {
186
 
@@ -200,7 +200,7 @@ final class Cache_Enabler_Disk {
200
  }
201
 
202
  // check modified since with cached file and return 304 if no difference
203
- if ( $http_if_modified_since && ( strtotime( $http_if_modified_since ) == filemtime( self::_file_html() ) ) ) {
204
  header( $_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified', true, 304 );
205
  exit;
206
  }
@@ -231,13 +231,13 @@ final class Cache_Enabler_Disk {
231
 
232
 
233
  /**
234
- * create signature
235
- *
236
- * @since 1.0.0
237
- * @change 1.0.0
238
- *
239
- * @return string signature
240
- */
241
 
242
  private static function _cache_signatur() {
243
  return sprintf(
@@ -252,13 +252,13 @@ final class Cache_Enabler_Disk {
252
 
253
 
254
  /**
255
- * create files
256
- *
257
- * @since 1.0.0
258
- * @change 1.1.1
259
- *
260
- * @param string $data html content
261
- */
262
 
263
  private static function _create_files($data) {
264
 
@@ -301,14 +301,14 @@ final class Cache_Enabler_Disk {
301
 
302
 
303
  /**
304
- * create file
305
- *
306
- * @since 1.0.0
307
- * @change 1.0.0
308
- *
309
- * @param string $file file path
310
- * @param string $data content of the html
311
- */
312
 
313
  private static function _create_file($file, $data) {
314
 
@@ -332,13 +332,13 @@ final class Cache_Enabler_Disk {
332
 
333
 
334
  /**
335
- * clear directory
336
- *
337
- * @since 1.0.0
338
- * @change 1.0.0
339
- *
340
- * @param string $dir directory
341
- */
342
 
343
  private static function _clear_dir($dir) {
344
 
@@ -381,14 +381,14 @@ final class Cache_Enabler_Disk {
381
 
382
 
383
  /**
384
- * get cache size
385
- *
386
- * @since 1.0.0
387
- * @change 1.0.0
388
- *
389
- * @param string $dir folder path
390
- * @return mixed $size size in bytes
391
- */
392
 
393
  public static function cache_size($dir = '.') {
394
 
@@ -426,14 +426,14 @@ final class Cache_Enabler_Disk {
426
 
427
 
428
  /**
429
- * cache path
430
- *
431
- * @since 1.0.0
432
- * @change 1.1.0
433
- *
434
- * @param string $path uri or permlink
435
- * @return string $diff path to cached asset
436
- */
437
 
438
  private static function _file_path($path = NULL) {
439
 
@@ -460,13 +460,13 @@ final class Cache_Enabler_Disk {
460
 
461
 
462
  /**
463
- * get file path
464
- *
465
- * @since 1.0.0
466
- * @change 1.0.7
467
- *
468
- * @return string path to the html file
469
- */
470
 
471
  private static function _file_html() {
472
  return self::_file_path(). self::FILE_HTML;
@@ -474,13 +474,13 @@ final class Cache_Enabler_Disk {
474
 
475
 
476
  /**
477
- * get gzip file path
478
- *
479
- * @since 1.0.1
480
- * @change 1.0.7
481
- *
482
- * @return string path to the gzipped html file
483
- */
484
 
485
  private static function _file_gzip() {
486
  return self::_file_path(). self::FILE_GZIP;
@@ -488,13 +488,13 @@ final class Cache_Enabler_Disk {
488
 
489
 
490
  /**
491
- * get webp file path
492
- *
493
- * @since 1.0.7
494
- * @change 1.0.7
495
- *
496
- * @return string path to the webp html file
497
- */
498
 
499
  private static function _file_webp_html() {
500
  return self::_file_path(). self::FILE_WEBP_HTML;
@@ -502,13 +502,13 @@ final class Cache_Enabler_Disk {
502
 
503
 
504
  /**
505
- * get gzip webp file path
506
- *
507
- * @since 1.0.1
508
- * @change 1.0.7
509
- *
510
- * @return string path to the webp gzipped html file
511
- */
512
 
513
  private static function _file_webp_gzip() {
514
  return self::_file_path(). self::FILE_WEBP_GZIP;
@@ -550,14 +550,14 @@ final class Cache_Enabler_Disk {
550
  }
551
 
552
 
553
- /**
554
- * record settings for advanced-cache.php
555
- *
556
- * @since 1.2.3
557
- *
558
- * @param array settings as array pairs
559
- * @return boolean true if successful
560
- */
561
 
562
  public static function record_advcache_settings($settings) {
563
  $settings_file = sprintf('%s-%s%s.json',
@@ -584,14 +584,14 @@ final class Cache_Enabler_Disk {
584
  }
585
 
586
 
587
- /**
588
- * delete settings for advanced-cache.php
589
- *
590
- * @since 1.2.3
591
- *
592
- * @param array settings as array or empty for delete all
593
- * @return boolean true if successful
594
- */
595
 
596
  public static function delete_advcache_settings($remsettings = array()) {
597
  $settings_file = sprintf('%s-%s%s.json',
@@ -627,13 +627,13 @@ final class Cache_Enabler_Disk {
627
 
628
 
629
  /**
630
- * convert to webp
631
- *
632
- * @since 1.0.1
633
- * @change 1.1.1
634
- *
635
- * @return string converted HTML file
636
- */
637
 
638
  private static function _convert_webp($asset) {
639
 
@@ -651,13 +651,13 @@ final class Cache_Enabler_Disk {
651
 
652
 
653
  /**
654
- * convert src to webp source
655
- *
656
- * @since 1.0.1
657
- * @change 1.1.0
658
- *
659
- * @return string converted src webp source
660
- */
661
 
662
  private static function _convert_webp_src($src) {
663
  $upload_dir = wp_upload_dir();
@@ -694,13 +694,13 @@ final class Cache_Enabler_Disk {
694
 
695
 
696
  /**
697
- * convert srcset to webp source
698
- *
699
- * @since 1.0.8
700
- * @change 1.1.0
701
- *
702
- * @return string converted srcset webp source
703
- */
704
 
705
  private static function _convert_webp_srcset($srcset) {
706
 
6
 
7
 
8
  /**
9
+ * Cache_Enabler_Disk
10
+ *
11
+ * @since 1.0.0
12
+ */
13
 
14
  final class Cache_Enabler_Disk {
15
 
16
 
17
  /**
18
+ * cached filename settings
19
+ *
20
+ * @since 1.0.7
21
+ * @change 1.0.7
22
+ *
23
+ * @var string
24
+ */
25
 
26
  const FILE_HTML = 'index.html';
27
  const FILE_GZIP = 'index.html.gz';
30
 
31
 
32
  /**
33
+ * permalink check
34
+ *
35
+ * @since 1.0.0
36
+ * @change 1.0.0
37
+ *
38
+ * @return boolean true if installed
39
+ */
40
 
41
  public static function is_permalink() {
42
  return get_option('permalink_structure');
44
 
45
 
46
  /**
47
+ * store asset
48
+ *
49
+ * @since 1.0.0
50
+ * @change 1.0.0
51
+ *
52
+ * @param string $data content of the asset
53
+ */
54
 
55
  public static function store_asset($data) {
56
 
68
 
69
 
70
  /**
71
+ * check asset
72
+ *
73
+ * @since 1.0.0
74
+ * @change 1.0.0
75
+ *
76
+ * @return boolean true if asset exists
77
+ */
78
 
79
  public static function check_asset() {
80
  return is_readable(
84
 
85
 
86
  /**
87
+ * check expiry
88
+ *
89
+ * @since 1.0.1
90
+ * @change 1.0.1
91
+ *
92
+ * @return boolean true if asset expired
93
+ */
94
 
95
  public static function check_expiry() {
96
 
116
 
117
 
118
  /**
119
+ * delete asset
120
+ *
121
+ * @since 1.0.0
122
+ * @change 1.0.0
123
+ *
124
+ * @param string $url url of cached asset
125
+ */
126
 
127
  public static function delete_asset($url) {
128
 
139
 
140
 
141
  /**
142
+ * clear cache
143
+ *
144
+ * @since 1.0.0
145
+ * @change 1.0.0
146
+ */
147
 
148
  public static function clear_cache() {
149
  self::_clear_dir(
153
 
154
 
155
  /**
156
+ * clear home cache
157
+ *
158
+ * @since 1.0.7
159
+ * @change 1.0.9
160
+ */
161
 
162
  public static function clear_home() {
163
  $path = sprintf(
176
 
177
 
178
  /**
179
+ * get asset
180
+ *
181
+ * @since 1.0.0
182
+ * @change 1.0.9
183
+ */
184
 
185
  public static function get_asset() {
186
 
200
  }
201
 
202
  // check modified since with cached file and return 304 if no difference
203
+ if ( $http_if_modified_since && ( strtotime( $http_if_modified_since ) >= filemtime( self::_file_html() ) ) ) {
204
  header( $_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified', true, 304 );
205
  exit;
206
  }
231
 
232
 
233
  /**
234
+ * create signature
235
+ *
236
+ * @since 1.0.0
237
+ * @change 1.0.0
238
+ *
239
+ * @return string signature
240
+ */
241
 
242
  private static function _cache_signatur() {
243
  return sprintf(
252
 
253
 
254
  /**
255
+ * create files
256
+ *
257
+ * @since 1.0.0
258
+ * @change 1.1.1
259
+ *
260
+ * @param string $data html content
261
+ */
262
 
263
  private static function _create_files($data) {
264
 
301
 
302
 
303
  /**
304
+ * create file
305
+ *
306
+ * @since 1.0.0
307
+ * @change 1.0.0
308
+ *
309
+ * @param string $file file path
310
+ * @param string $data content of the html
311
+ */
312
 
313
  private static function _create_file($file, $data) {
314
 
332
 
333
 
334
  /**
335
+ * clear directory
336
+ *
337
+ * @since 1.0.0
338
+ * @change 1.0.0
339
+ *
340
+ * @param string $dir directory
341
+ */
342
 
343
  private static function _clear_dir($dir) {
344
 
381
 
382
 
383
  /**
384
+ * get cache size
385
+ *
386
+ * @since 1.0.0
387
+ * @change 1.0.0
388
+ *
389
+ * @param string $dir folder path
390
+ * @return mixed $size size in bytes
391
+ */
392
 
393
  public static function cache_size($dir = '.') {
394
 
426
 
427
 
428
  /**
429
+ * cache path
430
+ *
431
+ * @since 1.0.0
432
+ * @change 1.1.0
433
+ *
434
+ * @param string $path uri or permlink
435
+ * @return string $diff path to cached asset
436
+ */
437
 
438
  private static function _file_path($path = NULL) {
439
 
460
 
461
 
462
  /**
463
+ * get file path
464
+ *
465
+ * @since 1.0.0
466
+ * @change 1.0.7
467
+ *
468
+ * @return string path to the html file
469
+ */
470
 
471
  private static function _file_html() {
472
  return self::_file_path(). self::FILE_HTML;
474
 
475
 
476
  /**
477
+ * get gzip file path
478
+ *
479
+ * @since 1.0.1
480
+ * @change 1.0.7
481
+ *
482
+ * @return string path to the gzipped html file
483
+ */
484
 
485
  private static function _file_gzip() {
486
  return self::_file_path(). self::FILE_GZIP;
488
 
489
 
490
  /**
491
+ * get webp file path
492
+ *
493
+ * @since 1.0.7
494
+ * @change 1.0.7
495
+ *
496
+ * @return string path to the webp html file
497
+ */
498
 
499
  private static function _file_webp_html() {
500
  return self::_file_path(). self::FILE_WEBP_HTML;
502
 
503
 
504
  /**
505
+ * get gzip webp file path
506
+ *
507
+ * @since 1.0.1
508
+ * @change 1.0.7
509
+ *
510
+ * @return string path to the webp gzipped html file
511
+ */
512
 
513
  private static function _file_webp_gzip() {
514
  return self::_file_path(). self::FILE_WEBP_GZIP;
550
  }
551
 
552
 
553
+ /**
554
+ * record settings for advanced-cache.php
555
+ *
556
+ * @since 1.2.3
557
+ *
558
+ * @param array settings as array pairs
559
+ * @return boolean true if successful
560
+ */
561
 
562
  public static function record_advcache_settings($settings) {
563
  $settings_file = sprintf('%s-%s%s.json',
584
  }
585
 
586
 
587
+ /**
588
+ * delete settings for advanced-cache.php
589
+ *
590
+ * @since 1.2.3
591
+ *
592
+ * @param array settings as array or empty for delete all
593
+ * @return boolean true if successful
594
+ */
595
 
596
  public static function delete_advcache_settings($remsettings = array()) {
597
  $settings_file = sprintf('%s-%s%s.json',
627
 
628
 
629
  /**
630
+ * convert to webp
631
+ *
632
+ * @since 1.0.1
633
+ * @change 1.1.1
634
+ *
635
+ * @return string converted HTML file
636
+ */
637
 
638
  private static function _convert_webp($asset) {
639
 
651
 
652
 
653
  /**
654
+ * convert src to webp source
655
+ *
656
+ * @since 1.0.1
657
+ * @change 1.1.0
658
+ *
659
+ * @return string converted src webp source
660
+ */
661
 
662
  private static function _convert_webp_src($src) {
663
  $upload_dir = wp_upload_dir();
694
 
695
 
696
  /**
697
+ * convert srcset to webp source
698
+ *
699
+ * @since 1.0.8
700
+ * @change 1.1.0
701
+ *
702
+ * @return string converted srcset webp source
703
+ */
704
 
705
  private static function _convert_webp_srcset($srcset) {
706
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: keycdn
3
  Tags: cache, caching, wordpress cache, wp cache, performance, gzip, webp, http2
4
  Requires at least: 4.6
5
- Tested up to: 4.9
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -68,7 +68,12 @@ When combined with Optimus, the Wordpress Cache Enabler allows you to easily del
68
 
69
  == Changelog ==
70
 
71
- = 1.3.1
 
 
 
 
 
72
  * Fix for missing trailing slashes was incomplete
73
  * Add filter option before minification
74
 
2
  Contributors: keycdn
3
  Tags: cache, caching, wordpress cache, wp cache, performance, gzip, webp, http2
4
  Requires at least: 4.6
5
+ Tested up to: 5.0
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
68
 
69
  == Changelog ==
70
 
71
+ = 1.3.2 =
72
+ * Changed to page specific as new default
73
+ * Added regex setting for analytics tags in get variables
74
+ * Fixed 304 responses
75
+
76
+ = 1.3.1 =
77
  * Fix for missing trailing slashes was incomplete
78
  * Add filter option before minification
79