Cachify - Version 2.1.6

Version Description

  • Button "Cache leeren" sichtbar sowohl in WP 3.8 wie WP 3.9
Download this release

Release Info

Developer sergej.mueller
Plugin Icon 128x128 Cachify
Version 2.1.6
Comparing to
See all releases

Code changes from version 2.0.4 to 2.1.6

apc/proxy.php CHANGED
@@ -1,16 +1,26 @@
1
  <?php
 
 
 
 
 
 
 
 
 
2
  if (
3
- extension_loaded('apc')
4
- && ( !empty($_SERVER['PHP_SELF']) && strpos($_SERVER['PHP_SELF'], '/wp-admin/') === false )
5
- && ( !empty($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false )
 
6
  && ( $cache = apc_fetch(md5($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) . '.cachify') )
7
  ) {
8
  ini_set('zlib.output_compression', 'Off');
9
-
10
  header('Vary: Accept-Encoding');
11
  header('X-Powered-By: Cachify');
12
  header('Content-Encoding: gzip');
13
- header('Content-Length: '.strlen($cache));
14
  header('Content-Type: text/html; charset=utf-8');
15
 
16
  echo $cache;
1
  <?php
2
+
3
+ if ( ! empty($_COOKIE) ) {
4
+ foreach ( $_COOKIE as $k => $v ) {
5
+ if ( preg_match('/^(wp-postpass|wordpress_logged_in|comment_author)_/', $k) ) {
6
+ $_cachify_logged_in = true; break;
7
+ }
8
+ }
9
+ }
10
+
11
  if (
12
+ empty($_cachify_logged_in)
13
+ && ( ! empty($_SERVER['PHP_SELF']) && strpos($_SERVER['PHP_SELF'], '/wp-admin/') === false )
14
+ && ( ! empty($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false )
15
+ && extension_loaded('apc')
16
  && ( $cache = apc_fetch(md5($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']) . '.cachify') )
17
  ) {
18
  ini_set('zlib.output_compression', 'Off');
19
+
20
  header('Vary: Accept-Encoding');
21
  header('X-Powered-By: Cachify');
22
  header('Content-Encoding: gzip');
23
+ header('Content-Length: ' .strlen($cache));
24
  header('Content-Type: text/html; charset=utf-8');
25
 
26
  echo $cache;
cachify.php CHANGED
@@ -1,68 +1,64 @@
1
  <?php
2
  /*
3
  Plugin Name: Cachify
4
- Description: Smarter Cache für WordPress. Reduziert die Ladezeit der Blogseiten, indem Inhalte in statischer Form abgelegt und ausgeliefert werden.
 
 
5
  Author: Sergej M&uuml;ller
6
- Author URI: http://wpseo.de
7
  Plugin URI: http://cachify.de
8
- Version: 2.0.4
9
  */
10
 
11
 
12
- /* Sicherheitsabfrage */
13
- if ( !class_exists('WP') ) {
14
- die();
15
- }
16
 
17
 
18
- /* Filter */
19
- if ( ! (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) ) {
20
- /* PHP-Check */
21
- if ( ! function_exists('spl_autoload_register') ) {
22
- wp_die('Cachify benötigt mindestens PHP 5.1.2');
23
- }
24
-
25
- /* Autoload */
26
- spl_autoload_register('cachify_autoload');
27
-
28
- /* Konstanten */
29
- define('CACHIFY_FILE', __FILE__);
30
- define('CACHIFY_BASE', plugin_basename(__FILE__));
31
- define('CACHIFY_CACHE_DIR', WP_CONTENT_DIR. '/cache/cachify');
32
-
33
- /* Init */
34
- add_action(
35
- 'init',
36
- array(
37
- 'Cachify',
38
- 'init'
39
- ),
40
- 99
41
- );
42
-
43
- /* Install */
44
- register_activation_hook(
45
- __FILE__,
46
- array(
47
- 'Cachify',
48
- 'install'
49
- )
50
- );
51
-
52
- /* Uninstall */
53
- register_uninstall_hook(
54
- __FILE__,
55
- array(
56
- 'Cachify',
57
- 'uninstall'
58
- )
59
- );
60
- }
61
 
 
 
62
 
63
- /* Autoload */
64
  function cachify_autoload($class) {
65
- if ( in_array($class, array('Cachify', 'Cachify_APC', 'Cachify_DB', 'Cachify_HDD')) ) {
66
  require_once(
67
  sprintf(
68
  '%s/inc/%s.class.php',
1
  <?php
2
  /*
3
  Plugin Name: Cachify
4
+ Text Domain: cachify
5
+ Domain Path: /lang
6
+ Description: Easy to use WordPress cache plugin with static file serving in the database, hard disc, memcached and apc.
7
  Author: Sergej M&uuml;ller
8
+ Author URI: http://wpcoder.de
9
  Plugin URI: http://cachify.de
10
+ Version: 2.1.6
11
  */
12
 
13
 
14
+ /* Quit */
15
+ defined('ABSPATH') OR exit;
 
 
16
 
17
 
18
+ /* Konstanten */
19
+ define('CACHIFY_FILE', __FILE__);
20
+ define('CACHIFY_BASE', plugin_basename(__FILE__));
21
+ define('CACHIFY_CACHE_DIR', WP_CONTENT_DIR. '/cache/cachify');
22
+
23
+
24
+ /* Hooks */
25
+ add_action(
26
+ 'plugins_loaded',
27
+ array(
28
+ 'Cachify',
29
+ 'instance'
30
+ ),
31
+ 99
32
+ );
33
+ register_activation_hook(
34
+ __FILE__,
35
+ array(
36
+ 'Cachify',
37
+ 'on_activation'
38
+ )
39
+ );
40
+ register_deactivation_hook(
41
+ __FILE__,
42
+ array(
43
+ 'Cachify',
44
+ 'on_deactivation'
45
+ )
46
+ );
47
+ register_uninstall_hook(
48
+ __FILE__,
49
+ array(
50
+ 'Cachify',
51
+ 'on_uninstall'
52
+ )
53
+ );
54
+
 
 
 
 
 
 
55
 
56
+ /* Autoload Init */
57
+ spl_autoload_register('cachify_autoload');
58
 
59
+ /* Autoload Funktion */
60
  function cachify_autoload($class) {
61
+ if ( in_array($class, array('Cachify', 'Cachify_APC', 'Cachify_DB', 'Cachify_HDD', 'Cachify_MEMCACHED')) ) {
62
  require_once(
63
  sprintf(
64
  '%s/inc/%s.class.php',
css/dashboard.css ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* @group Dashboard */
2
+
3
+ @font-face {
4
+ font-family: 'cachify-icons';
5
+ src: url('data:font/opentype;base64,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') format('woff');
6
+ }
7
+
8
+ #dashboard_right_now .cachify-icon:before {
9
+ color: #888;
10
+ font-family: "cachify-icons";
11
+ }
12
+ #dashboard_right_now .cachify-icon--hdd:before {
13
+ margin: 3px 7px 0 2px;
14
+ content: "\e801";
15
+ font-size: 16px;
16
+ }
17
+ #dashboard_right_now .cachify-icon--db:before {
18
+ margin: 1px 9px 0 3px;
19
+ content: "\e802";
20
+ font-size: 18px;
21
+ }
22
+ #dashboard_right_now .cachify-icon--apc:before,
23
+ #dashboard_right_now .cachify-icon--memcached:before {
24
+ margin: 3px 6px 0 0;
25
+ content: "\e800";
26
+ font-size: 13px;
27
+ }
28
+
29
+ /* @end group */
css/dashboard.min.css ADDED
@@ -0,0 +1 @@
 
1
+ @font-face{font-family:cachify-icons;src:url(data:font/opentype;base64,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) format(woff)}#dashboard_right_now .cachify-icon:before{font-family:cachify-icons;color:#888;}#dashboard_right_now .cachify-icon--hdd:before{content:"\e801";font-size:16px;margin:3px 7px 0 2px}#dashboard_right_now .cachify-icon--db:before{content:"\e802";font-size:18px;margin:1px 9px 0 3px}#dashboard_right_now .cachify-icon--apc:before,#dashboard_right_now .cachify-icon--memcached:before{content:"\e800";font-size:13px;margin:3px 6px 0 0}
css/style.css DELETED
@@ -1 +0,0 @@
1
- #icon-cachify{width:32px;height:32px;background:url('../img/icon@2x.png');background-size:100%;}#wp-admin-bar-cachify .ab-icon{float:left;width:16px;height:16px;position:relative;margin-top:6px;background:url(../img/trash@2x.png);background-size:100%;}#cachify_main .table{width:460px;height:1%;margin:20px 0 0;padding:0 0 5px;overflow:hidden;border:1px solid #dfdfdf;}#cachify_main .form-table{margin:0;}#cachify_main .form-table th{width:230px;vertical-align:middle;}#cachify_main .form-table th small{color:#8f8f8f;display:block;text-shadow:none;}#cachify_main .form-table caption{width:100%;color:#8f8f8f;margin:0 0 5px;background:whiteSmoke;line-height:20px;text-shadow:1px 1px #FFF;}#cachify_main .rounded{border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;}#cachify_main input,#cachify_main select{width:172px;}#cachify_main input.small{width:50px;}#cachify_main .submit{width:460px;height:1%;overflow:hidden;}#cachify_main .help{float:right;color:#bebebe;font-size:11px;text-align:right;line-height:11px;}#dashboard_right_now .table_cachify{margin-top:36px;border-top:#ececec 1px solid;}#dashboard_right_now .table_cachify .b{font-size:18px;padding-top:0;}
 
css/style.dev.css DELETED
@@ -1,99 +0,0 @@
1
- /* @group Plugin Icon */
2
-
3
- #icon-cachify {
4
- width: 32px;
5
- height: 32px;
6
- background: url('../img/icon@2x.png');
7
- background-size: 100%;
8
- }
9
-
10
- /* @end group */
11
-
12
-
13
- /* @group Adminbar Icon */
14
-
15
- #wp-admin-bar-cachify .ab-icon {
16
- float: left;
17
- width: 16px;
18
- height: 16px;
19
- position: relative;
20
- margin-top: 6px;
21
- background: url(../img/trash@2x.png);
22
- background-size: 100%;
23
-
24
- }
25
-
26
- /* @end group */
27
-
28
-
29
- /* @group GUI */
30
-
31
- #cachify_main .table {
32
- width: 460px;
33
- height: 1%;
34
- margin: 20px 0 0;
35
- padding: 0 0 5px;
36
- overflow: hidden;
37
- border: 1px solid #DFDFDF;
38
- }
39
- #cachify_main .form-table {
40
- margin: 0;
41
- }
42
- #cachify_main .form-table th {
43
- width: 230px;
44
- vertical-align: middle;
45
- }
46
- #cachify_main .form-table th small {
47
- color: #8F8F8F;
48
- display: block;
49
- text-shadow: none;
50
- }
51
- #cachify_main .form-table caption {
52
- width: 100%;
53
- color: #8F8F8F;
54
- margin: 0 0 5px;
55
- background: whiteSmoke;
56
- line-height: 20px;
57
- text-shadow: 1px 1px #FFF;
58
- }
59
- #cachify_main .rounded {
60
- border-radius: 3px;
61
- -moz-border-radius: 3px;
62
- -webkit-border-radius: 3px;
63
- }
64
-
65
- #cachify_main input,
66
- #cachify_main select {
67
- width: 172px;
68
- }
69
- #cachify_main input.small {
70
- width: 50px;
71
- }
72
- #cachify_main .submit {
73
- width: 460px;
74
- height: 1%;
75
- overflow: hidden;
76
- }
77
- #cachify_main .help {
78
- float: right;
79
- color: #bebebe;
80
- font-size: 11px;
81
- text-align: right;
82
- line-height: 11px;
83
- }
84
-
85
- /* @end group */
86
-
87
-
88
- /* @group Dashboard */
89
-
90
- #dashboard_right_now .table_cachify {
91
- margin-top: 36px;
92
- border-top: #ececec 1px solid;
93
- }
94
- #dashboard_right_now .table_cachify .b {
95
- font-size: 18px;
96
- padding-top: 0;
97
- }
98
-
99
- /* @end group */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
img/icon@2x.png DELETED
Binary file
img/trash@2x.png DELETED
Binary file
inc/cachify.class.php CHANGED
@@ -1,6 +1,10 @@
1
  <?php
2
 
3
 
 
 
 
 
4
  /**
5
  * Cachify
6
  */
@@ -14,44 +18,108 @@ final class Cachify {
14
  * @since 2.0
15
  * @var array
16
  */
17
-
18
  private static $options;
19
-
20
-
21
  /**
22
  * Cache-Methode
23
  *
24
  * @since 2.0
25
  * @var object
26
  */
27
-
28
  private static $method;
29
 
30
 
31
  /**
32
- * Initialisierung des Plugins
33
  *
34
- * @since 1.0
35
- * @change 2.0.3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  */
37
 
38
- public static function init()
39
- {
40
- /* Variablen */
41
- self::_set_vars();
42
-
 
 
 
 
 
43
  /* Publish-Hooks */
44
- self::_publish_hooks();
45
-
46
- /* Flush Hook */
 
 
 
 
 
 
 
47
  add_action(
48
  'cachify_flush_cache',
49
  array(
50
  __CLASS__,
51
- 'flush_cache'
52
  )
53
  );
54
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  /* Backend */
56
  if ( is_admin() ) {
57
  add_action(
@@ -68,7 +136,14 @@ final class Cachify {
68
  'uninstall_later'
69
  )
70
  );
71
-
 
 
 
 
 
 
 
72
  add_action(
73
  'admin_init',
74
  array(
@@ -80,7 +155,7 @@ final class Cachify {
80
  'admin_init',
81
  array(
82
  __CLASS__,
83
- 'receive_flush'
84
  )
85
  );
86
  add_action(
@@ -91,12 +166,12 @@ final class Cachify {
91
  )
92
  );
93
  add_action(
94
- 'admin_print_styles',
95
- array(
96
- __CLASS__,
97
- 'add_css'
98
- )
99
- );
100
 
101
  add_action(
102
  'transition_comment_status',
@@ -118,15 +193,22 @@ final class Cachify {
118
  'admin_bar_menu',
119
  array(
120
  __CLASS__,
121
- 'add_menu'
122
  ),
123
  90
124
  );
125
  add_action(
126
- 'right_now_content_table_end',
127
  array(
128
  __CLASS__,
129
- 'add_count'
 
 
 
 
 
 
 
130
  )
131
  );
132
 
@@ -150,12 +232,13 @@ final class Cachify {
150
  /* Frontend */
151
  } else {
152
  add_action(
153
- 'preprocess_comment',
154
  array(
155
  __CLASS__,
156
- 'add_comment'
157
  ),
158
- 1
 
159
  );
160
  add_action(
161
  'template_redirect',
@@ -174,19 +257,32 @@ final class Cachify {
174
  );
175
  }
176
  }
177
-
178
-
179
  /**
180
- * Plugin-Installation für MU-Blogs
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  *
182
  * @since 1.0
183
- * @change 1.0
184
  */
185
 
186
- public static function install()
187
  {
188
  /* Multisite & Network */
189
- if ( is_multisite() && !empty($_GET['networkwide']) ) {
190
  /* Blog-IDs */
191
  $ids = self::_get_blog_ids();
192
 
@@ -214,7 +310,7 @@ final class Cachify {
214
 
215
  public static function install_later($id) {
216
  /* Kein Netzwerk-Plugin */
217
- if ( !is_plugin_active_for_network(CACHIFY_BASE) ) {
218
  return;
219
  }
220
 
@@ -244,7 +340,7 @@ final class Cachify {
244
  );
245
 
246
  /* Flush */
247
- self::flush_cache();
248
  }
249
 
250
 
@@ -252,10 +348,10 @@ final class Cachify {
252
  * Deinstallation des Plugins pro MU-Blog
253
  *
254
  * @since 1.0
255
- * @change 1.0
256
  */
257
 
258
- public static function uninstall()
259
  {
260
  /* Global */
261
  global $wpdb;
@@ -292,7 +388,7 @@ final class Cachify {
292
  public static function uninstall_later($id)
293
  {
294
  /* Kein Netzwerk-Plugin */
295
- if ( !is_plugin_active_for_network(CACHIFY_BASE) ) {
296
  return;
297
  }
298
 
@@ -320,10 +416,10 @@ final class Cachify {
320
  delete_option('cachify');
321
 
322
  /* Cache leeren */
323
- self::flush_cache();
324
  }
325
-
326
-
327
  /**
328
  * Rückgabe der IDs installierter Blogs
329
  *
@@ -332,101 +428,68 @@ final class Cachify {
332
  *
333
  * @return array Blog-IDs
334
  */
335
-
336
  private static function _get_blog_ids()
337
  {
338
  /* Global */
339
  global $wpdb;
340
-
341
- return $wpdb->get_col(
342
- $wpdb->prepare("SELECT blog_id FROM `$wpdb->blogs`")
343
- );
344
  }
345
-
346
-
347
  /**
348
  * Eigenschaften des Objekts
349
  *
350
  * @since 2.0
351
- * @change 2.0
352
  */
353
-
354
- private static function _set_vars()
355
  {
356
  /* Optionen */
357
  self::$options = self::_get_options();
358
-
359
- /* Methode */
360
- if ( self::$options['use_apc'] === 1 && extension_loaded('apc') ) {
361
  self::$method = new Cachify_APC;
362
- } else if ( self::$options['use_apc'] === 2 ) {
 
 
363
  self::$method = new Cachify_HDD;
 
 
 
 
 
 
364
  } else {
365
  self::$method = new Cachify_DB;
366
  }
367
  }
368
-
369
-
370
- /**
371
- * Generierung von Publish-Hooks für Custom Post Types
372
- *
373
- * @since 2.0.3
374
- * @change 2.0.3
375
- */
376
-
377
- private static function _publish_hooks() {
378
- /* Verfügbare CPT */
379
- $available_cpt = get_post_types(
380
- array('public' => true)
381
- );
382
 
383
- /* Leer? */
384
- if ( empty($available_cpt) ) {
385
- return;
386
- }
387
 
388
- /* Loopen */
389
- foreach ( $available_cpt as $cpt ) {
390
- add_action(
391
- 'publish_' .$cpt,
392
- array(
393
- __CLASS__,
394
- 'publish_cpt'
395
- ),
396
- 10,
397
- 2
398
- );
399
- add_action(
400
- 'publish_future_' .$cpt,
401
- array(
402
- __CLASS__,
403
- 'publish_cpt'
404
- )
405
- );
406
- }
407
- }
408
-
409
-
410
  /**
411
  * Rückgabe der Optionen
412
  *
413
  * @since 2.0
414
- * @change 2.0
415
  *
416
  * @return array $diff Array mit Werten
417
  */
418
-
419
  private static function _get_options()
420
  {
421
  return wp_parse_args(
422
  get_option('cachify'),
423
  array(
424
- 'only_guests' => 1,
425
- 'compress_html' => 0,
426
- 'cache_expires' => 12,
427
- 'without_ids' => '',
428
- 'without_agents' => '',
429
- 'use_apc' => 0
 
430
  )
431
  );
432
  }
@@ -441,27 +504,27 @@ final class Cachify {
441
  * @param string $data Ursprungsinhalt der dynamischen robots.txt
442
  * @return string $data Modifizierter Inhalt der robots.txt
443
  */
444
-
445
  public static function robots_txt($data)
446
  {
447
  /* HDD only */
448
- if ( self::$options['use_apc'] !== 2 ) {
449
  return $data;
450
  }
451
-
452
  /* Pfad */
453
  $path = parse_url(site_url(), PHP_URL_PATH);
454
-
455
  /* Ausgabe */
456
  $data .= sprintf(
457
  'Disallow: %s/wp-content/cache/%s',
458
  ( empty($path) ? '' : $path ),
459
  "\n"
460
  );
461
-
462
  return $data;
463
  }
464
-
465
 
466
  /**
467
  * Hinzufügen der Action-Links
@@ -476,7 +539,7 @@ final class Cachify {
476
  public static function action_links($data)
477
  {
478
  /* Rechte? */
479
- if ( !current_user_can('manage_options') ) {
480
  return $data;
481
  }
482
 
@@ -502,68 +565,115 @@ final class Cachify {
502
  * Meta-Links des Plugins
503
  *
504
  * @since 0.5
505
- * @change 1.3
506
  *
507
- * @param array $data Bereits vorhandene Links
508
- * @param string $page Aktuelle Seite
509
- * @return array $data Modifizierte Links
510
  */
511
 
512
- public static function row_meta($data, $page)
513
  {
514
  /* Rechte */
515
  if ( $page != CACHIFY_BASE ) {
516
- return $data;
517
  }
518
-
519
  return array_merge(
520
- $data,
521
  array(
522
- '<a href="http://wpcoder.de" target="_blank">Weitere Plugins des Autors</a>'
 
523
  )
524
  );
525
  }
526
-
527
-
528
  /**
529
  * Hinzufügen eines Admin-Bar-Menüs
530
  *
531
  * @since 1.2
532
- * @change 1.2.1
533
  *
534
  * @param object Objekt mit Menü-Eigenschaften
535
  */
536
-
537
- public static function add_menu($wp_admin_bar)
538
  {
539
  /* Aussteigen */
540
- if ( !is_admin_bar_showing() or !is_super_admin() ) {
541
  return;
542
  }
543
-
 
 
 
544
  /* Hinzufügen */
545
  $wp_admin_bar->add_menu(
546
  array(
547
  'id' => 'cachify',
548
- 'title' => '<span class="ab-icon" title="Cache leeren"></span>',
549
  'href' => add_query_arg('_cachify', 'flush'),
550
- 'parent' => 'top-secondary'
 
 
551
  )
552
  );
553
  }
554
-
555
-
556
  /**
557
  * Anzeige des Spam-Counters auf dem Dashboard
558
  *
559
- * @since 2.0
560
- * @change 2.0.4
561
  */
562
 
563
- public static function add_count()
564
  {
565
- /* Größe */
566
- if ( !$size = get_transient('cachify_cache_size') ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
567
  /* Auslesen */
568
  $size = (int) call_user_func(
569
  array(
@@ -571,36 +681,16 @@ final class Cachify {
571
  'get_stats'
572
  )
573
  );
574
-
575
  /* Speichern */
576
  set_transient(
577
- 'cachify_cache_size',
578
- $size,
579
- 60 * 15
580
- );
581
  }
582
-
583
- /* Formatierung */
584
- $format = ( empty($size) ? array(0, 'Bytes') : explode(' ', size_format($size)) );
585
-
586
- /* Ausgabe */
587
- echo sprintf(
588
- '<tr>
589
- <td colspan="2">
590
- <div class="table table_cachify">
591
- <p class="sub">Cache</p>
592
- <table>
593
- <tr>
594
- <td class="b">%s</td>
595
- <td class="last t">%s</td>
596
- </tr>
597
- </table>
598
- </div>
599
- </td>
600
- </tr>',
601
- (int)$format[0],
602
- $format[1]
603
- );
604
  }
605
 
606
 
@@ -608,18 +698,18 @@ final class Cachify {
608
  * Verarbeitung der Plugin-Meta-Aktionen
609
  *
610
  * @since 0.5
611
- * @change 1.2
612
  *
613
  * @param array $data Metadaten der Plugins
614
  */
615
 
616
- public static function receive_flush($data)
617
  {
618
  /* Leer? */
619
- if ( empty($_GET['_cachify']) or $_GET['_cachify'] !== 'flush' ) {
620
  return;
621
  }
622
-
623
  /* Global */
624
  global $wpdb;
625
 
@@ -634,12 +724,12 @@ final class Cachify {
634
  /* Loopen */
635
  foreach ($ids as $id) {
636
  switch_to_blog($id);
637
- self::flush_cache();
638
  }
639
 
640
  /* Wechsel zurück */
641
  switch_to_blog($old);
642
-
643
  /* Notiz */
644
  add_action(
645
  'network_admin_notices',
@@ -650,8 +740,8 @@ final class Cachify {
650
  );
651
  } else {
652
  /* Leeren */
653
- self::flush_cache();
654
-
655
  /* Notiz */
656
  add_action(
657
  'admin_notices',
@@ -662,62 +752,73 @@ final class Cachify {
662
  );
663
  }
664
  }
665
-
666
-
667
  /**
668
  * Hinweis nach erfolgreichem Cache-Leeren
669
  *
670
  * @since 1.2
671
- * @change 1.2
672
  */
673
-
674
  public static function flush_notice()
675
  {
676
  /* Kein Admin */
677
- if ( !is_super_admin() ) {
678
  return false;
679
  }
680
-
681
- echo '<div id="message" class="updated"><p><strong>Cachify-Cache geleert.</strong></p></div>';
 
 
 
682
  }
683
 
684
 
685
  /**
686
  * Löschung des Cache beim Kommentar-Editieren
687
  *
688
- * @since 0.1
689
- * @change 0.4
690
  *
691
  * @param integer $id ID des Kommentars
692
  */
693
 
694
  public static function edit_comment($id)
695
  {
696
- self::_delete_cache(
697
- get_permalink(
 
 
698
  get_comment($id)->comment_post_ID
699
- )
700
- );
701
  }
702
 
703
 
704
  /**
705
  * Löschung des Cache beim neuen Kommentar
706
  *
707
- * @since 0.1
708
- * @change 0.1
709
  *
710
- * @param array $comment Array mit Eigenschaften
711
- * @return array $comment Array mit Eigenschaften
 
712
  */
713
 
714
- public static function add_comment($comment)
715
  {
716
- self::_delete_cache(
717
- get_permalink($comment['comment_post_ID'])
718
- );
 
 
 
 
 
719
 
720
- return $comment;
721
  }
722
 
723
 
@@ -725,7 +826,7 @@ final class Cachify {
725
  * Löschung des Cache beim Editieren der Kommentare
726
  *
727
  * @since 0.1
728
- * @change 0.4
729
  *
730
  * @param string $new_status Neuer Status
731
  * @param string $old_status Alter Status
@@ -735,37 +836,152 @@ final class Cachify {
735
  public static function touch_comment($new_status, $old_status, $comment)
736
  {
737
  if ( $new_status != $old_status ) {
738
- self::_delete_cache(
739
- get_permalink($comment->comment_post_ID)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
740
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
741
  }
742
  }
743
-
744
-
745
  /**
746
- * Leerung des Cache bei neuen CPTs
747
  *
748
  * @since 2.0.3
749
- * @change 2.0.3
750
  *
751
- * @param integer $id PostID
752
- * @param object $post Object mit CPT-Metadaten [optional]
753
  */
754
 
755
- public static function publish_cpt($id, $post = false)
756
  {
757
- /* Leer? */
758
- if ( empty($post) ) {
759
  return;
760
  }
761
-
762
- /* Status */
763
- if ( in_array( $post->post_status, array('publish', 'future') ) ) {
764
- self::flush_cache();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
765
  }
 
 
 
 
 
 
 
 
 
766
  }
767
-
768
-
769
  /**
770
  * Rückgabe der Cache-Gültigkeit
771
  *
@@ -774,12 +990,12 @@ final class Cachify {
774
  *
775
  * @return intval Gültigkeit in Sekunden
776
  */
777
-
778
  private static function _cache_expires()
779
  {
780
  return 60 * 60 * self::$options['cache_expires'];
781
  }
782
-
783
 
784
  /**
785
  * Rückgabe des Cache-Hash-Wertes
@@ -791,7 +1007,7 @@ final class Cachify {
791
  * @return string Cachify-Hash-Wert
792
  */
793
 
794
- private static function _cache_hash($url = '')
795
  {
796
  return md5(
797
  empty($url) ? ( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) : ( parse_url($url, PHP_URL_HOST) . parse_url($url, PHP_URL_PATH) )
@@ -813,25 +1029,6 @@ final class Cachify {
813
  {
814
  return (array)preg_split('/,/', $input, -1, PREG_SPLIT_NO_EMPTY);
815
  }
816
-
817
-
818
- /**
819
- * Prüfung der WordPress-Version
820
- *
821
- * @since 2.0
822
- * @change 2.0
823
- *
824
- * @param integer $version Gesuchte WP-Version
825
- * @return boolean TRUE, wenn mindestens gesuchte
826
- */
827
-
828
- private static function _is_wp($version) {
829
- return version_compare(
830
- $GLOBALS['wp_version'],
831
- $version. 'alpha',
832
- '>='
833
- );
834
- }
835
 
836
 
837
  /**
@@ -853,95 +1050,102 @@ final class Cachify {
853
  * Prüfung auf Mobile Devices
854
  *
855
  * @since 0.9.1
856
- * @change 1.0
857
  *
858
  * @return boolean TRUE bei Mobile
859
  */
860
 
861
  private static function _is_mobile()
862
  {
863
- return ( strpos(TEMPLATEPATH, 'wptouch') or strpos(TEMPLATEPATH, 'carrington') );
864
  }
865
-
866
-
867
  /**
868
  * Prüfung auf eingeloggte und kommentierte Nutzer
869
  *
870
- * @since 2.0
871
- * @change 2.0
872
  *
873
  * @return boolean $diff TRUE bei "vermerkten" Nutzern
874
  */
875
-
876
  private static function _is_logged_in()
877
  {
878
  /* Eingeloggt */
879
  if ( is_user_logged_in() ) {
880
  return true;
881
  }
882
-
883
  /* Cookie? */
884
  if ( empty($_COOKIE) ) {
885
  return false;
886
  }
887
-
888
  /* Loopen */
889
  foreach ( $_COOKIE as $k => $v) {
890
- if ( preg_match('/^(wp-postpass|wordpress|comment_author)_/', $k) ) {
891
  return true;
892
  }
893
  }
894
  }
895
-
896
 
897
  /**
898
  * Definition der Ausnahmen für den Cache
899
  *
900
  * @since 0.2
901
- * @change 2.0
902
  *
903
  * @return boolean TRUE bei Ausnahmen
 
 
904
  */
905
 
906
  private static function _skip_cache()
907
  {
908
- /* Optionen */
909
- $options = self::$options;
910
-
911
- /* Filter */
 
 
912
  if ( self::_is_index() or is_search() or is_404() or is_feed() or is_trackback() or is_robots() or is_preview() or post_password_required() ) {
913
  return true;
914
  }
915
-
916
- /* Request */
917
- if ( !empty($_POST) or (!empty($_GET) && get_option('permalink_structure')) ) {
 
 
 
918
  return true;
919
  }
920
-
921
  /* Logged in */
922
  if ( $options['only_guests'] && self::_is_logged_in() ) {
923
  return true;
924
  }
925
-
926
- /* WP Touch */
927
  if ( self::_is_mobile() ) {
928
  return true;
929
  }
930
-
931
  /* Post IDs */
932
  if ( $options['without_ids'] && is_singular() ) {
933
  if ( in_array( $GLOBALS['wp_query']->get_queried_object_id(), self::_preg_split($options['without_ids']) ) ) {
934
  return true;
935
  }
936
  }
937
-
938
  /* User Agents */
939
  if ( $options['without_agents'] && isset($_SERVER['HTTP_USER_AGENT']) ) {
940
  if ( array_filter( self::_preg_split($options['without_agents']), create_function('$a', 'return strpos($_SERVER["HTTP_USER_AGENT"], $a);') ) ) {
941
  return true;
942
  }
943
  }
944
-
945
  return false;
946
  }
947
 
@@ -950,23 +1154,47 @@ final class Cachify {
950
  * Minimierung des HTML-Codes
951
  *
952
  * @since 0.9.2
953
- * @change 2.0.1
954
  *
955
  * @param string $data Zu minimierender Datensatz
956
  * @return string $data Minimierter Datensatz
 
 
957
  */
958
 
959
  private static function _minify_cache($data) {
960
- /* Minimierung? */
961
- if ( !self::$options['compress_html'] ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
962
  return($data);
963
  }
964
-
965
- /* Verkleinern */
 
 
 
966
  $cleaned = preg_replace(
967
  array(
968
  '/<!--[^\[><](.*?)-->/s',
969
- '#(?ix)(?>[^\S ]\s*|\s{2,})(?=(?:(?:[^<]++|<(?!/?(?:textarea|pre)\b))*+)(?:<(?>textarea|pre)\b|\z))#'
970
  ),
971
  array(
972
  '',
@@ -974,8 +1202,8 @@ final class Cachify {
974
  ),
975
  (string) $data
976
  );
977
-
978
- /* Fehlerhaft? */
979
  if ( strlen($cleaned) <= 1 ) {
980
  return($data);
981
  }
@@ -984,28 +1212,6 @@ final class Cachify {
984
  }
985
 
986
 
987
- /**
988
- * Löschung des Cache für eine URL
989
- *
990
- * @since 0.1
991
- * @change 2.0
992
- *
993
- * @param string $url URL für den Hash-Wert
994
- */
995
-
996
- private static function _delete_cache($url)
997
- {
998
- call_user_func(
999
- array(
1000
- self::$method,
1001
- 'delete_item'
1002
- ),
1003
- self::_cache_hash($url),
1004
- $url
1005
- );
1006
- }
1007
-
1008
-
1009
  /**
1010
  * Zurücksetzen des kompletten Cache
1011
  *
@@ -1013,22 +1219,25 @@ final class Cachify {
1013
  * @change 2.0
1014
  */
1015
 
1016
- public static function flush_cache()
1017
  {
1018
  /* DB */
1019
  Cachify_DB::clear_cache();
1020
-
1021
  /* APC */
1022
  Cachify_APC::clear_cache();
1023
-
1024
- /* HD */
1025
  Cachify_HDD::clear_cache();
1026
-
 
 
 
1027
  /* Transient */
1028
  delete_transient('cachify_cache_size');
1029
  }
1030
-
1031
-
1032
  /**
1033
  * Zuweisung des Cache
1034
  *
@@ -1074,7 +1283,7 @@ final class Cachify {
1074
  if ( self::_skip_cache() ) {
1075
  return;
1076
  }
1077
-
1078
  /* Daten im Cache */
1079
  $cache = call_user_func(
1080
  array(
@@ -1083,13 +1292,13 @@ final class Cachify {
1083
  ),
1084
  self::_cache_hash()
1085
  );
1086
-
1087
  /* Kein Cache? */
1088
  if ( empty($cache) ) {
1089
  ob_start('Cachify::set_cache');
1090
  return;
1091
  }
1092
-
1093
  /* Cache verarbeiten */
1094
  call_user_func(
1095
  array(
@@ -1105,24 +1314,113 @@ final class Cachify {
1105
  * Einbindung von CSS
1106
  *
1107
  * @since 1.0
1108
- * @change 2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1109
  */
1110
 
1111
- public static function add_css()
1112
  {
1113
- /* Infos auslesen */
1114
- $data = get_plugin_data(CACHIFY_FILE);
1115
-
1116
- /* CSS registrieren */
1117
- wp_register_style(
1118
- 'cachify_css',
1119
- plugins_url('css/style.css', CACHIFY_FILE),
1120
- array(),
1121
- $data['Version']
 
 
 
 
 
 
 
 
 
1122
  );
1123
 
1124
- /* CSS einbinden */
1125
- wp_enqueue_style('cachify_css');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1126
  }
1127
 
1128
 
@@ -1145,125 +1443,80 @@ final class Cachify {
1145
  'options_page'
1146
  )
1147
  );
1148
-
1149
- /* Hilfe */
1150
- add_action(
1151
- 'load-' .$page,
1152
- array(
1153
- __CLASS__,
1154
- 'add_help'
1155
- )
1156
- );
1157
  }
1158
-
1159
-
1160
  /**
1161
- * Hilfe-Tab oben rechts
1162
  *
1163
- * @since 2.0
1164
- * @change 2.0.2
 
 
1165
  */
1166
-
1167
- public static function add_help()
1168
  {
1169
- /* WP zu alt? */
1170
- if ( !self::_is_wp('3.3') ) {
1171
- return;
1172
- }
1173
-
1174
- /* Screen */
1175
- $screen = get_current_screen();
1176
-
1177
- /* Tabs */
1178
- $screen->add_help_tab(
1179
- array(
1180
- 'id' => 'cachify_settings',
1181
- 'title' => 'Einstellungen',
1182
- 'content' => '<p>Bereitgestellte Einstellungen in Schnellübersicht:</p>'.
1183
- '<ul>'.
1184
- '<li><strong>Aufbewahrungsort für Cache</strong><br />'.
1185
- 'Je nach Verfügbarkeit stehen 3 Methoden der Cache-Speicherung zur Nutzung bereit: <em>Datenbank</em>, <em>APC</em>, <em>Festplatte</em>. Die Standard-Einstellung ist <em>Datenbank</em> - Cache-Inhalte werden dabei in der WordPress-Datenbank abgelegt und dort verwaltet. <em>APC</em> (Alternative PHP Cache) kann bei installiertem APC-PHP-Modul ausgewählt und verwendet werden. <em>Festplatte</em> als Methode ist erst bei eingeschalteten WordPress-Permalinks nutzbar. Bei der Auswahl <em>Festplatte</em> und <em>APC</em> sind Anpassungen in der Datei <em>.htaccess</em> / <em>nginx.conf</em> notwendig (siehe Online-Dokumentation).</li>'.
1186
-
1187
- '<li><strong>Cache-Gültigkeit in Stunden</strong><br />'.
1188
- 'Gültigkeitsdauer der Aufbewahrung von Cache-Inhalten. Keine Verwendung bei <em>Festplatte</em> als Caching-Methode. <em>0</em> = <em>unbegrenzt</em></li>'.
1189
-
1190
- '<li><strong>Minimierung der Ausgabe</strong><br />'.
1191
- 'Durch die Entfernung von HTML-Kommentaren und Umbrüchen im Quelltext der Blogseiten kann die Ausgabegröße reduziert und die Übertragung der Daten zum Browser beschleunigt werden. In Fehlerfällen ist die Option zu deaktivieren.</li>'.
1192
- '</ul>'
1193
- )
1194
- );
1195
- $screen->add_help_tab(
1196
- array(
1197
- 'id' => 'cachify_filter',
1198
- 'title' => 'Filter',
1199
- 'content' => '<p>Filter grenzen die Cache-Anwendung wie folgt ein:</p>'.
1200
- '<ul>'.
1201
- '<li><strong>Ausnahme für (Post/Pages) IDs</strong><br />'.
1202
- 'IDs bestimmter Artikel oder/und Seiten, die vom Caching ausgeschlossen werden sollen. Kommaseparierte Liste.</li>'.
1203
-
1204
- '<li><strong>Ausnahme für User Agents</strong><br />'.
1205
- 'User Agents gewünschter Browser bzw. Apps, die eine zwischengespeicherte Version der Webseite nie angezeigt bekommen sollen. Gilt nicht bei <em>APC</em> und <em>Festplatte</em> als Caching-Methoden.</li>'.
1206
-
1207
- '<li><strong>Kein Cache für eingeloggte bzw. kommentierende Nutzer</strong><br />'.
1208
- 'Bei aktiver Option bekommen ausschließlich nicht angemeldete bzw. nicht kommentierende Blog-Nutzer die Cache-Variante einer Webseite angezeigt. Gilt nicht bei <em>APC</em>. Online-Dokumentation beachten.</li>'.
1209
- '</ul>'
1210
- )
1211
- );
1212
- $screen->add_help_tab(
1213
- array(
1214
- 'id' => 'cachify_dashboard',
1215
- 'title' => 'Dashboard',
1216
- 'content' => '<p>Auf dem Admin-Dashboard bildet Cachify die aktuelle Cache-Größe ab. Cachify speichert den Wert für 15 Minuten zwischen.</p>'
1217
- )
1218
- );
1219
- $screen->add_help_tab(
1220
- array(
1221
- 'id' => 'cachify_manual',
1222
- 'title' => 'Dokumentation',
1223
- 'content' => '<p>Ausführliche Dokumentation für das Cachify-Plugin online verfügbar:</p>'.
1224
- '<p><a href="http://playground.ebiene.de/cachify-wordpress-cache/" target="_blank">http://playground.ebiene.de/cachify-wordpress-cache/</a></p>'
1225
- )
1226
- );
1227
-
1228
- /* Sidebar */
1229
- $screen->set_help_sidebar(
1230
- '<p><strong>Mehr zum Autor</strong></p>'.
1231
- '<p><a href="https://plus.google.com/110569673423509816572/" target="_blank">Google+</a></p>'.
1232
- '<p><a href="http://wpcoder.de" target="_blank">Plugins</a></p>'.
1233
- '<p><a href="http://ebiene.de" target="_blank">Portfolio</a></p>'
1234
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1235
  }
1236
-
1237
-
1238
  /**
1239
- * Verfügbare Cache-Methoden
1240
  *
1241
- * @since 2.0
1242
- * @change 2.0
1243
  *
1244
- * @param array $available Array mit verfügbaren Arten
1245
  */
1246
-
1247
- private static function _method_select()
1248
  {
1249
- /* Verfügbar */
1250
- $available = array(
1251
- 0 => 'Datenbank',
1252
- 1 => 'APC',
1253
- 2 => 'Festplatte'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1254
  );
1255
-
1256
- /* Kein APC */
1257
- if ( !extension_loaded('apc') ) {
1258
- unset($available[1]);
1259
- }
1260
-
1261
- /* Keine Permalinks */
1262
- if ( !get_option('permalink_structure') ) {
1263
- unset($available[2]);
1264
- }
1265
-
1266
- return $available;
1267
  }
1268
 
1269
 
@@ -1290,8 +1543,8 @@ final class Cachify {
1290
  /**
1291
  * Valisierung der Optionsseite
1292
  *
1293
- * @since 1.0
1294
- * @change 2.0
1295
  *
1296
  * @param array $data Array mit Formularwerten
1297
  * @return array Array mit geprüften Werten
@@ -1300,26 +1553,30 @@ final class Cachify {
1300
  public static function validate_options($data)
1301
  {
1302
  /* Cache leeren */
1303
- self::flush_cache();
1304
-
1305
  /* Hinweis */
1306
- if ( self::$options['use_apc'] != $data['use_apc'] && $data['use_apc'] >= 1 ) {
1307
  add_settings_error(
1308
  'cachify_method_tip',
1309
  'cachify_method_tip',
1310
- 'Die Server-Konfigurationsdatei (z.B. .htaccess) muss jetzt erweitert werden [<a href="http://playground.ebiene.de/cachify-wordpress-cache/" target="_blank">?</a>]',
1311
- 'error'
 
 
 
1312
  );
1313
  }
1314
-
1315
  /* Rückgabe */
1316
  return array(
1317
- 'only_guests' => (int)(!empty($data['only_guests'])),
1318
- 'compress_html' => (int)(!empty($data['compress_html'])),
1319
- 'cache_expires' => (int)(@$data['cache_expires']),
1320
- 'without_ids' => (string)sanitize_text_field(@$data['without_ids']),
1321
- 'without_agents' => (string)sanitize_text_field(@$data['without_agents']),
1322
- 'use_apc' => (int)$data['use_apc']
 
1323
  );
1324
  }
1325
 
@@ -1328,14 +1585,19 @@ final class Cachify {
1328
  * Darstellung der Optionsseite
1329
  *
1330
  * @since 1.0
1331
- * @change 2.0
1332
  */
1333
 
1334
  public static function options_page()
1335
  { ?>
1336
- <div class="wrap" id="cachify_main">
1337
- <?php screen_icon('cachify') ?>
 
 
 
 
1338
 
 
1339
  <h2>
1340
  Cachify
1341
  </h2>
@@ -1344,81 +1606,103 @@ final class Cachify {
1344
  <?php settings_fields('cachify') ?>
1345
 
1346
  <?php $options = self::_get_options() ?>
1347
-
1348
- <div class="table rounded">
1349
- <table class="form-table">
1350
- <caption class="rounded">Einstellungen</caption>
1351
-
1352
- <tr>
1353
- <th>
1354
- Aufbewahrungsort für Cache
1355
- </th>
1356
- <td>
1357
- <select name="cachify[use_apc]">
1358
  <?php foreach( self::_method_select() as $k => $v ) { ?>
1359
  <option value="<?php echo esc_attr($k) ?>" <?php selected($options['use_apc'], $k); ?>><?php echo esc_html($v) ?></option>
1360
  <?php } ?>
1361
  </select>
1362
- </td>
1363
- </tr>
1364
-
1365
- <tr>
1366
- <th>
1367
- Cache-Gültigkeit in Stunden
1368
- </th>
1369
- <td>
1370
- <input type="text" name="cachify[cache_expires]" value="<?php echo $options['cache_expires'] ?>" class="small" />
1371
- </td>
1372
- </tr>
1373
-
1374
- <tr>
1375
- <th>
1376
- Minimierung der Ausgabe
1377
- </th>
1378
- <td>
1379
- <input type="checkbox" name="cachify[compress_html]" value="1" <?php checked('1', $options['compress_html']); ?> />
1380
- </td>
1381
- </tr>
1382
- </table>
1383
- </div>
1384
-
1385
- <div class="table rounded">
1386
- <table class="form-table">
1387
- <caption class="rounded">Filter</caption>
1388
-
1389
- <tr>
1390
- <th>
1391
- Ausnahme für (Post/Pages) IDs
1392
- </th>
1393
- <td>
1394
- <input type="text" name="cachify[without_ids]" value="<?php echo $options['without_ids'] ?>" />
1395
- </td>
1396
- </tr>
1397
-
1398
- <tr>
1399
- <th>
1400
- Ausnahme für User Agents
1401
- </th>
1402
- <td>
1403
- <input type="text" name="cachify[without_agents]" value="<?php echo $options['without_agents'] ?>" />
1404
- </td>
1405
- </tr>
1406
-
1407
- <tr>
1408
- <th>
1409
- Kein Cache für eingeloggte<br />bzw. kommentierende Nutzer
1410
- </th>
1411
- <td>
1412
- <input type="checkbox" name="cachify[only_guests]" value="1" <?php checked('1', $options['only_guests']); ?> />
1413
- </td>
1414
- </tr>
1415
- </table>
1416
- </div>
1417
-
1418
- <p class="submit">
1419
- <span class="help">Beachte die Hilfe<br />oben rechts</span>
1420
- <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
1421
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1422
  </form>
1423
  </div><?php
1424
  }
1
  <?php
2
 
3
 
4
+ /* Quit */
5
+ defined('ABSPATH') OR exit;
6
+
7
+
8
  /**
9
  * Cachify
10
  */
18
  * @since 2.0
19
  * @var array
20
  */
21
+
22
  private static $options;
23
+
24
+
25
  /**
26
  * Cache-Methode
27
  *
28
  * @since 2.0
29
  * @var object
30
  */
31
+
32
  private static $method;
33
 
34
 
35
  /**
36
+ * Method settings
37
  *
38
+ * @since 2.0.9
39
+ * @var integer
40
+ */
41
+
42
+ const METHOD_DB = 0;
43
+ const METHOD_APC = 1;
44
+ const METHOD_HDD = 2;
45
+ const METHOD_MMC = 3;
46
+
47
+
48
+ /**
49
+ * Minify settings
50
+ *
51
+ * @since 2.0.9
52
+ * @var integer
53
+ */
54
+
55
+ const MINIFY_DISABLED = 0;
56
+ const MINIFY_HTML_ONLY = 1;
57
+ const MINIFY_HTML_JS = 2;
58
+
59
+
60
+ /**
61
+ * Pseudo-Konstruktor der Klasse
62
+ *
63
+ * @since 2.0.5
64
+ * @change 2.0.5
65
+ */
66
+
67
+ public static function instance()
68
+ {
69
+ new self();
70
+ }
71
+
72
+
73
+ /**
74
+ * Konstruktor der Klasse
75
+ *
76
+ * @since 1.0.0
77
+ * @change 2.1.3
78
  */
79
 
80
+ public function __construct()
81
+ {
82
+ /* Filter */
83
+ if ( ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) OR ( defined('DONOTCACHEPAGE') && DONOTCACHEPAGE ) ) {
84
+ return;
85
+ }
86
+
87
+ /* Set defaults */
88
+ self::_set_default_vars();
89
+
90
  /* Publish-Hooks */
91
+ self::_register_publish_hooks();
92
+
93
+ /* Flush Hooks */
94
+ add_action(
95
+ 'cachify_remove_post_cache',
96
+ array(
97
+ __CLASS__,
98
+ 'remove_page_cache_by_post_id'
99
+ )
100
+ );
101
  add_action(
102
  'cachify_flush_cache',
103
  array(
104
  __CLASS__,
105
+ 'flush_total_cache'
106
  )
107
  );
108
+ add_action(
109
+ '_core_updated_successfully',
110
+ array(
111
+ __CLASS__,
112
+ 'flush_total_cache'
113
+ )
114
+ );
115
+ add_action(
116
+ 'switch_theme',
117
+ array(
118
+ __CLASS__,
119
+ 'flush_total_cache'
120
+ )
121
+ );
122
+
123
  /* Backend */
124
  if ( is_admin() ) {
125
  add_action(
136
  'uninstall_later'
137
  )
138
  );
139
+
140
+ add_action(
141
+ 'admin_init',
142
+ array(
143
+ __CLASS__,
144
+ 'register_textdomain'
145
+ )
146
+ );
147
  add_action(
148
  'admin_init',
149
  array(
155
  'admin_init',
156
  array(
157
  __CLASS__,
158
+ 'process_flush_request'
159
  )
160
  );
161
  add_action(
166
  )
167
  );
168
  add_action(
169
+ 'admin_enqueue_scripts',
170
+ array(
171
+ __CLASS__,
172
+ 'add_admin_resources'
173
+ )
174
+ );
175
 
176
  add_action(
177
  'transition_comment_status',
193
  'admin_bar_menu',
194
  array(
195
  __CLASS__,
196
+ 'add_flush_icon'
197
  ),
198
  90
199
  );
200
  add_action(
201
+ 'dashboard_glance_items',
202
  array(
203
  __CLASS__,
204
+ 'add_dashboard_count'
205
+ )
206
+ );
207
+ add_action(
208
+ 'post_submitbox_misc_actions',
209
+ array(
210
+ __CLASS__,
211
+ 'print_flush_dropdown'
212
  )
213
  );
214
 
232
  /* Frontend */
233
  } else {
234
  add_action(
235
+ 'pre_comment_approved',
236
  array(
237
  __CLASS__,
238
+ 'pre_comment'
239
  ),
240
+ 99,
241
+ 2
242
  );
243
  add_action(
244
  'template_redirect',
257
  );
258
  }
259
  }
260
+
261
+
262
  /**
263
+ * Deactivation hook
264
+ *
265
+ * @since 2.1.0
266
+ * @change 2.1.0
267
+ */
268
+
269
+ public static function on_deactivation()
270
+ {
271
+ self::flush_total_cache();
272
+ }
273
+
274
+
275
+ /**
276
+ * Activation hook
277
  *
278
  * @since 1.0
279
+ * @change 2.1.0
280
  */
281
 
282
+ public static function on_activation()
283
  {
284
  /* Multisite & Network */
285
+ if ( is_multisite() && ! empty($_GET['networkwide']) ) {
286
  /* Blog-IDs */
287
  $ids = self::_get_blog_ids();
288
 
310
 
311
  public static function install_later($id) {
312
  /* Kein Netzwerk-Plugin */
313
+ if ( ! is_plugin_active_for_network(CACHIFY_BASE) ) {
314
  return;
315
  }
316
 
340
  );
341
 
342
  /* Flush */
343
+ self::flush_total_cache();
344
  }
345
 
346
 
348
  * Deinstallation des Plugins pro MU-Blog
349
  *
350
  * @since 1.0
351
+ * @change 2.1.0
352
  */
353
 
354
+ public static function on_uninstall()
355
  {
356
  /* Global */
357
  global $wpdb;
388
  public static function uninstall_later($id)
389
  {
390
  /* Kein Netzwerk-Plugin */
391
+ if ( ! is_plugin_active_for_network(CACHIFY_BASE) ) {
392
  return;
393
  }
394
 
416
  delete_option('cachify');
417
 
418
  /* Cache leeren */
419
+ self::flush_total_cache();
420
  }
421
+
422
+
423
  /**
424
  * Rückgabe der IDs installierter Blogs
425
  *
428
  *
429
  * @return array Blog-IDs
430
  */
431
+
432
  private static function _get_blog_ids()
433
  {
434
  /* Global */
435
  global $wpdb;
436
+
437
+ return $wpdb->get_col("SELECT blog_id FROM `$wpdb->blogs`");
 
 
438
  }
439
+
440
+
441
  /**
442
  * Eigenschaften des Objekts
443
  *
444
  * @since 2.0
445
+ * @change 2.0.7
446
  */
447
+
448
+ private static function _set_default_vars()
449
  {
450
  /* Optionen */
451
  self::$options = self::_get_options();
452
+
453
+ /* APC */
454
+ if ( self::$options['use_apc'] === self::METHOD_APC && Cachify_APC::is_available() ) {
455
  self::$method = new Cachify_APC;
456
+
457
+ /* HDD */
458
+ } else if ( self::$options['use_apc'] === self::METHOD_HDD && Cachify_HDD::is_available() ) {
459
  self::$method = new Cachify_HDD;
460
+
461
+ /* MEMCACHED */
462
+ } else if ( self::$options['use_apc'] === self::METHOD_MMC && Cachify_MEMCACHED::is_available() ) {
463
+ self::$method = new Cachify_MEMCACHED;
464
+
465
+ /* DB */
466
  } else {
467
  self::$method = new Cachify_DB;
468
  }
469
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
 
 
 
 
 
471
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
  /**
473
  * Rückgabe der Optionen
474
  *
475
  * @since 2.0
476
+ * @change 2.1.2
477
  *
478
  * @return array $diff Array mit Werten
479
  */
480
+
481
  private static function _get_options()
482
  {
483
  return wp_parse_args(
484
  get_option('cachify'),
485
  array(
486
+ 'only_guests' => 1,
487
+ 'compress_html' => self::MINIFY_DISABLED,
488
+ 'cache_expires' => 12,
489
+ 'without_ids' => '',
490
+ 'without_agents' => '',
491
+ 'use_apc' => self::METHOD_DB,
492
+ 'reset_on_comment' => 0
493
  )
494
  );
495
  }
504
  * @param string $data Ursprungsinhalt der dynamischen robots.txt
505
  * @return string $data Modifizierter Inhalt der robots.txt
506
  */
507
+
508
  public static function robots_txt($data)
509
  {
510
  /* HDD only */
511
+ if ( self::$options['use_apc'] !== self::METHOD_HDD ) {
512
  return $data;
513
  }
514
+
515
  /* Pfad */
516
  $path = parse_url(site_url(), PHP_URL_PATH);
517
+
518
  /* Ausgabe */
519
  $data .= sprintf(
520
  'Disallow: %s/wp-content/cache/%s',
521
  ( empty($path) ? '' : $path ),
522
  "\n"
523
  );
524
+
525
  return $data;
526
  }
527
+
528
 
529
  /**
530
  * Hinzufügen der Action-Links
539
  public static function action_links($data)
540
  {
541
  /* Rechte? */
542
+ if ( ! current_user_can('manage_options') ) {
543
  return $data;
544
  }
545
 
565
  * Meta-Links des Plugins
566
  *
567
  * @since 0.5
568
+ * @change 2.0.5
569
  *
570
+ * @param array $input Bereits vorhandene Links
571
+ * @param string $page Aktuelle Seite
572
+ * @return array $data Modifizierte Links
573
  */
574
 
575
+ public static function row_meta($input, $page)
576
  {
577
  /* Rechte */
578
  if ( $page != CACHIFY_BASE ) {
579
+ return $input;
580
  }
581
+
582
  return array_merge(
583
+ $input,
584
  array(
585
+ '<a href="https://flattr.com/t/1327625" target="_blank">Flattr</a>',
586
+ '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=5RDDW9FEHGLG6" target="_blank">PayPal</a>'
587
  )
588
  );
589
  }
590
+
591
+
592
  /**
593
  * Hinzufügen eines Admin-Bar-Menüs
594
  *
595
  * @since 1.2
596
+ * @change 2.1.5
597
  *
598
  * @param object Objekt mit Menü-Eigenschaften
599
  */
600
+
601
+ public static function add_flush_icon($wp_admin_bar)
602
  {
603
  /* Aussteigen */
604
+ if ( ! is_admin_bar_showing() OR ! is_super_admin() ) {
605
  return;
606
  }
607
+
608
+ /* Display the admin icon anytime */
609
+ echo '<style>#wp-admin-bar-cachify{display:list-item !important} .ab-icon:before{content:"\f182";top:2px;margin:0}</style>';
610
+
611
  /* Hinzufügen */
612
  $wp_admin_bar->add_menu(
613
  array(
614
  'id' => 'cachify',
 
615
  'href' => add_query_arg('_cachify', 'flush'),
616
+ 'parent' => 'top-secondary',
617
+ 'title' => '<span class="ab-icon dashicons"></span>',
618
+ 'meta' => array( 'title' => __('Flush the cachify cache', 'cachify') )
619
  )
620
  );
621
  }
622
+
623
+
624
  /**
625
  * Anzeige des Spam-Counters auf dem Dashboard
626
  *
627
+ * @since 2.0.0
628
+ * @change 2.1.3
629
  */
630
 
631
+ public static function add_dashboard_count()
632
  {
633
+ /* Cache size */
634
+ $size = self::get_cache_size();
635
+
636
+ /* Caching method */
637
+ $method = call_user_func(
638
+ array(
639
+ self::$method,
640
+ 'stringify‎_method'
641
+ )
642
+ );
643
+
644
+ /* Print the link */
645
+ echo sprintf(
646
+ '<li>
647
+ <a href="%s" class="cachify-icon cachify-icon--%s" title="%s: %s">
648
+ %s Cache
649
+ </a>
650
+ </li>',
651
+ add_query_arg(
652
+ array(
653
+ 'page' => 'cachify'
654
+ ),
655
+ admin_url('options-general.php')
656
+ ),
657
+ esc_attr(strtolower($method)),
658
+ __('Caching method', 'cachify'),
659
+ esc_attr($method),
660
+ ( empty($size) ? __('Empty', 'cachify') : size_format($size) )
661
+ );
662
+ }
663
+
664
+
665
+ /**
666
+ * Rückgabe der Cache-Größe
667
+ *
668
+ * @since 2.0.6
669
+ * @change 2.0.6
670
+ *
671
+ * @param integer $size Cache-Größe in Bytes
672
+ */
673
+
674
+ public static function get_cache_size()
675
+ {
676
+ if ( ! $size = get_transient('cachify_cache_size') ) {
677
  /* Auslesen */
678
  $size = (int) call_user_func(
679
  array(
681
  'get_stats'
682
  )
683
  );
684
+
685
  /* Speichern */
686
  set_transient(
687
+ 'cachify_cache_size',
688
+ $size,
689
+ 60 * 15
690
+ );
691
  }
692
+
693
+ return $size;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
694
  }
695
 
696
 
698
  * Verarbeitung der Plugin-Meta-Aktionen
699
  *
700
  * @since 0.5
701
+ * @change 2.1.3
702
  *
703
  * @param array $data Metadaten der Plugins
704
  */
705
 
706
+ public static function process_flush_request($data)
707
  {
708
  /* Leer? */
709
+ if ( empty($_GET['_cachify']) OR $_GET['_cachify'] !== 'flush' OR ! is_super_admin() ) {
710
  return;
711
  }
712
+
713
  /* Global */
714
  global $wpdb;
715
 
724
  /* Loopen */
725
  foreach ($ids as $id) {
726
  switch_to_blog($id);
727
+ self::flush_total_cache();
728
  }
729
 
730
  /* Wechsel zurück */
731
  switch_to_blog($old);
732
+
733
  /* Notiz */
734
  add_action(
735
  'network_admin_notices',
740
  );
741
  } else {
742
  /* Leeren */
743
+ self::flush_total_cache();
744
+
745
  /* Notiz */
746
  add_action(
747
  'admin_notices',
752
  );
753
  }
754
  }
755
+
756
+
757
  /**
758
  * Hinweis nach erfolgreichem Cache-Leeren
759
  *
760
  * @since 1.2
761
+ * @change 2.1.3
762
  */
763
+
764
  public static function flush_notice()
765
  {
766
  /* Kein Admin */
767
+ if ( ! is_super_admin() ) {
768
  return false;
769
  }
770
+
771
+ echo sprintf(
772
+ '<div id="message" class="updated"><p><strong>%s</strong></p></div>',
773
+ __('Cachify cache is flushed.', 'cachify')
774
+ );
775
  }
776
 
777
 
778
  /**
779
  * Löschung des Cache beim Kommentar-Editieren
780
  *
781
+ * @since 0.1.0
782
+ * @change 2.1.2
783
  *
784
  * @param integer $id ID des Kommentars
785
  */
786
 
787
  public static function edit_comment($id)
788
  {
789
+ if ( self::$options['reset_on_comment'] ) {
790
+ self::flush_total_cache();
791
+ } else {
792
+ self::remove_page_cache_by_post_id(
793
  get_comment($id)->comment_post_ID
794
+ );
795
+ }
796
  }
797
 
798
 
799
  /**
800
  * Löschung des Cache beim neuen Kommentar
801
  *
802
+ * @since 0.1.0
803
+ * @change 2.1.2
804
  *
805
+ * @param mixed $approved Kommentar-Status
806
+ * @param array $comment Array mit Eigenschaften
807
+ * @return mixed $approved Kommentar-Status
808
  */
809
 
810
+ public static function pre_comment($approved, $comment)
811
  {
812
+ /* Approved comment? */
813
+ if ( $approved === 1 ) {
814
+ if ( self::$options['reset_on_comment'] ) {
815
+ self::flush_total_cache();
816
+ } else {
817
+ self::remove_page_cache_by_post_id( $comment['comment_post_ID'] );
818
+ }
819
+ }
820
 
821
+ return $approved;
822
  }
823
 
824
 
826
  * Löschung des Cache beim Editieren der Kommentare
827
  *
828
  * @since 0.1
829
+ * @change 2.1.2
830
  *
831
  * @param string $new_status Neuer Status
832
  * @param string $old_status Alter Status
836
  public static function touch_comment($new_status, $old_status, $comment)
837
  {
838
  if ( $new_status != $old_status ) {
839
+ if ( self::$options['reset_on_comment'] ) {
840
+ self::flush_total_cache();
841
+ } else {
842
+ self::remove_page_cache_by_post_id( $comment->comment_post_ID );
843
+ }
844
+ }
845
+ }
846
+
847
+
848
+ /**
849
+ * Generierung von Publish-Hooks für Custom Post Types
850
+ *
851
+ * @since 2.0.3
852
+ * @change 2.1.3
853
+ */
854
+
855
+ private static function _register_publish_hooks() {
856
+ /* Available post types */
857
+ $post_types = get_post_types(
858
+ array('public' => true)
859
+ );
860
+
861
+ /* Empty data? */
862
+ if ( empty($post_types) ) {
863
+ return;
864
+ }
865
+
866
+ /* Loopen */
867
+ foreach ( $post_types as $post_type ) {
868
+ add_action(
869
+ 'publish_' .$post_type,
870
+ array(
871
+ __CLASS__,
872
+ 'publish_post_types'
873
+ ),
874
+ 10,
875
+ 2
876
  );
877
+ add_action(
878
+ 'publish_future_' .$post_type,
879
+ array(
880
+ __CLASS__,
881
+ 'flush_total_cache'
882
+ )
883
+ );
884
+ }
885
+ }
886
+
887
+
888
+ /**
889
+ * Removes the post type cache on updates
890
+ *
891
+ * @since 2.0.3
892
+ * @change 2.1.3
893
+ *
894
+ * @param integer $post_ID Post ID
895
+ */
896
+
897
+ public static function publish_post_types($post_ID, $post) {
898
+ /* No Post_ID? */
899
+ if ( empty($post_ID) OR empty($post) ) {
900
+ return;
901
+ }
902
+
903
+ /* Post status check */
904
+ if ( ! in_array( $post->post_status, array('publish', 'future') ) ) {
905
+ return;
906
+ }
907
+
908
+ /* Check for post var AND flush */
909
+ if ( ! isset($_POST['_cachify_remove_post_type_cache_on_update']) ) {
910
+ return self::flush_total_cache();
911
+ }
912
+
913
+ /* Security */
914
+ check_admin_referer(CACHIFY_BASE, '_cachify_status_nonce');
915
+
916
+ /* Save as var */
917
+ $remove_post_type_cache = (int)$_POST['_cachify_remove_post_type_cache_on_update'];
918
+
919
+ /* Save as user meta */
920
+ update_user_meta(
921
+ get_current_user_id(),
922
+ '_cachify_remove_post_type_cache_on_update',
923
+ $remove_post_type_cache
924
+ );
925
+
926
+ /* Remove cache OR flush */
927
+ if ( $remove_post_type_cache ) {
928
+ self::remove_page_cache_by_post_id( $post_ID );
929
+ } else {
930
+ self::flush_total_cache();
931
  }
932
  }
933
+
934
+
935
  /**
936
+ * Removes a page (id) from cache
937
  *
938
  * @since 2.0.3
939
+ * @change 2.1.3
940
  *
941
+ * @param integer $post_ID Post ID
 
942
  */
943
 
944
+ public static function remove_page_cache_by_post_id($post_ID)
945
  {
946
+ /* Value check */
947
+ if ( ! $post_ID = (int)$post_ID ) {
948
  return;
949
  }
950
+
951
+ /* Remove page by url */
952
+ self::remove_page_cache_by_url(
953
+ get_permalink( $post_ID )
954
+ );
955
+ }
956
+
957
+
958
+ /**
959
+ * Removes a page url from cache
960
+ *
961
+ * @since 0.1
962
+ * @change 2.1.3
963
+ *
964
+ * @param string $url Page URL
965
+ */
966
+
967
+ public static function remove_page_cache_by_url($url)
968
+ {
969
+ /* Value check */
970
+ if ( ! $url = (string)$url ) {
971
+ return;
972
  }
973
+
974
+ call_user_func(
975
+ array(
976
+ self::$method,
977
+ 'delete_item'
978
+ ),
979
+ self::_cache_hash( $url ),
980
+ $url
981
+ );
982
  }
983
+
984
+
985
  /**
986
  * Rückgabe der Cache-Gültigkeit
987
  *
990
  *
991
  * @return intval Gültigkeit in Sekunden
992
  */
993
+
994
  private static function _cache_expires()
995
  {
996
  return 60 * 60 * self::$options['cache_expires'];
997
  }
998
+
999
 
1000
  /**
1001
  * Rückgabe des Cache-Hash-Wertes
1007
  * @return string Cachify-Hash-Wert
1008
  */
1009
 
1010
+ private static function _cache_hash($url = '')
1011
  {
1012
  return md5(
1013
  empty($url) ? ( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) : ( parse_url($url, PHP_URL_HOST) . parse_url($url, PHP_URL_PATH) )
1029
  {
1030
  return (array)preg_split('/,/', $input, -1, PREG_SPLIT_NO_EMPTY);
1031
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1032
 
1033
 
1034
  /**
1050
  * Prüfung auf Mobile Devices
1051
  *
1052
  * @since 0.9.1
1053
+ * @change 2.0.7
1054
  *
1055
  * @return boolean TRUE bei Mobile
1056
  */
1057
 
1058
  private static function _is_mobile()
1059
  {
1060
+ return ( strpos(TEMPLATEPATH, 'wptouch') or strpos(TEMPLATEPATH, 'carrington') or strpos(TEMPLATEPATH, 'jetpack') or strpos(TEMPLATEPATH, 'handheld') );
1061
  }
1062
+
1063
+
1064
  /**
1065
  * Prüfung auf eingeloggte und kommentierte Nutzer
1066
  *
1067
+ * @since 2.0.0
1068
+ * @change 2.0.5
1069
  *
1070
  * @return boolean $diff TRUE bei "vermerkten" Nutzern
1071
  */
1072
+
1073
  private static function _is_logged_in()
1074
  {
1075
  /* Eingeloggt */
1076
  if ( is_user_logged_in() ) {
1077
  return true;
1078
  }
1079
+
1080
  /* Cookie? */
1081
  if ( empty($_COOKIE) ) {
1082
  return false;
1083
  }
1084
+
1085
  /* Loopen */
1086
  foreach ( $_COOKIE as $k => $v) {
1087
+ if ( preg_match('/^(wp-postpass|wordpress_logged_in|comment_author)_/', $k) ) {
1088
  return true;
1089
  }
1090
  }
1091
  }
1092
+
1093
 
1094
  /**
1095
  * Definition der Ausnahmen für den Cache
1096
  *
1097
  * @since 0.2
1098
+ * @change 2.1.1
1099
  *
1100
  * @return boolean TRUE bei Ausnahmen
1101
+ *
1102
+ * @hook boolean cachify_skip_cache
1103
  */
1104
 
1105
  private static function _skip_cache()
1106
  {
1107
+ /* No cache hook */
1108
+ if ( apply_filters('cachify_skip_cache', false) ) {
1109
+ return true;
1110
+ }
1111
+
1112
+ /* Conditional Tags */
1113
  if ( self::_is_index() or is_search() or is_404() or is_feed() or is_trackback() or is_robots() or is_preview() or post_password_required() ) {
1114
  return true;
1115
  }
1116
+
1117
+ /* Plugin options */
1118
+ $options = self::$options;
1119
+
1120
+ /* Request vars */
1121
+ if ( !empty($_POST) OR (!empty($_GET) && get_option('permalink_structure')) ) {
1122
  return true;
1123
  }
1124
+
1125
  /* Logged in */
1126
  if ( $options['only_guests'] && self::_is_logged_in() ) {
1127
  return true;
1128
  }
1129
+
1130
+ /* Mobile request */
1131
  if ( self::_is_mobile() ) {
1132
  return true;
1133
  }
1134
+
1135
  /* Post IDs */
1136
  if ( $options['without_ids'] && is_singular() ) {
1137
  if ( in_array( $GLOBALS['wp_query']->get_queried_object_id(), self::_preg_split($options['without_ids']) ) ) {
1138
  return true;
1139
  }
1140
  }
1141
+
1142
  /* User Agents */
1143
  if ( $options['without_agents'] && isset($_SERVER['HTTP_USER_AGENT']) ) {
1144
  if ( array_filter( self::_preg_split($options['without_agents']), create_function('$a', 'return strpos($_SERVER["HTTP_USER_AGENT"], $a);') ) ) {
1145
  return true;
1146
  }
1147
  }
1148
+
1149
  return false;
1150
  }
1151
 
1154
  * Minimierung des HTML-Codes
1155
  *
1156
  * @since 0.9.2
1157
+ * @change 2.0.9
1158
  *
1159
  * @param string $data Zu minimierender Datensatz
1160
  * @return string $data Minimierter Datensatz
1161
+ *
1162
+ * @hook array cachify_minify_ignore_tags
1163
  */
1164
 
1165
  private static function _minify_cache($data) {
1166
+ /* Disabled? */
1167
+ if ( ! self::$options['compress_html'] ) {
1168
+ return($data);
1169
+ }
1170
+
1171
+ /* Ignore this html tags */
1172
+ $ignore_tags = (array)apply_filters(
1173
+ 'cachify_minify_ignore_tags',
1174
+ array(
1175
+ 'textarea',
1176
+ 'pre'
1177
+ )
1178
+ );
1179
+
1180
+ /* Add the script tag */
1181
+ if ( self::$options['compress_html'] !== self::MINIFY_HTML_JS ) {
1182
+ $ignore_tags[] = 'script';
1183
+ }
1184
+
1185
+ /* Empty blacklist? | TODO: Make better */
1186
+ if ( ! $ignore_tags ) {
1187
  return($data);
1188
  }
1189
+
1190
+ /* Convert to string */
1191
+ $ignore_regex = implode('|', $ignore_tags);
1192
+
1193
+ /* Minify */
1194
  $cleaned = preg_replace(
1195
  array(
1196
  '/<!--[^\[><](.*?)-->/s',
1197
+ '#(?ix)(?>[^\S ]\s*|\s{2,})(?=(?:(?:[^<]++|<(?!/?(?:' .$ignore_regex. ')\b))*+)(?:<(?>' .$ignore_regex. ')\b|\z))#'
1198
  ),
1199
  array(
1200
  '',
1202
  ),
1203
  (string) $data
1204
  );
1205
+
1206
+ /* Fault */
1207
  if ( strlen($cleaned) <= 1 ) {
1208
  return($data);
1209
  }
1212
  }
1213
 
1214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1215
  /**
1216
  * Zurücksetzen des kompletten Cache
1217
  *
1219
  * @change 2.0
1220
  */
1221
 
1222
+ public static function flush_total_cache()
1223
  {
1224
  /* DB */
1225
  Cachify_DB::clear_cache();
1226
+
1227
  /* APC */
1228
  Cachify_APC::clear_cache();
1229
+
1230
+ /* HDD */
1231
  Cachify_HDD::clear_cache();
1232
+
1233
+ /* MEMCACHED */
1234
+ Cachify_MEMCACHED::clear_cache();
1235
+
1236
  /* Transient */
1237
  delete_transient('cachify_cache_size');
1238
  }
1239
+
1240
+
1241
  /**
1242
  * Zuweisung des Cache
1243
  *
1283
  if ( self::_skip_cache() ) {
1284
  return;
1285
  }
1286
+
1287
  /* Daten im Cache */
1288
  $cache = call_user_func(
1289
  array(
1292
  ),
1293
  self::_cache_hash()
1294
  );
1295
+
1296
  /* Kein Cache? */
1297
  if ( empty($cache) ) {
1298
  ob_start('Cachify::set_cache');
1299
  return;
1300
  }
1301
+
1302
  /* Cache verarbeiten */
1303
  call_user_func(
1304
  array(
1314
  * Einbindung von CSS
1315
  *
1316
  * @since 1.0
1317
+ * @change 2.1.3
1318
+ */
1319
+
1320
+ public static function add_admin_resources($hook)
1321
+ {
1322
+ /* Hooks check */
1323
+ if ( $hook !== 'index.php' AND $hook !== 'post.php' ) {
1324
+ return;
1325
+ }
1326
+
1327
+ /* Plugin data */
1328
+ $plugin_data = get_plugin_data(CACHIFY_FILE);
1329
+
1330
+ /* Register css */
1331
+ switch($hook) {
1332
+ case 'index.php':
1333
+ wp_enqueue_style(
1334
+ 'cachify-dashboard',
1335
+ plugins_url('css/dashboard.min.css', CACHIFY_FILE),
1336
+ array(),
1337
+ $plugin_data['Version']
1338
+ );
1339
+ break;
1340
+
1341
+ case 'post.php':
1342
+ wp_enqueue_script(
1343
+ 'cachify-post',
1344
+ plugins_url('js/post.min.js', CACHIFY_FILE),
1345
+ array('jquery'),
1346
+ $plugin_data['Version'],
1347
+ true
1348
+ );
1349
+ break;
1350
+
1351
+ default:
1352
+ break;
1353
+ }
1354
+ }
1355
+
1356
+
1357
+ /**
1358
+ * Display a combo select on post publish box
1359
+ *
1360
+ * @since 2.1.3
1361
+ * @change 2.1.3
1362
  */
1363
 
1364
+ public static function print_flush_dropdown()
1365
  {
1366
+ /* Post page only */
1367
+ if ( empty($GLOBALS['pagenow']) OR $GLOBALS['pagenow'] !== 'post.php' ) {
1368
+ return;
1369
+ }
1370
+
1371
+ /* Published posts only */
1372
+ if ( empty($GLOBALS['post']) OR ! is_object($GLOBALS['post']) OR $GLOBALS['post']->post_status !== 'publish' ) {
1373
+ return;
1374
+ }
1375
+
1376
+ /* Security */
1377
+ wp_nonce_field(CACHIFY_BASE, '_cachify_status_nonce');
1378
+
1379
+ /* Already saved? */
1380
+ $current_action = (int)get_user_meta(
1381
+ get_current_user_id(),
1382
+ '_cachify_remove_post_type_cache_on_update',
1383
+ true
1384
  );
1385
 
1386
+ /* Init vars */
1387
+ $dropdown_options = '';
1388
+ $available_options = array(__('Total cache', 'cachify'), __('Page cache', 'cachify'));
1389
+
1390
+ /* Select options */
1391
+ foreach( $available_options as $key => $value ) {
1392
+ $dropdown_options .= sprintf(
1393
+ '<option value="%1$d" %3$s>%2$s</option>',
1394
+ $key,
1395
+ $value,
1396
+ selected($key, $current_action, false)
1397
+ );
1398
+ }
1399
+
1400
+ /* Output */
1401
+ echo sprintf(
1402
+ '<div class="misc-pub-section" style="border-top:1px solid #eee">
1403
+ <label for="cachify_status">
1404
+ %1$s: <span id="output-cachify-status">%2$s</span>
1405
+ </label>
1406
+ <a href="#" class="edit-cachify-status hide-if-no-js">%3$s</a>
1407
+
1408
+ <div class="hide-if-js">
1409
+ <select name="_cachify_remove_post_type_cache_on_update" id="cachify_status">
1410
+ %4$s
1411
+ </select>
1412
+
1413
+ <a href="#" class="save-cachify-status hide-if-no-js button">%5$s</a>
1414
+ <a href="#" class="cancel-cachify-status hide-if-no-js button-cancel">%6$s</a>
1415
+ </div>
1416
+ </div>',
1417
+ __('Remove', 'cachify'),
1418
+ $available_options[$current_action],
1419
+ __('Edit'),
1420
+ $dropdown_options,
1421
+ __('OK'),
1422
+ __('Cancel')
1423
+ );
1424
  }
1425
 
1426
 
1443
  'options_page'
1444
  )
1445
  );
 
 
 
 
 
 
 
 
 
1446
  }
1447
+
1448
+
1449
  /**
1450
+ * Verfügbare Cache-Methoden
1451
  *
1452
+ * @since 2.0.0
1453
+ * @change 2.1.3
1454
+ *
1455
+ * @param array $methods Array mit verfügbaren Arten
1456
  */
1457
+
1458
+ private static function _method_select()
1459
  {
1460
+ /* Defaults */
1461
+ $methods = array(
1462
+ self::METHOD_DB => __('Database', 'cachify'),
1463
+ self::METHOD_APC => 'APC',
1464
+ self::METHOD_HDD => __('Hard disk', 'cachify'),
1465
+ self::METHOD_MMC => 'Memcached'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1466
  );
1467
+
1468
+ /* APC */
1469
+ if ( ! Cachify_APC::is_available() ) {
1470
+ unset($methods[1]);
1471
+ }
1472
+
1473
+ /* Memcached? */
1474
+ if ( ! Cachify_MEMCACHED::is_available() ) {
1475
+ unset($methods[3]);
1476
+ }
1477
+
1478
+ /* HDD */
1479
+ if ( ! Cachify_HDD::is_available() ) {
1480
+ unset($methods[2]);
1481
+ }
1482
+
1483
+ return $methods;
1484
  }
1485
+
1486
+
1487
  /**
1488
+ * Minify cache dropdown
1489
  *
1490
+ * @since 2.1.3
1491
+ * @change 2.1.3
1492
  *
1493
+ * @return array Key => value array
1494
  */
1495
+
1496
+ private static function _minify_select()
1497
  {
1498
+ return array(
1499
+ self::MINIFY_DISABLED => __('No minify', 'cachify'),
1500
+ self::MINIFY_HTML_ONLY => 'HTML',
1501
+ self::MINIFY_HTML_JS => 'HTML + Inline JavaScript'
1502
+ );
1503
+ }
1504
+
1505
+
1506
+ /**
1507
+ * Register the language file
1508
+ *
1509
+ * @since 2.1.3
1510
+ * @change 2.1.3
1511
+ */
1512
+
1513
+ public static function register_textdomain()
1514
+ {
1515
+ load_plugin_textdomain(
1516
+ 'cachify',
1517
+ false,
1518
+ 'cachify/lang'
1519
  );
 
 
 
 
 
 
 
 
 
 
 
 
1520
  }
1521
 
1522
 
1543
  /**
1544
  * Valisierung der Optionsseite
1545
  *
1546
+ * @since 1.0.0
1547
+ * @change 2.1.3
1548
  *
1549
  * @param array $data Array mit Formularwerten
1550
  * @return array Array mit geprüften Werten
1553
  public static function validate_options($data)
1554
  {
1555
  /* Cache leeren */
1556
+ self::flush_total_cache();
1557
+
1558
  /* Hinweis */
1559
+ if ( self::$options['use_apc'] != $data['use_apc'] && $data['use_apc'] >= self::METHOD_APC ) {
1560
  add_settings_error(
1561
  'cachify_method_tip',
1562
  'cachify_method_tip',
1563
+ sprintf(
1564
+ '%s [<a href="http://playground.ebiene.de/cachify-wordpress-cache/" target="_blank">?</a>]',
1565
+ __('The server configuration file (e.g. .htaccess) needs to be adjusted', 'cachify')
1566
+ ),
1567
+ 'updated'
1568
  );
1569
  }
1570
+
1571
  /* Rückgabe */
1572
  return array(
1573
+ 'only_guests' => (int)(!empty($data['only_guests'])),
1574
+ 'compress_html' => (int)$data['compress_html'],
1575
+ 'cache_expires' => (int)(@$data['cache_expires']),
1576
+ 'without_ids' => (string)sanitize_text_field(@$data['without_ids']),
1577
+ 'without_agents' => (string)sanitize_text_field(@$data['without_agents']),
1578
+ 'use_apc' => (int)$data['use_apc'],
1579
+ 'reset_on_comment' => (int)(!empty($data['reset_on_comment']))
1580
  );
1581
  }
1582
 
1585
  * Darstellung der Optionsseite
1586
  *
1587
  * @since 1.0
1588
+ * @change 2.1.3
1589
  */
1590
 
1591
  public static function options_page()
1592
  { ?>
1593
+ <style>
1594
+ #cachify_settings input[type="text"],
1595
+ #cachify_settings input[type="number"] {
1596
+ height: 30px;
1597
+ }
1598
+ </style>
1599
 
1600
+ <div class="wrap" id="cachify_settings">
1601
  <h2>
1602
  Cachify
1603
  </h2>
1606
  <?php settings_fields('cachify') ?>
1607
 
1608
  <?php $options = self::_get_options() ?>
1609
+
1610
+ <table class="form-table">
1611
+ <tr valign="top">
1612
+ <th scope="row">
1613
+ <?php _e('Cache method', 'cachify') ?>
1614
+ </th>
1615
+ <td>
1616
+ <label for="cachify_cache_method">
1617
+ <select name="cachify[use_apc]" id="cachify_cache_method">
 
 
1618
  <?php foreach( self::_method_select() as $k => $v ) { ?>
1619
  <option value="<?php echo esc_attr($k) ?>" <?php selected($options['use_apc'], $k); ?>><?php echo esc_html($v) ?></option>
1620
  <?php } ?>
1621
  </select>
1622
+ </label>
1623
+ </td>
1624
+ </tr>
1625
+
1626
+ <tr valign="top">
1627
+ <th scope="row">
1628
+ <?php _e('Cache validity', 'cachify') ?>
1629
+ </th>
1630
+ <td>
1631
+ <label for="cachify_cache_expires">
1632
+ <input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="<?php echo $options['cache_expires'] ?>" class="small-text" />
1633
+ <?php _e('Hours', 'cachify') ?>
1634
+ </label>
1635
+ </td>
1636
+ </tr>
1637
+
1638
+ <tr valign="top">
1639
+ <th scope="row">
1640
+ <?php _e('Cache generation', 'cachify') ?>
1641
+ </th>
1642
+ <td>
1643
+ <fieldset>
1644
+ <label for="cachify_only_guests">
1645
+ <input type="checkbox" name="cachify[only_guests]" id="cachify_only_guests" value="1" <?php checked('1', $options['only_guests']); ?> />
1646
+ <?php _e('No cache generation by logged in users', 'cachify') ?>
1647
+ </label>
1648
+
1649
+ <br />
1650
+
1651
+ <label for="cachify_reset_on_comment">
1652
+ <input type="checkbox" name="cachify[reset_on_comment]" id="cachify_reset_on_comment" value="1" <?php checked('1', $options['reset_on_comment']); ?> />
1653
+ <?php _e('Flush the cache at new comments', 'cachify') ?>
1654
+ </label>
1655
+ </fieldset>
1656
+ </td>
1657
+ </tr>
1658
+
1659
+ <tr valign="top">
1660
+ <th scope="row">
1661
+ <?php _e('Cache exceptions', 'cachify') ?>
1662
+ </th>
1663
+ <td>
1664
+ <fieldset>
1665
+ <label for="cachify_without_ids">
1666
+ <input type="text" name="cachify[without_ids]" id="cachify_without_ids" value="<?php echo $options['without_ids'] ?>" />
1667
+ Post/Pages-IDs
1668
+ </label>
1669
+
1670
+ <br />
1671
+
1672
+ <label for="cachify_without_agents">
1673
+ <input type="text" name="cachify[without_agents]" id="cachify_without_agents" value="<?php echo $options['without_agents'] ?>" />
1674
+ Browser User-Agents
1675
+ </label>
1676
+ </fieldset>
1677
+ </td>
1678
+ </tr>
1679
+
1680
+ <tr valign="top">
1681
+ <th scope="row">
1682
+ <?php _e('Cache minify', 'cachify') ?>
1683
+ </th>
1684
+ <td>
1685
+ <label for="cachify_compress_html">
1686
+ <select name="cachify[compress_html]" id="cachify_compress_html">
1687
+ <?php foreach( self::_minify_select() as $k => $v ) { ?>
1688
+ <option value="<?php echo esc_attr($k) ?>" <?php selected($options['compress_html'], $k); ?>>
1689
+ <?php echo esc_html($v) ?>
1690
+ </option>
1691
+ <?php } ?>
1692
+ </select>
1693
+ </label>
1694
+ </td>
1695
+ </tr>
1696
+
1697
+ <tr valign="top">
1698
+ <th scope="row">
1699
+ <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
1700
+ </th>
1701
+ <td>
1702
+ <a href="http://playground.ebiene.de/cachify-wordpress-cache/" target="_blank"><?php _e('Manual', 'cachify') ?></a> &bull; <a href="http://playground.ebiene.de/cachify-wordpress-cache/#book" target="_blank"><?php _e('Books', 'cachify') ?></a> &bull; <a href="https://flattr.com/t/1327625" target="_blank">Flattr</a> &bull; <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=5RDDW9FEHGLG6" target="_blank">PayPal</a>
1703
+ </td>
1704
+ </tr>
1705
+ </table>
1706
  </form>
1707
  </div><?php
1708
  }
inc/cachify_apc.class.php CHANGED
@@ -1,10 +1,8 @@
1
  <?php
2
 
3
 
4
- /* Secure check */
5
- if ( !class_exists('Cachify') ) {
6
- die();
7
- }
8
 
9
 
10
  /**
@@ -12,8 +10,37 @@ if ( !class_exists('Cachify') ) {
12
  */
13
 
14
  final class Cachify_APC {
15
-
16
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  /**
18
  * Speicherung im Cache
19
  *
@@ -24,14 +51,14 @@ final class Cachify_APC {
24
  * @param string $data Inhalt des Eintrags
25
  * @param integer $lifetime Lebensdauer des Eintrags
26
  */
27
-
28
  public static function store_item($hash, $data, $lifetime)
29
  {
30
  /* Leer? */
31
  if ( empty($hash) or empty($data) ) {
32
  wp_die('APC add item: Empty input.');
33
  }
34
-
35
  /* Store */
36
  apc_store(
37
  $hash,
@@ -39,8 +66,8 @@ final class Cachify_APC {
39
  $lifetime
40
  );
41
  }
42
-
43
-
44
  /**
45
  * Lesen aus dem Cache
46
  *
@@ -50,18 +77,18 @@ final class Cachify_APC {
50
  * @param string $hash Hash des Eintrags
51
  * @return mixed $diff Wert des Eintrags
52
  */
53
-
54
  public static function get_item($hash)
55
  {
56
  /* Leer? */
57
  if ( empty($hash) ) {
58
  wp_die('APC get item: Empty input.');
59
  }
60
-
61
  return ( function_exists('apc_exists') ? apc_exists($hash) : apc_fetch($hash) );
62
  }
63
-
64
-
65
  /**
66
  * Entfernung aus dem Cache
67
  *
@@ -71,47 +98,49 @@ final class Cachify_APC {
71
  * @param string $hash Hash des Eintrags
72
  * @param string $url URL des Eintrags [optional]
73
  */
74
-
75
  public static function delete_item($hash, $url = '')
76
  {
77
  /* Leer? */
78
  if ( empty($hash) ) {
79
  wp_die('APC delete item: Empty input.');
80
  }
81
-
82
  /* Löschen */
83
  apc_delete($hash);
84
  }
85
-
86
-
87
  /**
88
  * Leerung des Cache
89
  *
90
- * @since 2.0
91
- * @change 2.0
92
  */
93
-
94
  public static function clear_cache()
95
  {
96
- if ( extension_loaded('apc') ) {
97
- apc_clear_cache('user');
98
  }
 
 
99
  }
100
-
101
-
102
  /**
103
  * Ausgabe des Cache
104
  *
105
  * @since 2.0
106
  * @change 2.0
107
  */
108
-
109
  public static function print_cache()
110
  {
111
  return;
112
  }
113
-
114
-
115
  /**
116
  * Ermittlung der Cache-Größe
117
  *
@@ -120,35 +149,35 @@ final class Cachify_APC {
120
  *
121
  * @return mixed $diff Cache-Größe
122
  */
123
-
124
  public static function get_stats()
125
  {
126
  /* Infos */
127
  $data = apc_cache_info('user');
128
-
129
  /* Leer */
130
  if ( empty($data['mem_size']) ) {
131
  return NULL;
132
  }
133
-
134
  return $data['mem_size'];
135
  }
136
-
137
-
138
  /**
139
  * Generierung der Signatur
140
  *
141
  * @since 2.0
142
- * @change 2.0
143
  *
144
  * @return string $diff Signatur als String
145
  */
146
-
147
  private static function _cache_signatur()
148
  {
149
  return sprintf(
150
  "\n\n<!-- %s\n%s @ %s -->",
151
- 'Cachify | http://bit.ly/cachify',
152
  'APC Cache',
153
  date_i18n(
154
  'd.m.Y H:i:s',
1
  <?php
2
 
3
 
4
+ /* Quit */
5
+ defined('ABSPATH') OR exit;
 
 
6
 
7
 
8
  /**
10
  */
11
 
12
  final class Cachify_APC {
13
+
14
+
15
+ /**
16
+ * Availability check
17
+ *
18
+ * @since 2.0.7
19
+ * @change 2.0.7
20
+ *
21
+ * @return boolean true/false TRUE when installed
22
+ */
23
+
24
+ public static function is_available()
25
+ {
26
+ return extension_loaded('apc');
27
+ }
28
+
29
+
30
+ /**
31
+ * Caching method as string
32
+ *
33
+ * @since 2.1.2
34
+ * @change 2.1.2
35
+ *
36
+ * @return string Caching method
37
+ */
38
+
39
+ public static function stringify‎_method() {
40
+ return 'APC';
41
+ }
42
+
43
+
44
  /**
45
  * Speicherung im Cache
46
  *
51
  * @param string $data Inhalt des Eintrags
52
  * @param integer $lifetime Lebensdauer des Eintrags
53
  */
54
+
55
  public static function store_item($hash, $data, $lifetime)
56
  {
57
  /* Leer? */
58
  if ( empty($hash) or empty($data) ) {
59
  wp_die('APC add item: Empty input.');
60
  }
61
+
62
  /* Store */
63
  apc_store(
64
  $hash,
66
  $lifetime
67
  );
68
  }
69
+
70
+
71
  /**
72
  * Lesen aus dem Cache
73
  *
77
  * @param string $hash Hash des Eintrags
78
  * @return mixed $diff Wert des Eintrags
79
  */
80
+
81
  public static function get_item($hash)
82
  {
83
  /* Leer? */
84
  if ( empty($hash) ) {
85
  wp_die('APC get item: Empty input.');
86
  }
87
+
88
  return ( function_exists('apc_exists') ? apc_exists($hash) : apc_fetch($hash) );
89
  }
90
+
91
+
92
  /**
93
  * Entfernung aus dem Cache
94
  *
98
  * @param string $hash Hash des Eintrags
99
  * @param string $url URL des Eintrags [optional]
100
  */
101
+
102
  public static function delete_item($hash, $url = '')
103
  {
104
  /* Leer? */
105
  if ( empty($hash) ) {
106
  wp_die('APC delete item: Empty input.');
107
  }
108
+
109
  /* Löschen */
110
  apc_delete($hash);
111
  }
112
+
113
+
114
  /**
115
  * Leerung des Cache
116
  *
117
+ * @since 2.0.0
118
+ * @change 2.0.7
119
  */
120
+
121
  public static function clear_cache()
122
  {
123
+ if ( ! self::is_available() ) {
124
+ return;
125
  }
126
+
127
+ @apc_clear_cache('user');
128
  }
129
+
130
+
131
  /**
132
  * Ausgabe des Cache
133
  *
134
  * @since 2.0
135
  * @change 2.0
136
  */
137
+
138
  public static function print_cache()
139
  {
140
  return;
141
  }
142
+
143
+
144
  /**
145
  * Ermittlung der Cache-Größe
146
  *
149
  *
150
  * @return mixed $diff Cache-Größe
151
  */
152
+
153
  public static function get_stats()
154
  {
155
  /* Infos */
156
  $data = apc_cache_info('user');
157
+
158
  /* Leer */
159
  if ( empty($data['mem_size']) ) {
160
  return NULL;
161
  }
162
+
163
  return $data['mem_size'];
164
  }
165
+
166
+
167
  /**
168
  * Generierung der Signatur
169
  *
170
  * @since 2.0
171
+ * @change 2.0.5
172
  *
173
  * @return string $diff Signatur als String
174
  */
175
+
176
  private static function _cache_signatur()
177
  {
178
  return sprintf(
179
  "\n\n<!-- %s\n%s @ %s -->",
180
+ 'Cachify | http://cachify.de',
181
  'APC Cache',
182
  date_i18n(
183
  'd.m.Y H:i:s',
inc/cachify_db.class.php CHANGED
@@ -1,10 +1,8 @@
1
  <?php
2
 
3
 
4
- /* Secure check */
5
- if ( !class_exists('Cachify') ) {
6
- die();
7
- }
8
 
9
 
10
  /**
@@ -12,8 +10,37 @@ if ( !class_exists('Cachify') ) {
12
  */
13
 
14
  final class Cachify_DB {
15
-
16
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  /**
18
  * Speicherung im Cache
19
  *
@@ -24,14 +51,14 @@ final class Cachify_DB {
24
  * @param string $data Inhalt des Eintrags
25
  * @param integer $lifetime Lebensdauer des Eintrags
26
  */
27
-
28
  public static function store_item($hash, $data, $lifetime)
29
  {
30
  /* Leer? */
31
  if ( empty($hash) or empty($data) ) {
32
  wp_die('DB add item: Empty input.');
33
  }
34
-
35
  /* Store */
36
  set_transient(
37
  $hash,
@@ -47,8 +74,8 @@ final class Cachify_DB {
47
  $lifetime
48
  );
49
  }
50
-
51
-
52
  /**
53
  * Lesen aus dem Cache
54
  *
@@ -58,18 +85,18 @@ final class Cachify_DB {
58
  * @param string $hash Hash des Eintrags
59
  * @return mixed $diff Wert des Eintrags
60
  */
61
-
62
  public static function get_item($hash)
63
  {
64
  /* Leer? */
65
  if ( empty($hash) ) {
66
  wp_die('DB get item: Empty input.');
67
  }
68
-
69
  return get_transient($hash);
70
  }
71
-
72
-
73
  /**
74
  * Entfernung aus dem Cache
75
  *
@@ -79,55 +106,55 @@ final class Cachify_DB {
79
  * @param string $hash Hash des Eintrags
80
  * @param string $url URL des Eintrags [optional]
81
  */
82
-
83
  public static function delete_item($hash, $url = '')
84
  {
85
  /* Leer? */
86
  if ( empty($hash) ) {
87
  wp_die('DB delete item: Empty input.');
88
  }
89
-
90
  /* Löschen */
91
  delete_transient($hash);
92
  }
93
-
94
-
95
  /**
96
  * Leerung des Cache
97
  *
98
  * @since 2.0
99
  * @change 2.0
100
  */
101
-
102
  public static function clear_cache()
103
  {
104
  /* Init */
105
  global $wpdb;
106
-
107
  /* Löschen */
108
- $wpdb->query("DELETE FROM `" .$wpdb->options. "` WHERE `option_name` LIKE ('_transient%.cachify')");
109
-
110
  /* Optimieren */
111
  $wpdb->query("OPTIMIZE TABLE `" .$wpdb->options. "`");
112
  }
113
-
114
-
115
  /**
116
  * Ausgabe des Cache
117
  *
118
  * @since 2.0
119
  * @change 2.0.2
120
- *
121
  * @param array $cache Array mit Cache-Werten
122
  */
123
-
124
  public static function print_cache($cache)
125
  {
126
  /* Kein Array? */
127
  if ( ! is_array($cache) ) {
128
  return;
129
  }
130
-
131
  /* Content */
132
  echo $cache['data'];
133
 
@@ -135,12 +162,12 @@ final class Cachify_DB {
135
  if ( isset($cache['meta']) ) {
136
  echo self::_cache_signatur($cache['meta']);
137
  }
138
-
139
  /* Raus */
140
  exit;
141
  }
142
-
143
-
144
  /**
145
  * Ermittlung der Cache-Größe
146
  *
@@ -149,39 +176,39 @@ final class Cachify_DB {
149
  *
150
  * @return integer $diff Spaltengröße
151
  */
152
-
153
  public static function get_stats()
154
  {
155
  /* Init */
156
  global $wpdb;
157
-
158
  /* Auslesen */
159
  return $wpdb->get_var(
160
- "SELECT SUM( CHAR_LENGTH(option_value) ) FROM `" .$wpdb->options. "` WHERE `option_name` LIKE ('_transient%.cachify')"
161
  );
162
  }
163
-
164
-
165
  /**
166
  * Generierung der Signatur
167
  *
168
  * @since 2.0
169
- * @change 2.0.2
170
  *
171
  * @param array $meta Inhalt der Metadaten
172
  * @return string $diff Signatur als String
173
  */
174
-
175
  private static function _cache_signatur($meta)
176
  {
177
  /* Kein Array? */
178
  if ( ! is_array($meta) ) {
179
  return;
180
  }
181
-
182
  return sprintf(
183
  "\n\n<!--\n%s\n%s\n%s\n%s\n-->",
184
- 'Cachify | http://bit.ly/cachify',
185
  sprintf(
186
  'Ohne Plugin: %d DB-Anfragen, %s Sekunden, %s',
187
  $meta['queries'],
@@ -200,8 +227,8 @@ final class Cachify_DB {
200
  )
201
  );
202
  }
203
-
204
-
205
  /**
206
  * Rückgabe der Query-Anzahl
207
  *
1
  <?php
2
 
3
 
4
+ /* Quit */
5
+ defined('ABSPATH') OR exit;
 
 
6
 
7
 
8
  /**
10
  */
11
 
12
  final class Cachify_DB {
13
+
14
+
15
+ /**
16
+ * Availability check
17
+ *
18
+ * @since 2.0.7
19
+ * @change 2.0.7
20
+ *
21
+ * @return boolean true/false TRUE when installed
22
+ */
23
+
24
+ public static function is_available()
25
+ {
26
+ return true;
27
+ }
28
+
29
+
30
+ /**
31
+ * Caching method as string
32
+ *
33
+ * @since 2.1.2
34
+ * @change 2.1.2
35
+ *
36
+ * @return string Caching method
37
+ */
38
+
39
+ public static function stringify‎_method() {
40
+ return 'DB';
41
+ }
42
+
43
+
44
  /**
45
  * Speicherung im Cache
46
  *
51
  * @param string $data Inhalt des Eintrags
52
  * @param integer $lifetime Lebensdauer des Eintrags
53
  */
54
+
55
  public static function store_item($hash, $data, $lifetime)
56
  {
57
  /* Leer? */
58
  if ( empty($hash) or empty($data) ) {
59
  wp_die('DB add item: Empty input.');
60
  }
61
+
62
  /* Store */
63
  set_transient(
64
  $hash,
74
  $lifetime
75
  );
76
  }
77
+
78
+
79
  /**
80
  * Lesen aus dem Cache
81
  *
85
  * @param string $hash Hash des Eintrags
86
  * @return mixed $diff Wert des Eintrags
87
  */
88
+
89
  public static function get_item($hash)
90
  {
91
  /* Leer? */
92
  if ( empty($hash) ) {
93
  wp_die('DB get item: Empty input.');
94
  }
95
+
96
  return get_transient($hash);
97
  }
98
+
99
+
100
  /**
101
  * Entfernung aus dem Cache
102
  *
106
  * @param string $hash Hash des Eintrags
107
  * @param string $url URL des Eintrags [optional]
108
  */
109
+
110
  public static function delete_item($hash, $url = '')
111
  {
112
  /* Leer? */
113
  if ( empty($hash) ) {
114
  wp_die('DB delete item: Empty input.');
115
  }
116
+
117
  /* Löschen */
118
  delete_transient($hash);
119
  }
120
+
121
+
122
  /**
123
  * Leerung des Cache
124
  *
125
  * @since 2.0
126
  * @change 2.0
127
  */
128
+
129
  public static function clear_cache()
130
  {
131
  /* Init */
132
  global $wpdb;
133
+
134
  /* Löschen */
135
+ $wpdb->query("DELETE FROM `" .$wpdb->options. "` WHERE `option_name` LIKE ('\_transient%.cachify')");
136
+
137
  /* Optimieren */
138
  $wpdb->query("OPTIMIZE TABLE `" .$wpdb->options. "`");
139
  }
140
+
141
+
142
  /**
143
  * Ausgabe des Cache
144
  *
145
  * @since 2.0
146
  * @change 2.0.2
147
+ *
148
  * @param array $cache Array mit Cache-Werten
149
  */
150
+
151
  public static function print_cache($cache)
152
  {
153
  /* Kein Array? */
154
  if ( ! is_array($cache) ) {
155
  return;
156
  }
157
+
158
  /* Content */
159
  echo $cache['data'];
160
 
162
  if ( isset($cache['meta']) ) {
163
  echo self::_cache_signatur($cache['meta']);
164
  }
165
+
166
  /* Raus */
167
  exit;
168
  }
169
+
170
+
171
  /**
172
  * Ermittlung der Cache-Größe
173
  *
176
  *
177
  * @return integer $diff Spaltengröße
178
  */
179
+
180
  public static function get_stats()
181
  {
182
  /* Init */
183
  global $wpdb;
184
+
185
  /* Auslesen */
186
  return $wpdb->get_var(
187
+ "SELECT SUM( CHAR_LENGTH(option_value) ) FROM `" .$wpdb->options. "` WHERE `option_name` LIKE ('\_transient%.cachify')"
188
  );
189
  }
190
+
191
+
192
  /**
193
  * Generierung der Signatur
194
  *
195
  * @since 2.0
196
+ * @change 2.0.5
197
  *
198
  * @param array $meta Inhalt der Metadaten
199
  * @return string $diff Signatur als String
200
  */
201
+
202
  private static function _cache_signatur($meta)
203
  {
204
  /* Kein Array? */
205
  if ( ! is_array($meta) ) {
206
  return;
207
  }
208
+
209
  return sprintf(
210
  "\n\n<!--\n%s\n%s\n%s\n%s\n-->",
211
+ 'Cachify | http://cachify.de',
212
  sprintf(
213
  'Ohne Plugin: %d DB-Anfragen, %s Sekunden, %s',
214
  $meta['queries'],
227
  )
228
  );
229
  }
230
+
231
+
232
  /**
233
  * Rückgabe der Query-Anzahl
234
  *
inc/cachify_hdd.class.php CHANGED
@@ -1,10 +1,8 @@
1
  <?php
2
 
3
 
4
- /* Secure check */
5
- if ( !class_exists('Cachify') ) {
6
- die();
7
- }
8
 
9
 
10
  /**
@@ -12,8 +10,37 @@ if ( !class_exists('Cachify') ) {
12
  */
13
 
14
  final class Cachify_HDD {
15
-
16
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  /**
18
  * Speicherung im Cache
19
  *
@@ -24,21 +51,21 @@ final class Cachify_HDD {
24
  * @param string $data Inhalt des Eintrags
25
  * @param integer $lifetime Lebensdauer des Eintrags [optional]
26
  */
27
-
28
  public static function store_item($hash, $data, $lifetime)
29
  {
30
  /* Leer? */
31
  if ( empty($data) ) {
32
  wp_die('HDD add item: Empty input.');
33
  }
34
-
35
  /* Speichern */
36
  self::_create_files(
37
  $data . self::_cache_signatur()
38
  );
39
  }
40
-
41
-
42
  /**
43
  * Lesen aus dem Cache
44
  *
@@ -47,13 +74,15 @@ final class Cachify_HDD {
47
  *
48
  * @return boolean $diff TRUE wenn Cache vorhanden
49
  */
50
-
51
  public static function get_item()
52
  {
53
- return is_readable( self::_file_html() );
 
 
54
  }
55
-
56
-
57
  /**
58
  * Entfernen aus dem Cache
59
  *
@@ -63,49 +92,49 @@ final class Cachify_HDD {
63
  * @param string $hash Hash des Eintrags [optional]
64
  * @param string $url URL des Eintrags
65
  */
66
-
67
  public static function delete_item($hash = '', $url)
68
  {
69
  /* Leer? */
70
  if ( empty($url) ) {
71
  wp_die('HDD delete item: Empty input.');
72
  }
73
-
74
  /* Löschen */
75
  self::_clear_dir(
76
  self::_file_path($url)
77
  );
78
  }
79
-
80
-
81
  /**
82
  * Leerung des Cache
83
  *
84
  * @since 2.0
85
  * @change 2.0
86
  */
87
-
88
  public static function clear_cache()
89
  {
90
  self::_clear_dir(
91
  CACHIFY_CACHE_DIR
92
  );
93
  }
94
-
95
-
96
  /**
97
  * Ausgabe des Cache
98
  *
99
  * @since 2.0
100
  * @change 2.0
101
  */
102
-
103
  public static function print_cache()
104
  {
105
  return;
106
  }
107
-
108
-
109
  /**
110
  * Ermittlung der Cache-Größe
111
  *
@@ -114,27 +143,27 @@ final class Cachify_HDD {
114
  *
115
  * @return integer $diff Ordnergröße
116
  */
117
-
118
  public static function get_stats()
119
  {
120
  return self::_dir_size( CACHIFY_CACHE_DIR );
121
  }
122
-
123
-
124
  /**
125
  * Generierung der Signatur
126
  *
127
  * @since 2.0
128
- * @change 2.0
129
  *
130
  * @return string $diff Signatur als String
131
  */
132
-
133
  private static function _cache_signatur()
134
  {
135
  return sprintf(
136
  "\n\n<!-- %s\n%s @ %s -->",
137
- 'Cachify | http://bit.ly/cachify',
138
  'HDD Cache',
139
  date_i18n(
140
  'd.m.Y H:i:s',
@@ -142,8 +171,8 @@ final class Cachify_HDD {
142
  )
143
  );
144
  }
145
-
146
-
147
  /**
148
  * Initialisierung des Cache-Speichervorgangs
149
  *
@@ -152,20 +181,20 @@ final class Cachify_HDD {
152
  *
153
  * @param string $data Cache-Inhalt
154
  */
155
-
156
  private static function _create_files($data)
157
  {
158
  /* Ordner anlegen */
159
- if ( !wp_mkdir_p( self::_file_path() ) ) {
160
  wp_die('Unable to create directory.');
161
  }
162
-
163
  /* Dateien schreiben */
164
  self::_create_file( self::_file_html(), $data );
165
  self::_create_file( self::_file_gzip(), gzencode($data, 9) );
166
  }
167
-
168
-
169
  /**
170
  * Anlegen der Cache-Datei
171
  *
@@ -175,19 +204,19 @@ final class Cachify_HDD {
175
  * @param string $file Pfad der Cache-Datei
176
  * @param string $data Cache-Inhalt
177
  */
178
-
179
  private static function _create_file($file, $data)
180
  {
181
  /* Beschreibbar? */
182
- if ( !$handle = @fopen($file, 'wb') ) {
183
  wp_die('Could not write file.');
184
  }
185
-
186
  /* Schreiben */
187
  @fwrite($handle, $data);
188
  fclose($handle);
189
  clearstatcache();
190
-
191
  /* Permissions */
192
  $stat = @stat( dirname($file) );
193
  $perms = $stat['mode'] & 0007777;
@@ -195,39 +224,42 @@ final class Cachify_HDD {
195
  @chmod($file, $perms);
196
  clearstatcache();
197
  }
198
-
199
-
200
  /**
201
  * Rekrusive Leerung eines Ordners
202
  *
203
  * @since 2.0
204
- * @change 2.0
205
  *
206
  * @param string $dir Ordnerpfad
207
  */
208
-
209
  private static function _clear_dir($dir) {
 
 
 
210
  /* Ordner? */
211
- if ( !is_dir($dir) ) {
212
  return;
213
  }
214
-
215
  /* Einlesen */
216
  $objects = array_diff(
217
  scandir($dir),
218
  array('..', '.')
219
  );
220
-
221
  /* Leer? */
222
  if ( empty($objects) ) {
223
  return;
224
  }
225
-
226
  /* Loopen */
227
  foreach ( $objects as $object ) {
228
  /* Um Pfad erweitern */
229
  $object = $dir. DIRECTORY_SEPARATOR .$object;
230
-
231
  /* Ordner/Datei */
232
  if ( is_dir($object) ) {
233
  self::_clear_dir($object);
@@ -235,15 +267,15 @@ final class Cachify_HDD {
235
  unlink($object);
236
  }
237
  }
238
-
239
  /* Killen */
240
  @rmdir($dir);
241
-
242
  /* Aufräumen */
243
  clearstatcache();
244
  }
245
-
246
-
247
  /**
248
  * Ermittlung der Ordnergröße
249
  *
@@ -253,33 +285,33 @@ final class Cachify_HDD {
253
  * @param string $dir Ordnerpfad
254
  * @return mixed $size Ordnergröße
255
  */
256
-
257
  public static function _dir_size($dir = '.')
258
  {
259
  /* Ordner? */
260
- if ( !is_dir($dir) ) {
261
  return;
262
  }
263
-
264
  /* Einlesen */
265
  $objects = array_diff(
266
  scandir($dir),
267
  array('..', '.')
268
  );
269
-
270
  /* Leer? */
271
  if ( empty($objects) ) {
272
  return;
273
  }
274
-
275
  /* Init */
276
  $size = 0;
277
-
278
  /* Loopen */
279
  foreach ( $objects as $object ) {
280
  /* Um Pfad erweitern */
281
  $object = $dir. DIRECTORY_SEPARATOR .$object;
282
-
283
  /* Ordner/Datei */
284
  if ( is_dir($object) ) {
285
  $size += self::_dir_size($object);
@@ -287,11 +319,11 @@ final class Cachify_HDD {
287
  $size += filesize($object);
288
  }
289
  }
290
-
291
  return $size;
292
  }
293
-
294
-
295
  /**
296
  * Pfad der Cache-Datei
297
  *
@@ -301,22 +333,25 @@ final class Cachify_HDD {
301
  * @param string $path Request-URI oder Permalink [optional]
302
  * @return string $diff Pfad zur Cache-Datei
303
  */
304
-
305
  private static function _file_path($path = NULL)
306
  {
307
- return sprintf(
308
- '%s%s%s%s',
309
- CACHIFY_CACHE_DIR,
310
- DIRECTORY_SEPARATOR,
311
- $_SERVER['HTTP_HOST'],
312
- parse_url(
313
- ( $path ? $path : $_SERVER['REQUEST_URI'] ),
314
- PHP_URL_PATH
 
 
 
315
  )
316
  );
317
  }
318
-
319
-
320
  /**
321
  * Pfad der HTML-Datei
322
  *
@@ -325,13 +360,13 @@ final class Cachify_HDD {
325
  *
326
  * @return string $diff Pfad zur HTML-Datei
327
  */
328
-
329
  private static function _file_html()
330
  {
331
  return self::_file_path(). 'index.html';
332
  }
333
-
334
-
335
  /**
336
  * Pfad der GZIP-Datei
337
  *
@@ -340,7 +375,7 @@ final class Cachify_HDD {
340
  *
341
  * @return string $diff Pfad zur GZIP-Datei
342
  */
343
-
344
  private static function _file_gzip()
345
  {
346
  return self::_file_path(). 'index.html.gz';
1
  <?php
2
 
3
 
4
+ /* Quit */
5
+ defined('ABSPATH') OR exit;
 
 
6
 
7
 
8
  /**
10
  */
11
 
12
  final class Cachify_HDD {
13
+
14
+
15
+ /**
16
+ * Availability check
17
+ *
18
+ * @since 2.0.7
19
+ * @change 2.0.7
20
+ *
21
+ * @return boolean true/false TRUE when installed
22
+ */
23
+
24
+ public static function is_available()
25
+ {
26
+ return get_option('permalink_structure');
27
+ }
28
+
29
+
30
+ /**
31
+ * Caching method as string
32
+ *
33
+ * @since 2.1.2
34
+ * @change 2.1.2
35
+ *
36
+ * @return string Caching method
37
+ */
38
+
39
+ public static function stringify‎_method() {
40
+ return 'HDD';
41
+ }
42
+
43
+
44
  /**
45
  * Speicherung im Cache
46
  *
51
  * @param string $data Inhalt des Eintrags
52
  * @param integer $lifetime Lebensdauer des Eintrags [optional]
53
  */
54
+
55
  public static function store_item($hash, $data, $lifetime)
56
  {
57
  /* Leer? */
58
  if ( empty($data) ) {
59
  wp_die('HDD add item: Empty input.');
60
  }
61
+
62
  /* Speichern */
63
  self::_create_files(
64
  $data . self::_cache_signatur()
65
  );
66
  }
67
+
68
+
69
  /**
70
  * Lesen aus dem Cache
71
  *
74
  *
75
  * @return boolean $diff TRUE wenn Cache vorhanden
76
  */
77
+
78
  public static function get_item()
79
  {
80
+ return is_readable(
81
+ self::_file_html()
82
+ );
83
  }
84
+
85
+
86
  /**
87
  * Entfernen aus dem Cache
88
  *
92
  * @param string $hash Hash des Eintrags [optional]
93
  * @param string $url URL des Eintrags
94
  */
95
+
96
  public static function delete_item($hash = '', $url)
97
  {
98
  /* Leer? */
99
  if ( empty($url) ) {
100
  wp_die('HDD delete item: Empty input.');
101
  }
102
+
103
  /* Löschen */
104
  self::_clear_dir(
105
  self::_file_path($url)
106
  );
107
  }
108
+
109
+
110
  /**
111
  * Leerung des Cache
112
  *
113
  * @since 2.0
114
  * @change 2.0
115
  */
116
+
117
  public static function clear_cache()
118
  {
119
  self::_clear_dir(
120
  CACHIFY_CACHE_DIR
121
  );
122
  }
123
+
124
+
125
  /**
126
  * Ausgabe des Cache
127
  *
128
  * @since 2.0
129
  * @change 2.0
130
  */
131
+
132
  public static function print_cache()
133
  {
134
  return;
135
  }
136
+
137
+
138
  /**
139
  * Ermittlung der Cache-Größe
140
  *
143
  *
144
  * @return integer $diff Ordnergröße
145
  */
146
+
147
  public static function get_stats()
148
  {
149
  return self::_dir_size( CACHIFY_CACHE_DIR );
150
  }
151
+
152
+
153
  /**
154
  * Generierung der Signatur
155
  *
156
  * @since 2.0
157
+ * @change 2.0.5
158
  *
159
  * @return string $diff Signatur als String
160
  */
161
+
162
  private static function _cache_signatur()
163
  {
164
  return sprintf(
165
  "\n\n<!-- %s\n%s @ %s -->",
166
+ 'Cachify | http://cachify.de',
167
  'HDD Cache',
168
  date_i18n(
169
  'd.m.Y H:i:s',
171
  )
172
  );
173
  }
174
+
175
+
176
  /**
177
  * Initialisierung des Cache-Speichervorgangs
178
  *
181
  *
182
  * @param string $data Cache-Inhalt
183
  */
184
+
185
  private static function _create_files($data)
186
  {
187
  /* Ordner anlegen */
188
+ if ( ! wp_mkdir_p( self::_file_path() ) ) {
189
  wp_die('Unable to create directory.');
190
  }
191
+
192
  /* Dateien schreiben */
193
  self::_create_file( self::_file_html(), $data );
194
  self::_create_file( self::_file_gzip(), gzencode($data, 9) );
195
  }
196
+
197
+
198
  /**
199
  * Anlegen der Cache-Datei
200
  *
204
  * @param string $file Pfad der Cache-Datei
205
  * @param string $data Cache-Inhalt
206
  */
207
+
208
  private static function _create_file($file, $data)
209
  {
210
  /* Beschreibbar? */
211
+ if ( ! $handle = @fopen($file, 'wb') ) {
212
  wp_die('Could not write file.');
213
  }
214
+
215
  /* Schreiben */
216
  @fwrite($handle, $data);
217
  fclose($handle);
218
  clearstatcache();
219
+
220
  /* Permissions */
221
  $stat = @stat( dirname($file) );
222
  $perms = $stat['mode'] & 0007777;
224
  @chmod($file, $perms);
225
  clearstatcache();
226
  }
227
+
228
+
229
  /**
230
  * Rekrusive Leerung eines Ordners
231
  *
232
  * @since 2.0
233
+ * @change 2.0.5
234
  *
235
  * @param string $dir Ordnerpfad
236
  */
237
+
238
  private static function _clear_dir($dir) {
239
+ /* Weg mit dem Slash */
240
+ $dir = untrailingslashit($dir);
241
+
242
  /* Ordner? */
243
+ if ( ! is_dir($dir) ) {
244
  return;
245
  }
246
+
247
  /* Einlesen */
248
  $objects = array_diff(
249
  scandir($dir),
250
  array('..', '.')
251
  );
252
+
253
  /* Leer? */
254
  if ( empty($objects) ) {
255
  return;
256
  }
257
+
258
  /* Loopen */
259
  foreach ( $objects as $object ) {
260
  /* Um Pfad erweitern */
261
  $object = $dir. DIRECTORY_SEPARATOR .$object;
262
+
263
  /* Ordner/Datei */
264
  if ( is_dir($object) ) {
265
  self::_clear_dir($object);
267
  unlink($object);
268
  }
269
  }
270
+
271
  /* Killen */
272
  @rmdir($dir);
273
+
274
  /* Aufräumen */
275
  clearstatcache();
276
  }
277
+
278
+
279
  /**
280
  * Ermittlung der Ordnergröße
281
  *
285
  * @param string $dir Ordnerpfad
286
  * @return mixed $size Ordnergröße
287
  */
288
+
289
  public static function _dir_size($dir = '.')
290
  {
291
  /* Ordner? */
292
+ if ( ! is_dir($dir) ) {
293
  return;
294
  }
295
+
296
  /* Einlesen */
297
  $objects = array_diff(
298
  scandir($dir),
299
  array('..', '.')
300
  );
301
+
302
  /* Leer? */
303
  if ( empty($objects) ) {
304
  return;
305
  }
306
+
307
  /* Init */
308
  $size = 0;
309
+
310
  /* Loopen */
311
  foreach ( $objects as $object ) {
312
  /* Um Pfad erweitern */
313
  $object = $dir. DIRECTORY_SEPARATOR .$object;
314
+
315
  /* Ordner/Datei */
316
  if ( is_dir($object) ) {
317
  $size += self::_dir_size($object);
319
  $size += filesize($object);
320
  }
321
  }
322
+
323
  return $size;
324
  }
325
+
326
+
327
  /**
328
  * Pfad der Cache-Datei
329
  *
333
  * @param string $path Request-URI oder Permalink [optional]
334
  * @return string $diff Pfad zur Cache-Datei
335
  */
336
+
337
  private static function _file_path($path = NULL)
338
  {
339
+
340
+ return trailingslashit(
341
+ sprintf(
342
+ '%s%s%s%s',
343
+ CACHIFY_CACHE_DIR,
344
+ DIRECTORY_SEPARATOR,
345
+ $_SERVER['HTTP_HOST'],
346
+ parse_url(
347
+ ( $path ? $path : $_SERVER['REQUEST_URI'] ),
348
+ PHP_URL_PATH
349
+ )
350
  )
351
  );
352
  }
353
+
354
+
355
  /**
356
  * Pfad der HTML-Datei
357
  *
360
  *
361
  * @return string $diff Pfad zur HTML-Datei
362
  */
363
+
364
  private static function _file_html()
365
  {
366
  return self::_file_path(). 'index.html';
367
  }
368
+
369
+
370
  /**
371
  * Pfad der GZIP-Datei
372
  *
375
  *
376
  * @return string $diff Pfad zur GZIP-Datei
377
  */
378
+
379
  private static function _file_gzip()
380
  {
381
  return self::_file_path(). 'index.html.gz';
inc/cachify_memcached.class.php ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ /* Quit */
5
+ defined('ABSPATH') OR exit;
6
+
7
+
8
+ /**
9
+ * Cachify_MEMCACHED
10
+ */
11
+
12
+ final class Cachify_MEMCACHED {
13
+
14
+
15
+ /**
16
+ * Memcached-Object
17
+ *
18
+ * @since 2.0.7
19
+ * @var object
20
+ */
21
+
22
+ private static $_memcached;
23
+
24
+
25
+ /**
26
+ * Availability check
27
+ *
28
+ * @since 2.0.7
29
+ * @change 2.0.7
30
+ *
31
+ * @return boolean true/false TRUE when installed
32
+ */
33
+
34
+ public static function is_available()
35
+ {
36
+ return class_exists('Memcached') && isset($_SERVER['SERVER_SOFTWARE']) && strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'nginx') !== false;
37
+ }
38
+
39
+
40
+ /**
41
+ * Caching method as string
42
+ *
43
+ * @since 2.1.2
44
+ * @change 2.1.2
45
+ *
46
+ * @return string Caching method
47
+ */
48
+
49
+ public static function stringify‎_method() {
50
+ return 'Memcached';
51
+ }
52
+
53
+
54
+ /**
55
+ * Speicherung im Cache
56
+ *
57
+ * @since 2.0.7
58
+ * @change 2.0.7
59
+ *
60
+ * @param string $hash Hash des Eintrags
61
+ * @param string $data Inhalt des Eintrags
62
+ * @param integer $lifetime Lebensdauer des Eintrags
63
+ */
64
+
65
+ public static function store_item($hash, $data, $lifetime)
66
+ {
67
+ /* Empty? */
68
+ if ( empty($data) ) {
69
+ wp_die('MEMCACHE add item: Empty input.');
70
+ }
71
+
72
+ /* Server connect */
73
+ if ( ! self::_connect_server() ) {
74
+ return;
75
+ }
76
+
77
+ /* Add item */
78
+ self::$_memcached->set(
79
+ self::_file_path(),
80
+ $data . self::_cache_signatur(),
81
+ $lifetime
82
+ );
83
+ }
84
+
85
+
86
+ /**
87
+ * Lesen aus dem Cache
88
+ *
89
+ * @since 2.0.7
90
+ * @change 2.0.7
91
+ *
92
+ * @param string $hash Hash des Eintrags
93
+ * @return mixed $diff Wert des Eintrags
94
+ */
95
+
96
+ public static function get_item($hash)
97
+ {
98
+ /* Server connect */
99
+ if ( ! self::_connect_server() ) {
100
+ return;
101
+ }
102
+
103
+ /* Get item */
104
+ return self::$_memcached->get(
105
+ self::_file_path()
106
+ );
107
+ }
108
+
109
+
110
+ /**
111
+ * Entfernung aus dem Cache
112
+ *
113
+ * @since 2.0.7
114
+ * @change 2.0.7
115
+ *
116
+ * @param string $hash Hash des Eintrags
117
+ * @param string $url URL des Eintrags [optional]
118
+ */
119
+
120
+ public static function delete_item($hash, $url = '')
121
+ {
122
+ /* Server connect */
123
+ if ( ! self::_connect_server() ) {
124
+ return;
125
+ }
126
+
127
+ /* Delete */
128
+ self::$_memcached->delete(
129
+ self::_file_path($url)
130
+ );
131
+ }
132
+
133
+
134
+ /**
135
+ * Leerung des Cache
136
+ *
137
+ * @since 2.0.7
138
+ * @change 2.0.7
139
+ */
140
+
141
+ public static function clear_cache()
142
+ {
143
+ /* Server connect */
144
+ if ( ! self::_connect_server() ) {
145
+ return;
146
+ }
147
+
148
+ /* Flush */
149
+ @self::$_memcached->flush();
150
+ }
151
+
152
+
153
+ /**
154
+ * Ausgabe des Cache
155
+ *
156
+ * @since 2.0.7
157
+ * @change 2.0.7
158
+ */
159
+
160
+ public static function print_cache()
161
+ {
162
+ return;
163
+ }
164
+
165
+
166
+ /**
167
+ * Ermittlung der Cache-Größe
168
+ *
169
+ * @since 2.0.7
170
+ * @change 2.0.7
171
+ *
172
+ * @return mixed $diff Cache-Größe
173
+ */
174
+
175
+ public static function get_stats()
176
+ {
177
+ /* Server connect */
178
+ if ( ! self::_connect_server() ) {
179
+ wp_die('MEMCACHE: Not enabled.');
180
+ }
181
+
182
+ /* Infos */
183
+ $data = self::$_memcached->getStats();
184
+
185
+ /* No stats? */
186
+ if ( empty($data) ) {
187
+ return NULL;
188
+ }
189
+
190
+ /* Get first key */
191
+ $data = $data[key($data)];
192
+
193
+ /* Leer */
194
+ if ( empty($data['bytes']) ) {
195
+ return NULL;
196
+ }
197
+
198
+ return $data['bytes'];
199
+ }
200
+
201
+
202
+ /**
203
+ * Generierung der Signatur
204
+ *
205
+ * @since 2.0.7
206
+ * @change 2.0.7
207
+ *
208
+ * @return string $diff Signatur als String
209
+ */
210
+
211
+ private static function _cache_signatur()
212
+ {
213
+ return sprintf(
214
+ "\n\n<!-- %s\n%s @ %s -->",
215
+ 'Cachify | http://cachify.de',
216
+ 'Memcached',
217
+ date_i18n(
218
+ 'd.m.Y H:i:s',
219
+ current_time('timestamp')
220
+ )
221
+ );
222
+ }
223
+
224
+
225
+ /**
226
+ * Pfad der Cache-Datei
227
+ *
228
+ * @since 2.0.7
229
+ * @change 2.0.7
230
+ *
231
+ * @param string $path Request-URI oder Permalink [optional]
232
+ * @return string $diff Pfad zur Cache-Datei
233
+ */
234
+
235
+ private static function _file_path($path = NULL)
236
+ {
237
+ return trailingslashit(
238
+ sprintf(
239
+ '%s%s',
240
+ $_SERVER['HTTP_HOST'],
241
+ parse_url(
242
+ ( $path ? $path : $_SERVER['REQUEST_URI'] ),
243
+ PHP_URL_PATH
244
+ )
245
+ )
246
+ );
247
+ }
248
+
249
+
250
+ /**
251
+ * Connect to Memcached server
252
+ *
253
+ * @since 2.0.7
254
+ * @change 2.0.7
255
+ *
256
+ * @hook array cachify_memcached_servers Array with memcached servers
257
+ *
258
+ * @return boolean true/false TRUE bei Erfolg
259
+ */
260
+
261
+ private static function _connect_server()
262
+ {
263
+ /* Not enabled? */
264
+ if ( ! self::is_available() ) {
265
+ return false;
266
+ }
267
+
268
+ /* Already connected */
269
+ if ( is_object(self::$_memcached) ) {
270
+ return true;
271
+ }
272
+
273
+ /* Init */
274
+ self::$_memcached = new Memcached();
275
+
276
+ /* Options */
277
+ self::$_memcached->setOptions(
278
+ array(
279
+ Memcached::OPT_COMPRESSION => false,
280
+ Memcached::OPT_BUFFER_WRITES => true,
281
+ Memcached::OPT_BINARY_PROTOCOL => true
282
+ )
283
+ );
284
+
285
+ /* Connect */
286
+ self::$_memcached->addServers(
287
+ (array)apply_filters(
288
+ 'cachify_memcached_servers',
289
+ array(
290
+ array(
291
+ '127.0.0.1',
292
+ 11211
293
+ )
294
+ )
295
+ )
296
+ );
297
+
298
+ return true;
299
+ }
300
+ }
js/post.js ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(
2
+ function($) {
3
+
4
+ $('.edit-cachify-status', '#misc-publishing-actions').click(
5
+ function(e) {
6
+ $(this)
7
+ .next(':hidden')
8
+ .slideDown('fast')
9
+ .end()
10
+ .hide();
11
+
12
+ e.preventDefault();
13
+ }
14
+ );
15
+
16
+ $('.save-cachify-status', '#misc-publishing-actions').click(
17
+ function(e) {
18
+ $(this)
19
+ .parent()
20
+ .slideUp('fast')
21
+ .prev(':hidden')
22
+ .show();
23
+
24
+ $('#output-cachify-status').text(
25
+ $('#cachify_status').children('option:selected').text()
26
+ );
27
+
28
+ e.preventDefault();
29
+ }
30
+ );
31
+
32
+ $('.cancel-cachify-status', '#misc-publishing-actions').click(
33
+ function(e) {
34
+ $(this)
35
+ .parent()
36
+ .slideUp('fast')
37
+ .prev(':hidden')
38
+ .show();
39
+
40
+ e.preventDefault();
41
+ }
42
+ );
43
+ }
44
+ );
js/post.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ jQuery(document).ready(function(a){a(".edit-cachify-status","#misc-publishing-actions").click(function(b){a(this).next(":hidden").slideDown("fast").end().hide();b.preventDefault()});a(".save-cachify-status","#misc-publishing-actions").click(function(b){a(this).parent().slideUp("fast").prev(":hidden").show();a("#output-cachify-status").text(a("#cachify_status").children("option:selected").text());b.preventDefault()});a(".cancel-cachify-status","#misc-publishing-actions").click(function(b){a(this).parent().slideUp("fast").prev(":hidden").show();
2
+ b.preventDefault()})});
lang/cachify-de_DE.mo ADDED
Binary file
lang/cachify-de_DE.po ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Cachify\n"
4
+ "POT-Creation-Date: \n"
5
+ "PO-Revision-Date: \n"
6
+ "Last-Translator: Sergej Müller\n"
7
+ "Language-Team: Sergej Müller\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=utf-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Poedit-Language: German\n"
12
+ "X-Poedit-Country: GERMANY\n"
13
+ "X-Poedit-SourceCharset: utf-8\n"
14
+ "X-Poedit-KeywordsList: __;_e\n"
15
+ "X-Poedit-Basepath: .\n"
16
+ "X-Poedit-SearchPath-0: .\n"
17
+
18
+ msgid "Flush the cachify cache"
19
+ msgstr "Cachify-Cache leeren"
20
+
21
+ msgid "Caching method"
22
+ msgstr "Caching-Methode"
23
+
24
+ msgid "Empty"
25
+ msgstr "Leerer"
26
+
27
+ msgid "Remove"
28
+ msgstr "Löschen"
29
+
30
+ msgid "Total cache"
31
+ msgstr "Gesamtcache"
32
+
33
+ msgid "Page cache"
34
+ msgstr "Seitencache"
35
+
36
+ msgid "Cachify cache is flushed."
37
+ msgstr "Cachify-Cache ist geleert."
38
+
39
+ msgid "The server configuration file (e.g. .htaccess) needs to be adjusted"
40
+ msgstr "Die Serverkonfigurationsdatei (z.B. .htaccess) muss jetzt erweitert werden"
41
+
42
+ msgid "No minify"
43
+ msgstr "Keine Minimierung"
44
+
45
+ msgid "Database"
46
+ msgstr "Datenbank"
47
+
48
+ msgid "Hard disk"
49
+ msgstr "Festplatte"
50
+
51
+ msgid "Cache method"
52
+ msgstr "Cache-Aufbewahrungsort"
53
+
54
+ msgid "Cache validity"
55
+ msgstr "Cache-Gültigkeit"
56
+
57
+ msgid "Hours"
58
+ msgstr "Stunden"
59
+
60
+ msgid "Cache generation"
61
+ msgstr "Cache-Generierung"
62
+
63
+ msgid "No cache generation by logged in users"
64
+ msgstr "Kein Cache-Aufbau durch eingeloggte Nutzer"
65
+
66
+ msgid "Flush the cache at new comments"
67
+ msgstr "Neue Kommentare leeren den Cache"
68
+
69
+ msgid "Cache exceptions"
70
+ msgstr "Cache-Ausnahmen"
71
+
72
+ msgid "Cache minify"
73
+ msgstr "Cache-Minimierung"
74
+
75
+ msgid "Manual"
76
+ msgstr "Dokumentation"
77
+
78
+ msgid "Books"
79
+ msgstr "Handbücher"
80
+
81
+ msgid "Easy to use WordPress cache plugin with static file serving in the database, hard disc, memcached and apc."
82
+ msgstr "Smarter Cache für WordPress. Reduziert die Ladezeit der Blogseiten, indem Inhalte in statischer Form abgelegt und ausgeliefert werden."
83
+
readme.txt CHANGED
@@ -2,9 +2,11 @@
2
  Contributors: sergej.mueller
3
  Tags: apc, cache, caching, performance
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RDDW9FEHGLG6
5
- Requires at least: 3.1
6
- Tested up to: 3.5
7
  Stable tag: trunk
 
 
8
 
9
 
10
 
@@ -15,41 +17,116 @@ Turbo für WordPress. Smarte, aber effiziente Cache-Lösung für WordPress. Mit
15
  == Description ==
16
 
17
  = Unkompliziert und ausbaufähig =
18
- *Cachify* optimiert Ladezeit der Blogseiten, indem Seiteninhalte in statischer Form wahlweise in der Datenbank, auf der Festplatte des Webservers oder im APC (Alternative PHP Cache) abgelegt und beim Seitenaufruf ohne Umwege ausgegeben werden. Die Anzahl der DB-Anfragen und PHP-Anweisungen reduziert sich je nach Methode um Faktor 10.
19
 
20
- = Stärken =
 
21
  * Zusammenarbeit mit Custom Post Types
22
- * Speicherungsmethoden: DB, HDD und APC
 
23
  * "Cache leeren" als Schaltfläche in der Admin Bar
24
- * Inline- und Online-Handbuch
 
25
  * Optionale Komprimierung der HTML-Ausgabe
26
  * Ausnahmelisten für Beiträge und User Agents
27
  * Manueller und automatischer Cache-Reset
28
- * Ausgabe der "davor, danach" Informationen im Quelltext
29
- * Verständliche Oberfläche zum Sofortstart
30
  * Automatisches Management des Cache-Bestandes
31
  * Anzeige der Cache-Belegung auf dem Dashboard
32
- * Deutschsprachige Benutzeroberfläche
33
  * Konfigurationseinstellungen für Apache- und Nginx-Server
 
 
 
 
 
 
 
 
 
 
34
 
35
  = Systemvoraussetzungen =
36
- * WordPress ab 3.1
37
- * PHP ab 5.1.2
38
- * APC ab 3.1.4 (falls installiert)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- = Informationen =
41
- * [Offizielle Homepage](http://cachify.de "Cachify WordPress Cache")
42
- * [Online-Dokumentation](http://playground.ebiene.de/cachify-wordpress-cache/ "Cachify Online-Doku")
43
 
44
  = Autor =
 
45
  * [Google+](https://plus.google.com/110569673423509816572 "Google+")
46
  * [Plugins](http://wpcoder.de "Plugins")
47
- * [Portfolio](http://ebiene.de "Portfolio")
48
 
49
 
50
 
51
  == Changelog ==
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  = 2.0.4 =
54
  * Bessere Trennung der Cache-Gesamtgröße im Dashboard-Widget "Auf einen Blick"
55
 
@@ -146,8 +223,7 @@ Turbo für WordPress. Smarte, aber effiziente Cache-Lösung für WordPress. Mit
146
 
147
 
148
 
149
- == Screenshots ==
150
 
151
- 1. Cachify Optionen
152
 
153
- 2. Cachegröße auf dem Dashboard
2
  Contributors: sergej.mueller
3
  Tags: apc, cache, caching, performance
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RDDW9FEHGLG6
5
+ Requires at least: 3.8
6
+ Tested up to: 3.9
7
  Stable tag: trunk
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
 
12
 
17
  == Description ==
18
 
19
  = Unkompliziert und ausbaufähig =
20
+ *Cachify* optimiert Ladezeit der Blogseiten, indem Seiteninhalte in statischer Form wahlweise in der Datenbank, auf der Festplatte (HDD) oder dank APC (Alternative PHP Cache) im Speicher des Webservers abgelegt und beim Seitenaufruf ohne Umwege ausgegeben werden. Die Anzahl der DB-Anfragen und PHP-Anweisungen reduziert sich je nach gewählter Methode gegen Null.
21
 
22
+
23
+ = Pluspunkte =
24
  * Zusammenarbeit mit Custom Post Types
25
+ * Unterstützung von WooCommerce
26
+ * Speicherungsmethoden: DB, HDD, APC und Memcached
27
  * "Cache leeren" als Schaltfläche in der Admin Bar
28
+ * Handbuch als Online-, Kindle- oder Print-Version
29
+ * Einsatzbereit für WordPress-Multisite
30
  * Optionale Komprimierung der HTML-Ausgabe
31
  * Ausnahmelisten für Beiträge und User Agents
32
  * Manueller und automatischer Cache-Reset
33
+ * Deutschsprachige Oberfläche zum Sofortstart
 
34
  * Automatisches Management des Cache-Bestandes
35
  * Anzeige der Cache-Belegung auf dem Dashboard
 
36
  * Konfigurationseinstellungen für Apache- und Nginx-Server
37
+ * Zahlreiche Hooks/Filter als Schnittstelle
38
+
39
+
40
+ > #### Cachify-Handbuch
41
+ > Als Begleithandbuch und Installationshilfe für *Cachify* wurden ein Kindle-eBook und ein gedrucktes Taschenbuch mit dem Titel „[WordPress Performance](http://www.amazon.de/dp/B0091LDUVA "WordPress Performance"): Beschleunigung der Blogseiten durch Caching“ konzipiert und veröffentlicht. Beide Handbücher beleuchten verfügbare Caching-Methoden, empfehlen Plugin-Einstellungen und liefern wertvolle Tipps & Tricks zur Geschwindigkeitsoptimierung unter WordPress.
42
+
43
+
44
+ = Support =
45
+ Freundlich formulierte Fragen rund um das Plugin werden per E-Mail beantwortet.
46
+
47
 
48
  = Systemvoraussetzungen =
49
+ * WordPress ab 3.8
50
+ * PHP ab 5.2.4
51
+ * APC ab 3.1.4 (optional)
52
+ * Memcached unter Nginx (optional)
53
+
54
+
55
+ = Unterstützung =
56
+ * Per [Flattr](https://flattr.com/t/1327625)
57
+ * Per [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5RDDW9FEHGLG6)
58
+
59
+
60
+ = Handbuch =
61
+ * [Cachify: Caching für WordPress](http://playground.ebiene.de/cachify-wordpress-cache/)
62
+
63
+
64
+ = Website =
65
+ * [cachify.de](http://cachify.de "Cachify WordPress Cache")
66
 
 
 
 
67
 
68
  = Autor =
69
+ * [Twitter](https://twitter.com/wpSEO)
70
  * [Google+](https://plus.google.com/110569673423509816572 "Google+")
71
  * [Plugins](http://wpcoder.de "Plugins")
72
+
73
 
74
 
75
 
76
  == Changelog ==
77
 
78
+ = 2.1.6 =
79
+ * Button "Cache leeren" sichtbar sowohl in WP 3.8 wie WP 3.9
80
+
81
+ = 2.1.5 =
82
+ * Support für WordPress 3.9
83
+ * Button "Cache leeren" sichtbar bei jeder Bildschirmauflösung
84
+
85
+ = 2.1.4 =
86
+ * Support für WordPress 3.8.1
87
+
88
+ = 2.1.3 =
89
+ * Manuelle Auswahl: Beim Artikel-Update nur den Seitencache löschen
90
+ * Lokalisierung der Plugin-Dateien
91
+ * Umbauten am Plugin-Core
92
+ * Detaillierter auf [Google+](https://plus.google.com/+SergejMüller/posts/By2PEtRMk8g)
93
+
94
+ = 2.1.2 =
95
+ * Optimierung für WordPress 3.8
96
+ * Option hinzugefügt: Neue Kommentare lösen einen Cache-Reset aus
97
+
98
+ = 2.1.1 =
99
+ * Hook `cachify_skip_cache` für die Steuerung der Cache-Generierung
100
+ * Support für das MP6 Plugin
101
+ * Detaillierter auf [Google+](https://plus.google.com/110569673423509816572/posts/S1mpFsG3NZC)
102
+
103
+ = 2.1.0 =
104
+ * Cache-Leerung bei Plugin-Deaktivierung
105
+
106
+ = 2.0.9 =
107
+ * Quelltext-Minimierung als Selektbox und Hook
108
+ * Interne Umstellung auf Konstanten
109
+
110
+ = 2.0.8 =
111
+ * Volle Unterstützung von WooCommerce (WC 1.4.2+)
112
+ * Detaillierter auf [Google+](https://plus.google.com/110569673423509816572/posts/ic4heMghbxw)
113
+
114
+ = 2.0.7 =
115
+ * Unterstützung für Memcached
116
+ * WordPress 3.6 Support
117
+ * Cache-Neuaufbau beim Theme-Wechsel
118
+ * Quelltext-Optimierungen
119
+
120
+ = 2.0.6 =
121
+ * Cache-Neuaufbau einer Blogseite nur bei Kommentaren, die freigegeben sind
122
+
123
+ = 2.0.5 =
124
+ * Cache-Leerung nach einem WordPress-Upgrade
125
+ * Keine Cache-Ausgabe für Jetpack Mobile Theme
126
+ * Abfrage auf eingeloggte Nutzer bei APC als Caching-Methode
127
+ * Änderung der Systemvoraussetzungen
128
+ * Cache-Reset nach WordPress-Update
129
+
130
  = 2.0.4 =
131
  * Bessere Trennung der Cache-Gesamtgröße im Dashboard-Widget "Auf einen Blick"
132
 
223
 
224
 
225
 
 
226
 
227
+ == Screenshots ==
228
 
229
+ 1. Cachify auf dem Dashboard
screenshot-1.png DELETED
Binary file
screenshot-2.png DELETED
Binary file