Version Description
Download this release
Release Info
Developer | pluginkollektiv |
Plugin | Cachify |
Version | 2.3.0 |
Comparing to | |
See all releases |
Code changes from version 2.2.4 to 2.3.0
- CHANGELOG.md +71 -35
- LICENSE.txt +339 -0
- README.md +13 -48
- apc/proxy.php +41 -17
- cachify.php +26 -18
- css/dashboard.css +8 -26
- css/dashboard.min.css +1 -1
- css/settings.css +28 -0
- css/settings.min.css +1 -0
- images/symbols.svg +19 -0
- inc/cachify.class.php +859 -1000
- inc/cachify.settings.php +129 -0
- inc/cachify.settings_footer.php +11 -0
- inc/cachify_apc.class.php +92 -132
- inc/cachify_cli.class.php +112 -0
- inc/cachify_db.class.php +157 -193
- inc/cachify_hdd.class.php +287 -260
- inc/cachify_memcached.class.php +124 -161
- inc/setup/cachify.apc.htaccess.php +31 -0
- inc/setup/cachify.apc.nginx.php +41 -0
- inc/setup/cachify.hdd.htaccess.php +86 -0
- inc/setup/cachify.hdd.nginx.php +74 -0
- inc/setup/cachify.memcached.nginx.php +79 -0
- js/post.js +0 -44
- js/post.min.js +0 -2
- readme.txt +137 -0
CHANGELOG.md
CHANGED
@@ -1,86 +1,122 @@
|
|
1 |
# Changelog
|
2 |
-
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
* Vervollständigung des Cachify-Pfades in `robots.txt`: `Disallow: /wp-content/cache/cachify/`
|
6 |
* *Release-Zeitaufwand (Development & QA): 0,75 Stunden*
|
7 |
|
8 |
-
|
9 |
* HHVM-Unterstützung für die *Memcached* Caching-Methode (Danke, [Ulrich Block](http://www.ulrich-block.de))
|
10 |
|
11 |
-
|
12 |
* Cache-Leerung bei Custom Post Types
|
13 |
* Einführung zusätzlicher Sicherheitsabfragen
|
14 |
* Code-Refactoring
|
15 |
|
16 |
-
|
17 |
* Button "Cache leeren" sichtbar sowohl in WP 3.8 wie WP 3.9
|
18 |
|
19 |
-
|
20 |
* Support für WordPress 3.9
|
21 |
* Button "Cache leeren" sichtbar bei jeder Bildschirmauflösung
|
22 |
|
23 |
-
|
24 |
* Support für WordPress 3.8.1
|
25 |
|
26 |
-
|
27 |
* Manuelle Auswahl: Beim Artikel-Update nur den Seitencache löschen
|
28 |
* Lokalisierung der Plugin-Dateien
|
29 |
* Umbauten am Plugin-Core
|
30 |
* Detaillierter auf [Google+](https://plus.google.com/+SergejMüller/posts/By2PEtRMk8g)
|
31 |
|
32 |
-
|
33 |
* Optimierung für WordPress 3.8
|
34 |
* Option hinzugefügt: Neue Kommentare lösen einen Cache-Reset aus
|
35 |
|
36 |
-
|
37 |
* Hook `cachify_skip_cache` für die Steuerung der Cache-Generierung
|
38 |
* Support für das MP6 Plugin
|
39 |
* Detaillierter auf [Google+](https://plus.google.com/110569673423509816572/posts/S1mpFsG3NZC)
|
40 |
|
41 |
-
|
42 |
* Cache-Leerung bei Plugin-Deaktivierung
|
43 |
|
44 |
-
|
45 |
* Quelltext-Minimierung als Selektbox und Hook
|
46 |
* Interne Umstellung auf Konstanten
|
47 |
|
48 |
-
|
49 |
* Unterstützung für Memcached
|
50 |
* WordPress 3.6 Support
|
51 |
* Cache-Neuaufbau beim Theme-Wechsel
|
52 |
* Quelltext-Optimierungen
|
53 |
|
54 |
-
|
55 |
* Cache-Neuaufbau einer Blogseite nur bei Kommentaren, die freigegeben sind
|
56 |
|
57 |
-
|
58 |
* Cache-Leerung nach einem WordPress-Upgrade
|
59 |
* Keine Cache-Ausgabe für Jetpack Mobile Theme
|
60 |
* Abfrage auf eingeloggte Nutzer bei APC als Caching-Methode
|
61 |
* Änderung der Systemvoraussetzungen
|
62 |
* Cache-Reset nach WordPress-Update
|
63 |
|
64 |
-
|
65 |
* Bessere Trennung der Cache-Gesamtgröße im Dashboard-Widget "Auf einen Blick"
|
66 |
|
67 |
-
|
68 |
* Cache-Leerung beim Veröffentlichen verfügbarer Custom Post Types
|
69 |
* Noindex in der von WordPress generierten `robots.txt` für den Ordner mit HDD-Cache
|
70 |
* Hook `cachify_flush_cache` zum Leeren des Cache aus Drittanwendungen
|
71 |
|
72 |
-
|
73 |
* Unterstützung für WordPress 3.4
|
74 |
* Hochauflösende Icons für iPad & Co.
|
75 |
* Anpassungen für ältere PHP5-Versionen
|
76 |
* Entfernung des Plugin-Icons aus der Sidebar
|
77 |
|
78 |
-
|
79 |
* Verbesserter Autoload-Prozess
|
80 |
* Diverse Umbenennungen der Optionen
|
81 |
* Cache-Neuaufbau bei geplanten Beiträgen (Cachify DB)
|
82 |
|
83 |
-
|
84 |
* Überarbeitung der GUI
|
85 |
* Source Code-Modularisierung
|
86 |
* Cache-Größe auf dem Dashboard
|
@@ -92,36 +128,36 @@
|
|
92 |
* Schnellübersicht der Optionen als Inline-Hilfe
|
93 |
* Mindestanforderungen: WordPress 3.1 & PHP 5.1.2
|
94 |
|
95 |
-
|
96 |
* `zlib.output_compression = Off` für Apache Webserver
|
97 |
|
98 |
-
|
99 |
* Überarbeitung des Regexp für HTML-Minify
|
100 |
* Reduzierung des Toolbar-Buttons auf das Icon
|
101 |
* Formatierung und Kommentierung des Quelltextes
|
102 |
|
103 |
-
|
104 |
* Xmas Edition
|
105 |
|
106 |
-
|
107 |
* Unterstützung für APC (Alternative PHP Cache)
|
108 |
* Umpositionierung des Admin Bar Buttons
|
109 |
|
110 |
-
|
111 |
* Icon für die "Cache leeren" Schaltfläche in der Admin Bar
|
112 |
|
113 |
-
|
114 |
* Schaltfläche "Cache leeren" in der Adminbar (ab WordPress 3.1)
|
115 |
* `flush_cache` auf public gesetzt, um von [wpSEO](http://wpseo.de "WordPress SEO Plugin") ansprechen zu können
|
116 |
* Ausführliche Tests unter WordPress 3.3
|
117 |
|
118 |
-
|
119 |
* Interne Prüfung auf fehlerhafte Cache-Generierung
|
120 |
* Anpassungen an der Code-Struktur
|
121 |
* Entfernung der Inline-Hilfe
|
122 |
* Verknüpfung der Online-Hilfe mit Optionen
|
123 |
|
124 |
-
|
125 |
* Leerung des Cache beim Aktualisieren von statischen Seiten
|
126 |
* Seite mit Plugin-Einstellungen
|
127 |
* Inline-Dokumentation in der Optionsseite
|
@@ -131,26 +167,26 @@
|
|
131 |
* Umstellung auf den template_redirect-Hook (Plugin-Kompatibilität)
|
132 |
* Interne Code-Bereinigung
|
133 |
|
134 |
-
|
135 |
* HTML-Kompression
|
136 |
* Flattr-Link
|
137 |
|
138 |
-
|
139 |
* Cache-Reset bei geplanten Beiträgen
|
140 |
* Unterstützung für das Carrington-Mobile Theme
|
141 |
|
142 |
-
|
143 |
* Workaround für Redirects
|
144 |
|
145 |
-
|
146 |
* Blacklist für PostIDs
|
147 |
* Blacklist für UserAgents
|
148 |
* Ausnahme für WP Touch
|
149 |
* Ausgabe des Zeitpunktes der Generierung
|
150 |
* Umbenennung der Konstanten
|
151 |
|
152 |
-
|
153 |
* Ausgabe des Speicherverbrauchs
|
154 |
|
155 |
-
|
156 |
* Live auf wordpress.org
|
1 |
# Changelog
|
2 |
+
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
|
3 |
+
|
4 |
+
## [2.3.0]
|
5 |
+
* New: WP-CLI integration, see #165, props derweili
|
6 |
+
* New: `cachify_flush_cache_hooks` filter added to modify all hooks that flush the cache
|
7 |
+
* New: Flush cache when a user is created / updated / deleted
|
8 |
+
* New: Flush cache when a term is created / updated / deleted, see #169, props derweili
|
9 |
+
* New: Cache behavior after post modification is now configurable in plugin settings
|
10 |
+
* Enhance: Cache exceptions/User-Agents translation, see #52, props timse201
|
11 |
+
* Enhance: Readme FAQ, see #51, props timse201
|
12 |
+
* Enhance: sizeable exclusion boxes + placeholder, see #53, props timse201
|
13 |
+
* Enhance: FAQ and Support links, see #55, props timse201
|
14 |
+
* Enhance: Add text caption to "flush cache" button
|
15 |
+
* Security: Tabnabbing prevention, see #55, props timse201
|
16 |
+
|
17 |
+
## 2.2.4
|
18 |
+
* Fixes caching for mixed HTTPS and HTTP setups
|
19 |
+
* Fixes an issue with the icon styling in the admin toolbar
|
20 |
+
* Ensures compatibility with the latest WordPress version
|
21 |
+
|
22 |
+
## 2.2.3
|
23 |
+
* New: Generated a POT file
|
24 |
+
* New: Added German formal translation
|
25 |
+
* Updated, translated + formatted README.md
|
26 |
+
* Updated expired link URLs in plugin and languages files
|
27 |
+
* Updated plugin authors
|
28 |
+
|
29 |
+
## 2.2.2
|
30 |
+
* Fix: parameter return by filter dashboard_glance_items
|
31 |
+
* Generous use of the filter esc_html
|
32 |
+
|
33 |
+
## 2.2.1
|
34 |
+
* Fix for the PHP notice "Call to undefined function is_plugin_active_for_network" on WordPress Multisite
|
35 |
+
|
36 |
+
## 2.2.0
|
37 |
+
* Toolbar: Display of the "Flush the cachify cache" button on the frontend
|
38 |
+
* Toolbar: Controlling the display of the "Flush the cachify cache" button via hook
|
39 |
+
|
40 |
+
## 2.1.9
|
41 |
* Vervollständigung des Cachify-Pfades in `robots.txt`: `Disallow: /wp-content/cache/cachify/`
|
42 |
* *Release-Zeitaufwand (Development & QA): 0,75 Stunden*
|
43 |
|
44 |
+
## 2.1.8
|
45 |
* HHVM-Unterstützung für die *Memcached* Caching-Methode (Danke, [Ulrich Block](http://www.ulrich-block.de))
|
46 |
|
47 |
+
## 2.1.7
|
48 |
* Cache-Leerung bei Custom Post Types
|
49 |
* Einführung zusätzlicher Sicherheitsabfragen
|
50 |
* Code-Refactoring
|
51 |
|
52 |
+
## 2.1.6
|
53 |
* Button "Cache leeren" sichtbar sowohl in WP 3.8 wie WP 3.9
|
54 |
|
55 |
+
## 2.1.5
|
56 |
* Support für WordPress 3.9
|
57 |
* Button "Cache leeren" sichtbar bei jeder Bildschirmauflösung
|
58 |
|
59 |
+
## 2.1.4
|
60 |
* Support für WordPress 3.8.1
|
61 |
|
62 |
+
## 2.1.3
|
63 |
* Manuelle Auswahl: Beim Artikel-Update nur den Seitencache löschen
|
64 |
* Lokalisierung der Plugin-Dateien
|
65 |
* Umbauten am Plugin-Core
|
66 |
* Detaillierter auf [Google+](https://plus.google.com/+SergejMüller/posts/By2PEtRMk8g)
|
67 |
|
68 |
+
## 2.1.2
|
69 |
* Optimierung für WordPress 3.8
|
70 |
* Option hinzugefügt: Neue Kommentare lösen einen Cache-Reset aus
|
71 |
|
72 |
+
## 2.1.1
|
73 |
* Hook `cachify_skip_cache` für die Steuerung der Cache-Generierung
|
74 |
* Support für das MP6 Plugin
|
75 |
* Detaillierter auf [Google+](https://plus.google.com/110569673423509816572/posts/S1mpFsG3NZC)
|
76 |
|
77 |
+
## 2.1.0
|
78 |
* Cache-Leerung bei Plugin-Deaktivierung
|
79 |
|
80 |
+
## 2.0.9
|
81 |
* Quelltext-Minimierung als Selektbox und Hook
|
82 |
* Interne Umstellung auf Konstanten
|
83 |
|
84 |
+
## 2.0.7
|
85 |
* Unterstützung für Memcached
|
86 |
* WordPress 3.6 Support
|
87 |
* Cache-Neuaufbau beim Theme-Wechsel
|
88 |
* Quelltext-Optimierungen
|
89 |
|
90 |
+
## 2.0.6
|
91 |
* Cache-Neuaufbau einer Blogseite nur bei Kommentaren, die freigegeben sind
|
92 |
|
93 |
+
## 2.0.5
|
94 |
* Cache-Leerung nach einem WordPress-Upgrade
|
95 |
* Keine Cache-Ausgabe für Jetpack Mobile Theme
|
96 |
* Abfrage auf eingeloggte Nutzer bei APC als Caching-Methode
|
97 |
* Änderung der Systemvoraussetzungen
|
98 |
* Cache-Reset nach WordPress-Update
|
99 |
|
100 |
+
## 2.0.4
|
101 |
* Bessere Trennung der Cache-Gesamtgröße im Dashboard-Widget "Auf einen Blick"
|
102 |
|
103 |
+
## 2.0.3
|
104 |
* Cache-Leerung beim Veröffentlichen verfügbarer Custom Post Types
|
105 |
* Noindex in der von WordPress generierten `robots.txt` für den Ordner mit HDD-Cache
|
106 |
* Hook `cachify_flush_cache` zum Leeren des Cache aus Drittanwendungen
|
107 |
|
108 |
+
## 2.0.2
|
109 |
* Unterstützung für WordPress 3.4
|
110 |
* Hochauflösende Icons für iPad & Co.
|
111 |
* Anpassungen für ältere PHP5-Versionen
|
112 |
* Entfernung des Plugin-Icons aus der Sidebar
|
113 |
|
114 |
+
## 2.0.1
|
115 |
* Verbesserter Autoload-Prozess
|
116 |
* Diverse Umbenennungen der Optionen
|
117 |
* Cache-Neuaufbau bei geplanten Beiträgen (Cachify DB)
|
118 |
|
119 |
+
## 2.0
|
120 |
* Überarbeitung der GUI
|
121 |
* Source Code-Modularisierung
|
122 |
* Cache-Größe auf dem Dashboard
|
128 |
* Schnellübersicht der Optionen als Inline-Hilfe
|
129 |
* Mindestanforderungen: WordPress 3.1 & PHP 5.1.2
|
130 |
|
131 |
+
## 1.5.1
|
132 |
* `zlib.output_compression = Off` für Apache Webserver
|
133 |
|
134 |
+
## 1.5
|
135 |
* Überarbeitung des Regexp für HTML-Minify
|
136 |
* Reduzierung des Toolbar-Buttons auf das Icon
|
137 |
* Formatierung und Kommentierung des Quelltextes
|
138 |
|
139 |
+
## 1.4
|
140 |
* Xmas Edition
|
141 |
|
142 |
+
## 1.3
|
143 |
* Unterstützung für APC (Alternative PHP Cache)
|
144 |
* Umpositionierung des Admin Bar Buttons
|
145 |
|
146 |
+
## 1.2.1
|
147 |
* Icon für die "Cache leeren" Schaltfläche in der Admin Bar
|
148 |
|
149 |
+
## 1.2
|
150 |
* Schaltfläche "Cache leeren" in der Adminbar (ab WordPress 3.1)
|
151 |
* `flush_cache` auf public gesetzt, um von [wpSEO](http://wpseo.de "WordPress SEO Plugin") ansprechen zu können
|
152 |
* Ausführliche Tests unter WordPress 3.3
|
153 |
|
154 |
+
## 1.1
|
155 |
* Interne Prüfung auf fehlerhafte Cache-Generierung
|
156 |
* Anpassungen an der Code-Struktur
|
157 |
* Entfernung der Inline-Hilfe
|
158 |
* Verknüpfung der Online-Hilfe mit Optionen
|
159 |
|
160 |
+
## 1.0
|
161 |
* Leerung des Cache beim Aktualisieren von statischen Seiten
|
162 |
* Seite mit Plugin-Einstellungen
|
163 |
* Inline-Dokumentation in der Optionsseite
|
167 |
* Umstellung auf den template_redirect-Hook (Plugin-Kompatibilität)
|
168 |
* Interne Code-Bereinigung
|
169 |
|
170 |
+
## 0.9.2
|
171 |
* HTML-Kompression
|
172 |
* Flattr-Link
|
173 |
|
174 |
+
## 0.9.1
|
175 |
* Cache-Reset bei geplanten Beiträgen
|
176 |
* Unterstützung für das Carrington-Mobile Theme
|
177 |
|
178 |
+
## 0.9
|
179 |
* Workaround für Redirects
|
180 |
|
181 |
+
## 0.8
|
182 |
* Blacklist für PostIDs
|
183 |
* Blacklist für UserAgents
|
184 |
* Ausnahme für WP Touch
|
185 |
* Ausgabe des Zeitpunktes der Generierung
|
186 |
* Umbenennung der Konstanten
|
187 |
|
188 |
+
## 0.7
|
189 |
* Ausgabe des Speicherverbrauchs
|
190 |
|
191 |
+
## 0.6
|
192 |
* Live auf wordpress.org
|
LICENSE.txt
ADDED
@@ -0,0 +1,339 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
Preamble
|
10 |
+
|
11 |
+
The licenses for most software are designed to take away your
|
12 |
+
freedom to share and change it. By contrast, the GNU General Public
|
13 |
+
License is intended to guarantee your freedom to share and change free
|
14 |
+
software--to make sure the software is free for all its users. This
|
15 |
+
General Public License applies to most of the Free Software
|
16 |
+
Foundation's software and to any other program whose authors commit to
|
17 |
+
using it. (Some other Free Software Foundation software is covered by
|
18 |
+
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
+
your programs, too.
|
20 |
+
|
21 |
+
When we speak of free software, we are referring to freedom, not
|
22 |
+
price. Our General Public Licenses are designed to make sure that you
|
23 |
+
have the freedom to distribute copies of free software (and charge for
|
24 |
+
this service if you wish), that you receive source code or can get it
|
25 |
+
if you want it, that you can change the software or use pieces of it
|
26 |
+
in new free programs; and that you know you can do these things.
|
27 |
+
|
28 |
+
To protect your rights, we need to make restrictions that forbid
|
29 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
+
These restrictions translate to certain responsibilities for you if you
|
31 |
+
distribute copies of the software, or if you modify it.
|
32 |
+
|
33 |
+
For example, if you distribute copies of such a program, whether
|
34 |
+
gratis or for a fee, you must give the recipients all the rights that
|
35 |
+
you have. You must make sure that they, too, receive or can get the
|
36 |
+
source code. And you must show them these terms so they know their
|
37 |
+
rights.
|
38 |
+
|
39 |
+
We protect your rights with two steps: (1) copyright the software, and
|
40 |
+
(2) offer you this license which gives you legal permission to copy,
|
41 |
+
distribute and/or modify the software.
|
42 |
+
|
43 |
+
Also, for each author's protection and ours, we want to make certain
|
44 |
+
that everyone understands that there is no warranty for this free
|
45 |
+
software. If the software is modified by someone else and passed on, we
|
46 |
+
want its recipients to know that what they have is not the original, so
|
47 |
+
that any problems introduced by others will not reflect on the original
|
48 |
+
authors' reputations.
|
49 |
+
|
50 |
+
Finally, any free program is threatened constantly by software
|
51 |
+
patents. We wish to avoid the danger that redistributors of a free
|
52 |
+
program will individually obtain patent licenses, in effect making the
|
53 |
+
program proprietary. To prevent this, we have made it clear that any
|
54 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
GNU GENERAL PUBLIC LICENSE
|
60 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
+
|
62 |
+
0. This License applies to any program or other work which contains
|
63 |
+
a notice placed by the copyright holder saying it may be distributed
|
64 |
+
under the terms of this General Public License. The "Program", below,
|
65 |
+
refers to any such program or work, and a "work based on the Program"
|
66 |
+
means either the Program or any derivative work under copyright law:
|
67 |
+
that is to say, a work containing the Program or a portion of it,
|
68 |
+
either verbatim or with modifications and/or translated into another
|
69 |
+
language. (Hereinafter, translation is included without limitation in
|
70 |
+
the term "modification".) Each licensee is addressed as "you".
|
71 |
+
|
72 |
+
Activities other than copying, distribution and modification are not
|
73 |
+
covered by this License; they are outside its scope. The act of
|
74 |
+
running the Program is not restricted, and the output from the Program
|
75 |
+
is covered only if its contents constitute a work based on the
|
76 |
+
Program (independent of having been made by running the Program).
|
77 |
+
Whether that is true depends on what the Program does.
|
78 |
+
|
79 |
+
1. You may copy and distribute verbatim copies of the Program's
|
80 |
+
source code as you receive it, in any medium, provided that you
|
81 |
+
conspicuously and appropriately publish on each copy an appropriate
|
82 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
+
notices that refer to this License and to the absence of any warranty;
|
84 |
+
and give any other recipients of the Program a copy of this License
|
85 |
+
along with the Program.
|
86 |
+
|
87 |
+
You may charge a fee for the physical act of transferring a copy, and
|
88 |
+
you may at your option offer warranty protection in exchange for a fee.
|
89 |
+
|
90 |
+
2. You may modify your copy or copies of the Program or any portion
|
91 |
+
of it, thus forming a work based on the Program, and copy and
|
92 |
+
distribute such modifications or work under the terms of Section 1
|
93 |
+
above, provided that you also meet all of these conditions:
|
94 |
+
|
95 |
+
a) You must cause the modified files to carry prominent notices
|
96 |
+
stating that you changed the files and the date of any change.
|
97 |
+
|
98 |
+
b) You must cause any work that you distribute or publish, that in
|
99 |
+
whole or in part contains or is derived from the Program or any
|
100 |
+
part thereof, to be licensed as a whole at no charge to all third
|
101 |
+
parties under the terms of this License.
|
102 |
+
|
103 |
+
c) If the modified program normally reads commands interactively
|
104 |
+
when run, you must cause it, when started running for such
|
105 |
+
interactive use in the most ordinary way, to print or display an
|
106 |
+
announcement including an appropriate copyright notice and a
|
107 |
+
notice that there is no warranty (or else, saying that you provide
|
108 |
+
a warranty) and that users may redistribute the program under
|
109 |
+
these conditions, and telling the user how to view a copy of this
|
110 |
+
License. (Exception: if the Program itself is interactive but
|
111 |
+
does not normally print such an announcement, your work based on
|
112 |
+
the Program is not required to print an announcement.)
|
113 |
+
|
114 |
+
These requirements apply to the modified work as a whole. If
|
115 |
+
identifiable sections of that work are not derived from the Program,
|
116 |
+
and can be reasonably considered independent and separate works in
|
117 |
+
themselves, then this License, and its terms, do not apply to those
|
118 |
+
sections when you distribute them as separate works. But when you
|
119 |
+
distribute the same sections as part of a whole which is a work based
|
120 |
+
on the Program, the distribution of the whole must be on the terms of
|
121 |
+
this License, whose permissions for other licensees extend to the
|
122 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
+
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
282 |
+
How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
{description}
|
294 |
+
Copyright (C) {year} {fullname}
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License along
|
307 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) year name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
{signature of Ty Coon}, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Lesser General
|
339 |
+
Public License instead of this License.
|
README.md
CHANGED
@@ -1,17 +1,8 @@
|
|
1 |
# Cachify #
|
2 |
-
* Contributors: pluginkollektiv
|
3 |
-
* Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ
|
4 |
-
* Tags: apc, cache, caching, performance
|
5 |
-
* Requires at least: 3.8
|
6 |
-
* Tested up to: 4.6
|
7 |
-
* Stable tag: 2.2.4
|
8 |
-
* License: GPLv2 or later
|
9 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
|
11 |
Smart, efficient cache solution for WordPress. Use DB, HDD, APC or Memcached for storing your blog pages. Make WordPress faster!
|
12 |
|
13 |
## Description ##
|
14 |
-
*Cachify* optimizes your page loads by caching posts, pages and custom post types as static content. You can choose between caching via database, on the web server’s hard drive (HDD), or—thanks to APC (Alternative PHP Cache)—directly in the web server’s system cache. Whenever a page or post is loaded, it can be pulled directly from the cache. The amount of database queries and PHP requests will dramatically decrease towards zero, depending on the caching method you chose.
|
15 |
|
16 |
### Features ###
|
17 |
* Works with custom post types.
|
@@ -26,65 +17,39 @@ Smart, efficient cache solution for WordPress. Use DB, HDD, APC or Memcached for
|
|
26 |
* Settings for Apache and Nginx servers.
|
27 |
* Extendability via hooks/filters.
|
28 |
|
29 |
-
> #### Auf Deutsch? ####
|
30 |
-
> Für eine ausführliche Dokumentation besuche bitte das [Cachify-Wiki](https://github.com/pluginkollektiv/cachify/wiki).
|
31 |
-
>
|
32 |
-
> **Community-Support auf Deutsch** erhältst du in einem der [deutschsprachigen Foren](https://de.forums.wordpress.org/forum/plugins); im [Plugin-Forum für Cachify](https://wordpress.org/support/plugin/cachify) wird, wie in allen Plugin-Foren auf wordpress.org, ausschließlich **Englisch** gesprochen.
|
33 |
-
|
34 |
### Support ###
|
35 |
* Community support via the [support forums on wordpress.org](https://wordpress.org/support/plugin/cachify)
|
36 |
* We don’t handle support via e-mail, Twitter, GitHub issues etc.
|
37 |
|
38 |
### Contribute ###
|
39 |
-
* Active development of this plugin is handled on GitHub.
|
40 |
* Pull requests for documented bugs are highly appreciated.
|
41 |
* If you think you’ve found a bug (e.g. you’re experiencing unexpected behavior), please post at the [support forums](https://wordpress.org/support/plugin/cachify) first.
|
|
|
|
|
|
|
|
|
42 |
|
43 |
### Credits ###
|
44 |
* Author: [Sergej Müller](https://sergejmueller.github.io/)
|
45 |
* Maintainers: [pluginkollektiv](http://pluginkollektiv.org)
|
46 |
|
|
|
47 |
## Installation ##
|
48 |
* If you don’t know how to install a plugin for WordPress, [here’s how](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
|
49 |
|
50 |
### Requirements ###
|
51 |
* PHP 5.2.4 or greater
|
52 |
-
* WordPress
|
53 |
* APC 3.1.4 or greater (optional)
|
54 |
* Memcached in Nginx (optional)
|
55 |
|
56 |
|
57 |
-
##
|
58 |
-
|
59 |
-
### 2.2.4 ###
|
60 |
-
* Fixes caching for mixed HTTPS and HTTP setups
|
61 |
-
* Fixes an issue with the icon styling in the admin toolbar
|
62 |
-
* Ensures compatibility with the latest WordPress version
|
63 |
-
|
64 |
-
### 2.2.3 ###
|
65 |
-
* New: Generated a POT file
|
66 |
-
* New: Added German formal translation
|
67 |
-
* Updated, translated + formatted README.md
|
68 |
-
* Updated expired link URLs in plugin and languages files
|
69 |
-
* Updated [plugin authors](https://gist.github.com/glueckpress/f058c0ab973d45a72720)
|
70 |
-
|
71 |
-
### 2.2.2 ###
|
72 |
-
* Fix: Parameter-Rückgabe beim Filter `dashboard_glance_items`
|
73 |
-
* Großzügige Anwendung des Filters `esc_html`
|
74 |
-
|
75 |
-
### 2.2.1 ###
|
76 |
-
* Fix für die Meldung "Call to undefined function is_plugin_active_for_network" in WordPress-Multisite
|
77 |
|
78 |
-
|
79 |
-
* Werkzeugleiste: Anzeige des "Cache leeren" Buttons im Frontend der Website
|
80 |
-
* Werkzeugleiste: Steuerung der Anzeige des "Cache leeren" Buttons via Hook
|
81 |
|
82 |
-
For the complete changelog, check out our [GitHub repository](https://github.com/pluginkollektiv/cachify).
|
83 |
|
84 |
-
##
|
85 |
-
|
86 |
-
### 2.2.4 ###
|
87 |
-
This is mainly a maintenance release ensuring compatibility with the latest version of WordPress. Expect bigger changes in 2.3.0 soon!
|
88 |
-
|
89 |
-
## Screenshots ##
|
90 |
-
1. Cachify Dashboard Widget
|
1 |
# Cachify #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
Smart, efficient cache solution for WordPress. Use DB, HDD, APC or Memcached for storing your blog pages. Make WordPress faster!
|
3 |
|
4 |
## Description ##
|
5 |
+
*Cachify* optimizes your page loads by caching posts, pages and custom post types as static content. You can choose between caching via database, on the web server’s hard drive (HDD), Memcached (only on Nginx) or — thanks to APC (Alternative PHP Cache) — directly in the web server’s system cache. Whenever a page or post is loaded, it can be pulled directly from the cache. The amount of database queries and PHP requests will dramatically decrease towards zero, depending on the caching method you chose.
|
6 |
|
7 |
### Features ###
|
8 |
* Works with custom post types.
|
17 |
* Settings for Apache and Nginx servers.
|
18 |
* Extendability via hooks/filters.
|
19 |
|
|
|
|
|
|
|
|
|
|
|
20 |
### Support ###
|
21 |
* Community support via the [support forums on wordpress.org](https://wordpress.org/support/plugin/cachify)
|
22 |
* We don’t handle support via e-mail, Twitter, GitHub issues etc.
|
23 |
|
24 |
### Contribute ###
|
25 |
+
* Active development of this plugin is handled [on GitHub](https://github.com/pluginkollektiv/cachify).
|
26 |
* Pull requests for documented bugs are highly appreciated.
|
27 |
* If you think you’ve found a bug (e.g. you’re experiencing unexpected behavior), please post at the [support forums](https://wordpress.org/support/plugin/cachify) first.
|
28 |
+
* If you want to help us translate this plugin you can do so [on WordPress Translate](https://translate.wordpress.org/projects/wp-plugins/cachify).
|
29 |
+
|
30 |
+
### Donate
|
31 |
+
[Donate to us via Paypal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW)
|
32 |
|
33 |
### Credits ###
|
34 |
* Author: [Sergej Müller](https://sergejmueller.github.io/)
|
35 |
* Maintainers: [pluginkollektiv](http://pluginkollektiv.org)
|
36 |
|
37 |
+
|
38 |
## Installation ##
|
39 |
* If you don’t know how to install a plugin for WordPress, [here’s how](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
|
40 |
|
41 |
### Requirements ###
|
42 |
* PHP 5.2.4 or greater
|
43 |
+
* WordPress 4.4 or greater
|
44 |
* APC 3.1.4 or greater (optional)
|
45 |
* Memcached in Nginx (optional)
|
46 |
|
47 |
|
48 |
+
## Frequently Asked Questions ##
|
49 |
+
Please have a look [in the FAQ pages](https://cachify.pluginkollektiv.org/documentation#faq).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
+
A complete documentation is available in the [online handbook](https://cachify.pluginkollektiv.org/documentation/).
|
|
|
|
|
52 |
|
|
|
53 |
|
54 |
+
## Changelog ##
|
55 |
+
[Changelog](./CHANGELOG.md).
|
|
|
|
|
|
|
|
|
|
apc/proxy.php
CHANGED
@@ -1,28 +1,52 @@
|
|
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;
|
|
|
7 |
}
|
8 |
}
|
9 |
}
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
if (
|
12 |
-
empty($_cachify_logged_in)
|
13 |
-
&& ( strpos( filter_input(INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING), '/wp-admin/' ) === false )
|
14 |
-
&& ( strpos( filter_input(INPUT_SERVER, 'HTTP_ACCEPT_ENCODING', FILTER_SANITIZE_STRING), '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 |
-
|
27 |
-
|
28 |
-
}
|
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;
|
7 |
+
break;
|
8 |
}
|
9 |
}
|
10 |
}
|
11 |
|
12 |
+
/**
|
13 |
+
* Determines if SSL is used.
|
14 |
+
*
|
15 |
+
* @see is_ssl() (wp-includes/load.php).
|
16 |
+
*
|
17 |
+
* @return bool True if SSL, otherwise false.
|
18 |
+
*/
|
19 |
+
function cachify_is_ssl() {
|
20 |
+
if ( isset( $_SERVER['HTTPS'] ) ) {
|
21 |
+
if ( 'on' === strtolower( $_SERVER['HTTPS'] ) ) {
|
22 |
+
return true;
|
23 |
+
}
|
24 |
+
|
25 |
+
if ( '1' === $_SERVER['HTTPS'] ) {
|
26 |
+
return true;
|
27 |
+
}
|
28 |
+
} elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' === $_SERVER['SERVER_PORT'] ) ) {
|
29 |
+
return true;
|
30 |
+
}
|
31 |
+
|
32 |
+
return false;
|
33 |
+
}
|
34 |
+
|
35 |
if (
|
36 |
+
empty( $_cachify_logged_in )
|
37 |
+
&& ( strpos( filter_input( INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING ), '/wp-admin/' ) === false )
|
38 |
+
&& ( strpos( filter_input( INPUT_SERVER, 'HTTP_ACCEPT_ENCODING', FILTER_SANITIZE_STRING ), 'gzip' ) !== false )
|
39 |
+
&& extension_loaded( 'apc' )
|
40 |
+
&& ( $cache = apc_fetch( md5( ( cachify_is_ssl() ? 'https-' : '' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) . '.cachify' ) )
|
41 |
) {
|
42 |
+
ini_set( 'zlib.output_compression', 'Off' );
|
43 |
|
44 |
+
header( 'Vary: Accept-Encoding' );
|
45 |
+
header( 'X-Powered-By: Cachify' );
|
46 |
+
header( 'Content-Encoding: gzip' );
|
47 |
+
header( 'Content-Length: ' . strlen( $cache ) );
|
48 |
+
header( 'Content-Type: text/html; charset=utf-8' );
|
49 |
|
50 |
+
echo $cache;
|
51 |
+
exit;
|
52 |
+
}
|
cachify.php
CHANGED
@@ -3,11 +3,11 @@
|
|
3 |
Plugin Name: Cachify
|
4 |
Description: Easy to use WordPress caching plugin. Serving static blog pages from database, disk, Memcached or APC.
|
5 |
Author: pluginkollektiv
|
6 |
-
Author URI:
|
7 |
-
Plugin URI: https://
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
-
Version: 2.
|
11 |
Text Domain: cachify
|
12 |
Domain Path: /lang
|
13 |
*/
|
@@ -32,14 +32,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|
32 |
|
33 |
|
34 |
/* Quit */
|
35 |
-
defined('ABSPATH')
|
36 |
|
37 |
|
38 |
-
/*
|
39 |
-
define('CACHIFY_FILE', __FILE__);
|
40 |
-
define('CACHIFY_DIR', dirname(__FILE__));
|
41 |
-
define('CACHIFY_BASE', plugin_basename(__FILE__));
|
42 |
-
define('CACHIFY_CACHE_DIR', WP_CONTENT_DIR. '/cache/cachify');
|
43 |
|
44 |
|
45 |
/* Hooks */
|
@@ -47,43 +47,51 @@ add_action(
|
|
47 |
'plugins_loaded',
|
48 |
array(
|
49 |
'Cachify',
|
50 |
-
'instance'
|
51 |
)
|
52 |
);
|
53 |
register_activation_hook(
|
54 |
__FILE__,
|
55 |
array(
|
56 |
'Cachify',
|
57 |
-
'on_activation'
|
58 |
)
|
59 |
);
|
60 |
register_deactivation_hook(
|
61 |
__FILE__,
|
62 |
array(
|
63 |
'Cachify',
|
64 |
-
'on_deactivation'
|
65 |
)
|
66 |
);
|
67 |
register_uninstall_hook(
|
68 |
__FILE__,
|
69 |
array(
|
70 |
'Cachify',
|
71 |
-
'on_uninstall'
|
72 |
)
|
73 |
);
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
/* Autoload Init */
|
77 |
-
spl_autoload_register('cachify_autoload');
|
78 |
|
79 |
-
/* Autoload
|
80 |
-
function cachify_autoload($class) {
|
81 |
-
if ( in_array($class, array('Cachify', 'Cachify_APC', 'Cachify_DB', 'Cachify_HDD', 'Cachify_MEMCACHED')) ) {
|
82 |
require_once(
|
83 |
sprintf(
|
84 |
'%s/inc/%s.class.php',
|
85 |
CACHIFY_DIR,
|
86 |
-
strtolower($class)
|
87 |
)
|
88 |
);
|
89 |
}
|
3 |
Plugin Name: Cachify
|
4 |
Description: Easy to use WordPress caching plugin. Serving static blog pages from database, disk, Memcached or APC.
|
5 |
Author: pluginkollektiv
|
6 |
+
Author URI: https://pluginkollektiv.org
|
7 |
+
Plugin URI: https://cachify.pluginkollektiv.org/
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
Version: 2.3.0
|
11 |
Text Domain: cachify
|
12 |
Domain Path: /lang
|
13 |
*/
|
32 |
|
33 |
|
34 |
/* Quit */
|
35 |
+
defined( 'ABSPATH' ) || exit;
|
36 |
|
37 |
|
38 |
+
/* Constants */
|
39 |
+
define( 'CACHIFY_FILE', __FILE__ );
|
40 |
+
define( 'CACHIFY_DIR', dirname( __FILE__ ) );
|
41 |
+
define( 'CACHIFY_BASE', plugin_basename( __FILE__ ) );
|
42 |
+
define( 'CACHIFY_CACHE_DIR', WP_CONTENT_DIR . '/cache/cachify' );
|
43 |
|
44 |
|
45 |
/* Hooks */
|
47 |
'plugins_loaded',
|
48 |
array(
|
49 |
'Cachify',
|
50 |
+
'instance',
|
51 |
)
|
52 |
);
|
53 |
register_activation_hook(
|
54 |
__FILE__,
|
55 |
array(
|
56 |
'Cachify',
|
57 |
+
'on_activation',
|
58 |
)
|
59 |
);
|
60 |
register_deactivation_hook(
|
61 |
__FILE__,
|
62 |
array(
|
63 |
'Cachify',
|
64 |
+
'on_deactivation',
|
65 |
)
|
66 |
);
|
67 |
register_uninstall_hook(
|
68 |
__FILE__,
|
69 |
array(
|
70 |
'Cachify',
|
71 |
+
'on_uninstall',
|
72 |
)
|
73 |
);
|
74 |
|
75 |
+
/* WP-CLI */
|
76 |
+
add_action(
|
77 |
+
'cli_init',
|
78 |
+
array(
|
79 |
+
'Cachify_CLI',
|
80 |
+
'add_commands'
|
81 |
+
)
|
82 |
+
);
|
83 |
|
84 |
/* Autoload Init */
|
85 |
+
spl_autoload_register( 'cachify_autoload' );
|
86 |
|
87 |
+
/* Autoload function */
|
88 |
+
function cachify_autoload( $class ) {
|
89 |
+
if ( in_array( $class, array( 'Cachify', 'Cachify_APC', 'Cachify_DB', 'Cachify_HDD', 'Cachify_MEMCACHED', 'Cachify_CLI' ) ) ) {
|
90 |
require_once(
|
91 |
sprintf(
|
92 |
'%s/inc/%s.class.php',
|
93 |
CACHIFY_DIR,
|
94 |
+
strtolower( $class )
|
95 |
)
|
96 |
);
|
97 |
}
|
css/dashboard.css
CHANGED
@@ -1,29 +1,11 @@
|
|
1 |
/* @group Dashboard */
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
}
|
7 |
-
|
8 |
-
#dashboard_right_now .cachify-icon:before {
|
9 |
-
color: #82878c;
|
10 |
-
font-family: "cachifyIcons";
|
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 |
-
|
|
|
|
|
|
1 |
/* @group Dashboard */
|
2 |
+
#dashboard_right_now .cachify-icon{
|
3 |
+
width: 19px;
|
4 |
+
height: 13px;
|
5 |
+
fill: #606a73;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
}
|
7 |
|
8 |
+
#dashboard_right_now li a.cachify-glance::before{
|
9 |
+
content: "";
|
10 |
+
padding: 0;
|
11 |
+
}/* @end group */
|
css/dashboard.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
1 |
+
#dashboard_right_now .cachify-icon{width:19px;height:13px;fill:#606a73}#dashboard_right_now li a.cachify-glance::before{content:"";padding:0}
|
css/settings.css
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.wp-core-ui .button-flush {
|
2 |
+
background: #dd823b;
|
3 |
+
border-color: #c36922 #ad5d1e #ad5d1e;
|
4 |
+
color: #fff;
|
5 |
+
box-shadow: 0 1px 0 #ad5d1e;
|
6 |
+
text-shadow: 0 -1px 1px #ad5d1e,1px 0 1px #ad5d1e,0 1px 1px #ad5d1e,-1px 0 1px #ad5d1e
|
7 |
+
}
|
8 |
+
|
9 |
+
.wp-core-ui .button-flush:focus,
|
10 |
+
.wp-core-ui .button-flush:hover {
|
11 |
+
background: #df8a48;
|
12 |
+
border-color: #ad5d1e;
|
13 |
+
color: #fff;
|
14 |
+
box-shadow: 0 1px 0 #ad5d1e
|
15 |
+
}
|
16 |
+
|
17 |
+
.wp-core-ui .button-flush:focus {
|
18 |
+
box-shadow: inset 0 1px 0 #c36922,0 0 2px 1px #33b3db
|
19 |
+
}
|
20 |
+
|
21 |
+
.wp-core-ui .button-flush.active,
|
22 |
+
.wp-core-ui .button-flush.active:focus,
|
23 |
+
.wp-core-ui .button-flush.active:hover,
|
24 |
+
.wp-core-ui .button-flush:active {
|
25 |
+
background: #c36922;
|
26 |
+
border-color: #ad5d1e;
|
27 |
+
box-shadow: inset 0 2px 0 #ad5d1e
|
28 |
+
}
|
css/settings.min.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.wp-core-ui .button-flush{background:#dd823b;border-color:#c36922 #ad5d1e #ad5d1e;color:#fff;box-shadow:0 1px 0 #ad5d1e;text-shadow:0 -1px 1px #ad5d1e,1px 0 1px #ad5d1e,0 1px 1px #ad5d1e,-1px 0 1px #ad5d1e}.wp-core-ui .button-flush:focus,.wp-core-ui .button-flush:hover{background:#df8a48;border-color:#ad5d1e;color:#fff;box-shadow:0 1px 0 #ad5d1e}.wp-core-ui .button-flush:focus{box-shadow:inset 0 1px 0 #c36922,0 0 2px 1px #33b3db}.wp-core-ui .button-flush.active,.wp-core-ui .button-flush.active:focus,.wp-core-ui .button-flush.active:hover,.wp-core-ui .button-flush:active{background:#c36922;border-color:#ad5d1e;box-shadow:inset 0 2px 0 #ad5d1e}
|
images/symbols.svg
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
2 |
+
<defs>
|
3 |
+
<symbol id="cachify-icon-hdd" viewBox="0 0 430 300">
|
4 |
+
<path class="path1" d="m 352.46233,188.63185 -70.04051,-189.00377 -211.881322,0 L 0.4999975,188.63185 28.656997,299.5 l 295.648343,0 z m -27.45307,17.95009 -19.35793,74.96796 -258.340332,0 -19.3579,-74.96796 297.056162,0 z M 94.825908,243.88995 c 0,-3.75439 -1.40684,-7.03996 -4.22253,-9.85566 -2.81571,-2.8157 -6.10056,-4.22353 -9.85495,-4.22353 -3.75443,0 -7.15683,1.40783 -10.20723,4.22353 -3.0505,2.8157 -4.3411,6.10057 -3.872,9.85495 0.4692,3.75436 1.7598,7.15676 3.8716,10.20726 2.1118,3.0505 5.5142,4.3411 10.20693,3.872 4.6927,-0.4692 7.97756,-1.7599 9.8546,-3.8716 1.87701,-2.1118 3.28486,-5.5142 4.22354,-10.20694 z"></path>
|
5 |
+
</symbol>
|
6 |
+
|
7 |
+
<symbol id="cachify-icon-apc" viewBox="0 0 430 300">
|
8 |
+
<path class="path1" d="M 291.81225,0.57657577 C 403.84867,1.1854758 410.85094,1.1854758 414.19986,3.3165758 c 6.69783,4.2623 12.78677,14.9179002 14.309,24.9647002 0.60889,3.0444 0.60889,70.631605 0,71.240505 0,0.30445 -1.52223,0.913339 -3.04447,1.217779 -7.61117,1.82669 -14.309,9.43786 -16.44013,18.87571 -1.82668,7.30672 -1.52223,17.35347 1.21779,24.66018 2.43558,7.00228 9.43785,14.00456 14.91789,15.22234 l 3.65337,0.91335 0,36.22916 c 0.30444,52.97376 0,70.93612 -0.30445,74.89393 -0.91334,6.39338 -4.87115,15.83123 -8.52451,20.09348 -6.08894,6.69783 -10.35119,7.61117 -30.14023,7.91562 -9.43785,0 -17.65792,0 -17.65792,-0.30445 -0.30444,-0.30444 -0.30444,-8.22006 -0.60889,-17.96236 0,-9.43785 -0.30445,-18.2668 -0.91334,-19.48459 -0.60889,-1.82668 -1.82668,-2.13113 -5.1756,-2.13113 -8.22006,0 -7.91562,-0.30445 -7.91562,21.00683 l 0,18.8757 -28.618,0 -0.30444,-6.69783 c 0,-3.34891 0,-11.56898 0.30444,-17.65791 0,-14.00456 -0.60889,-15.52679 -7.61116,-15.52679 -3.95781,0 -5.1756,0.30445 -5.7845,2.43557 -0.60889,1.21779 -0.91333,10.35119 -0.91333,19.78905 l 0,17.65791 -28.618,0 0,-11.56898 0,-18.2668 c 0,-8.52452 -0.91335,-10.04675 -6.69783,-10.04675 -7.30673,0 -7.61117,0.6089 -7.61117,21.92017 l 0,17.96236 -28.618,0 0,-14.00455 c -0.30444,-7.61117 0,-16.13568 0,-18.57125 0.30445,-5.48005 -1.21779,-7.00228 -7.00227,-7.30673 -7.30673,-0.30445 -7.30673,0 -7.30673,21.00683 l 0,18.57125 -7.91561,0.6089 -14.30901,0 -6.39338,-0.6089 0,-18.26681 c 0,-12.78676 -0.30445,-18.8757 -0.91334,-19.78904 -0.60889,-0.91333 -3.34892,-1.52223 -6.39338,-1.52223 -3.95781,0 -5.1756,0.30445 -6.08894,2.43557 -0.30444,1.21779 -0.91334,10.35119 -0.91334,19.78905 l 0,17.65791 -14.309,0 c -10.65564,0 -14.309,-0.60889 -14.309,-1.82668 l 0,-17.35346 c 0,-8.82896 -0.30444,-17.04903 -0.91334,-18.26682 -0.60889,-2.13112 -1.82668,-2.43557 -5.17559,-2.43557 -8.22006,0 -8.22006,-0.30445 -8.22006,21.00683 l 0,18.57125 -9.43786,0.6089 -14.30899,0 -4.5667,-0.6089 0,-17.96236 c 0,-21.00682 -0.30445,-21.61572 -7.61118,-21.61572 -3.9578,0 -5.17559,0.30445 -5.78448,2.43557 -0.6089,1.21779 -0.91335,10.35119 -0.91335,19.78905 l 0,17.65791 -28.617996,0 0,-18.57126 c 0,-12.78676 -0.30444,-18.8757 -1.21778,-19.78904 -0.6089,-0.91333 -3.04447,-1.52223 -5.78449,-1.52223 -7.00228,0 -7.30672,0.6089 -7.30672,21.31127 0,9.7423 0,17.65792 -0.30445,17.96237 -0.30445,0.30444 -8.22006,0.60889 -17.35347,0.60889 -21.92017,0 -26.48687,-1.52223 -32.8802495,-10.96008 -6.39339002,-9.43786 -6.39339002,-7.00228 -6.39339002,-71.24055 -0.30444,-46.58037 -0.30444,-57.54046 0.60890002,-57.54046 8.22006,-0.60889 16.4401195,-8.82896 19.1801495,-19.18014 1.52223,-6.39339 1.21779,-17.04902 -0.6089,-23.13796 -2.74001,-8.52451 -11.5689695,-17.35347 -17.9623495,-17.35347 -1.52224002,0 -1.52224002,-1.826679 -1.52224002,-35.315819 0,-30.444675 0.30444,-35.924775 1.52224002,-41.404775 2.13112,-8.8289 6.08893,-14.6134002 11.8734195,-18.8757002 3.9578,-2.74 6.08893,-3.3489 13.39566,-3.65330003 15.83123,-0.9134 145.525556,-0.9134 264.868706,-0.3045 z M 301.2501,82.777211 c -0.6089,1.21778 -0.91335,24.660179 -0.91335,57.540439 0,49.01593 0,55.71376 1.2178,57.54044 1.21778,1.82668 5.17559,1.82668 27.4002,1.82668 22.22462,0 25.87798,0 27.09577,-1.82668 1.21779,-1.82668 1.52223,-8.82895 1.52223,-57.84489 0,-49.015929 -0.30444,-56.018209 -1.52223,-57.844889 -2.13112,-2.74002 -53.58264,-2.43557 -54.80042,0.6089 z m -113.86311,-0.6089 c -1.21778,1.82668 -1.52223,9.13341 -1.52223,57.844889 0,49.32038 0.30445,56.01821 1.52223,57.84489 2.13113,3.04448 52.36485,2.74003 54.49598,0 0.91335,-1.82668 1.21779,-9.1334 1.21779,-57.84489 0,-48.407039 -0.30444,-56.018209 -1.52224,-57.844889 -1.82668,-2.74002 -52.0604,-2.74002 -54.19153,0 z M 73.523904,81.254971 c -0.91334,0.60889 -0.91334,1.82668 -0.6089,2.74002 0.30445,1.21779 0.30445,1.21779 -0.30444,0.6089 -0.91335,-0.6089 -0.91335,12.78676 -0.91335,55.409309 0,48.40704 0.30445,56.32266 1.21779,57.84489 2.13113,3.04448 52.364846,2.74003 54.495976,0 1.21778,-1.82668 1.21778,-8.52451 1.21778,-57.84489 0,-48.711479 0,-56.018209 -1.21778,-57.844889 -1.21779,-1.82668 -5.1756,-1.82668 -27.09577,-1.82668 -14.004546,0 -26.182416,0.30445 -26.791306,0.91334 z"></path>
|
9 |
+
</symbol>
|
10 |
+
|
11 |
+
<symbol id="cachify-icon-db" viewBox="0 0 430 300">
|
12 |
+
<path class="path1" d="M 5.2707,197.95216 C 2.0903,193.40872 0.5,193.63502 0.5,198.63303 l 0,34.07666 c 0,16.81101 11.8133,32.14551 35.4397,46.00351 23.62637,13.8579 51.56924,20.7868 83.8286,20.7868 31.80477,0 59.63416,-6.9289 83.48783,-20.7868 23.85367,-13.858 35.78051,-29.1925 35.78051,-46.00351 l 0,-34.07666 c 0,-1.81731 -0.45425,-2.95309 -1.36307,-3.40733 -0.90882,-0.45425 -2.0446,0.45457 -3.40766,2.72646 -7.26958,11.81336 -21.46831,21.58212 -42.59584,29.30628 -21.12753,7.72416 -45.09467,11.58607 -71.90176,11.58607 -26.8071,0 -50.77425,-3.86191 -71.90178,-11.58607 C 26.739,219.53428 12.5403,209.76552 5.2707,197.95216 z M 4.5892,111.3964 c -1.8173,-3.63496 -3.1797,-3.63496 -4.0885,0 l 0,39.52894 c 0,15.44797 11.586,28.39711 34.75815,38.8474 23.17212,10.45029 51.34229,15.67526 84.51014,15.67526 32.71359,0 60.76993,-5.22497 84.16935,-15.67526 23.39943,-10.45029 35.09897,-23.39943 35.09897,-38.8474 l 0,-39.52894 c 0,-4.54344 -1.59035,-4.54344 -4.77073,0 -6.81534,10.45029 -20.90024,18.96946 -42.25507,25.5575 -21.35481,6.58804 -45.43578,9.88224 -72.24287,9.88224 -26.80709,0 -50.88805,-3.29419 -72.24288,-9.88224 C 26.17093,130.36586 11.8587,121.84669 4.5892,111.3964 z M 119.76899,-0.37507 c -32.71361,0 -60.76995,4.42998 -84.16938,13.2899 C 12.2002,21.77477 0.5007,32.33854 0.5007,44.60614 l 0,21.80907 c 0,13.17642 11.6995,24.42172 35.09891,33.73589 23.39943,9.31418 51.45577,13.97143 84.16938,13.97143 32.71359,0 60.76993,-4.65725 84.16935,-13.97143 23.39943,-9.31417 35.09897,-20.55947 35.09897,-33.73589 l 0,-21.80907 c 0,-12.2676 -11.69954,-22.83137 -35.09897,-31.69131 -23.39942,-8.85992 -51.45576,-13.2899 -84.16936,-13.2899 z"></path>
|
13 |
+
</symbol>
|
14 |
+
|
15 |
+
<symbol id="cachify-icon-memcached" viewBox="0 0 430 300">
|
16 |
+
<path class="path1" d="M 291.81225,0.57657577 C 403.84867,1.1854758 410.85094,1.1854758 414.19986,3.3165758 c 6.69783,4.2623 12.78677,14.9179002 14.309,24.9647002 0.60889,3.0444 0.60889,70.631605 0,71.240505 0,0.30445 -1.52223,0.913339 -3.04447,1.217779 -7.61117,1.82669 -14.309,9.43786 -16.44013,18.87571 -1.82668,7.30672 -1.52223,17.35347 1.21779,24.66018 2.43558,7.00228 9.43785,14.00456 14.91789,15.22234 l 3.65337,0.91335 0,36.22916 c 0.30444,52.97376 0,70.93612 -0.30445,74.89393 -0.91334,6.39338 -4.87115,15.83123 -8.52451,20.09348 -6.08894,6.69783 -10.35119,7.61117 -30.14023,7.91562 -9.43785,0 -17.65792,0 -17.65792,-0.30445 -0.30444,-0.30444 -0.30444,-8.22006 -0.60889,-17.96236 0,-9.43785 -0.30445,-18.2668 -0.91334,-19.48459 -0.60889,-1.82668 -1.82668,-2.13113 -5.1756,-2.13113 -8.22006,0 -7.91562,-0.30445 -7.91562,21.00683 l 0,18.8757 -28.618,0 -0.30444,-6.69783 c 0,-3.34891 0,-11.56898 0.30444,-17.65791 0,-14.00456 -0.60889,-15.52679 -7.61116,-15.52679 -3.95781,0 -5.1756,0.30445 -5.7845,2.43557 -0.60889,1.21779 -0.91333,10.35119 -0.91333,19.78905 l 0,17.65791 -28.618,0 0,-11.56898 0,-18.2668 c 0,-8.52452 -0.91335,-10.04675 -6.69783,-10.04675 -7.30673,0 -7.61117,0.6089 -7.61117,21.92017 l 0,17.96236 -28.618,0 0,-14.00455 c -0.30444,-7.61117 0,-16.13568 0,-18.57125 0.30445,-5.48005 -1.21779,-7.00228 -7.00227,-7.30673 -7.30673,-0.30445 -7.30673,0 -7.30673,21.00683 l 0,18.57125 -7.91561,0.6089 -14.30901,0 -6.39338,-0.6089 0,-18.26681 c 0,-12.78676 -0.30445,-18.8757 -0.91334,-19.78904 -0.60889,-0.91333 -3.34892,-1.52223 -6.39338,-1.52223 -3.95781,0 -5.1756,0.30445 -6.08894,2.43557 -0.30444,1.21779 -0.91334,10.35119 -0.91334,19.78905 l 0,17.65791 -14.309,0 c -10.65564,0 -14.309,-0.60889 -14.309,-1.82668 l 0,-17.35346 c 0,-8.82896 -0.30444,-17.04903 -0.91334,-18.26682 -0.60889,-2.13112 -1.82668,-2.43557 -5.17559,-2.43557 -8.22006,0 -8.22006,-0.30445 -8.22006,21.00683 l 0,18.57125 -9.43786,0.6089 -14.30899,0 -4.5667,-0.6089 0,-17.96236 c 0,-21.00682 -0.30445,-21.61572 -7.61118,-21.61572 -3.9578,0 -5.17559,0.30445 -5.78448,2.43557 -0.6089,1.21779 -0.91335,10.35119 -0.91335,19.78905 l 0,17.65791 -28.617996,0 0,-18.57126 c 0,-12.78676 -0.30444,-18.8757 -1.21778,-19.78904 -0.6089,-0.91333 -3.04447,-1.52223 -5.78449,-1.52223 -7.00228,0 -7.30672,0.6089 -7.30672,21.31127 0,9.7423 0,17.65792 -0.30445,17.96237 -0.30445,0.30444 -8.22006,0.60889 -17.35347,0.60889 -21.92017,0 -26.48687,-1.52223 -32.8802495,-10.96008 -6.39339002,-9.43786 -6.39339002,-7.00228 -6.39339002,-71.24055 -0.30444,-46.58037 -0.30444,-57.54046 0.60890002,-57.54046 8.22006,-0.60889 16.4401195,-8.82896 19.1801495,-19.18014 1.52223,-6.39339 1.21779,-17.04902 -0.6089,-23.13796 -2.74001,-8.52451 -11.5689695,-17.35347 -17.9623495,-17.35347 -1.52224002,0 -1.52224002,-1.826679 -1.52224002,-35.315819 0,-30.444675 0.30444,-35.924775 1.52224002,-41.404775 2.13112,-8.8289 6.08893,-14.6134002 11.8734195,-18.8757002 3.9578,-2.74 6.08893,-3.3489 13.39566,-3.65330003 15.83123,-0.9134 145.525556,-0.9134 264.868706,-0.3045 z M 301.2501,82.777211 c -0.6089,1.21778 -0.91335,24.660179 -0.91335,57.540439 0,49.01593 0,55.71376 1.2178,57.54044 1.21778,1.82668 5.17559,1.82668 27.4002,1.82668 22.22462,0 25.87798,0 27.09577,-1.82668 1.21779,-1.82668 1.52223,-8.82895 1.52223,-57.84489 0,-49.015929 -0.30444,-56.018209 -1.52223,-57.844889 -2.13112,-2.74002 -53.58264,-2.43557 -54.80042,0.6089 z m -113.86311,-0.6089 c -1.21778,1.82668 -1.52223,9.13341 -1.52223,57.844889 0,49.32038 0.30445,56.01821 1.52223,57.84489 2.13113,3.04448 52.36485,2.74003 54.49598,0 0.91335,-1.82668 1.21779,-9.1334 1.21779,-57.84489 0,-48.407039 -0.30444,-56.018209 -1.52224,-57.844889 -1.82668,-2.74002 -52.0604,-2.74002 -54.19153,0 z M 73.523904,81.254971 c -0.91334,0.60889 -0.91334,1.82668 -0.6089,2.74002 0.30445,1.21779 0.30445,1.21779 -0.30444,0.6089 -0.91335,-0.6089 -0.91335,12.78676 -0.91335,55.409309 0,48.40704 0.30445,56.32266 1.21779,57.84489 2.13113,3.04448 52.364846,2.74003 54.495976,0 1.21778,-1.82668 1.21778,-8.52451 1.21778,-57.84489 0,-48.711479 0,-56.018209 -1.21778,-57.844889 -1.21779,-1.82668 -5.1756,-1.82668 -27.09577,-1.82668 -14.004546,0 -26.182416,0.30445 -26.791306,0.91334 z"></path>
|
17 |
+
</symbol>
|
18 |
+
</defs>
|
19 |
+
</svg>
|
inc/cachify.class.php
CHANGED
@@ -1,151 +1,116 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
/* Quit */
|
5 |
-
defined('ABSPATH') OR exit;
|
6 |
-
|
7 |
-
|
8 |
/**
|
9 |
* Cachify
|
10 |
*/
|
11 |
-
|
12 |
final class Cachify {
|
13 |
|
14 |
-
|
15 |
/**
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
private static $options;
|
23 |
|
24 |
-
|
25 |
/**
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
private static $method;
|
33 |
|
34 |
-
|
35 |
/**
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
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 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
const MINIFY_DISABLED = 0;
|
56 |
const MINIFY_HTML_ONLY = 1;
|
57 |
const MINIFY_HTML_JS = 2;
|
58 |
|
59 |
-
|
60 |
/**
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
public static function instance()
|
68 |
-
{
|
69 |
new self();
|
70 |
}
|
71 |
|
72 |
-
|
73 |
/**
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
public function __construct()
|
84 |
-
{
|
85 |
/* Set defaults */
|
86 |
self::_set_default_vars();
|
87 |
|
|
|
|
|
88 |
/* Publish hooks */
|
89 |
add_action(
|
90 |
'init',
|
91 |
array(
|
92 |
__CLASS__,
|
93 |
-
'register_publish_hooks'
|
94 |
),
|
95 |
99
|
96 |
);
|
97 |
|
98 |
/* Flush Hooks */
|
|
|
|
|
99 |
add_action(
|
100 |
'cachify_remove_post_cache',
|
101 |
array(
|
102 |
__CLASS__,
|
103 |
-
'remove_page_cache_by_post_id'
|
104 |
-
)
|
105 |
-
);
|
106 |
-
add_action(
|
107 |
-
'cachify_flush_cache',
|
108 |
-
array(
|
109 |
-
__CLASS__,
|
110 |
-
'flush_total_cache'
|
111 |
-
)
|
112 |
-
);
|
113 |
-
add_action(
|
114 |
-
'_core_updated_successfully',
|
115 |
-
array(
|
116 |
-
__CLASS__,
|
117 |
-
'flush_total_cache'
|
118 |
-
)
|
119 |
-
);
|
120 |
-
add_action(
|
121 |
-
'switch_theme',
|
122 |
-
array(
|
123 |
-
__CLASS__,
|
124 |
-
'flush_total_cache'
|
125 |
-
)
|
126 |
-
);
|
127 |
-
add_action(
|
128 |
-
'wp_trash_post',
|
129 |
-
array(
|
130 |
-
__CLASS__,
|
131 |
-
'flush_total_cache'
|
132 |
)
|
133 |
);
|
134 |
|
135 |
-
|
136 |
add_action(
|
137 |
'admin_bar_menu',
|
138 |
array(
|
139 |
__CLASS__,
|
140 |
-
'add_flush_icon'
|
141 |
),
|
142 |
90
|
143 |
);
|
|
|
144 |
add_action(
|
145 |
'init',
|
146 |
array(
|
147 |
__CLASS__,
|
148 |
-
'process_flush_request'
|
149 |
)
|
150 |
);
|
151 |
|
@@ -154,7 +119,7 @@ final class Cachify {
|
|
154 |
'pre_comment_approved',
|
155 |
array(
|
156 |
__CLASS__,
|
157 |
-
'pre_comment'
|
158 |
),
|
159 |
99,
|
160 |
2
|
@@ -166,14 +131,15 @@ final class Cachify {
|
|
166 |
'wpmu_new_blog',
|
167 |
array(
|
168 |
__CLASS__,
|
169 |
-
'install_later'
|
170 |
)
|
171 |
);
|
|
|
172 |
add_action(
|
173 |
'delete_blog',
|
174 |
array(
|
175 |
__CLASS__,
|
176 |
-
'uninstall_later'
|
177 |
)
|
178 |
);
|
179 |
|
@@ -181,14 +147,15 @@ final class Cachify {
|
|
181 |
'admin_init',
|
182 |
array(
|
183 |
__CLASS__,
|
184 |
-
'register_textdomain'
|
185 |
)
|
186 |
);
|
|
|
187 |
add_action(
|
188 |
'admin_init',
|
189 |
array(
|
190 |
__CLASS__,
|
191 |
-
'register_settings'
|
192 |
)
|
193 |
);
|
194 |
|
@@ -196,14 +163,31 @@ final class Cachify {
|
|
196 |
'admin_menu',
|
197 |
array(
|
198 |
__CLASS__,
|
199 |
-
'add_page'
|
200 |
)
|
201 |
);
|
|
|
202 |
add_action(
|
203 |
'admin_enqueue_scripts',
|
204 |
array(
|
205 |
__CLASS__,
|
206 |
-
'add_admin_resources'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
)
|
208 |
);
|
209 |
|
@@ -211,16 +195,17 @@ final class Cachify {
|
|
211 |
'transition_comment_status',
|
212 |
array(
|
213 |
__CLASS__,
|
214 |
-
'touch_comment'
|
215 |
),
|
216 |
10,
|
217 |
3
|
218 |
);
|
|
|
219 |
add_action(
|
220 |
'edit_comment',
|
221 |
array(
|
222 |
__CLASS__,
|
223 |
-
'edit_comment'
|
224 |
)
|
225 |
);
|
226 |
|
@@ -228,14 +213,7 @@ final class Cachify {
|
|
228 |
'dashboard_glance_items',
|
229 |
array(
|
230 |
__CLASS__,
|
231 |
-
'add_dashboard_count'
|
232 |
-
)
|
233 |
-
);
|
234 |
-
add_action(
|
235 |
-
'post_submitbox_misc_actions',
|
236 |
-
array(
|
237 |
-
__CLASS__,
|
238 |
-
'print_flush_dropdown'
|
239 |
)
|
240 |
);
|
241 |
|
@@ -243,74 +221,70 @@ final class Cachify {
|
|
243 |
'plugin_row_meta',
|
244 |
array(
|
245 |
__CLASS__,
|
246 |
-
'row_meta'
|
247 |
),
|
248 |
10,
|
249 |
2
|
250 |
);
|
|
|
251 |
add_filter(
|
252 |
-
'plugin_action_links_' .CACHIFY_BASE,
|
253 |
array(
|
254 |
__CLASS__,
|
255 |
-
'action_links'
|
256 |
)
|
257 |
);
|
258 |
|
259 |
-
|
260 |
} else {
|
261 |
add_action(
|
262 |
'template_redirect',
|
263 |
array(
|
264 |
__CLASS__,
|
265 |
-
'manage_cache'
|
266 |
),
|
267 |
0
|
268 |
);
|
|
|
269 |
add_action(
|
270 |
'robots_txt',
|
271 |
array(
|
272 |
__CLASS__,
|
273 |
-
'robots_txt'
|
274 |
)
|
275 |
);
|
276 |
-
}
|
277 |
}
|
278 |
|
279 |
-
|
280 |
/**
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
{
|
289 |
-
self::flush_total_cache(true);
|
290 |
}
|
291 |
|
292 |
-
|
293 |
/**
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
public static function on_activation()
|
301 |
-
{
|
302 |
/* Multisite & Network */
|
303 |
-
if ( is_multisite() && ! empty($_GET['networkwide']) ) {
|
304 |
-
/* Blog
|
305 |
$ids = self::_get_blog_ids();
|
306 |
|
307 |
-
/*
|
308 |
-
foreach ($ids as $id) {
|
309 |
-
switch_to_blog($id);
|
310 |
self::_install_backend();
|
311 |
}
|
312 |
|
313 |
-
/*
|
314 |
restore_current_blog();
|
315 |
|
316 |
} else {
|
@@ -318,189 +292,169 @@ final class Cachify {
|
|
318 |
}
|
319 |
}
|
320 |
|
321 |
-
|
322 |
/**
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
{
|
331 |
-
/*
|
332 |
-
if ( ! is_plugin_active_for_network(CACHIFY_BASE) ) {
|
333 |
return;
|
334 |
}
|
335 |
|
336 |
-
/*
|
337 |
-
switch_to_blog($id);
|
338 |
|
339 |
-
/*
|
340 |
self::_install_backend();
|
341 |
|
342 |
-
/*
|
343 |
restore_current_blog();
|
344 |
}
|
345 |
|
346 |
-
|
347 |
/**
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
private static function _install_backend()
|
355 |
-
{
|
356 |
add_option(
|
357 |
'cachify',
|
358 |
array()
|
359 |
);
|
360 |
|
361 |
/* Flush */
|
362 |
-
self::flush_total_cache(true);
|
363 |
}
|
364 |
|
365 |
-
|
366 |
/**
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
public static function on_uninstall()
|
374 |
-
{
|
375 |
/* Global */
|
376 |
global $wpdb;
|
377 |
|
378 |
/* Multisite & Network */
|
379 |
-
if ( is_multisite() && ! empty($_GET['networkwide']) ) {
|
380 |
/* Alter Blog */
|
381 |
$old = $wpdb->blogid;
|
382 |
|
383 |
-
/* Blog
|
384 |
$ids = self::_get_blog_ids();
|
385 |
|
386 |
-
/*
|
387 |
-
foreach ($ids as $id) {
|
388 |
-
switch_to_blog($id);
|
389 |
self::_uninstall_backend();
|
390 |
}
|
391 |
|
392 |
-
/*
|
393 |
-
switch_to_blog($old);
|
394 |
} else {
|
395 |
self::_uninstall_backend();
|
396 |
}
|
397 |
}
|
398 |
|
399 |
-
|
400 |
/**
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
{
|
409 |
-
/*
|
410 |
-
if ( ! is_plugin_active_for_network(CACHIFY_BASE) ) {
|
411 |
return;
|
412 |
}
|
413 |
|
414 |
-
/*
|
415 |
-
switch_to_blog($id);
|
416 |
|
417 |
-
/*
|
418 |
self::_uninstall_backend();
|
419 |
|
420 |
-
/*
|
421 |
restore_current_blog();
|
422 |
}
|
423 |
|
424 |
-
|
425 |
/**
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
private static function _uninstall_backend()
|
433 |
-
{
|
434 |
/* Option */
|
435 |
-
delete_option('cachify');
|
436 |
|
437 |
-
/*
|
438 |
-
self::flush_total_cache(true);
|
439 |
}
|
440 |
|
441 |
-
|
442 |
/**
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
private static function _get_blog_ids()
|
452 |
-
{
|
453 |
/* Global */
|
454 |
global $wpdb;
|
455 |
|
456 |
-
return $wpdb->get_col("SELECT blog_id FROM `$wpdb->blogs`");
|
457 |
}
|
458 |
|
459 |
-
|
460 |
/**
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
{
|
469 |
-
/* Optionen */
|
470 |
self::$options = self::_get_options();
|
471 |
|
472 |
/* APC */
|
473 |
-
if ( self::$options['use_apc']
|
474 |
self::$method = new Cachify_APC;
|
475 |
|
476 |
-
|
477 |
-
}
|
478 |
self::$method = new Cachify_HDD;
|
479 |
|
480 |
-
|
481 |
-
}
|
482 |
self::$method = new Cachify_MEMCACHED;
|
483 |
|
484 |
-
|
485 |
} else {
|
486 |
self::$method = new Cachify_DB;
|
487 |
}
|
488 |
}
|
489 |
|
490 |
-
|
491 |
/**
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
private static function _get_options()
|
501 |
-
{
|
502 |
return wp_parse_args(
|
503 |
-
get_option('cachify'),
|
504 |
array(
|
505 |
'only_guests' => 1,
|
506 |
'compress_html' => self::MINIFY_DISABLED,
|
@@ -508,57 +462,53 @@ final class Cachify {
|
|
508 |
'without_ids' => '',
|
509 |
'without_agents' => '',
|
510 |
'use_apc' => self::METHOD_DB,
|
511 |
-
'
|
|
|
|
|
512 |
)
|
513 |
);
|
514 |
}
|
515 |
|
516 |
-
|
517 |
/**
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
public static function robots_txt($data)
|
528 |
-
{
|
529 |
/* HDD only */
|
530 |
-
if ( self::$options['use_apc']
|
531 |
return $data;
|
532 |
}
|
533 |
|
534 |
-
/*
|
535 |
-
$
|
536 |
|
537 |
-
/*
|
538 |
$data .= sprintf(
|
539 |
'%2$sDisallow: %1$s/wp-content/cache/cachify/%2$s',
|
540 |
-
( empty($path) ? '' : $path ),
|
541 |
PHP_EOL
|
542 |
);
|
543 |
|
544 |
return $data;
|
545 |
}
|
546 |
|
547 |
-
|
548 |
/**
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
/* Rechte? */
|
561 |
-
if ( ! current_user_can('manage_options') ) {
|
562 |
return $data;
|
563 |
}
|
564 |
|
@@ -569,60 +519,55 @@ final class Cachify {
|
|
569 |
'<a href="%s">%s</a>',
|
570 |
add_query_arg(
|
571 |
array(
|
572 |
-
'page' => 'cachify'
|
573 |
),
|
574 |
-
admin_url('options-general.php')
|
575 |
),
|
576 |
-
|
577 |
)
|
578 |
)
|
579 |
);
|
580 |
}
|
581 |
|
582 |
-
|
583 |
/**
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
/* Rechte */
|
597 |
-
if ( $page != CACHIFY_BASE ) {
|
598 |
return $input;
|
599 |
}
|
600 |
|
601 |
return array_merge(
|
602 |
$input,
|
603 |
array(
|
604 |
-
'<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=
|
|
|
605 |
)
|
606 |
);
|
607 |
}
|
608 |
|
609 |
-
|
610 |
/**
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
public static function add_dashboard_count( $items = array() )
|
621 |
-
{
|
622 |
/* Skip */
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
|
627 |
/* Cache size */
|
628 |
$size = self::get_cache_size();
|
@@ -631,171 +576,181 @@ final class Cachify {
|
|
631 |
$method = call_user_func(
|
632 |
array(
|
633 |
self::$method,
|
634 |
-
'
|
635 |
)
|
636 |
);
|
637 |
|
|
|
|
|
|
|
|
|
|
|
|
|
638 |
/* Right now item */
|
639 |
$items[] = sprintf(
|
640 |
-
'<a href="%s"
|
|
|
|
|
|
|
641 |
add_query_arg(
|
642 |
array(
|
643 |
-
'page' => 'cachify'
|
644 |
),
|
645 |
-
admin_url('options-general.php')
|
646 |
),
|
647 |
-
esc_attr(strtolower($method)),
|
648 |
-
esc_html__('Caching method', 'cachify'),
|
649 |
-
esc_attr($method),
|
650 |
-
(
|
|
|
|
|
|
|
|
|
651 |
);
|
652 |
|
653 |
return $items;
|
654 |
}
|
655 |
|
656 |
-
|
657 |
/**
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
if ( ! $size = get_transient('cachify_cache_size') ) {
|
669 |
-
/* Auslesen */
|
670 |
$size = (int) call_user_func(
|
671 |
array(
|
672 |
self::$method,
|
673 |
-
'get_stats'
|
674 |
)
|
675 |
);
|
676 |
|
677 |
-
/*
|
678 |
set_transient(
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
);
|
683 |
}
|
684 |
|
685 |
return $size;
|
686 |
}
|
687 |
|
688 |
-
|
689 |
/**
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
/* Aussteigen */
|
703 |
-
if ( ! is_admin_bar_showing() OR ! apply_filters('cachify_user_can_flush_cache', current_user_can('manage_options')) ) {
|
704 |
return;
|
705 |
}
|
706 |
|
707 |
/* Display the admin icon anytime */
|
708 |
-
echo '<style>#wp-admin-bar-cachify{display:list-item !important} #wp-admin-bar-cachify .ab-icon{margin:0 !important} #wp-admin-bar-cachify .ab-icon:before{content:"\f182";top:2px;margin:0}</style>';
|
709 |
|
710 |
-
/*
|
711 |
$wp_admin_bar->add_menu(
|
712 |
array(
|
713 |
'id' => 'cachify',
|
714 |
-
'href' => wp_nonce_url( add_query_arg('_cachify', 'flush'), '_cachify__flush_nonce'), // esc_url in /wp-includes/class-wp-admin-bar.php#L438
|
715 |
'parent' => 'top-secondary',
|
716 |
-
'title' => '<span class="ab-icon dashicons"></span>'
|
717 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
718 |
)
|
719 |
);
|
720 |
}
|
721 |
|
722 |
-
|
723 |
/**
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
public static function process_flush_request($data)
|
735 |
-
{
|
736 |
/* Skip if not a flush request */
|
737 |
-
if ( empty($_GET['_cachify'])
|
738 |
return;
|
739 |
}
|
740 |
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
|
746 |
/* Skip if not necessary */
|
747 |
-
if ( ! is_admin_bar_showing()
|
748 |
return;
|
749 |
}
|
750 |
|
751 |
/* Load on demand */
|
752 |
-
if ( ! function_exists('is_plugin_active_for_network') ) {
|
753 |
-
require_once( ABSPATH. 'wp-admin/includes/plugin.php' );
|
754 |
}
|
755 |
|
756 |
-
/*
|
757 |
-
if ( is_multisite() &&
|
758 |
-
/*
|
759 |
$old = $GLOBALS['wpdb']->blogid;
|
760 |
|
761 |
-
/* Blog
|
762 |
$ids = self::_get_blog_ids();
|
763 |
|
764 |
-
/*
|
765 |
-
foreach ($ids as $id) {
|
766 |
-
switch_to_blog($id);
|
767 |
self::flush_total_cache();
|
768 |
}
|
769 |
|
770 |
-
/*
|
771 |
-
switch_to_blog($old);
|
772 |
|
773 |
-
/*
|
774 |
if ( is_admin() ) {
|
775 |
add_action(
|
776 |
'network_admin_notices',
|
777 |
array(
|
778 |
__CLASS__,
|
779 |
-
'flush_notice'
|
780 |
)
|
781 |
);
|
782 |
}
|
783 |
} else {
|
784 |
-
/* Leeren */
|
785 |
self::flush_total_cache();
|
786 |
|
787 |
-
/*
|
788 |
if ( is_admin() ) {
|
789 |
add_action(
|
790 |
'admin_notices',
|
791 |
array(
|
792 |
__CLASS__,
|
793 |
-
'flush_notice'
|
794 |
)
|
795 |
);
|
796 |
}
|
797 |
}
|
798 |
-
|
799 |
if ( ! is_admin() ) {
|
800 |
wp_safe_redirect(
|
801 |
remove_query_arg(
|
@@ -808,66 +763,57 @@ final class Cachify {
|
|
808 |
}
|
809 |
}
|
810 |
|
811 |
-
|
812 |
/**
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
/* Kein Admin */
|
824 |
-
if ( ! is_admin_bar_showing() OR ! apply_filters('cachify_user_can_flush_cache', current_user_can('manage_options')) ) {
|
825 |
return false;
|
826 |
}
|
827 |
|
828 |
echo sprintf(
|
829 |
'<div class="notice notice-success is-dismissible"><p>%s</p></div>',
|
830 |
-
esc_html__('Cachify cache is flushed.', 'cachify')
|
831 |
);
|
832 |
}
|
833 |
|
834 |
-
|
835 |
/**
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
public static function edit_comment($id)
|
845 |
-
{
|
846 |
if ( self::$options['reset_on_comment'] ) {
|
847 |
self::flush_total_cache();
|
848 |
} else {
|
849 |
self::remove_page_cache_by_post_id(
|
850 |
-
get_comment($id)->comment_post_ID
|
851 |
);
|
852 |
}
|
853 |
}
|
854 |
|
855 |
-
|
856 |
/**
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
public static function pre_comment($approved, $comment)
|
868 |
-
{
|
869 |
/* Approved comment? */
|
870 |
-
if (
|
871 |
if ( self::$options['reset_on_comment'] ) {
|
872 |
self::flush_total_cache();
|
873 |
} else {
|
@@ -878,21 +824,18 @@ final class Cachify {
|
|
878 |
return $approved;
|
879 |
}
|
880 |
|
881 |
-
|
882 |
/**
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
{
|
895 |
-
if ( $new_status != $old_status ) {
|
896 |
if ( self::$options['reset_on_comment'] ) {
|
897 |
self::flush_total_cache();
|
898 |
} else {
|
@@ -901,89 +844,76 @@ final class Cachify {
|
|
901 |
}
|
902 |
}
|
903 |
|
904 |
-
|
905 |
/**
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
public static function register_publish_hooks()
|
916 |
-
{
|
917 |
/* Available post types */
|
918 |
$post_types = get_post_types(
|
919 |
-
array(
|
|
|
|
|
920 |
);
|
921 |
|
922 |
/* Empty data? */
|
923 |
-
if ( empty($post_types) ) {
|
924 |
return;
|
925 |
}
|
926 |
|
927 |
/* Loop the post types */
|
928 |
foreach ( $post_types as $post_type ) {
|
929 |
add_action(
|
930 |
-
'publish_'
|
931 |
array(
|
932 |
__CLASS__,
|
933 |
-
'publish_post_types'
|
934 |
),
|
935 |
10,
|
936 |
2
|
937 |
);
|
938 |
add_action(
|
939 |
-
'publish_future_'
|
940 |
array(
|
941 |
__CLASS__,
|
942 |
-
'flush_total_cache'
|
943 |
)
|
944 |
);
|
945 |
}
|
946 |
}
|
947 |
|
948 |
-
|
949 |
/**
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
public static function publish_post_types($
|
959 |
-
|
960 |
-
|
961 |
-
if ( empty($post_ID) OR empty($post) ) {
|
962 |
return;
|
963 |
}
|
964 |
|
965 |
/* Post status check */
|
966 |
-
if ( ! in_array( $post->post_status, array('publish', 'future') ) ) {
|
967 |
-
return;
|
968 |
-
}
|
969 |
-
|
970 |
-
/* Check for post var AND flush */
|
971 |
-
if ( ! isset($_POST['_cachify_remove_post_type_cache_on_update']) ) {
|
972 |
-
return self::flush_total_cache();
|
973 |
-
}
|
974 |
-
|
975 |
-
/* Check nonce */
|
976 |
-
if ( ! isset($_POST['_cachify__status_nonce_' .$post_ID]) OR ! wp_verify_nonce($_POST['_cachify__status_nonce_' .$post_ID], CACHIFY_BASE) ) {
|
977 |
return;
|
978 |
}
|
979 |
|
980 |
/* Check user role */
|
981 |
-
if ( ! current_user_can('publish_posts') ) {
|
982 |
return;
|
983 |
}
|
984 |
|
985 |
/* Save as var */
|
986 |
-
$remove_post_type_cache = (int)$_POST['_cachify_remove_post_type_cache_on_update'];
|
987 |
|
988 |
/* Save as user meta */
|
989 |
update_user_meta(
|
@@ -993,212 +923,248 @@ final class Cachify {
|
|
993 |
);
|
994 |
|
995 |
/* Remove cache OR flush */
|
996 |
-
if (
|
997 |
-
self::remove_page_cache_by_post_id( $
|
998 |
} else {
|
999 |
self::flush_total_cache();
|
1000 |
}
|
1001 |
}
|
1002 |
|
1003 |
-
|
1004 |
/**
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
public static function remove_page_cache_by_post_id($post_ID)
|
1014 |
-
{
|
1015 |
/* Value check */
|
1016 |
-
if ( ! $
|
1017 |
return;
|
1018 |
}
|
1019 |
|
1020 |
/* Remove page by url */
|
1021 |
self::remove_page_cache_by_url(
|
1022 |
-
get_permalink( $
|
1023 |
);
|
1024 |
}
|
1025 |
|
1026 |
-
|
1027 |
/**
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
public static function remove_page_cache_by_url($url)
|
1037 |
-
{
|
1038 |
/* Value check */
|
1039 |
-
if ( ! $url = (string)$url ) {
|
1040 |
return;
|
1041 |
}
|
1042 |
|
1043 |
call_user_func(
|
1044 |
array(
|
1045 |
self::$method,
|
1046 |
-
'delete_item'
|
1047 |
),
|
1048 |
self::_cache_hash( $url ),
|
1049 |
$url
|
1050 |
);
|
1051 |
}
|
1052 |
|
1053 |
-
|
1054 |
/**
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
private static function _cache_expires()
|
1064 |
-
{
|
1065 |
return HOUR_IN_SECONDS * self::$options['cache_expires'];
|
1066 |
}
|
1067 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1068 |
|
1069 |
/**
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
private static function _cache_hash($url = '')
|
1080 |
-
{
|
1081 |
$prefix = is_ssl() ? 'https-' : '';
|
|
|
1082 |
return md5(
|
1083 |
-
empty($url) ? ( $prefix . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) : ( $prefix .
|
1084 |
) . '.cachify';
|
1085 |
}
|
1086 |
|
1087 |
-
|
1088 |
/**
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
{
|
1100 |
-
return (array)preg_split('/,/', $input, -1, PREG_SPLIT_NO_EMPTY);
|
1101 |
}
|
1102 |
|
1103 |
-
|
1104 |
/**
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
{
|
1115 |
-
return basename($_SERVER['SCRIPT_NAME']) != 'index.php';
|
1116 |
}
|
1117 |
|
1118 |
-
|
1119 |
/**
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
return ( strpos(TEMPLATEPATH, 'wptouch') OR strpos(TEMPLATEPATH, 'carrington') OR strpos(TEMPLATEPATH, 'jetpack') OR strpos(TEMPLATEPATH, 'handheld') );
|
1131 |
}
|
1132 |
|
1133 |
-
|
1134 |
/**
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
{
|
1145 |
-
/* Eingeloggt */
|
1146 |
if ( is_user_logged_in() ) {
|
1147 |
return true;
|
1148 |
}
|
1149 |
|
1150 |
/* Cookie? */
|
1151 |
-
if ( empty($_COOKIE) ) {
|
1152 |
return false;
|
1153 |
}
|
1154 |
|
1155 |
-
/*
|
1156 |
-
foreach ( $_COOKIE as $k => $v) {
|
1157 |
-
if ( preg_match('/^(wp-postpass|wordpress_logged_in|comment_author)_/', $k) ) {
|
1158 |
return true;
|
1159 |
}
|
1160 |
}
|
|
|
|
|
1161 |
}
|
1162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1163 |
|
1164 |
/**
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
|
|
|
|
1179 |
return true;
|
1180 |
}
|
1181 |
|
1182 |
-
/*
|
1183 |
-
if ( self::_is_index()
|
1184 |
return true;
|
1185 |
}
|
1186 |
|
1187 |
-
/*
|
1188 |
-
if (
|
1189 |
return true;
|
1190 |
}
|
1191 |
|
1192 |
-
/*
|
1193 |
-
|
|
|
|
|
1194 |
|
1195 |
-
/*
|
1196 |
-
if (
|
1197 |
return true;
|
1198 |
}
|
1199 |
|
1200 |
-
/*
|
1201 |
-
if (
|
1202 |
return true;
|
1203 |
}
|
1204 |
|
@@ -1209,57 +1175,58 @@ final class Cachify {
|
|
1209 |
|
1210 |
/* Post IDs */
|
1211 |
if ( $options['without_ids'] && is_singular() ) {
|
1212 |
-
|
|
|
1213 |
return true;
|
1214 |
}
|
1215 |
}
|
1216 |
|
1217 |
/* User Agents */
|
1218 |
-
if ( $options['without_agents'] && isset($_SERVER['HTTP_USER_AGENT']) ) {
|
1219 |
-
|
1220 |
-
|
|
|
|
|
|
|
1221 |
}
|
1222 |
}
|
1223 |
|
1224 |
return false;
|
1225 |
}
|
1226 |
|
1227 |
-
|
1228 |
/**
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
private static function _minify_cache($data)
|
1241 |
-
{
|
1242 |
/* Disabled? */
|
1243 |
if ( ! self::$options['compress_html'] ) {
|
1244 |
return $data;
|
1245 |
}
|
1246 |
|
1247 |
/* Avoid slow rendering */
|
1248 |
-
if ( strlen($data) > 700000) {
|
1249 |
return $data;
|
1250 |
}
|
1251 |
|
1252 |
/* Ignore this html tags */
|
1253 |
-
$ignore_tags = (array)apply_filters(
|
1254 |
'cachify_minify_ignore_tags',
|
1255 |
array(
|
1256 |
'textarea',
|
1257 |
-
'pre'
|
1258 |
)
|
1259 |
);
|
1260 |
|
1261 |
/* Add the script tag */
|
1262 |
-
if ( self::$options['compress_html']
|
1263 |
$ignore_tags[] = 'script';
|
1264 |
}
|
1265 |
|
@@ -1269,39 +1236,38 @@ final class Cachify {
|
|
1269 |
}
|
1270 |
|
1271 |
/* Convert to string */
|
1272 |
-
$ignore_regex = implode('|', $ignore_tags);
|
1273 |
|
1274 |
/* Minify */
|
1275 |
$cleaned = preg_replace(
|
1276 |
array(
|
1277 |
'/<!--[^\[><](.*?)-->/s',
|
1278 |
-
'#(?ix)(?>[^\S ]\s*|\s{2,})(?=(?:(?:[^<]++|<(?!/?(?:'
|
1279 |
),
|
1280 |
array(
|
1281 |
'',
|
1282 |
-
' '
|
1283 |
),
|
1284 |
$data
|
1285 |
);
|
1286 |
|
1287 |
/* Fault */
|
1288 |
-
if ( strlen($cleaned) <= 1 ) {
|
1289 |
return $data;
|
1290 |
}
|
1291 |
|
1292 |
return $cleaned;
|
1293 |
}
|
1294 |
|
1295 |
-
|
1296 |
/**
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
{
|
1305 |
if ( $clear_all_methods ) {
|
1306 |
/* DB */
|
1307 |
Cachify_DB::clear_cache();
|
@@ -1318,219 +1284,170 @@ final class Cachify {
|
|
1318 |
call_user_func(
|
1319 |
array(
|
1320 |
self::$method,
|
1321 |
-
'clear_cache'
|
1322 |
)
|
1323 |
);
|
1324 |
}
|
1325 |
|
1326 |
/* Transient */
|
1327 |
-
delete_transient('cachify_cache_size');
|
1328 |
}
|
1329 |
|
1330 |
-
|
1331 |
/**
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
/* Leer? */
|
1344 |
-
if ( empty($data) ) {
|
1345 |
return '';
|
1346 |
}
|
1347 |
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1358 |
|
1359 |
return $data;
|
1360 |
}
|
1361 |
|
1362 |
-
|
1363 |
/**
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
{
|
1372 |
-
/* Kein Caching? */
|
1373 |
if ( self::_skip_cache() ) {
|
1374 |
return;
|
1375 |
}
|
1376 |
|
1377 |
-
/*
|
1378 |
$cache = call_user_func(
|
1379 |
array(
|
1380 |
self::$method,
|
1381 |
-
'get_item'
|
1382 |
),
|
1383 |
self::_cache_hash()
|
1384 |
);
|
1385 |
|
1386 |
-
/*
|
1387 |
-
if ( empty($cache) ) {
|
1388 |
-
ob_start('Cachify::set_cache');
|
1389 |
return;
|
1390 |
}
|
1391 |
|
1392 |
-
/*
|
1393 |
call_user_func(
|
1394 |
array(
|
1395 |
self::$method,
|
1396 |
-
'print_cache'
|
1397 |
),
|
|
|
1398 |
$cache
|
1399 |
);
|
1400 |
}
|
1401 |
|
1402 |
-
|
1403 |
/**
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
{
|
1412 |
/* Hooks check */
|
1413 |
-
if (
|
1414 |
return;
|
1415 |
}
|
1416 |
|
1417 |
/* Plugin data */
|
1418 |
-
$plugin_data = get_plugin_data(CACHIFY_FILE);
|
1419 |
|
1420 |
/* Register css */
|
1421 |
-
switch($hook) {
|
1422 |
case 'index.php':
|
1423 |
wp_enqueue_style(
|
1424 |
'cachify-dashboard',
|
1425 |
-
plugins_url('css/dashboard.min.css', CACHIFY_FILE),
|
1426 |
array(),
|
1427 |
$plugin_data['Version']
|
1428 |
);
|
1429 |
break;
|
1430 |
|
1431 |
-
case '
|
1432 |
-
|
1433 |
-
'cachify-
|
1434 |
-
plugins_url('
|
1435 |
-
array(
|
1436 |
-
$plugin_data['Version']
|
1437 |
-
true
|
1438 |
);
|
1439 |
break;
|
1440 |
|
1441 |
default:
|
1442 |
break;
|
1443 |
}
|
1444 |
-
}
|
1445 |
|
|
|
1446 |
|
1447 |
/**
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
if ( empty($GLOBALS['pagenow']) OR $GLOBALS['pagenow'] !== 'post.php' ) {
|
1458 |
-
return;
|
1459 |
-
}
|
1460 |
-
|
1461 |
-
/* Published posts only */
|
1462 |
-
if ( empty($GLOBALS['post']) OR ! is_object($GLOBALS['post']) OR $GLOBALS['post']->post_status !== 'publish' ) {
|
1463 |
-
return;
|
1464 |
}
|
1465 |
-
|
1466 |
-
/* Check user role */
|
1467 |
-
if ( ! current_user_can('publish_posts') ) {
|
1468 |
-
return;
|
1469 |
-
}
|
1470 |
-
|
1471 |
-
/* Security */
|
1472 |
-
wp_nonce_field(CACHIFY_BASE, '_cachify__status_nonce_' .$GLOBALS['post']->ID);
|
1473 |
-
|
1474 |
-
/* Already saved? */
|
1475 |
-
$current_action = (int)get_user_meta(
|
1476 |
-
get_current_user_id(),
|
1477 |
-
'_cachify_remove_post_type_cache_on_update',
|
1478 |
-
true
|
1479 |
-
);
|
1480 |
-
|
1481 |
-
/* Init vars */
|
1482 |
-
$dropdown_options = '';
|
1483 |
-
$available_options = array(
|
1484 |
-
esc_html__('Total cache', 'cachify'),
|
1485 |
-
esc_html__('Page cache', 'cachify')
|
1486 |
-
);
|
1487 |
-
|
1488 |
-
/* Select options */
|
1489 |
-
foreach( $available_options as $key => $value ) {
|
1490 |
-
$dropdown_options .= sprintf(
|
1491 |
-
'<option value="%1$d" %3$s>%2$s</option>',
|
1492 |
-
$key,
|
1493 |
-
$value,
|
1494 |
-
selected($key, $current_action, false)
|
1495 |
-
);
|
1496 |
-
}
|
1497 |
-
|
1498 |
-
/* Output */
|
1499 |
-
echo sprintf(
|
1500 |
-
'<div class="misc-pub-section" style="border-top:1px solid #eee">
|
1501 |
-
<label for="cachify_status">
|
1502 |
-
%1$s: <span id="output-cachify-status">%2$s</span>
|
1503 |
-
</label>
|
1504 |
-
<a href="#" class="edit-cachify-status hide-if-no-js">%3$s</a>
|
1505 |
-
|
1506 |
-
<div class="hide-if-js">
|
1507 |
-
<select name="_cachify_remove_post_type_cache_on_update" id="cachify_status">
|
1508 |
-
%4$s
|
1509 |
-
</select>
|
1510 |
-
|
1511 |
-
<a href="#" class="save-cachify-status hide-if-no-js button">%5$s</a>
|
1512 |
-
<a href="#" class="cancel-cachify-status hide-if-no-js button-cancel">%6$s</a>
|
1513 |
-
</div>
|
1514 |
-
</div>',
|
1515 |
-
esc_html__( 'Remove', 'cachify' ),
|
1516 |
-
$available_options[$current_action],
|
1517 |
-
esc_html__( 'Edit', 'cachify' ),
|
1518 |
-
$dropdown_options,
|
1519 |
-
esc_html__( 'OK', 'cachify' ),
|
1520 |
-
esc_html__( 'Cancel', 'cachify' )
|
1521 |
-
);
|
1522 |
}
|
1523 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1524 |
|
1525 |
/**
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
public static function add_page()
|
1533 |
-
{
|
1534 |
add_options_page(
|
1535 |
__( 'Cachify', 'cachify' ),
|
1536 |
__( 'Cachify', 'cachify' ),
|
@@ -1538,78 +1455,70 @@ final class Cachify {
|
|
1538 |
'cachify',
|
1539 |
array(
|
1540 |
__CLASS__,
|
1541 |
-
'options_page'
|
1542 |
)
|
1543 |
);
|
1544 |
}
|
1545 |
|
1546 |
-
|
1547 |
/**
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
private static function _method_select()
|
1557 |
-
{
|
1558 |
/* Defaults */
|
1559 |
$methods = array(
|
1560 |
-
self::METHOD_DB => esc_html__('Database', 'cachify'),
|
1561 |
-
self::METHOD_APC => 'APC',
|
1562 |
-
self::METHOD_HDD => esc_html__('Hard disk', 'cachify'),
|
1563 |
-
self::METHOD_MMC => 'Memcached'
|
1564 |
);
|
1565 |
|
1566 |
/* APC */
|
1567 |
if ( ! Cachify_APC::is_available() ) {
|
1568 |
-
unset($methods[1]);
|
1569 |
}
|
1570 |
|
1571 |
/* Memcached? */
|
1572 |
if ( ! Cachify_MEMCACHED::is_available() ) {
|
1573 |
-
unset($methods[3]);
|
1574 |
}
|
1575 |
|
1576 |
/* HDD */
|
1577 |
if ( ! Cachify_HDD::is_available() ) {
|
1578 |
-
unset($methods[2]);
|
1579 |
}
|
1580 |
|
1581 |
return $methods;
|
1582 |
}
|
1583 |
|
1584 |
-
|
1585 |
/**
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
private static function _minify_select()
|
1595 |
-
{
|
1596 |
return array(
|
1597 |
-
self::MINIFY_DISABLED => esc_html__('No minify', 'cachify'),
|
1598 |
-
self::MINIFY_HTML_ONLY => 'HTML',
|
1599 |
-
self::MINIFY_HTML_JS => 'HTML + Inline JavaScript'
|
1600 |
);
|
1601 |
}
|
1602 |
|
1603 |
-
|
1604 |
/**
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
public static function register_textdomain()
|
1612 |
-
{
|
1613 |
load_plugin_textdomain(
|
1614 |
'cachify',
|
1615 |
false,
|
@@ -1618,194 +1527,144 @@ final class Cachify {
|
|
1618 |
}
|
1619 |
|
1620 |
/**
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
public static function register_settings()
|
1628 |
-
{
|
1629 |
register_setting(
|
1630 |
'cachify',
|
1631 |
'cachify',
|
1632 |
array(
|
1633 |
__CLASS__,
|
1634 |
-
'validate_options'
|
1635 |
)
|
1636 |
);
|
1637 |
}
|
1638 |
|
1639 |
-
|
1640 |
/**
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
public static function validate_options($data)
|
1651 |
-
{
|
1652 |
/* Empty data? */
|
1653 |
-
if ( empty($data) ) {
|
1654 |
return;
|
1655 |
}
|
1656 |
|
1657 |
-
/*
|
1658 |
-
self::flush_total_cache(true);
|
1659 |
|
1660 |
-
/*
|
1661 |
-
if ( self::$options['use_apc']
|
1662 |
add_settings_error(
|
1663 |
'cachify_method_tip',
|
1664 |
'cachify_method_tip',
|
1665 |
-
|
1666 |
-
|
1667 |
-
esc_html__('The server configuration file (e.g. .htaccess) needs to be adjusted', 'cachify')
|
1668 |
-
),
|
1669 |
-
'updated'
|
1670 |
);
|
1671 |
}
|
1672 |
|
1673 |
-
/*
|
1674 |
return array(
|
1675 |
-
'only_guests'
|
1676 |
-
'compress_html'
|
1677 |
-
'cache_expires'
|
1678 |
-
'without_ids'
|
1679 |
-
'without_agents'
|
1680 |
-
'use_apc'
|
1681 |
-
'
|
|
|
|
|
1682 |
);
|
1683 |
}
|
1684 |
|
1685 |
-
|
1686 |
/**
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
#cachify_settings input[type="number"] {
|
1698 |
-
height: 30px;
|
1699 |
-
}
|
1700 |
-
</style>
|
1701 |
|
1702 |
<div class="wrap" id="cachify_settings">
|
1703 |
-
<
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
<th scope="row">
|
1730 |
-
<?php esc_html_e('Cache expiration', 'cachify') ?>
|
1731 |
-
</th>
|
1732 |
-
<td>
|
1733 |
-
<label for="cachify_cache_expires">
|
1734 |
-
<input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="<?php echo esc_attr($options['cache_expires']) ?>" class="small-text" />
|
1735 |
-
<?php esc_html_e('Hours', 'cachify') ?>
|
1736 |
-
</label>
|
1737 |
-
</td>
|
1738 |
-
</tr>
|
1739 |
-
|
1740 |
-
<tr valign="top">
|
1741 |
-
<th scope="row">
|
1742 |
-
<?php esc_html_e('Cache generation', 'cachify') ?>
|
1743 |
-
</th>
|
1744 |
-
<td>
|
1745 |
-
<fieldset>
|
1746 |
-
<label for="cachify_only_guests">
|
1747 |
-
<input type="checkbox" name="cachify[only_guests]" id="cachify_only_guests" value="1" <?php checked('1', $options['only_guests']); ?> />
|
1748 |
-
<?php esc_html_e('No cache generation by logged in users', 'cachify') ?>
|
1749 |
-
</label>
|
1750 |
-
|
1751 |
-
<br />
|
1752 |
-
|
1753 |
-
<label for="cachify_reset_on_comment">
|
1754 |
-
<input type="checkbox" name="cachify[reset_on_comment]" id="cachify_reset_on_comment" value="1" <?php checked('1', $options['reset_on_comment']); ?> />
|
1755 |
-
<?php esc_html_e('Flush the cache at new comments', 'cachify') ?>
|
1756 |
-
</label>
|
1757 |
-
</fieldset>
|
1758 |
-
</td>
|
1759 |
-
</tr>
|
1760 |
-
|
1761 |
-
<tr valign="top">
|
1762 |
-
<th scope="row">
|
1763 |
-
<?php esc_html_e('Cache exceptions', 'cachify') ?>
|
1764 |
-
</th>
|
1765 |
-
<td>
|
1766 |
-
<fieldset>
|
1767 |
-
<label for="cachify_without_ids">
|
1768 |
-
<input type="text" name="cachify[without_ids]" id="cachify_without_ids" value="<?php echo esc_attr($options['without_ids']) ?>" />
|
1769 |
-
Post/Pages-IDs
|
1770 |
-
</label>
|
1771 |
-
|
1772 |
-
<br />
|
1773 |
-
|
1774 |
-
<label for="cachify_without_agents">
|
1775 |
-
<input type="text" name="cachify[without_agents]" id="cachify_without_agents" value="<?php echo esc_attr($options['without_agents']) ?>" />
|
1776 |
-
Browser User-Agents
|
1777 |
-
</label>
|
1778 |
-
</fieldset>
|
1779 |
-
</td>
|
1780 |
-
</tr>
|
1781 |
-
|
1782 |
-
<tr valign="top">
|
1783 |
-
<th scope="row">
|
1784 |
-
<?php esc_html_e('Cache minify', 'cachify') ?>
|
1785 |
-
</th>
|
1786 |
-
<td>
|
1787 |
-
<label for="cachify_compress_html">
|
1788 |
-
<select name="cachify[compress_html]" id="cachify_compress_html">
|
1789 |
-
<?php foreach( self::_minify_select() as $k => $v ) { ?>
|
1790 |
-
<option value="<?php echo esc_attr($k) ?>" <?php selected($options['compress_html'], $k); ?>>
|
1791 |
-
<?php echo esc_html($v) ?>
|
1792 |
-
</option>
|
1793 |
-
<?php } ?>
|
1794 |
-
</select>
|
1795 |
-
</label>
|
1796 |
-
</td>
|
1797 |
-
</tr>
|
1798 |
-
|
1799 |
-
<tr valign="top">
|
1800 |
-
<th scope="row">
|
1801 |
-
<?php submit_button() ?>
|
1802 |
-
</th>
|
1803 |
-
<td>
|
1804 |
-
<a href="https://github.com/pluginkollektiv/cachify/wiki" target="_blank"><?php esc_html_e('Manual', 'cachify') ?></a> • <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ" target="_blank">PayPal</a>
|
1805 |
-
</td>
|
1806 |
-
</tr>
|
1807 |
-
</table>
|
1808 |
-
</form>
|
1809 |
</div><?php
|
1810 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1811 |
}
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
/**
|
4 |
* Cachify
|
5 |
*/
|
|
|
6 |
final class Cachify {
|
7 |
|
|
|
8 |
/**
|
9 |
+
* Plugin options
|
10 |
+
*
|
11 |
+
* @since 2.0
|
12 |
+
* @var array
|
13 |
+
*/
|
|
|
14 |
private static $options;
|
15 |
|
|
|
16 |
/**
|
17 |
+
* Caching method
|
18 |
+
*
|
19 |
+
* @since 2.0
|
20 |
+
* @var object
|
21 |
+
*/
|
|
|
22 |
private static $method;
|
23 |
|
|
|
24 |
/**
|
25 |
+
* Whether we are on an Nginx server or not.
|
26 |
+
*
|
27 |
+
* @since 2.2.5
|
28 |
+
* @var boolean
|
29 |
+
*/
|
30 |
+
private static $is_nginx;
|
31 |
|
32 |
+
/**
|
33 |
+
* Method settings
|
34 |
+
*
|
35 |
+
* @since 2.0.9
|
36 |
+
* @var integer
|
37 |
+
*/
|
38 |
const METHOD_DB = 0;
|
39 |
const METHOD_APC = 1;
|
40 |
const METHOD_HDD = 2;
|
41 |
const METHOD_MMC = 3;
|
42 |
|
|
|
43 |
/**
|
44 |
+
* Minify settings
|
45 |
+
*
|
46 |
+
* @since 2.0.9
|
47 |
+
* @var integer
|
48 |
+
*/
|
|
|
49 |
const MINIFY_DISABLED = 0;
|
50 |
const MINIFY_HTML_ONLY = 1;
|
51 |
const MINIFY_HTML_JS = 2;
|
52 |
|
|
|
53 |
/**
|
54 |
+
* Pseudo constructor
|
55 |
+
*
|
56 |
+
* @since 2.0.5
|
57 |
+
* @change 2.0.5
|
58 |
+
*/
|
59 |
+
public static function instance() {
|
|
|
|
|
60 |
new self();
|
61 |
}
|
62 |
|
|
|
63 |
/**
|
64 |
+
* Constructor
|
65 |
+
*
|
66 |
+
* @since 1.0.0
|
67 |
+
* @change 2.2.2
|
68 |
+
*
|
69 |
+
* @param void
|
70 |
+
* @return void
|
71 |
+
*/
|
72 |
+
public function __construct() {
|
|
|
|
|
73 |
/* Set defaults */
|
74 |
self::_set_default_vars();
|
75 |
|
76 |
+
self::$is_nginx = $GLOBALS['is_nginx'];
|
77 |
+
|
78 |
/* Publish hooks */
|
79 |
add_action(
|
80 |
'init',
|
81 |
array(
|
82 |
__CLASS__,
|
83 |
+
'register_publish_hooks',
|
84 |
),
|
85 |
99
|
86 |
);
|
87 |
|
88 |
/* Flush Hooks */
|
89 |
+
add_action( 'init', array( __CLASS__, 'register_flush_cache_hooks' ), 10, 0 );
|
90 |
+
|
91 |
add_action(
|
92 |
'cachify_remove_post_cache',
|
93 |
array(
|
94 |
__CLASS__,
|
95 |
+
'remove_page_cache_by_post_id',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
)
|
97 |
);
|
98 |
|
99 |
+
/* Flush icon */
|
100 |
add_action(
|
101 |
'admin_bar_menu',
|
102 |
array(
|
103 |
__CLASS__,
|
104 |
+
'add_flush_icon',
|
105 |
),
|
106 |
90
|
107 |
);
|
108 |
+
|
109 |
add_action(
|
110 |
'init',
|
111 |
array(
|
112 |
__CLASS__,
|
113 |
+
'process_flush_request',
|
114 |
)
|
115 |
);
|
116 |
|
119 |
'pre_comment_approved',
|
120 |
array(
|
121 |
__CLASS__,
|
122 |
+
'pre_comment',
|
123 |
),
|
124 |
99,
|
125 |
2
|
131 |
'wpmu_new_blog',
|
132 |
array(
|
133 |
__CLASS__,
|
134 |
+
'install_later',
|
135 |
)
|
136 |
);
|
137 |
+
|
138 |
add_action(
|
139 |
'delete_blog',
|
140 |
array(
|
141 |
__CLASS__,
|
142 |
+
'uninstall_later',
|
143 |
)
|
144 |
);
|
145 |
|
147 |
'admin_init',
|
148 |
array(
|
149 |
__CLASS__,
|
150 |
+
'register_textdomain',
|
151 |
)
|
152 |
);
|
153 |
+
|
154 |
add_action(
|
155 |
'admin_init',
|
156 |
array(
|
157 |
__CLASS__,
|
158 |
+
'register_settings',
|
159 |
)
|
160 |
);
|
161 |
|
163 |
'admin_menu',
|
164 |
array(
|
165 |
__CLASS__,
|
166 |
+
'add_page',
|
167 |
)
|
168 |
);
|
169 |
+
|
170 |
add_action(
|
171 |
'admin_enqueue_scripts',
|
172 |
array(
|
173 |
__CLASS__,
|
174 |
+
'add_admin_resources',
|
175 |
+
)
|
176 |
+
);
|
177 |
+
|
178 |
+
add_action(
|
179 |
+
'admin_head',
|
180 |
+
array(
|
181 |
+
__CLASS__,
|
182 |
+
'admin_dashboard_styles',
|
183 |
+
)
|
184 |
+
);
|
185 |
+
|
186 |
+
add_action(
|
187 |
+
'doing_dark_mode',
|
188 |
+
array(
|
189 |
+
__CLASS__,
|
190 |
+
'admin_dashboard_dark_mode_styles'
|
191 |
)
|
192 |
);
|
193 |
|
195 |
'transition_comment_status',
|
196 |
array(
|
197 |
__CLASS__,
|
198 |
+
'touch_comment',
|
199 |
),
|
200 |
10,
|
201 |
3
|
202 |
);
|
203 |
+
|
204 |
add_action(
|
205 |
'edit_comment',
|
206 |
array(
|
207 |
__CLASS__,
|
208 |
+
'edit_comment',
|
209 |
)
|
210 |
);
|
211 |
|
213 |
'dashboard_glance_items',
|
214 |
array(
|
215 |
__CLASS__,
|
216 |
+
'add_dashboard_count',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
)
|
218 |
);
|
219 |
|
221 |
'plugin_row_meta',
|
222 |
array(
|
223 |
__CLASS__,
|
224 |
+
'row_meta',
|
225 |
),
|
226 |
10,
|
227 |
2
|
228 |
);
|
229 |
+
|
230 |
add_filter(
|
231 |
+
'plugin_action_links_' . CACHIFY_BASE,
|
232 |
array(
|
233 |
__CLASS__,
|
234 |
+
'action_links',
|
235 |
)
|
236 |
);
|
237 |
|
238 |
+
/* Frontend */
|
239 |
} else {
|
240 |
add_action(
|
241 |
'template_redirect',
|
242 |
array(
|
243 |
__CLASS__,
|
244 |
+
'manage_cache',
|
245 |
),
|
246 |
0
|
247 |
);
|
248 |
+
|
249 |
add_action(
|
250 |
'robots_txt',
|
251 |
array(
|
252 |
__CLASS__,
|
253 |
+
'robots_txt',
|
254 |
)
|
255 |
);
|
256 |
+
}// End if().
|
257 |
}
|
258 |
|
|
|
259 |
/**
|
260 |
+
* Deactivation hook
|
261 |
+
*
|
262 |
+
* @since 2.1.0
|
263 |
+
* @change 2.1.0
|
264 |
+
*/
|
265 |
+
public static function on_deactivation() {
|
266 |
+
self::flush_total_cache( true );
|
|
|
|
|
267 |
}
|
268 |
|
|
|
269 |
/**
|
270 |
+
* Activation hook
|
271 |
+
*
|
272 |
+
* @since 1.0
|
273 |
+
* @change 2.1.0
|
274 |
+
*/
|
275 |
+
public static function on_activation() {
|
|
|
|
|
276 |
/* Multisite & Network */
|
277 |
+
if ( is_multisite() && ! empty( $_GET['networkwide'] ) ) {
|
278 |
+
/* Blog IDs */
|
279 |
$ids = self::_get_blog_ids();
|
280 |
|
281 |
+
/* Loop over blogs */
|
282 |
+
foreach ( $ids as $id ) {
|
283 |
+
switch_to_blog( $id );
|
284 |
self::_install_backend();
|
285 |
}
|
286 |
|
287 |
+
/* Switch back */
|
288 |
restore_current_blog();
|
289 |
|
290 |
} else {
|
292 |
}
|
293 |
}
|
294 |
|
|
|
295 |
/**
|
296 |
+
* Plugin installation on new MU blog.
|
297 |
+
*
|
298 |
+
* @since 1.0
|
299 |
+
* @change 1.0
|
300 |
+
*
|
301 |
+
* @param integer $id Blog ID.
|
302 |
+
*/
|
303 |
+
public static function install_later( $id ) {
|
304 |
+
/* No network plugin */
|
305 |
+
if ( ! is_plugin_active_for_network( CACHIFY_BASE ) ) {
|
306 |
return;
|
307 |
}
|
308 |
|
309 |
+
/* Switch to blog */
|
310 |
+
switch_to_blog( $id );
|
311 |
|
312 |
+
/* Install */
|
313 |
self::_install_backend();
|
314 |
|
315 |
+
/* Switch back */
|
316 |
restore_current_blog();
|
317 |
}
|
318 |
|
|
|
319 |
/**
|
320 |
+
* Actual installation of the options
|
321 |
+
*
|
322 |
+
* @since 1.0
|
323 |
+
* @change 2.0
|
324 |
+
*/
|
325 |
+
private static function _install_backend() {
|
|
|
|
|
326 |
add_option(
|
327 |
'cachify',
|
328 |
array()
|
329 |
);
|
330 |
|
331 |
/* Flush */
|
332 |
+
self::flush_total_cache( true );
|
333 |
}
|
334 |
|
|
|
335 |
/**
|
336 |
+
* Uninstalling of the plugin per MU blog.
|
337 |
+
*
|
338 |
+
* @since 1.0
|
339 |
+
* @change 2.1.0
|
340 |
+
*/
|
341 |
+
public static function on_uninstall() {
|
|
|
|
|
342 |
/* Global */
|
343 |
global $wpdb;
|
344 |
|
345 |
/* Multisite & Network */
|
346 |
+
if ( is_multisite() && ! empty( $_GET['networkwide'] ) ) {
|
347 |
/* Alter Blog */
|
348 |
$old = $wpdb->blogid;
|
349 |
|
350 |
+
/* Blog IDs */
|
351 |
$ids = self::_get_blog_ids();
|
352 |
|
353 |
+
/* Loop */
|
354 |
+
foreach ( $ids as $id ) {
|
355 |
+
switch_to_blog( $id );
|
356 |
self::_uninstall_backend();
|
357 |
}
|
358 |
|
359 |
+
/* Switch back */
|
360 |
+
switch_to_blog( $old );
|
361 |
} else {
|
362 |
self::_uninstall_backend();
|
363 |
}
|
364 |
}
|
365 |
|
|
|
366 |
/**
|
367 |
+
* Uninstalling of the plugin for MU and network.
|
368 |
+
*
|
369 |
+
* @since 1.0
|
370 |
+
* @change 1.0
|
371 |
+
*
|
372 |
+
* @param integer $id Blog ID.
|
373 |
+
*/
|
374 |
+
public static function uninstall_later( $id ) {
|
375 |
+
/* No network plugin */
|
376 |
+
if ( ! is_plugin_active_for_network( CACHIFY_BASE ) ) {
|
377 |
return;
|
378 |
}
|
379 |
|
380 |
+
/* Switch to blog */
|
381 |
+
switch_to_blog( $id );
|
382 |
|
383 |
+
/* Install */
|
384 |
self::_uninstall_backend();
|
385 |
|
386 |
+
/* Switch back */
|
387 |
restore_current_blog();
|
388 |
}
|
389 |
|
|
|
390 |
/**
|
391 |
+
* Actual uninstalling of the plugin
|
392 |
+
*
|
393 |
+
* @since 1.0
|
394 |
+
* @change 1.0
|
395 |
+
*/
|
396 |
+
private static function _uninstall_backend() {
|
|
|
|
|
397 |
/* Option */
|
398 |
+
delete_option( 'cachify' );
|
399 |
|
400 |
+
/* Flush cache */
|
401 |
+
self::flush_total_cache( true );
|
402 |
}
|
403 |
|
|
|
404 |
/**
|
405 |
+
* Get IDs of installed blogs
|
406 |
+
*
|
407 |
+
* @since 1.0
|
408 |
+
* @change 1.0
|
409 |
+
*
|
410 |
+
* @return array Blog IDs
|
411 |
+
*/
|
412 |
+
private static function _get_blog_ids() {
|
|
|
|
|
413 |
/* Global */
|
414 |
global $wpdb;
|
415 |
|
416 |
+
return $wpdb->get_col( "SELECT blog_id FROM `$wpdb->blogs`" );
|
417 |
}
|
418 |
|
|
|
419 |
/**
|
420 |
+
* Set default options
|
421 |
+
*
|
422 |
+
* @since 2.0
|
423 |
+
* @change 2.0.7
|
424 |
+
*/
|
425 |
+
private static function _set_default_vars() {
|
426 |
+
/* Options */
|
|
|
|
|
427 |
self::$options = self::_get_options();
|
428 |
|
429 |
/* APC */
|
430 |
+
if ( self::METHOD_APC === self::$options['use_apc'] && Cachify_APC::is_available() ) {
|
431 |
self::$method = new Cachify_APC;
|
432 |
|
433 |
+
/* HDD */
|
434 |
+
} elseif ( self::METHOD_HDD === self::$options['use_apc'] && Cachify_HDD::is_available() ) {
|
435 |
self::$method = new Cachify_HDD;
|
436 |
|
437 |
+
/* MEMCACHED */
|
438 |
+
} elseif ( self::METHOD_MMC === self::$options['use_apc'] && Cachify_MEMCACHED::is_available() ) {
|
439 |
self::$method = new Cachify_MEMCACHED;
|
440 |
|
441 |
+
/* DB */
|
442 |
} else {
|
443 |
self::$method = new Cachify_DB;
|
444 |
}
|
445 |
}
|
446 |
|
|
|
447 |
/**
|
448 |
+
* Get options
|
449 |
+
*
|
450 |
+
* @since 2.0
|
451 |
+
* @change 2.3.0
|
452 |
+
*
|
453 |
+
* @return array Array of option values
|
454 |
+
*/
|
455 |
+
private static function _get_options() {
|
|
|
|
|
456 |
return wp_parse_args(
|
457 |
+
get_option( 'cachify' ),
|
458 |
array(
|
459 |
'only_guests' => 1,
|
460 |
'compress_html' => self::MINIFY_DISABLED,
|
462 |
'without_ids' => '',
|
463 |
'without_agents' => '',
|
464 |
'use_apc' => self::METHOD_DB,
|
465 |
+
'reset_on_post' => 1,
|
466 |
+
'reset_on_comment' => 0,
|
467 |
+
'sig_detail' => 0,
|
468 |
)
|
469 |
);
|
470 |
}
|
471 |
|
|
|
472 |
/**
|
473 |
+
* Modify robots.txt
|
474 |
+
*
|
475 |
+
* @since 1.0
|
476 |
+
* @change 2.1.9
|
477 |
+
*
|
478 |
+
* @param string $data Original content of dynamic robots.txt.
|
479 |
+
* @return string Modified content of robots.txt.
|
480 |
+
*/
|
481 |
+
public static function robots_txt( $data ) {
|
|
|
|
|
482 |
/* HDD only */
|
483 |
+
if ( self::METHOD_HDD !== self::$options['use_apc'] ) {
|
484 |
return $data;
|
485 |
}
|
486 |
|
487 |
+
/* Parse site URL */
|
488 |
+
$url_parts = wp_parse_url( site_url() );
|
489 |
|
490 |
+
/* Output */
|
491 |
$data .= sprintf(
|
492 |
'%2$sDisallow: %1$s/wp-content/cache/cachify/%2$s',
|
493 |
+
( empty( $url_parts['path'] ) ? '' : $url_parts['path'] ),
|
494 |
PHP_EOL
|
495 |
);
|
496 |
|
497 |
return $data;
|
498 |
}
|
499 |
|
|
|
500 |
/**
|
501 |
+
* Add the action links
|
502 |
+
*
|
503 |
+
* @since 1.0
|
504 |
+
* @change 1.0
|
505 |
+
*
|
506 |
+
* @param array $data Initial array with action links.
|
507 |
+
* @return array Merged array with action links.
|
508 |
+
*/
|
509 |
+
public static function action_links( $data ) {
|
510 |
+
/* Permissions? */
|
511 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
|
|
|
|
512 |
return $data;
|
513 |
}
|
514 |
|
519 |
'<a href="%s">%s</a>',
|
520 |
add_query_arg(
|
521 |
array(
|
522 |
+
'page' => 'cachify',
|
523 |
),
|
524 |
+
admin_url( 'options-general.php' )
|
525 |
),
|
526 |
+
esc_html__( 'Settings', 'cachify' )
|
527 |
)
|
528 |
)
|
529 |
);
|
530 |
}
|
531 |
|
|
|
532 |
/**
|
533 |
+
* Meta links of the plugin
|
534 |
+
*
|
535 |
+
* @since 0.5
|
536 |
+
* @change 2.0.5
|
537 |
+
*
|
538 |
+
* @param array $input Initial array with meta links.
|
539 |
+
* @param string $page Current page.
|
540 |
+
* @return array Merged array with meta links.
|
541 |
+
*/
|
542 |
+
public static function row_meta( $input, $page ) {
|
543 |
+
/* Permissions */
|
544 |
+
if ( CACHIFY_BASE !== $page ) {
|
|
|
|
|
545 |
return $input;
|
546 |
}
|
547 |
|
548 |
return array_merge(
|
549 |
$input,
|
550 |
array(
|
551 |
+
'<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8CH5FPR88QYML" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Donate', 'cachify' ) . '</a>',
|
552 |
+
'<a href="https://wordpress.org/support/plugin/cachify" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Support', 'cachify' ) . '</a>',
|
553 |
)
|
554 |
);
|
555 |
}
|
556 |
|
|
|
557 |
/**
|
558 |
+
* Add cache properties to dashboard
|
559 |
+
*
|
560 |
+
* @since 2.0.0
|
561 |
+
* @change 2.2.2
|
562 |
+
*
|
563 |
+
* @param array $items Initial array with dashboard items.
|
564 |
+
* @return array Merged array with dashboard items.
|
565 |
+
*/
|
566 |
+
public static function add_dashboard_count( $items = array() ) {
|
|
|
|
|
567 |
/* Skip */
|
568 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
569 |
+
return $items;
|
570 |
+
}
|
571 |
|
572 |
/* Cache size */
|
573 |
$size = self::get_cache_size();
|
576 |
$method = call_user_func(
|
577 |
array(
|
578 |
self::$method,
|
579 |
+
'stringify_method',
|
580 |
)
|
581 |
);
|
582 |
|
583 |
+
/* Output of the cache size */
|
584 |
+
$cachesize = ( 0 === $size )
|
585 |
+
? esc_html__( 'Empty Cache', 'cachify' ) :
|
586 |
+
/* translators: %s: cache size */
|
587 |
+
sprintf( esc_html__( '%s Cache', 'cachify' ), size_format( $size ) );
|
588 |
+
|
589 |
/* Right now item */
|
590 |
$items[] = sprintf(
|
591 |
+
'<a href="%s" title="%s: %s" class="cachify-glance">
|
592 |
+
<svg class="cachify-icon cachify-icon--%s" aria-hidden="true" role="img">
|
593 |
+
<use href="%s#cachify-icon-%s" xlink:href="%s#cachify-icon-%s">
|
594 |
+
</svg> %s</a>',
|
595 |
add_query_arg(
|
596 |
array(
|
597 |
+
'page' => 'cachify',
|
598 |
),
|
599 |
+
admin_url( 'options-general.php' )
|
600 |
),
|
601 |
+
esc_attr( strtolower( $method ) ),
|
602 |
+
esc_html__( 'Caching method', 'cachify' ),
|
603 |
+
esc_attr( $method ),
|
604 |
+
plugins_url( 'images/symbols.svg', CACHIFY_FILE ),
|
605 |
+
esc_attr( strtolower( $method ) ),
|
606 |
+
plugins_url( 'images/symbols.svg', CACHIFY_FILE ),
|
607 |
+
esc_attr( strtolower( $method ) ),
|
608 |
+
$cachesize
|
609 |
);
|
610 |
|
611 |
return $items;
|
612 |
}
|
613 |
|
|
|
614 |
/**
|
615 |
+
* Get the cache size
|
616 |
+
*
|
617 |
+
* @since 2.0.6
|
618 |
+
* @change 2.0.6
|
619 |
+
*
|
620 |
+
* @return integer Cache size in bytes.
|
621 |
+
*/
|
622 |
+
public static function get_cache_size() {
|
623 |
+
if ( ! $size = get_transient( 'cachify_cache_size' ) ) {
|
624 |
+
/* Read */
|
|
|
|
|
625 |
$size = (int) call_user_func(
|
626 |
array(
|
627 |
self::$method,
|
628 |
+
'get_stats',
|
629 |
)
|
630 |
);
|
631 |
|
632 |
+
/* Save */
|
633 |
set_transient(
|
634 |
+
'cachify_cache_size',
|
635 |
+
$size,
|
636 |
+
60 * 15
|
637 |
);
|
638 |
}
|
639 |
|
640 |
return $size;
|
641 |
}
|
642 |
|
|
|
643 |
/**
|
644 |
+
* Add flush icon to admin bar menu
|
645 |
+
*
|
646 |
+
* @since 1.2
|
647 |
+
* @change 2.2.2
|
648 |
+
*
|
649 |
+
* @hook mixed cachify_user_can_flush_cache
|
650 |
+
*
|
651 |
+
* @param object $wp_admin_bar Object of menu items.
|
652 |
+
*/
|
653 |
+
public static function add_flush_icon( $wp_admin_bar ) {
|
654 |
+
/* Quit */
|
655 |
+
if ( ! is_admin_bar_showing() || ! apply_filters( 'cachify_user_can_flush_cache', current_user_can( 'manage_options' ) ) ) {
|
|
|
|
|
656 |
return;
|
657 |
}
|
658 |
|
659 |
/* Display the admin icon anytime */
|
660 |
+
echo '<style>#wp-admin-bar-cachify{display:list-item !important} #wp-admin-bar-cachify .ab-icon{margin:0 !important} #wp-admin-bar-cachify .ab-icon:before{content:"\f182";top:2px;margin:0;} #wp-admin-bar-cachify .ab-label{margin:0 5px}</style>';
|
661 |
|
662 |
+
/* Add menu item */
|
663 |
$wp_admin_bar->add_menu(
|
664 |
array(
|
665 |
'id' => 'cachify',
|
666 |
+
'href' => wp_nonce_url( add_query_arg( '_cachify', 'flush' ), '_cachify__flush_nonce' ), // esc_url in /wp-includes/class-wp-admin-bar.php#L438.
|
667 |
'parent' => 'top-secondary',
|
668 |
+
'title' => '<span class="ab-icon dashicons"></span>' .
|
669 |
+
'<span class="ab-label">' .
|
670 |
+
__(
|
671 |
+
'Flush site cache',
|
672 |
+
'cachify'
|
673 |
+
) .
|
674 |
+
'</span>',
|
675 |
+
'meta' => array(
|
676 |
+
'title' => esc_html__( 'Flush the cachify cache', 'cachify' ),
|
677 |
+
),
|
678 |
)
|
679 |
);
|
680 |
}
|
681 |
|
|
|
682 |
/**
|
683 |
+
* Process plugin's meta actions
|
684 |
+
*
|
685 |
+
* @since 0.5
|
686 |
+
* @change 2.2.2
|
687 |
+
*
|
688 |
+
* @hook mixed cachify_user_can_flush_cache
|
689 |
+
*
|
690 |
+
* @param array $data Metadata of the plugin.
|
691 |
+
*/
|
692 |
+
public static function process_flush_request( $data ) {
|
|
|
|
|
693 |
/* Skip if not a flush request */
|
694 |
+
if ( empty( $_GET['_cachify'] ) || 'flush' !== $_GET['_cachify'] ) {
|
695 |
return;
|
696 |
}
|
697 |
|
698 |
+
/* Check nonce */
|
699 |
+
if ( empty( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], '_cachify__flush_nonce' ) ) {
|
700 |
+
return;
|
701 |
+
}
|
702 |
|
703 |
/* Skip if not necessary */
|
704 |
+
if ( ! is_admin_bar_showing() || ! apply_filters( 'cachify_user_can_flush_cache', current_user_can( 'manage_options' ) ) ) {
|
705 |
return;
|
706 |
}
|
707 |
|
708 |
/* Load on demand */
|
709 |
+
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
710 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
711 |
}
|
712 |
|
713 |
+
/* Flush cache */
|
714 |
+
if ( is_multisite() && is_network_admin() ) {
|
715 |
+
/* Old blog */
|
716 |
$old = $GLOBALS['wpdb']->blogid;
|
717 |
|
718 |
+
/* Blog IDs */
|
719 |
$ids = self::_get_blog_ids();
|
720 |
|
721 |
+
/* Loop over blogs */
|
722 |
+
foreach ( $ids as $id ) {
|
723 |
+
switch_to_blog( $id );
|
724 |
self::flush_total_cache();
|
725 |
}
|
726 |
|
727 |
+
/* Switch back to old blog */
|
728 |
+
switch_to_blog( $old );
|
729 |
|
730 |
+
/* Notice */
|
731 |
if ( is_admin() ) {
|
732 |
add_action(
|
733 |
'network_admin_notices',
|
734 |
array(
|
735 |
__CLASS__,
|
736 |
+
'flush_notice',
|
737 |
)
|
738 |
);
|
739 |
}
|
740 |
} else {
|
|
|
741 |
self::flush_total_cache();
|
742 |
|
743 |
+
/* Notice */
|
744 |
if ( is_admin() ) {
|
745 |
add_action(
|
746 |
'admin_notices',
|
747 |
array(
|
748 |
__CLASS__,
|
749 |
+
'flush_notice',
|
750 |
)
|
751 |
);
|
752 |
}
|
753 |
}
|
|
|
754 |
if ( ! is_admin() ) {
|
755 |
wp_safe_redirect(
|
756 |
remove_query_arg(
|
763 |
}
|
764 |
}
|
765 |
|
|
|
766 |
/**
|
767 |
+
* Notice after successful flushing of the cache
|
768 |
+
*
|
769 |
+
* @since 1.2
|
770 |
+
* @change 2.2.2
|
771 |
+
*
|
772 |
+
* @hook mixed cachify_user_can_flush_cache
|
773 |
+
*/
|
774 |
+
public static function flush_notice() {
|
775 |
+
/* No admin */
|
776 |
+
if ( ! is_admin_bar_showing() || ! apply_filters( 'cachify_user_can_flush_cache', current_user_can( 'manage_options' ) ) ) {
|
|
|
|
|
777 |
return false;
|
778 |
}
|
779 |
|
780 |
echo sprintf(
|
781 |
'<div class="notice notice-success is-dismissible"><p>%s</p></div>',
|
782 |
+
esc_html__( 'Cachify cache is flushed.', 'cachify' )
|
783 |
);
|
784 |
}
|
785 |
|
|
|
786 |
/**
|
787 |
+
* Remove page from cache or flush on comment edit
|
788 |
+
*
|
789 |
+
* @since 0.1.0
|
790 |
+
* @change 2.1.2
|
791 |
+
*
|
792 |
+
* @param integer $id Comment ID.
|
793 |
+
*/
|
794 |
+
public static function edit_comment( $id ) {
|
|
|
|
|
795 |
if ( self::$options['reset_on_comment'] ) {
|
796 |
self::flush_total_cache();
|
797 |
} else {
|
798 |
self::remove_page_cache_by_post_id(
|
799 |
+
get_comment( $id )->comment_post_ID
|
800 |
);
|
801 |
}
|
802 |
}
|
803 |
|
|
|
804 |
/**
|
805 |
+
* Remove page from cache or flush on new comment
|
806 |
+
*
|
807 |
+
* @since 0.1.0
|
808 |
+
* @change 2.1.2
|
809 |
+
*
|
810 |
+
* @param mixed $approved Comment status.
|
811 |
+
* @param array $comment Array of properties.
|
812 |
+
* @return mixed Comment status.
|
813 |
+
*/
|
814 |
+
public static function pre_comment( $approved, $comment ) {
|
|
|
|
|
815 |
/* Approved comment? */
|
816 |
+
if ( 1 === $approved ) {
|
817 |
if ( self::$options['reset_on_comment'] ) {
|
818 |
self::flush_total_cache();
|
819 |
} else {
|
824 |
return $approved;
|
825 |
}
|
826 |
|
|
|
827 |
/**
|
828 |
+
* Remove page from cache or flush on comment edit
|
829 |
+
*
|
830 |
+
* @since 0.1
|
831 |
+
* @change 2.1.2
|
832 |
+
*
|
833 |
+
* @param string $new_status New status.
|
834 |
+
* @param string $old_status Old status.
|
835 |
+
* @param object $comment The comment.
|
836 |
+
*/
|
837 |
+
public static function touch_comment( $new_status, $old_status, $comment ) {
|
838 |
+
if ( $new_status !== $old_status ) {
|
|
|
|
|
839 |
if ( self::$options['reset_on_comment'] ) {
|
840 |
self::flush_total_cache();
|
841 |
} else {
|
844 |
}
|
845 |
}
|
846 |
|
|
|
847 |
/**
|
848 |
+
* Generate publish hook for custom post types
|
849 |
+
*
|
850 |
+
* @since 2.1.7 Make the function public
|
851 |
+
* @since 2.0.3
|
852 |
+
*
|
853 |
+
* @param void
|
854 |
+
* @return void
|
855 |
+
*/
|
856 |
+
public static function register_publish_hooks() {
|
|
|
|
|
857 |
/* Available post types */
|
858 |
$post_types = get_post_types(
|
859 |
+
array(
|
860 |
+
'public' => true,
|
861 |
+
)
|
862 |
);
|
863 |
|
864 |
/* Empty data? */
|
865 |
+
if ( empty( $post_types ) ) {
|
866 |
return;
|
867 |
}
|
868 |
|
869 |
/* Loop the post types */
|
870 |
foreach ( $post_types as $post_type ) {
|
871 |
add_action(
|
872 |
+
'publish_' . $post_type,
|
873 |
array(
|
874 |
__CLASS__,
|
875 |
+
'publish_post_types',
|
876 |
),
|
877 |
10,
|
878 |
2
|
879 |
);
|
880 |
add_action(
|
881 |
+
'publish_future_' . $post_type,
|
882 |
array(
|
883 |
__CLASS__,
|
884 |
+
'flush_total_cache',
|
885 |
)
|
886 |
);
|
887 |
}
|
888 |
}
|
889 |
|
|
|
890 |
/**
|
891 |
+
* Removes the post type cache on post updates
|
892 |
+
*
|
893 |
+
* @since 2.0.3
|
894 |
+
* @change 2.3.0
|
895 |
+
*
|
896 |
+
* @param integer $post_id Post ID.
|
897 |
+
* @param object $post Post object.
|
898 |
+
*/
|
899 |
+
public static function publish_post_types( $post_id, $post ) {
|
900 |
+
/* No post_id? */
|
901 |
+
if ( empty( $post_id ) || empty( $post ) ) {
|
|
|
902 |
return;
|
903 |
}
|
904 |
|
905 |
/* Post status check */
|
906 |
+
if ( ! in_array( $post->post_status, array( 'publish', 'future' ), true ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
907 |
return;
|
908 |
}
|
909 |
|
910 |
/* Check user role */
|
911 |
+
if ( ! current_user_can( 'publish_posts' ) ) {
|
912 |
return;
|
913 |
}
|
914 |
|
915 |
/* Save as var */
|
916 |
+
$remove_post_type_cache = (int) $_POST['_cachify_remove_post_type_cache_on_update'];
|
917 |
|
918 |
/* Save as user meta */
|
919 |
update_user_meta(
|
923 |
);
|
924 |
|
925 |
/* Remove cache OR flush */
|
926 |
+
if ( 1 !== self::$options['reset_on_post'] ) {
|
927 |
+
self::remove_page_cache_by_post_id( $post_id );
|
928 |
} else {
|
929 |
self::flush_total_cache();
|
930 |
}
|
931 |
}
|
932 |
|
|
|
933 |
/**
|
934 |
+
* Removes a page (id) from cache
|
935 |
+
*
|
936 |
+
* @since 2.0.3
|
937 |
+
* @change 2.1.3
|
938 |
+
*
|
939 |
+
* @param integer $post_id Post ID.
|
940 |
+
*/
|
941 |
+
public static function remove_page_cache_by_post_id( $post_id ) {
|
|
|
|
|
942 |
/* Value check */
|
943 |
+
if ( ! $post_id = (int) $post_id ) {
|
944 |
return;
|
945 |
}
|
946 |
|
947 |
/* Remove page by url */
|
948 |
self::remove_page_cache_by_url(
|
949 |
+
get_permalink( $post_id )
|
950 |
);
|
951 |
}
|
952 |
|
|
|
953 |
/**
|
954 |
+
* Removes a page url from cache
|
955 |
+
*
|
956 |
+
* @since 0.1
|
957 |
+
* @change 2.1.3
|
958 |
+
*
|
959 |
+
* @param string $url Page URL.
|
960 |
+
*/
|
961 |
+
public static function remove_page_cache_by_url( $url ) {
|
|
|
|
|
962 |
/* Value check */
|
963 |
+
if ( ! $url = (string) $url ) {
|
964 |
return;
|
965 |
}
|
966 |
|
967 |
call_user_func(
|
968 |
array(
|
969 |
self::$method,
|
970 |
+
'delete_item',
|
971 |
),
|
972 |
self::_cache_hash( $url ),
|
973 |
$url
|
974 |
);
|
975 |
}
|
976 |
|
|
|
977 |
/**
|
978 |
+
* Get cache validity
|
979 |
+
*
|
980 |
+
* @since 2.0.0
|
981 |
+
* @change 2.1.7
|
982 |
+
*
|
983 |
+
* @return integer Validity period in seconds.
|
984 |
+
*/
|
985 |
+
private static function _cache_expires() {
|
|
|
|
|
986 |
return HOUR_IN_SECONDS * self::$options['cache_expires'];
|
987 |
}
|
988 |
|
989 |
+
/**
|
990 |
+
* Determine if cache details should be printed in signature
|
991 |
+
*
|
992 |
+
* @since 2.3.0
|
993 |
+
*
|
994 |
+
* @return bool Show details in signature.
|
995 |
+
*/
|
996 |
+
private static function _signature_details() {
|
997 |
+
return self::$options['sig_detail'] === 1;
|
998 |
+
}
|
999 |
|
1000 |
/**
|
1001 |
+
* Get hash value for caching
|
1002 |
+
*
|
1003 |
+
* @since 0.1
|
1004 |
+
* @change 2.0
|
1005 |
+
*
|
1006 |
+
* @param string $url URL to hash [optional].
|
1007 |
+
* @return string Cachify hash value.
|
1008 |
+
*/
|
1009 |
+
private static function _cache_hash( $url = '' ) {
|
|
|
|
|
1010 |
$prefix = is_ssl() ? 'https-' : '';
|
1011 |
+
$url_parts = wp_parse_url( $url );
|
1012 |
return md5(
|
1013 |
+
empty( $url ) ? ( $prefix . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) : ( $prefix . $url_parts['host'] . $url_parts['path'] )
|
1014 |
) . '.cachify';
|
1015 |
}
|
1016 |
|
|
|
1017 |
/**
|
1018 |
+
* Split by comma
|
1019 |
+
*
|
1020 |
+
* @since 0.9.1
|
1021 |
+
* @change 1.0
|
1022 |
+
*
|
1023 |
+
* @param string $input String to split.
|
1024 |
+
* @return array Splitted values.
|
1025 |
+
*/
|
1026 |
+
private static function _preg_split( $input ) {
|
1027 |
+
return (array) preg_split( '/,/', $input, -1, PREG_SPLIT_NO_EMPTY );
|
|
|
|
|
1028 |
}
|
1029 |
|
|
|
1030 |
/**
|
1031 |
+
* Check for index page
|
1032 |
+
*
|
1033 |
+
* @since 0.6
|
1034 |
+
* @change 1.0
|
1035 |
+
*
|
1036 |
+
* @return boolean TRUE if index
|
1037 |
+
*/
|
1038 |
+
private static function _is_index() {
|
1039 |
+
return basename( $_SERVER['SCRIPT_NAME'] ) === 'index.php';
|
|
|
|
|
1040 |
}
|
1041 |
|
|
|
1042 |
/**
|
1043 |
+
* Check for mobile devices
|
1044 |
+
*
|
1045 |
+
* @since 0.9.1
|
1046 |
+
* @change 2.3.0
|
1047 |
+
*
|
1048 |
+
* @return boolean TRUE if mobile
|
1049 |
+
*/
|
1050 |
+
private static function _is_mobile() {
|
1051 |
+
$templatedir = get_template_directory();
|
1052 |
+
return ( strpos( $templatedir, 'wptouch' ) || strpos( $templatedir, 'carrington' ) || strpos( $templatedir, 'jetpack' ) || strpos( $templatedir, 'handheld' ) );
|
|
|
1053 |
}
|
1054 |
|
|
|
1055 |
/**
|
1056 |
+
* Check if user is logged in or marked
|
1057 |
+
*
|
1058 |
+
* @since 2.0.0
|
1059 |
+
* @change 2.0.5
|
1060 |
+
*
|
1061 |
+
* @return boolean $diff TRUE on "marked" users
|
1062 |
+
*/
|
1063 |
+
private static function _is_logged_in() {
|
1064 |
+
/* Logged in */
|
|
|
|
|
1065 |
if ( is_user_logged_in() ) {
|
1066 |
return true;
|
1067 |
}
|
1068 |
|
1069 |
/* Cookie? */
|
1070 |
+
if ( empty( $_COOKIE ) ) {
|
1071 |
return false;
|
1072 |
}
|
1073 |
|
1074 |
+
/* Loop */
|
1075 |
+
foreach ( $_COOKIE as $k => $v ) {
|
1076 |
+
if ( preg_match( '/^(wp-postpass|wordpress_logged_in|comment_author)_/', $k ) ) {
|
1077 |
return true;
|
1078 |
}
|
1079 |
}
|
1080 |
+
|
1081 |
+
return false;
|
1082 |
}
|
1083 |
|
1084 |
+
/**
|
1085 |
+
* Register all hooks to flush the total cache
|
1086 |
+
*
|
1087 |
+
* @since 2.4.0
|
1088 |
+
*
|
1089 |
+
* @param void
|
1090 |
+
* @return void
|
1091 |
+
*/
|
1092 |
+
public static function register_flush_cache_hooks() {
|
1093 |
+
|
1094 |
+
/* Define all default flush cache hooks */
|
1095 |
+
$flush_cache_hooks = array(
|
1096 |
+
'cachify_flush_cache' => 10,
|
1097 |
+
'_core_updated_successfully' => 10,
|
1098 |
+
'switch_theme' => 10,
|
1099 |
+
'before_delete_post' => 10,
|
1100 |
+
'wp_trash_post' => 10,
|
1101 |
+
'create_term' => 10,
|
1102 |
+
'delete_term' => 10,
|
1103 |
+
'edit_terms' => 10,
|
1104 |
+
'user_register' => 10,
|
1105 |
+
'edit_user_profile_update' => 10,
|
1106 |
+
'delete_user' => 10
|
1107 |
+
);
|
1108 |
+
|
1109 |
+
$flush_cache_hooks = apply_filters( 'cachify_flush_cache_hooks', $flush_cache_hooks );
|
1110 |
+
|
1111 |
+
/* Loop all hooks and register actions */
|
1112 |
+
foreach ( $flush_cache_hooks as $hook => $priority ) {
|
1113 |
+
add_action(
|
1114 |
+
$hook,
|
1115 |
+
array(
|
1116 |
+
'Cachify',
|
1117 |
+
'flush_total_cache',
|
1118 |
+
),
|
1119 |
+
$priority,
|
1120 |
+
0
|
1121 |
+
);
|
1122 |
+
}
|
1123 |
+
|
1124 |
+
}
|
1125 |
|
1126 |
/**
|
1127 |
+
* Define exclusions for caching
|
1128 |
+
*
|
1129 |
+
* @since 0.2
|
1130 |
+
* @change 2.3.0
|
1131 |
+
*
|
1132 |
+
* @return boolean TRUE on exclusion
|
1133 |
+
*
|
1134 |
+
* @hook boolean cachify_skip_cache
|
1135 |
+
*/
|
1136 |
+
private static function _skip_cache() {
|
1137 |
+
|
1138 |
+
/* Plugin options */
|
1139 |
+
$options = self::$options;
|
1140 |
+
|
1141 |
+
/* Request vars */
|
1142 |
+
if ( ! empty( $_POST ) || ( ! empty( $_GET ) && get_option( 'permalink_structure' ) ) ) {
|
1143 |
return true;
|
1144 |
}
|
1145 |
|
1146 |
+
/* Only cache requests routed through main index.php (skip AJAX, WP-Cron, WP-CLI etc.) */
|
1147 |
+
if ( ! self::_is_index() ) {
|
1148 |
return true;
|
1149 |
}
|
1150 |
|
1151 |
+
/* Logged in */
|
1152 |
+
if ( $options['only_guests'] && self::_is_logged_in() ) {
|
1153 |
return true;
|
1154 |
}
|
1155 |
|
1156 |
+
/* No cache hook */
|
1157 |
+
if ( apply_filters( 'cachify_skip_cache', false ) ) {
|
1158 |
+
return true;
|
1159 |
+
}
|
1160 |
|
1161 |
+
/* Conditional Tags */
|
1162 |
+
if ( is_search() || is_404() || is_feed() || is_trackback() || is_robots() || is_preview() || post_password_required() ) {
|
1163 |
return true;
|
1164 |
}
|
1165 |
|
1166 |
+
/* WooCommerce usage */
|
1167 |
+
if ( defined( 'DONOTCACHEPAGE' ) && DONOTCACHEPAGE ) {
|
1168 |
return true;
|
1169 |
}
|
1170 |
|
1175 |
|
1176 |
/* Post IDs */
|
1177 |
if ( $options['without_ids'] && is_singular() ) {
|
1178 |
+
$without_ids = array_map( 'intval', self::_preg_split( $options['without_ids'] ) );
|
1179 |
+
if ( in_array( $GLOBALS['wp_query']->get_queried_object_id(), $without_ids, true ) ) {
|
1180 |
return true;
|
1181 |
}
|
1182 |
}
|
1183 |
|
1184 |
/* User Agents */
|
1185 |
+
if ( $options['without_agents'] && isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
1186 |
+
$user_agent_strings = self::_preg_split( $options['without_agents'] );
|
1187 |
+
foreach ( $user_agent_strings as $user_agent_string ) {
|
1188 |
+
if ( strpos( $_SERVER["HTTP_USER_AGENT"], $user_agent_string ) !== false ) {
|
1189 |
+
return true;
|
1190 |
+
}
|
1191 |
}
|
1192 |
}
|
1193 |
|
1194 |
return false;
|
1195 |
}
|
1196 |
|
|
|
1197 |
/**
|
1198 |
+
* Minify HTML code
|
1199 |
+
*
|
1200 |
+
* @since 0.9.2
|
1201 |
+
* @change 2.0.9
|
1202 |
+
*
|
1203 |
+
* @param string $data Original HTML code.
|
1204 |
+
* @return string Minified code
|
1205 |
+
*
|
1206 |
+
* @hook array cachify_minify_ignore_tags
|
1207 |
+
*/
|
1208 |
+
private static function _minify_cache( $data ) {
|
|
|
|
|
1209 |
/* Disabled? */
|
1210 |
if ( ! self::$options['compress_html'] ) {
|
1211 |
return $data;
|
1212 |
}
|
1213 |
|
1214 |
/* Avoid slow rendering */
|
1215 |
+
if ( strlen( $data ) > 700000 ) {
|
1216 |
return $data;
|
1217 |
}
|
1218 |
|
1219 |
/* Ignore this html tags */
|
1220 |
+
$ignore_tags = (array) apply_filters(
|
1221 |
'cachify_minify_ignore_tags',
|
1222 |
array(
|
1223 |
'textarea',
|
1224 |
+
'pre',
|
1225 |
)
|
1226 |
);
|
1227 |
|
1228 |
/* Add the script tag */
|
1229 |
+
if ( self::MINIFY_HTML_JS !== self::$options['compress_html'] ) {
|
1230 |
$ignore_tags[] = 'script';
|
1231 |
}
|
1232 |
|
1236 |
}
|
1237 |
|
1238 |
/* Convert to string */
|
1239 |
+
$ignore_regex = implode( '|', $ignore_tags );
|
1240 |
|
1241 |
/* Minify */
|
1242 |
$cleaned = preg_replace(
|
1243 |
array(
|
1244 |
'/<!--[^\[><](.*?)-->/s',
|
1245 |
+
'#(?ix)(?>[^\S ]\s*|\s{2,})(?=(?:(?:[^<]++|<(?!/?(?:' . $ignore_regex . ')\b))*+)(?:<(?>' . $ignore_regex . ')\b|\z))#',
|
1246 |
),
|
1247 |
array(
|
1248 |
'',
|
1249 |
+
' ',
|
1250 |
),
|
1251 |
$data
|
1252 |
);
|
1253 |
|
1254 |
/* Fault */
|
1255 |
+
if ( strlen( $cleaned ) <= 1 ) {
|
1256 |
return $data;
|
1257 |
}
|
1258 |
|
1259 |
return $cleaned;
|
1260 |
}
|
1261 |
|
|
|
1262 |
/**
|
1263 |
+
* Flush total cache
|
1264 |
+
*
|
1265 |
+
* @since 0.1
|
1266 |
+
* @change 2.0
|
1267 |
+
*
|
1268 |
+
* @param bool $clear_all_methods Flush all caching methods (default: FALSE).
|
1269 |
+
*/
|
1270 |
+
public static function flush_total_cache( $clear_all_methods = false ) {
|
1271 |
if ( $clear_all_methods ) {
|
1272 |
/* DB */
|
1273 |
Cachify_DB::clear_cache();
|
1284 |
call_user_func(
|
1285 |
array(
|
1286 |
self::$method,
|
1287 |
+
'clear_cache',
|
1288 |
)
|
1289 |
);
|
1290 |
}
|
1291 |
|
1292 |
/* Transient */
|
1293 |
+
delete_transient( 'cachify_cache_size' );
|
1294 |
}
|
1295 |
|
|
|
1296 |
/**
|
1297 |
+
* Assign the cache
|
1298 |
+
*
|
1299 |
+
* @since 0.1
|
1300 |
+
* @change 2.0
|
1301 |
+
*
|
1302 |
+
* @param string $data Content of the page.
|
1303 |
+
* @return string Content of the page.
|
1304 |
+
*/
|
1305 |
+
public static function set_cache( $data ) {
|
1306 |
+
/* Empty? */
|
1307 |
+
if ( empty( $data ) ) {
|
|
|
|
|
1308 |
return '';
|
1309 |
}
|
1310 |
|
1311 |
+
/**
|
1312 |
+
* Filters whether the buffered data should actually be cached
|
1313 |
+
*
|
1314 |
+
* @since 2.3
|
1315 |
+
*
|
1316 |
+
* @param bool $should_cache Whether the data should be cached.
|
1317 |
+
* @param string $data The actual data.
|
1318 |
+
* @param object $method Instance of the selected caching method.
|
1319 |
+
* @param string $cache_hash The cache hash.
|
1320 |
+
* @param int $cache_expires Cache validity period.
|
1321 |
+
*/
|
1322 |
+
$should_cache = apply_filters( 'cachify_store_item', true, $data, self::$method, self::_cache_hash(), self::_cache_expires() );
|
1323 |
+
|
1324 |
+
/* Save? */
|
1325 |
+
if ( $should_cache ) {
|
1326 |
+
call_user_func(
|
1327 |
+
array(
|
1328 |
+
self::$method,
|
1329 |
+
'store_item',
|
1330 |
+
),
|
1331 |
+
self::_cache_hash(),
|
1332 |
+
self::_minify_cache( $data ),
|
1333 |
+
self::_cache_expires(),
|
1334 |
+
self::_signature_details()
|
1335 |
+
);
|
1336 |
+
}
|
1337 |
|
1338 |
return $data;
|
1339 |
}
|
1340 |
|
|
|
1341 |
/**
|
1342 |
+
* Manage the cache.
|
1343 |
+
*
|
1344 |
+
* @since 0.1
|
1345 |
+
* @change 2.3
|
1346 |
+
*/
|
1347 |
+
public static function manage_cache() {
|
1348 |
+
/* No caching? */
|
|
|
|
|
1349 |
if ( self::_skip_cache() ) {
|
1350 |
return;
|
1351 |
}
|
1352 |
|
1353 |
+
/* Data present in cache */
|
1354 |
$cache = call_user_func(
|
1355 |
array(
|
1356 |
self::$method,
|
1357 |
+
'get_item',
|
1358 |
),
|
1359 |
self::_cache_hash()
|
1360 |
);
|
1361 |
|
1362 |
+
/* No cache? */
|
1363 |
+
if ( empty( $cache ) ) {
|
1364 |
+
ob_start( 'Cachify::set_cache' );
|
1365 |
return;
|
1366 |
}
|
1367 |
|
1368 |
+
/* Process cache */
|
1369 |
call_user_func(
|
1370 |
array(
|
1371 |
self::$method,
|
1372 |
+
'print_cache',
|
1373 |
),
|
1374 |
+
self::_signature_details(),
|
1375 |
$cache
|
1376 |
);
|
1377 |
}
|
1378 |
|
|
|
1379 |
/**
|
1380 |
+
* Register CSS
|
1381 |
+
*
|
1382 |
+
* @since 1.0
|
1383 |
+
* @change 2.3.0
|
1384 |
+
*
|
1385 |
+
* @param string $hook Current hook.
|
1386 |
+
*/
|
1387 |
+
public static function add_admin_resources( $hook ) {
|
1388 |
/* Hooks check */
|
1389 |
+
if ( 'index.php' !== $hook && 'settings_page_cachify' !== $hook ) {
|
1390 |
return;
|
1391 |
}
|
1392 |
|
1393 |
/* Plugin data */
|
1394 |
+
$plugin_data = get_plugin_data( CACHIFY_FILE );
|
1395 |
|
1396 |
/* Register css */
|
1397 |
+
switch ( $hook ) {
|
1398 |
case 'index.php':
|
1399 |
wp_enqueue_style(
|
1400 |
'cachify-dashboard',
|
1401 |
+
plugins_url( 'css/dashboard.min.css', CACHIFY_FILE ),
|
1402 |
array(),
|
1403 |
$plugin_data['Version']
|
1404 |
);
|
1405 |
break;
|
1406 |
|
1407 |
+
case 'settings_page_cachify':
|
1408 |
+
wp_enqueue_style(
|
1409 |
+
'cachify-settings',
|
1410 |
+
plugins_url( 'css/settings.min.css', CACHIFY_FILE ),
|
1411 |
+
array(),
|
1412 |
+
$plugin_data['Version']
|
|
|
1413 |
);
|
1414 |
break;
|
1415 |
|
1416 |
default:
|
1417 |
break;
|
1418 |
}
|
|
|
1419 |
|
1420 |
+
}
|
1421 |
|
1422 |
/**
|
1423 |
+
* Fixing some admin dashboard styles
|
1424 |
+
*
|
1425 |
+
* @since 2.3.0
|
1426 |
+
*/
|
1427 |
+
public static function admin_dashboard_styles() {
|
1428 |
+
$wp_version = get_bloginfo( 'version' );
|
1429 |
+
|
1430 |
+
if ( version_compare( $wp_version, '5.3', '<' ) ) {
|
1431 |
+
echo '<style>#dashboard_right_now .cachify-icon use { fill: #82878c; }</style>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1432 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1433 |
}
|
1434 |
|
1435 |
+
/**
|
1436 |
+
* Fixing some admin dashboard styles
|
1437 |
+
*
|
1438 |
+
* @since 2.3.0
|
1439 |
+
*/
|
1440 |
+
public static function admin_dashboard_dark_mode_styles() {
|
1441 |
+
echo '<style>#dashboard_right_now .cachify-icon use { fill: #bbc8d4; }</style>';
|
1442 |
+
}
|
1443 |
|
1444 |
/**
|
1445 |
+
* Add options page
|
1446 |
+
*
|
1447 |
+
* @since 1.0
|
1448 |
+
* @change 2.2.2
|
1449 |
+
*/
|
1450 |
+
public static function add_page() {
|
|
|
|
|
1451 |
add_options_page(
|
1452 |
__( 'Cachify', 'cachify' ),
|
1453 |
__( 'Cachify', 'cachify' ),
|
1455 |
'cachify',
|
1456 |
array(
|
1457 |
__CLASS__,
|
1458 |
+
'options_page',
|
1459 |
)
|
1460 |
);
|
1461 |
}
|
1462 |
|
|
|
1463 |
/**
|
1464 |
+
* Available caching methods
|
1465 |
+
*
|
1466 |
+
* @since 2.0.0
|
1467 |
+
* @change 2.1.3
|
1468 |
+
*
|
1469 |
+
* @param array $methods Array of all available methods.
|
1470 |
+
* @return array Array of actually available methods.
|
1471 |
+
*/
|
1472 |
+
private static function _method_select() {
|
|
|
1473 |
/* Defaults */
|
1474 |
$methods = array(
|
1475 |
+
self::METHOD_DB => esc_html__( 'Database', 'cachify' ),
|
1476 |
+
self::METHOD_APC => esc_html__( 'APC', 'cachify' ),
|
1477 |
+
self::METHOD_HDD => esc_html__( 'Hard disk', 'cachify' ),
|
1478 |
+
self::METHOD_MMC => esc_html__( 'Memcached', 'cachify' ),
|
1479 |
);
|
1480 |
|
1481 |
/* APC */
|
1482 |
if ( ! Cachify_APC::is_available() ) {
|
1483 |
+
unset( $methods[1] );
|
1484 |
}
|
1485 |
|
1486 |
/* Memcached? */
|
1487 |
if ( ! Cachify_MEMCACHED::is_available() ) {
|
1488 |
+
unset( $methods[3] );
|
1489 |
}
|
1490 |
|
1491 |
/* HDD */
|
1492 |
if ( ! Cachify_HDD::is_available() ) {
|
1493 |
+
unset( $methods[2] );
|
1494 |
}
|
1495 |
|
1496 |
return $methods;
|
1497 |
}
|
1498 |
|
|
|
1499 |
/**
|
1500 |
+
* Minify cache dropdown
|
1501 |
+
*
|
1502 |
+
* @since 2.1.3
|
1503 |
+
* @change 2.1.3
|
1504 |
+
*
|
1505 |
+
* @return array Key => value array
|
1506 |
+
*/
|
1507 |
+
private static function _minify_select() {
|
|
|
|
|
1508 |
return array(
|
1509 |
+
self::MINIFY_DISABLED => esc_html__( 'No minify', 'cachify' ),
|
1510 |
+
self::MINIFY_HTML_ONLY => esc_html__( 'HTML', 'cachify' ),
|
1511 |
+
self::MINIFY_HTML_JS => esc_html__( 'HTML + Inline JavaScript', 'cachify' ),
|
1512 |
);
|
1513 |
}
|
1514 |
|
|
|
1515 |
/**
|
1516 |
+
* Register the language file
|
1517 |
+
*
|
1518 |
+
* @since 2.1.3
|
1519 |
+
* @change 2.1.3
|
1520 |
+
*/
|
1521 |
+
public static function register_textdomain() {
|
|
|
|
|
1522 |
load_plugin_textdomain(
|
1523 |
'cachify',
|
1524 |
false,
|
1527 |
}
|
1528 |
|
1529 |
/**
|
1530 |
+
* Register settings
|
1531 |
+
*
|
1532 |
+
* @since 1.0
|
1533 |
+
* @change 1.0
|
1534 |
+
*/
|
1535 |
+
public static function register_settings() {
|
|
|
|
|
1536 |
register_setting(
|
1537 |
'cachify',
|
1538 |
'cachify',
|
1539 |
array(
|
1540 |
__CLASS__,
|
1541 |
+
'validate_options',
|
1542 |
)
|
1543 |
);
|
1544 |
}
|
1545 |
|
|
|
1546 |
/**
|
1547 |
+
* Validate options
|
1548 |
+
*
|
1549 |
+
* @since 1.0.0
|
1550 |
+
* @change 2.1.3
|
1551 |
+
*
|
1552 |
+
* @param array $data Array of form values.
|
1553 |
+
* @return array Array of validated values.
|
1554 |
+
*/
|
1555 |
+
public static function validate_options( $data ) {
|
|
|
|
|
1556 |
/* Empty data? */
|
1557 |
+
if ( empty( $data ) ) {
|
1558 |
return;
|
1559 |
}
|
1560 |
|
1561 |
+
/* Flush cache */
|
1562 |
+
self::flush_total_cache( true );
|
1563 |
|
1564 |
+
/* Notification */
|
1565 |
+
if ( self::$options['use_apc'] !== $data['use_apc'] && $data['use_apc'] >= self::METHOD_APC ) {
|
1566 |
add_settings_error(
|
1567 |
'cachify_method_tip',
|
1568 |
'cachify_method_tip',
|
1569 |
+
esc_html__( 'The server configuration file (e.g. .htaccess) needs to be adjusted. Please have a look at the setup tab.', 'cachify' ),
|
1570 |
+
'notice-warning'
|
|
|
|
|
|
|
1571 |
);
|
1572 |
}
|
1573 |
|
1574 |
+
/* Return */
|
1575 |
return array(
|
1576 |
+
'only_guests' => (int) ( ! empty( $data['only_guests'] )),
|
1577 |
+
'compress_html' => (int) $data['compress_html'],
|
1578 |
+
'cache_expires' => (int) ( isset( $data['cache_expires'] ) ? $data['cache_expires'] : self::$options['cache_expires'] ),
|
1579 |
+
'without_ids' => (string) isset( $data['without_ids'] ) ? sanitize_text_field( $data['without_ids'] ) : '',
|
1580 |
+
'without_agents' => (string) isset( $data['without_agents'] ) ? sanitize_text_field( $data['without_agents'] ) : '',
|
1581 |
+
'use_apc' => (int) $data['use_apc'],
|
1582 |
+
'reset_on_post' => (int) ( ! empty( $data['reset_on_post'] ) ),
|
1583 |
+
'reset_on_comment' => (int) ( ! empty( $data['reset_on_comment'] )),
|
1584 |
+
'sig_detail' => (int) ( ! empty( $data['sig_detail'] )),
|
1585 |
);
|
1586 |
}
|
1587 |
|
|
|
1588 |
/**
|
1589 |
+
* Display options page
|
1590 |
+
*
|
1591 |
+
* @since 1.0
|
1592 |
+
* @change 2.3.0
|
1593 |
+
*/
|
1594 |
+
public static function options_page() {
|
1595 |
+
$options = self::_get_options();
|
1596 |
+
$cachify_tabs = self::_get_tabs( $options );
|
1597 |
+
$current_tab = isset( $_GET['cachify_tab'] ) && isset( $cachify_tabs[ $_GET['cachify_tab'] ] ) ? $_GET['cachify_tab'] : 'settings';
|
1598 |
+
?>
|
|
|
|
|
|
|
|
|
1599 |
|
1600 |
<div class="wrap" id="cachify_settings">
|
1601 |
+
<h1>Cachify</h1>
|
1602 |
+
|
1603 |
+
<?php
|
1604 |
+
/* Add a navbar if necessary */
|
1605 |
+
if ( count( $cachify_tabs ) > 1 ) {
|
1606 |
+
echo '<h2 class="nav-tab-wrapper">';
|
1607 |
+
foreach ( $cachify_tabs as $tab_key => $tab_data ) {
|
1608 |
+
printf(
|
1609 |
+
'<a class="nav-tab %s" href="%s">%s</a>',
|
1610 |
+
$tab_key === $current_tab ? 'nav-tab-active' : '',
|
1611 |
+
add_query_arg(
|
1612 |
+
array( 'page' => 'cachify', 'cachify_tab' => $tab_key ),
|
1613 |
+
admin_url( 'options-general.php' )
|
1614 |
+
),
|
1615 |
+
esc_html( $tab_data['name'] )
|
1616 |
+
);
|
1617 |
+
}
|
1618 |
+
echo '</h2>';
|
1619 |
+
}
|
1620 |
+
|
1621 |
+
/* Include current tab */
|
1622 |
+
include $cachify_tabs[ $current_tab ]['page'];
|
1623 |
+
|
1624 |
+
/* Include common footer */
|
1625 |
+
include 'cachify.settings_footer.php';
|
1626 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1627 |
</div><?php
|
1628 |
}
|
1629 |
+
|
1630 |
+
/**
|
1631 |
+
* Return an array with all settings tabs applicable in context of current plugin options.
|
1632 |
+
*
|
1633 |
+
* @since 2.3.0
|
1634 |
+
* @change 2.3.0
|
1635 |
+
*
|
1636 |
+
* @param array $options
|
1637 |
+
* @return array
|
1638 |
+
*/
|
1639 |
+
private static function _get_tabs( $options ) {
|
1640 |
+
/* Settings tab is always present */
|
1641 |
+
$tabs = array(
|
1642 |
+
'settings' => array(
|
1643 |
+
'name' => __( 'Settings', 'cachify' ),
|
1644 |
+
'page' => 'cachify.settings.php',
|
1645 |
+
),
|
1646 |
+
);
|
1647 |
+
|
1648 |
+
if ( self::METHOD_HDD === $options['use_apc'] ) {
|
1649 |
+
/* Setup tab for HDD Cache */
|
1650 |
+
$tabs['setup'] = array(
|
1651 |
+
'name' => __( 'Setup', 'cachify' ),
|
1652 |
+
'page' => 'setup/cachify.hdd.' . ( self::$is_nginx ? 'nginx' : 'htaccess' ) . '.php',
|
1653 |
+
);
|
1654 |
+
} elseif ( self::METHOD_APC === $options['use_apc'] ) {
|
1655 |
+
/* Setup tab for APC */
|
1656 |
+
$tabs['setup'] = array(
|
1657 |
+
'name' => __( 'Setup', 'cachify' ),
|
1658 |
+
'page' => 'setup/cachify.apc.' . ( self::$is_nginx ? 'nginx' : 'htaccess' ) . '.php',
|
1659 |
+
);
|
1660 |
+
} elseif ( self::METHOD_MMC === $options['use_apc'] && self::$is_nginx ) {
|
1661 |
+
/* Setup tab for Memcached */
|
1662 |
+
$tabs['setup'] = array(
|
1663 |
+
'name' => __( 'Setup', 'cachify' ),
|
1664 |
+
'page' => 'setup/cachify.memcached.nginx.php',
|
1665 |
+
);
|
1666 |
+
}
|
1667 |
+
|
1668 |
+
return $tabs;
|
1669 |
+
}
|
1670 |
}
|
inc/cachify.settings.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Quit */
|
3 |
+
defined( 'ABSPATH' ) || exit;
|
4 |
+
?>
|
5 |
+
|
6 |
+
<form method="post" action="options.php">
|
7 |
+
<?php settings_fields( 'cachify' ) ?>
|
8 |
+
<table class="form-table">
|
9 |
+
<tr>
|
10 |
+
<th scope="row">
|
11 |
+
<label for="cachify_cache_method"><?php esc_html_e( 'Cache method', 'cachify' ); ?></label>
|
12 |
+
</th>
|
13 |
+
<td>
|
14 |
+
<select name="cachify[use_apc]" id="cachify_cache_method">
|
15 |
+
<?php foreach ( self::_method_select() as $k => $v ) { ?>
|
16 |
+
<option value="<?php echo esc_attr( $k ) ?>" <?php selected( $options['use_apc'], $k ); ?>><?php echo esc_html( $v ) ?></option>
|
17 |
+
<?php } ?>
|
18 |
+
</select>
|
19 |
+
</td>
|
20 |
+
</tr>
|
21 |
+
|
22 |
+
<tr>
|
23 |
+
<th scope="row">
|
24 |
+
<label for="cachify_cache_expires"><?php esc_html_e( 'Cache expiration', 'cachify' ) ?></label>
|
25 |
+
</th>
|
26 |
+
<td>
|
27 |
+
<?php if ( self::METHOD_HDD === $options['use_apc'] ) : ?>
|
28 |
+
<input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="" disabled="disabled" class="small-text" /> Hours
|
29 |
+
<p class="description"><?php esc_html_e( 'HDD cache will only expire as you update posts or flush it yourself.', 'cachify' ); ?></p>
|
30 |
+
<?php else : ?>
|
31 |
+
<input type="number" min="0" step="1" name="cachify[cache_expires]" id="cachify_cache_expires" value="<?php echo esc_attr( $options['cache_expires'] ) ?>" class="small-text" />
|
32 |
+
<?php esc_html_e( 'Hours', 'cachify' ); ?>
|
33 |
+
<?php endif; ?>
|
34 |
+
|
35 |
+
<p class="description">
|
36 |
+
<?php printf(
|
37 |
+
/* translators: Placeholder is the trash icon itself as dashicon */
|
38 |
+
esc_html__( 'Flush the cache by clicking the button below or the %1$s icon in the admin bar.', 'cachify' ),
|
39 |
+
'<span class="dashicons dashicons-trash" aria-hidden="true"></span><span class="screen-reader-text">"' . esc_html__( 'Flush the cachify cache', 'cachify' ) . '"</span>'
|
40 |
+
); ?>
|
41 |
+
</p>
|
42 |
+
|
43 |
+
<p><a class="button button-flush" href="<?php echo wp_nonce_url( add_query_arg( '_cachify', 'flush' ), '_cachify__flush_nonce' ); ?>"><?php esc_html_e( 'Flush cache now', 'cachify' ) ?></a></p>
|
44 |
+
</td>
|
45 |
+
</tr>
|
46 |
+
|
47 |
+
<tr>
|
48 |
+
<th scope="row">
|
49 |
+
<?php esc_html_e( 'Cache generation', 'cachify' ); ?>
|
50 |
+
</th>
|
51 |
+
<td>
|
52 |
+
<fieldset>
|
53 |
+
<label for="cachify_only_guests">
|
54 |
+
<input type="checkbox" name="cachify[only_guests]" id="cachify_only_guests" value="1" <?php checked( '1', $options['only_guests'] ); ?> />
|
55 |
+
<?php esc_html_e( 'No cache generation by logged in users', 'cachify' ); ?>
|
56 |
+
</label>
|
57 |
+
|
58 |
+
<br />
|
59 |
+
|
60 |
+
<label for="cachify_reset_on_post">
|
61 |
+
<input type="checkbox" name="cachify[reset_on_post]" id="cachify_reset_on_post" value="1" <?php checked( '1', $options['reset_on_post'] ); ?> />
|
62 |
+
<?php esc_html_e( 'Flush the cache at modified posts', 'cachify' ); ?>
|
63 |
+
</label>
|
64 |
+
<p class="description">
|
65 |
+
<?php esc_html_e( 'If selected, the site cache will be flushed, otherwise only the modified post is removed from the cache.', 'cachify' ); ?>
|
66 |
+
</p>
|
67 |
+
|
68 |
+
<br>
|
69 |
+
|
70 |
+
<label for="cachify_reset_on_comment">
|
71 |
+
<input type="checkbox" name="cachify[reset_on_comment]" id="cachify_reset_on_comment" value="1" <?php checked( '1', $options['reset_on_comment'] ); ?> />
|
72 |
+
<?php esc_html_e( 'Flush the cache at new comments', 'cachify' ); ?>
|
73 |
+
</label>
|
74 |
+
<p class="description">
|
75 |
+
<?php esc_html_e( 'If selected, the site cache will be flushed, otherwise only the corresponding post is removed from the cache.', 'cachify' ); ?>
|
76 |
+
</p>
|
77 |
+
</fieldset>
|
78 |
+
</td>
|
79 |
+
</tr>
|
80 |
+
|
81 |
+
<tr>
|
82 |
+
<th scope="row">
|
83 |
+
<?php esc_html_e( 'Cache exceptions', 'cachify' ); ?>
|
84 |
+
</th>
|
85 |
+
<td>
|
86 |
+
<fieldset>
|
87 |
+
<label for="cachify_without_ids">
|
88 |
+
<input type="text" name="cachify[without_ids]" id="cachify_without_ids" placeholder="<?php esc_attr_e( 'e.g. 1, 2, 3', 'cachify' ); ?>" value="<?php echo esc_attr( $options['without_ids'] ) ?>" />
|
89 |
+
<?php esc_html_e( 'Post/Pages-IDs', 'cachify' ); ?>
|
90 |
+
</label>
|
91 |
+
|
92 |
+
<br />
|
93 |
+
|
94 |
+
<label for="cachify_without_agents">
|
95 |
+
<input type="text" name="cachify[without_agents]" id="cachify_without_agents" placeholder="<?php esc_attr_e( 'e.g. MSIE 6, Opera', 'cachify' ); ?>" value="<?php echo esc_attr( $options['without_agents'] ) ?>" />
|
96 |
+
<?php esc_html_e( 'Browser User-Agents', 'cachify' ); ?>
|
97 |
+
</label>
|
98 |
+
</fieldset>
|
99 |
+
</td>
|
100 |
+
</tr>
|
101 |
+
|
102 |
+
<tr>
|
103 |
+
<th scope="row">
|
104 |
+
<label for="cachify_compress_html"><?php esc_html_e( 'Cache minify', 'cachify' ); ?></label>
|
105 |
+
</th>
|
106 |
+
<td>
|
107 |
+
<select name="cachify[compress_html]" id="cachify_compress_html">
|
108 |
+
<?php foreach ( self::_minify_select() as $k => $v ) { ?>
|
109 |
+
<option value="<?php echo esc_attr( $k ) ?>" <?php selected( $options['compress_html'], $k ); ?>>
|
110 |
+
<?php echo esc_html( $v ) ?>
|
111 |
+
</option>
|
112 |
+
<?php } ?>
|
113 |
+
</select>
|
114 |
+
</td>
|
115 |
+
</tr>
|
116 |
+
|
117 |
+
<tr>
|
118 |
+
<th scope="row">
|
119 |
+
<?php esc_html_e( 'Cache signature', 'cachify' ); ?>
|
120 |
+
</th>
|
121 |
+
<td>
|
122 |
+
<input type="checkbox" name="cachify[sig_detail]" id="cachify_sig_detail" value="1" <?php checked( '1', $options['sig_detail'] ); ?> />
|
123 |
+
<label for="cachify_sig_detail"><?php esc_html_e( 'Add additional details to Cachify signature (HTML comment)', 'cachify' ); ?></label>
|
124 |
+
</td>
|
125 |
+
</tr>
|
126 |
+
</table>
|
127 |
+
|
128 |
+
<?php submit_button() ?>
|
129 |
+
</form>
|
inc/cachify.settings_footer.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Quit */
|
3 |
+
defined( 'ABSPATH' ) || exit;
|
4 |
+
?>
|
5 |
+
|
6 |
+
<p>
|
7 |
+
<a href="<?php echo esc_url( __( 'https://cachify.pluginkollektiv.org/documentation#faq', 'cachify' ), 'https' ); ?>" rel="noopener noreferrer"><?php esc_html_e( 'FAQ', 'cachify' ); ?></a>
|
8 |
+
• <a href="https://cachify.pluginkollektiv.org/documentation/" rel="noopener noreferrer"><?php esc_html_e( 'Manual', 'cachify' ); ?></a>
|
9 |
+
• <a href="https://wordpress.org/support/plugin/cachify" rel="noopener noreferrer"><?php esc_html_e( 'Support', 'cachify' ); ?></a>
|
10 |
+
• <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Donate', 'cachify' ); ?></a>
|
11 |
+
</p>
|
inc/cachify_apc.class.php
CHANGED
@@ -1,188 +1,148 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
/* Quit */
|
5 |
-
defined('ABSPATH') OR exit;
|
6 |
-
|
7 |
-
|
8 |
/**
|
9 |
* Cachify_APC
|
10 |
*/
|
11 |
-
|
12 |
final class Cachify_APC {
|
13 |
|
14 |
-
|
15 |
/**
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
{
|
26 |
-
return extension_loaded('apc');
|
27 |
}
|
28 |
|
29 |
-
|
30 |
/**
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
public static function stringify_method() {
|
40 |
return 'APC';
|
41 |
}
|
42 |
|
43 |
-
|
44 |
/**
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
public static function store_item($hash, $data, $lifetime)
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
}
|
61 |
|
62 |
/* Store */
|
63 |
apc_store(
|
64 |
$hash,
|
65 |
-
gzencode( $data . self::
|
66 |
$lifetime
|
67 |
);
|
68 |
}
|
69 |
|
70 |
-
|
71 |
/**
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
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 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
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 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
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 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
public static function print_cache()
|
139 |
-
{
|
140 |
return;
|
141 |
}
|
142 |
|
143 |
-
|
144 |
/**
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
if ( empty($data['mem_size']) ) {
|
160 |
-
return NULL;
|
161 |
}
|
162 |
|
163 |
return $data['mem_size'];
|
164 |
}
|
165 |
|
166 |
-
|
167 |
/**
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
private static function
|
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',
|
184 |
-
current_time('timestamp')
|
185 |
)
|
186 |
);
|
187 |
}
|
188 |
-
}
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
/**
|
4 |
* Cachify_APC
|
5 |
*/
|
|
|
6 |
final class Cachify_APC {
|
7 |
|
|
|
8 |
/**
|
9 |
+
* Availability check
|
10 |
+
*
|
11 |
+
* @since 2.0.7
|
12 |
+
* @change 2.0.7
|
13 |
+
*
|
14 |
+
* @return boolean true/false TRUE when installed
|
15 |
+
*/
|
16 |
+
public static function is_available() {
|
17 |
+
return extension_loaded( 'apc' );
|
|
|
|
|
18 |
}
|
19 |
|
|
|
20 |
/**
|
21 |
+
* Caching method as string
|
22 |
+
*
|
23 |
+
* @since 2.1.2
|
24 |
+
* @change 2.1.2
|
25 |
+
*
|
26 |
+
* @return string Caching method
|
27 |
+
*/
|
28 |
+
public static function stringify_method() {
|
|
|
29 |
return 'APC';
|
30 |
}
|
31 |
|
|
|
32 |
/**
|
33 |
+
* Store item in cache
|
34 |
+
*
|
35 |
+
* @since 2.0
|
36 |
+
* @change 2.3.0
|
37 |
+
*
|
38 |
+
* @param string $hash Hash of the entry.
|
39 |
+
* @param string $data Content of the entry.
|
40 |
+
* @param integer $lifetime Lifetime of the entry.
|
41 |
+
* @param bool $sig_detail Show details in signature.
|
42 |
+
*/
|
43 |
+
public static function store_item( $hash, $data, $lifetime, $sig_detail ) {
|
44 |
+
/* Do not store empty data. */
|
45 |
+
if ( empty( $data ) ) {
|
46 |
+
trigger_error( __METHOD__ . ": Empty input.", E_USER_WARNING );
|
47 |
+
return;
|
48 |
}
|
49 |
|
50 |
/* Store */
|
51 |
apc_store(
|
52 |
$hash,
|
53 |
+
gzencode( $data . self::_cache_signature( $sig_detail ), 9 ),
|
54 |
$lifetime
|
55 |
);
|
56 |
}
|
57 |
|
|
|
58 |
/**
|
59 |
+
* Read item from cache
|
60 |
+
*
|
61 |
+
* @since 2.0
|
62 |
+
* @change 2.0
|
63 |
+
*
|
64 |
+
* @param string $hash Hash of the entry.
|
65 |
+
* @return mixed Content of the entry
|
66 |
+
*/
|
67 |
+
public static function get_item( $hash ) {
|
68 |
+
return ( function_exists( 'apc_exists' ) ? apc_exists( $hash ) : apc_fetch( $hash ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
|
|
|
71 |
/**
|
72 |
+
* Delete item from cache
|
73 |
+
*
|
74 |
+
* @since 2.0
|
75 |
+
* @change 2.0
|
76 |
+
*
|
77 |
+
* @param string $hash Hash of the entry.
|
78 |
+
* @param string $url URL of the entry [optional].
|
79 |
+
*/
|
80 |
+
public static function delete_item( $hash, $url = '' ) {
|
81 |
+
apc_delete( $hash );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
|
|
|
84 |
/**
|
85 |
+
* Clear the cache
|
86 |
+
*
|
87 |
+
* @since 2.0.0
|
88 |
+
* @change 2.0.7
|
89 |
+
*/
|
90 |
+
public static function clear_cache() {
|
|
|
|
|
91 |
if ( ! self::is_available() ) {
|
92 |
return;
|
93 |
}
|
94 |
|
95 |
+
@apc_clear_cache( 'user' );
|
96 |
}
|
97 |
|
|
|
98 |
/**
|
99 |
+
* Print the cache
|
100 |
+
*
|
101 |
+
* @since 2.0
|
102 |
+
* @change 2.0
|
103 |
+
*/
|
104 |
+
public static function print_cache() {
|
|
|
|
|
105 |
return;
|
106 |
}
|
107 |
|
|
|
108 |
/**
|
109 |
+
* Get the cache size
|
110 |
+
*
|
111 |
+
* @since 2.0
|
112 |
+
* @change 2.0
|
113 |
+
*
|
114 |
+
* @return mixed Cache size
|
115 |
+
*/
|
116 |
+
public static function get_stats() {
|
117 |
+
/* Info */
|
118 |
+
$data = apc_cache_info( 'user' );
|
119 |
+
|
120 |
+
/* Empty */
|
121 |
+
if ( empty( $data['mem_size'] ) ) {
|
122 |
+
return null;
|
|
|
|
|
123 |
}
|
124 |
|
125 |
return $data['mem_size'];
|
126 |
}
|
127 |
|
|
|
128 |
/**
|
129 |
+
* Generate signature
|
130 |
+
*
|
131 |
+
* @since 2.0
|
132 |
+
* @change 2.3.0
|
133 |
+
*
|
134 |
+
* @param bool $detail Show details in signature.
|
135 |
+
* @return string Signature string
|
136 |
+
*/
|
137 |
+
private static function _cache_signature( $detail ) {
|
|
|
138 |
return sprintf(
|
139 |
"\n\n<!-- %s\n%s @ %s -->",
|
140 |
'Cachify | http://cachify.de',
|
141 |
+
( $detail ? 'APC Cache' : __( 'Generated', 'cachify' ) ),
|
142 |
date_i18n(
|
143 |
'd.m.Y H:i:s',
|
144 |
+
current_time( 'timestamp' )
|
145 |
)
|
146 |
);
|
147 |
}
|
148 |
+
}
|
inc/cachify_cli.class.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Cachify_CLI
|
5 |
+
*/
|
6 |
+
final class Cachify_CLI {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Flush Cache Callback
|
10 |
+
*
|
11 |
+
* @since 2.3.0
|
12 |
+
* @change 2.3.0
|
13 |
+
*
|
14 |
+
* @param array $args
|
15 |
+
* @param array $assoc_args
|
16 |
+
*/
|
17 |
+
public static function flush_cache( $args, $assoc_args ) {
|
18 |
+
|
19 |
+
// set default args
|
20 |
+
$assoc_args = wp_parse_args( $assoc_args, array( 'all-methods' => false ) );
|
21 |
+
|
22 |
+
Cachify::flush_total_cache( $assoc_args['all-methods'] );
|
23 |
+
|
24 |
+
if ( $assoc_args['all-methods'] ) {
|
25 |
+
WP_CLI::success( "All Cachify caches flushed" );
|
26 |
+
} else {
|
27 |
+
WP_CLI::success( "Cachify cache flushed" );
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get cache size
|
34 |
+
*
|
35 |
+
* @since 2.3.0
|
36 |
+
* @change 2.3.0
|
37 |
+
*
|
38 |
+
* @param array $args
|
39 |
+
* @param array $assoc_args
|
40 |
+
*/
|
41 |
+
public static function get_cache_size( $args, $assoc_args ) {
|
42 |
+
|
43 |
+
// set default args
|
44 |
+
$assoc_args = wp_parse_args( $assoc_args, array( 'raw' => false ) );
|
45 |
+
|
46 |
+
// get cache size
|
47 |
+
$cache_size = Cachify::get_cache_size();
|
48 |
+
|
49 |
+
if ( $assoc_args["raw"] ) {
|
50 |
+
$message = $cache_size;
|
51 |
+
} else {
|
52 |
+
$message = "The cache size is $cache_size bytes";
|
53 |
+
}
|
54 |
+
|
55 |
+
WP_CLI::line( $message );
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Register CLI Commands
|
61 |
+
*
|
62 |
+
* @since 2.3.0
|
63 |
+
* @change 2.3.0
|
64 |
+
*/
|
65 |
+
public static function add_commands() {
|
66 |
+
|
67 |
+
/*
|
68 |
+
* Add flush command
|
69 |
+
*/
|
70 |
+
WP_CLI::add_command(
|
71 |
+
'cachify flush',
|
72 |
+
array(
|
73 |
+
'Cachify_CLI',
|
74 |
+
'flush_cache',
|
75 |
+
),
|
76 |
+
array(
|
77 |
+
'shortdesc' => 'Flush site cache',
|
78 |
+
'synopsis' => array(
|
79 |
+
array(
|
80 |
+
'type' => 'flag',
|
81 |
+
'name' => 'all-methods',
|
82 |
+
'description' => 'Flush all caching methods',
|
83 |
+
'optional' => true,
|
84 |
+
)
|
85 |
+
),
|
86 |
+
)
|
87 |
+
);
|
88 |
+
|
89 |
+
/*
|
90 |
+
* Add cache-size command
|
91 |
+
*/
|
92 |
+
WP_CLI::add_command(
|
93 |
+
'cachify cache-size',
|
94 |
+
array(
|
95 |
+
'Cachify_CLI',
|
96 |
+
'get_cache_size',
|
97 |
+
),
|
98 |
+
array(
|
99 |
+
'shortdesc' => 'Get the size of the cache in bytes',
|
100 |
+
'synopsis' => array(
|
101 |
+
array(
|
102 |
+
'type' => 'flag',
|
103 |
+
'name' => 'raw',
|
104 |
+
'description' => 'Raw size output in bytes',
|
105 |
+
'optional' => true,
|
106 |
+
),
|
107 |
+
),
|
108 |
+
)
|
109 |
+
);
|
110 |
+
|
111 |
+
}
|
112 |
+
}
|
inc/cachify_db.class.php
CHANGED
@@ -1,62 +1,49 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
/* Quit */
|
5 |
-
defined('ABSPATH') OR exit;
|
6 |
-
|
7 |
-
|
8 |
/**
|
9 |
* Cachify_DB
|
10 |
*/
|
11 |
-
|
12 |
final class Cachify_DB {
|
13 |
|
14 |
-
|
15 |
/**
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
public static function is_available()
|
25 |
-
{
|
26 |
return true;
|
27 |
}
|
28 |
|
29 |
-
|
30 |
/**
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
public static function stringify_method() {
|
40 |
return 'DB';
|
41 |
}
|
42 |
|
43 |
-
|
44 |
/**
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
wp_die('DB add item: Empty input.');
|
60 |
}
|
61 |
|
62 |
/* Store */
|
@@ -68,205 +55,182 @@ final class Cachify_DB {
|
|
68 |
'queries' => self::_page_queries(),
|
69 |
'timer' => self::_page_timer(),
|
70 |
'memory' => self::_page_memory(),
|
71 |
-
'time' => current_time('timestamp')
|
72 |
-
)
|
73 |
),
|
74 |
$lifetime
|
75 |
);
|
76 |
}
|
77 |
|
78 |
-
|
79 |
/**
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
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 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
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 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
public static function clear_cache()
|
130 |
-
{
|
131 |
/* Init */
|
132 |
global $wpdb;
|
133 |
|
134 |
-
/*
|
135 |
-
$wpdb->query(
|
136 |
}
|
137 |
|
138 |
-
|
139 |
/**
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
public static function print_cache($cache)
|
149 |
-
|
150 |
-
|
151 |
-
if ( ! is_array($cache) ) {
|
152 |
return;
|
153 |
}
|
154 |
|
155 |
/* Content */
|
156 |
echo $cache['data'];
|
157 |
|
158 |
-
/*
|
159 |
-
if ( isset($cache['meta']) ) {
|
160 |
-
echo self::
|
161 |
}
|
162 |
|
163 |
-
/*
|
164 |
exit;
|
165 |
}
|
166 |
|
167 |
-
|
168 |
/**
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
public static function get_stats()
|
178 |
-
{
|
179 |
/* Init */
|
180 |
global $wpdb;
|
181 |
|
182 |
-
/*
|
183 |
return $wpdb->get_var(
|
184 |
-
|
185 |
);
|
186 |
}
|
187 |
|
188 |
-
|
189 |
/**
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
private static function
|
200 |
-
|
201 |
-
|
202 |
-
if ( ! is_array($meta) ) {
|
203 |
return;
|
204 |
}
|
205 |
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
'
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
}
|
227 |
|
228 |
-
|
229 |
/**
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
private static function _page_queries()
|
239 |
-
{
|
240 |
return $GLOBALS['wpdb']->num_queries;
|
241 |
}
|
242 |
|
243 |
-
|
244 |
/**
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
{
|
255 |
-
return timer_stop(0, 2);
|
256 |
}
|
257 |
|
258 |
-
|
259 |
/**
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
{
|
270 |
-
return ( function_exists('memory_get_usage') ? size_format(memory_get_usage(), 2) : 0 );
|
271 |
}
|
272 |
-
}
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
/**
|
4 |
* Cachify_DB
|
5 |
*/
|
|
|
6 |
final class Cachify_DB {
|
7 |
|
|
|
8 |
/**
|
9 |
+
* Availability check
|
10 |
+
*
|
11 |
+
* @since 2.0.7
|
12 |
+
* @change 2.0.7
|
13 |
+
*
|
14 |
+
* @return boolean true/false TRUE when installed
|
15 |
+
*/
|
16 |
+
public static function is_available() {
|
|
|
|
|
17 |
return true;
|
18 |
}
|
19 |
|
|
|
20 |
/**
|
21 |
+
* Caching method as string
|
22 |
+
*
|
23 |
+
* @since 2.1.2
|
24 |
+
* @change 2.1.2
|
25 |
+
*
|
26 |
+
* @return string Caching method
|
27 |
+
*/
|
28 |
+
public static function stringify_method() {
|
|
|
29 |
return 'DB';
|
30 |
}
|
31 |
|
|
|
32 |
/**
|
33 |
+
* Store item in cache
|
34 |
+
*
|
35 |
+
* @since 2.0
|
36 |
+
* @change 2.0
|
37 |
+
*
|
38 |
+
* @param string $hash Hash of the entry.
|
39 |
+
* @param string $data Content of the entry.
|
40 |
+
* @param integer $lifetime Lifetime of the entry.
|
41 |
+
*/
|
42 |
+
public static function store_item( $hash, $data, $lifetime ) {
|
43 |
+
/* Do not store empty data. */
|
44 |
+
if ( empty( $data ) ) {
|
45 |
+
trigger_error( __METHOD__ . ": Empty input.", E_USER_WARNING );
|
46 |
+
return;
|
|
|
47 |
}
|
48 |
|
49 |
/* Store */
|
55 |
'queries' => self::_page_queries(),
|
56 |
'timer' => self::_page_timer(),
|
57 |
'memory' => self::_page_memory(),
|
58 |
+
'time' => current_time( 'timestamp' ),
|
59 |
+
),
|
60 |
),
|
61 |
$lifetime
|
62 |
);
|
63 |
}
|
64 |
|
|
|
65 |
/**
|
66 |
+
* Read item from cache
|
67 |
+
*
|
68 |
+
* @since 2.0
|
69 |
+
* @change 2.0
|
70 |
+
*
|
71 |
+
* @param string $hash Hash of the entry.
|
72 |
+
* @return mixed Content of the entry
|
73 |
+
*/
|
74 |
+
public static function get_item( $hash ) {
|
75 |
+
return get_transient( $hash );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
|
|
78 |
/**
|
79 |
+
* Delete item from cache
|
80 |
+
*
|
81 |
+
* @since 2.0
|
82 |
+
* @change 2.0
|
83 |
+
*
|
84 |
+
* @param string $hash Hash of the entry.
|
85 |
+
* @param string $url URL of the entry [optional].
|
86 |
+
*/
|
87 |
+
public static function delete_item( $hash, $url = '' ) {
|
88 |
+
delete_transient( $hash );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
|
|
|
91 |
/**
|
92 |
+
* Clear the cache
|
93 |
+
*
|
94 |
+
* @since 2.0
|
95 |
+
* @change 2.0
|
96 |
+
*/
|
97 |
+
public static function clear_cache() {
|
|
|
|
|
98 |
/* Init */
|
99 |
global $wpdb;
|
100 |
|
101 |
+
/* Clear */
|
102 |
+
$wpdb->query( 'DELETE FROM `' . $wpdb->options . "` WHERE `option_name` LIKE ('\_transient%.cachify')" );
|
103 |
}
|
104 |
|
|
|
105 |
/**
|
106 |
+
* Print the cache
|
107 |
+
*
|
108 |
+
* @since 2.0
|
109 |
+
* @change 2.3.0
|
110 |
+
*
|
111 |
+
* @param bool $sig_detail Show details in signature.
|
112 |
+
* @param array $cache Array of cache values.
|
113 |
+
*/
|
114 |
+
public static function print_cache( $sig_detail, $cache ) {
|
115 |
+
/* No array? */
|
116 |
+
if ( ! is_array( $cache ) ) {
|
|
|
117 |
return;
|
118 |
}
|
119 |
|
120 |
/* Content */
|
121 |
echo $cache['data'];
|
122 |
|
123 |
+
/* Signature - might contain runtime information, so it's generated at this point */
|
124 |
+
if ( isset( $cache['meta'] ) ) {
|
125 |
+
echo self::_cache_signature( $sig_detail, $cache['meta'] );
|
126 |
}
|
127 |
|
128 |
+
/* Quit */
|
129 |
exit;
|
130 |
}
|
131 |
|
|
|
132 |
/**
|
133 |
+
* Get the cache size
|
134 |
+
*
|
135 |
+
* @since 2.0
|
136 |
+
* @change 2.0
|
137 |
+
*
|
138 |
+
* @return integer Column size
|
139 |
+
*/
|
140 |
+
public static function get_stats() {
|
|
|
|
|
141 |
/* Init */
|
142 |
global $wpdb;
|
143 |
|
144 |
+
/* Read */
|
145 |
return $wpdb->get_var(
|
146 |
+
'SELECT SUM( CHAR_LENGTH(option_value) ) FROM `' . $wpdb->options . "` WHERE `option_name` LIKE ('\_transient%.cachify')"
|
147 |
);
|
148 |
}
|
149 |
|
|
|
150 |
/**
|
151 |
+
* Generate signature
|
152 |
+
*
|
153 |
+
* @since 2.0
|
154 |
+
* @change 2.3.0
|
155 |
+
*
|
156 |
+
* @param bool $detail Show details in signature.
|
157 |
+
* @param array $meta Content of metadata.
|
158 |
+
* @return string Signature string
|
159 |
+
*/
|
160 |
+
private static function _cache_signature( $detail, $meta ) {
|
161 |
+
/* No array? */
|
162 |
+
if ( ! is_array( $meta ) ) {
|
|
|
163 |
return;
|
164 |
}
|
165 |
|
166 |
+
if ( $detail ) {
|
167 |
+
return sprintf(
|
168 |
+
"\n\n<!-- %s\n%s @ %s\n%s\n%s\n-->",
|
169 |
+
'Cachify | http://cachify.de',
|
170 |
+
'DB Cache',
|
171 |
+
date_i18n(
|
172 |
+
'd.m.Y H:i:s',
|
173 |
+
$meta['time']
|
174 |
+
),
|
175 |
+
sprintf(
|
176 |
+
'Without Cachify: %d DB queries, %s seconds, %s',
|
177 |
+
$meta['queries'],
|
178 |
+
$meta['timer'],
|
179 |
+
$meta['memory']
|
180 |
+
),
|
181 |
+
sprintf(
|
182 |
+
'With Cachify: %d DB queries, %s seconds, %s',
|
183 |
+
self::_page_queries(),
|
184 |
+
self::_page_timer(),
|
185 |
+
self::_page_memory()
|
186 |
+
)
|
187 |
+
);
|
188 |
+
} else {
|
189 |
+
return sprintf(
|
190 |
+
"\n\n<!-- %s\n%s @ %s -->",
|
191 |
+
'Cachify | http://cachify.de',
|
192 |
+
__( 'Generated', 'cachify' ),
|
193 |
+
date_i18n(
|
194 |
+
'd.m.Y H:i:s',
|
195 |
+
$meta['time']
|
196 |
+
)
|
197 |
+
);
|
198 |
+
}
|
199 |
}
|
200 |
|
|
|
201 |
/**
|
202 |
+
* Return query count
|
203 |
+
*
|
204 |
+
* @since 0.1
|
205 |
+
* @change 2.0
|
206 |
+
*
|
207 |
+
* @return integer Number of queries
|
208 |
+
*/
|
209 |
+
private static function _page_queries() {
|
|
|
|
|
210 |
return $GLOBALS['wpdb']->num_queries;
|
211 |
}
|
212 |
|
|
|
213 |
/**
|
214 |
+
* Return execution time
|
215 |
+
*
|
216 |
+
* @since 0.1
|
217 |
+
* @change 2.0
|
218 |
+
*
|
219 |
+
* @return integer Execution time in seconds
|
220 |
+
*/
|
221 |
+
private static function _page_timer() {
|
222 |
+
return timer_stop( 0, 2 );
|
|
|
|
|
223 |
}
|
224 |
|
|
|
225 |
/**
|
226 |
+
* Return memory consumption
|
227 |
+
*
|
228 |
+
* @since 0.7
|
229 |
+
* @change 2.0
|
230 |
+
*
|
231 |
+
* @return string Formatted memory size
|
232 |
+
*/
|
233 |
+
private static function _page_memory() {
|
234 |
+
return ( function_exists( 'memory_get_usage' ) ? size_format( memory_get_usage(), 2 ) : 0 );
|
|
|
|
|
235 |
}
|
236 |
+
}
|
inc/cachify_hdd.class.php
CHANGED
@@ -1,392 +1,419 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
/* Quit */
|
5 |
-
defined('ABSPATH') OR exit;
|
6 |
-
|
7 |
-
|
8 |
/**
|
9 |
* Cachify_HDD
|
10 |
*/
|
11 |
-
|
12 |
final class Cachify_HDD {
|
13 |
|
14 |
-
|
15 |
/**
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
return get_option('permalink_structure');
|
27 |
}
|
28 |
|
29 |
-
|
30 |
/**
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
public static function stringify_method() {
|
40 |
return 'HDD';
|
41 |
}
|
42 |
|
43 |
-
|
44 |
/**
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
public static function store_item($hash, $data, $lifetime)
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
}
|
61 |
|
62 |
-
/*
|
63 |
self::_create_files(
|
64 |
-
$data . self::
|
65 |
);
|
66 |
}
|
67 |
|
68 |
-
|
69 |
/**
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
public static function get_item()
|
79 |
-
{
|
80 |
return is_readable(
|
81 |
self::_file_html()
|
82 |
);
|
83 |
}
|
84 |
|
85 |
-
|
86 |
/**
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
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 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
public static function clear_cache()
|
118 |
-
{
|
119 |
self::_clear_dir(
|
120 |
-
CACHIFY_CACHE_DIR
|
|
|
121 |
);
|
122 |
}
|
123 |
|
124 |
-
|
125 |
/**
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
135 |
}
|
136 |
|
137 |
-
|
138 |
/**
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
public static function get_stats()
|
148 |
-
{
|
149 |
return self::_dir_size( CACHIFY_CACHE_DIR );
|
150 |
}
|
151 |
|
152 |
-
|
153 |
/**
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
private static function
|
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',
|
170 |
-
current_time('timestamp')
|
171 |
)
|
172 |
);
|
173 |
}
|
174 |
|
175 |
-
|
176 |
/**
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
/*
|
188 |
-
if ( ! wp_mkdir_p(
|
189 |
-
|
|
|
190 |
}
|
191 |
|
192 |
-
/*
|
193 |
-
self::_create_file( self::_file_html(), $data );
|
194 |
-
self::_create_file( self::_file_gzip(), gzencode($data, 9) );
|
195 |
}
|
196 |
|
197 |
-
|
198 |
/**
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
wp_die('Could not write file.');
|
213 |
}
|
214 |
|
215 |
-
/*
|
216 |
-
@fwrite($handle, $data);
|
217 |
-
fclose($handle);
|
218 |
clearstatcache();
|
219 |
|
220 |
/* Permissions */
|
221 |
-
$stat = @stat( dirname($file) );
|
222 |
$perms = $stat['mode'] & 0007777;
|
223 |
$perms = $perms & 0000666;
|
224 |
-
@chmod($file, $perms);
|
225 |
clearstatcache();
|
226 |
}
|
227 |
|
228 |
-
|
229 |
/**
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
private static function _clear_dir($dir) {
|
239 |
-
/*
|
240 |
-
$dir = untrailingslashit($dir);
|
241 |
-
|
242 |
-
/*
|
243 |
-
if ( ! is_dir($dir) ) {
|
244 |
return;
|
245 |
}
|
246 |
|
247 |
-
/*
|
248 |
$objects = array_diff(
|
249 |
-
scandir($dir),
|
250 |
-
array('..', '.')
|
251 |
);
|
252 |
|
253 |
-
/*
|
254 |
-
if ( empty($objects) ) {
|
255 |
return;
|
256 |
}
|
257 |
|
258 |
-
/*
|
259 |
foreach ( $objects as $object ) {
|
260 |
-
/*
|
261 |
-
$object = $dir. DIRECTORY_SEPARATOR
|
262 |
|
263 |
-
/*
|
264 |
-
if ( is_dir($object) ) {
|
265 |
-
self::_clear_dir($object);
|
266 |
} else {
|
267 |
-
|
|
|
|
|
268 |
}
|
269 |
}
|
270 |
|
271 |
-
/*
|
272 |
-
|
|
|
|
|
|
|
|
|
273 |
|
274 |
-
/*
|
275 |
clearstatcache();
|
276 |
}
|
277 |
|
278 |
-
|
279 |
/**
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
/* Ordner? */
|
292 |
-
if ( ! is_dir($dir) ) {
|
293 |
return;
|
294 |
}
|
295 |
|
296 |
-
/*
|
297 |
$objects = array_diff(
|
298 |
-
scandir($dir),
|
299 |
-
array('..', '.')
|
300 |
);
|
301 |
|
302 |
-
/*
|
303 |
-
if ( empty($objects) ) {
|
304 |
return;
|
305 |
}
|
306 |
|
307 |
/* Init */
|
308 |
$size = 0;
|
309 |
|
310 |
-
/*
|
311 |
foreach ( $objects as $object ) {
|
312 |
-
/*
|
313 |
-
$object = $dir. DIRECTORY_SEPARATOR
|
314 |
|
315 |
-
/*
|
316 |
-
if ( is_dir($object) ) {
|
317 |
-
$size += self::_dir_size($object);
|
318 |
} else {
|
319 |
-
$size += filesize($object);
|
320 |
}
|
321 |
}
|
322 |
|
323 |
return $size;
|
324 |
}
|
325 |
|
326 |
-
|
327 |
/**
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
private static function _file_path($path = NULL)
|
338 |
-
{
|
339 |
$prefix = is_ssl() ? 'https-' : '';
|
340 |
|
|
|
|
|
341 |
$path = sprintf(
|
342 |
'%s%s%s%s%s',
|
343 |
CACHIFY_CACHE_DIR,
|
344 |
DIRECTORY_SEPARATOR,
|
345 |
$prefix,
|
346 |
-
|
347 |
-
|
348 |
-
PHP_URL_HOST
|
349 |
-
),
|
350 |
-
parse_url(
|
351 |
-
( $path ? $path : $_SERVER['REQUEST_URI'] ),
|
352 |
-
PHP_URL_PATH
|
353 |
-
)
|
354 |
);
|
355 |
|
356 |
-
if ( validate_file($path) > 0 ) {
|
357 |
-
wp_die('
|
358 |
}
|
359 |
|
360 |
-
return trailingslashit($path);
|
361 |
}
|
362 |
|
363 |
-
|
364 |
/**
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
private static function _file_html()
|
374 |
-
|
375 |
-
return self::_file_path(). 'index.html';
|
376 |
}
|
377 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
|
379 |
/**
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
}
|
392 |
-
}
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
/**
|
4 |
* Cachify_HDD
|
5 |
*/
|
|
|
6 |
final class Cachify_HDD {
|
7 |
|
|
|
8 |
/**
|
9 |
+
* Availability check
|
10 |
+
*
|
11 |
+
* @since 2.0.7
|
12 |
+
* @change 2.0.7
|
13 |
+
*
|
14 |
+
* @return boolean true/false TRUE when installed
|
15 |
+
*/
|
16 |
+
public static function is_available() {
|
17 |
+
$option = get_option( 'permalink_structure' );
|
18 |
+
return ! empty( $option );
|
|
|
19 |
}
|
20 |
|
|
|
21 |
/**
|
22 |
+
* Caching method as string
|
23 |
+
*
|
24 |
+
* @since 2.1.2
|
25 |
+
* @change 2.1.2
|
26 |
+
*
|
27 |
+
* @return string Caching method
|
28 |
+
*/
|
29 |
+
public static function stringify_method() {
|
|
|
30 |
return 'HDD';
|
31 |
}
|
32 |
|
|
|
33 |
/**
|
34 |
+
* Store item in cache
|
35 |
+
*
|
36 |
+
* @since 2.0
|
37 |
+
* @change 2.3.0
|
38 |
+
*
|
39 |
+
* @param string $hash Hash of the entry [ignored].
|
40 |
+
* @param string $data Content of the entry.
|
41 |
+
* @param integer $lifetime Lifetime of the entry [ignored].
|
42 |
+
* @param bool $sig_detail Show details in signature.
|
43 |
+
*/
|
44 |
+
public static function store_item( $hash, $data, $lifetime, $sig_detail ) {
|
45 |
+
/* Do not store empty data. */
|
46 |
+
if ( empty( $data ) ) {
|
47 |
+
trigger_error( __METHOD__ . ": Empty input.", E_USER_WARNING );
|
48 |
+
return;
|
49 |
}
|
50 |
|
51 |
+
/* Store data */
|
52 |
self::_create_files(
|
53 |
+
$data . self::_cache_signature( $sig_detail )
|
54 |
);
|
55 |
}
|
56 |
|
|
|
57 |
/**
|
58 |
+
* Read item from cache
|
59 |
+
*
|
60 |
+
* @since 2.0
|
61 |
+
* @change 2.0
|
62 |
+
*
|
63 |
+
* @return boolean True if cache is present.
|
64 |
+
*/
|
65 |
+
public static function get_item() {
|
|
|
|
|
66 |
return is_readable(
|
67 |
self::_file_html()
|
68 |
);
|
69 |
}
|
70 |
|
|
|
71 |
/**
|
72 |
+
* Delete item from cache
|
73 |
+
*
|
74 |
+
* @since 2.0
|
75 |
+
* @change 2.0
|
76 |
+
*
|
77 |
+
* @param string $hash Hash of the entry [ignored].
|
78 |
+
* @param string $url URL of the entry.
|
79 |
+
*/
|
80 |
+
public static function delete_item( $hash, $url ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
self::_clear_dir(
|
82 |
+
self::_file_path( $url )
|
83 |
);
|
84 |
}
|
85 |
|
|
|
86 |
/**
|
87 |
+
* Clear the cache
|
88 |
+
*
|
89 |
+
* @since 2.0
|
90 |
+
* @change 2.0
|
91 |
+
*/
|
92 |
+
public static function clear_cache() {
|
|
|
|
|
93 |
self::_clear_dir(
|
94 |
+
CACHIFY_CACHE_DIR,
|
95 |
+
true
|
96 |
);
|
97 |
}
|
98 |
|
|
|
99 |
/**
|
100 |
+
* Print the cache
|
101 |
+
*
|
102 |
+
* @since 2.0
|
103 |
+
* @change 2.3
|
104 |
+
*/
|
105 |
+
public static function print_cache() {
|
106 |
+
$filename = self::_file_html();
|
107 |
+
$size = is_readable( $filename ) ? readfile( $filename ) : false;
|
108 |
+
if ( ! empty ( $size ) ) {
|
109 |
+
/* Ok, cache file has been sent to output. */
|
110 |
+
exit;
|
111 |
+
}
|
112 |
}
|
113 |
|
|
|
114 |
/**
|
115 |
+
* Get the cache size
|
116 |
+
*
|
117 |
+
* @since 2.0
|
118 |
+
* @change 2.0
|
119 |
+
*
|
120 |
+
* @return integer Directory size
|
121 |
+
*/
|
122 |
+
public static function get_stats() {
|
|
|
|
|
123 |
return self::_dir_size( CACHIFY_CACHE_DIR );
|
124 |
}
|
125 |
|
|
|
126 |
/**
|
127 |
+
* Generate signature
|
128 |
+
*
|
129 |
+
* @since 2.0
|
130 |
+
* @change 2.3.0
|
131 |
+
*
|
132 |
+
* @param bool $detail Show details in signature.
|
133 |
+
* @return string Signature string
|
134 |
+
*/
|
135 |
+
private static function _cache_signature( $detail ) {
|
|
|
136 |
return sprintf(
|
137 |
"\n\n<!-- %s\n%s @ %s -->",
|
138 |
'Cachify | http://cachify.de',
|
139 |
+
( $detail ? 'HDD Cache' : __( 'Generated', 'cachify' ) ),
|
140 |
date_i18n(
|
141 |
'd.m.Y H:i:s',
|
142 |
+
current_time( 'timestamp' )
|
143 |
)
|
144 |
);
|
145 |
}
|
146 |
|
|
|
147 |
/**
|
148 |
+
* Initialize caching process
|
149 |
+
*
|
150 |
+
* @since 2.0
|
151 |
+
* @change 2.0
|
152 |
+
*
|
153 |
+
* @param string $data Cache content.
|
154 |
+
*/
|
155 |
+
private static function _create_files( $data ) {
|
156 |
+
$file_path = self::_file_path();
|
157 |
+
|
158 |
+
/* Create directory */
|
159 |
+
if ( ! wp_mkdir_p( $file_path ) ) {
|
160 |
+
trigger_error( __METHOD__ . ": Unable to create directory {$file_path}.", E_USER_WARNING );
|
161 |
+
return;
|
162 |
}
|
163 |
|
164 |
+
/* Write to file */
|
165 |
+
self::_create_file( self::_file_html( $file_path ), $data );
|
166 |
+
self::_create_file( self::_file_gzip( $file_path ), gzencode( $data, 9 ) );
|
167 |
}
|
168 |
|
|
|
169 |
/**
|
170 |
+
* Create cache file
|
171 |
+
*
|
172 |
+
* @since 2.0
|
173 |
+
* @change 2.0
|
174 |
+
*
|
175 |
+
* @param string $file Path to cache file.
|
176 |
+
* @param string $data Cache content.
|
177 |
+
*/
|
178 |
+
private static function _create_file( $file, $data ) {
|
179 |
+
/* Writable? */
|
180 |
+
if ( ! $handle = @fopen( $file, 'wb' ) ) {
|
181 |
+
trigger_error( __METHOD__ . ": Could not write file {$file}.", E_USER_WARNING );
|
182 |
+
return;
|
|
|
183 |
}
|
184 |
|
185 |
+
/* Write */
|
186 |
+
@fwrite( $handle, $data );
|
187 |
+
fclose( $handle );
|
188 |
clearstatcache();
|
189 |
|
190 |
/* Permissions */
|
191 |
+
$stat = @stat( dirname( $file ) );
|
192 |
$perms = $stat['mode'] & 0007777;
|
193 |
$perms = $perms & 0000666;
|
194 |
+
@chmod( $file, $perms );
|
195 |
clearstatcache();
|
196 |
}
|
197 |
|
|
|
198 |
/**
|
199 |
+
* Clear directory
|
200 |
+
*
|
201 |
+
* @since 2.0
|
202 |
+
* @change 2.0.5
|
203 |
+
*
|
204 |
+
* @param string $dir Directory path.
|
205 |
+
* @param boolean $recursive Clear subdirectories?
|
206 |
+
*/
|
207 |
+
private static function _clear_dir( $dir, $recursive = false ) {
|
208 |
+
/* Remote training slash */
|
209 |
+
$dir = untrailingslashit( $dir );
|
210 |
+
|
211 |
+
/* Is directory? */
|
212 |
+
if ( ! is_dir( $dir ) ) {
|
213 |
return;
|
214 |
}
|
215 |
|
216 |
+
/* Read */
|
217 |
$objects = array_diff(
|
218 |
+
scandir( $dir ),
|
219 |
+
array( '..', '.' )
|
220 |
);
|
221 |
|
222 |
+
/* Empty? */
|
223 |
+
if ( empty( $objects ) ) {
|
224 |
return;
|
225 |
}
|
226 |
|
227 |
+
/* Loop over items */
|
228 |
foreach ( $objects as $object ) {
|
229 |
+
/* Expand path */
|
230 |
+
$object = $dir . DIRECTORY_SEPARATOR . $object;
|
231 |
|
232 |
+
/* Directory or file */
|
233 |
+
if ( is_dir( $object ) && $recursive ) {
|
234 |
+
self::_clear_dir( $object, $recursive );
|
235 |
} else {
|
236 |
+
if ( self::_user_can_delete( $object ) ) {
|
237 |
+
unlink( $object );
|
238 |
+
}
|
239 |
}
|
240 |
}
|
241 |
|
242 |
+
/* Remove directory */
|
243 |
+
if ( $recursive ) {
|
244 |
+
if ( self::_user_can_delete( $dir ) && 0 === count( glob( trailingslashit( $dir ) . '*' ) ) ) {
|
245 |
+
@rmdir( $dir );
|
246 |
+
}
|
247 |
+
}
|
248 |
|
249 |
+
/* Clean up */
|
250 |
clearstatcache();
|
251 |
}
|
252 |
|
|
|
253 |
/**
|
254 |
+
* Get directory size
|
255 |
+
*
|
256 |
+
* @since 2.0
|
257 |
+
* @change 2.0
|
258 |
+
*
|
259 |
+
* @param string $dir Directory path.
|
260 |
+
* @return mixed Directory size
|
261 |
+
*/
|
262 |
+
public static function _dir_size( $dir = '.' ) {
|
263 |
+
/* Is directory? */
|
264 |
+
if ( ! is_dir( $dir ) ) {
|
|
|
|
|
265 |
return;
|
266 |
}
|
267 |
|
268 |
+
/* Read */
|
269 |
$objects = array_diff(
|
270 |
+
scandir( $dir ),
|
271 |
+
array( '..', '.' )
|
272 |
);
|
273 |
|
274 |
+
/* Empty? */
|
275 |
+
if ( empty( $objects ) ) {
|
276 |
return;
|
277 |
}
|
278 |
|
279 |
/* Init */
|
280 |
$size = 0;
|
281 |
|
282 |
+
/* Loop over items */
|
283 |
foreach ( $objects as $object ) {
|
284 |
+
/* Expand path */
|
285 |
+
$object = $dir . DIRECTORY_SEPARATOR . $object;
|
286 |
|
287 |
+
/* Directory or file */
|
288 |
+
if ( is_dir( $object ) ) {
|
289 |
+
$size += self::_dir_size( $object );
|
290 |
} else {
|
291 |
+
$size += filesize( $object );
|
292 |
}
|
293 |
}
|
294 |
|
295 |
return $size;
|
296 |
}
|
297 |
|
|
|
298 |
/**
|
299 |
+
* Path to cache file
|
300 |
+
*
|
301 |
+
* @since 2.0
|
302 |
+
* @change 2.0
|
303 |
+
*
|
304 |
+
* @param string $path Request URI or permalink [optional].
|
305 |
+
* @return string Path to cache file
|
306 |
+
*/
|
307 |
+
private static function _file_path( $path = null ) {
|
|
|
|
|
308 |
$prefix = is_ssl() ? 'https-' : '';
|
309 |
|
310 |
+
$path_parts = wp_parse_url( $path ? $path : $_SERVER['REQUEST_URI'] );
|
311 |
+
|
312 |
$path = sprintf(
|
313 |
'%s%s%s%s%s',
|
314 |
CACHIFY_CACHE_DIR,
|
315 |
DIRECTORY_SEPARATOR,
|
316 |
$prefix,
|
317 |
+
strtolower( $_SERVER['HTTP_HOST'] ),
|
318 |
+
$path_parts['path']
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
);
|
320 |
|
321 |
+
if ( validate_file( $path ) > 0 ) {
|
322 |
+
wp_die( 'Invalid file path.' );
|
323 |
}
|
324 |
|
325 |
+
return trailingslashit( $path );
|
326 |
}
|
327 |
|
|
|
328 |
/**
|
329 |
+
* Path to HTML file
|
330 |
+
*
|
331 |
+
* @since 2.0
|
332 |
+
* @change 2.3.0
|
333 |
+
*
|
334 |
+
* @param string $file_path File path [optional].
|
335 |
+
* @return string Path to HTML file
|
336 |
+
*/
|
337 |
+
private static function _file_html( $file_path = '' ) {
|
338 |
+
return ( empty( $file_path ) ? self::_file_path() : $file_path ) . 'index.html';
|
|
|
339 |
}
|
340 |
|
341 |
+
/**
|
342 |
+
* Path to GZIP file
|
343 |
+
*
|
344 |
+
* @since 2.0
|
345 |
+
* @change 2.3.0
|
346 |
+
*
|
347 |
+
* @param string $file_path File path [optional].
|
348 |
+
* @return string Path to GZIP file
|
349 |
+
*/
|
350 |
+
private static function _file_gzip( $file_path = '' ) {
|
351 |
+
return ( empty( $file_path ) ? self::_file_path() : $file_path ) . 'index.html.gz';
|
352 |
+
}
|
353 |
|
354 |
/**
|
355 |
+
* Does the user has the right to delete this file?
|
356 |
+
*
|
357 |
+
* @param string $file
|
358 |
+
*
|
359 |
+
* @return bool
|
360 |
+
*/
|
361 |
+
private static function _user_can_delete( $file ) {
|
362 |
+
|
363 |
+
if ( ! is_file( $file ) && ! is_dir( $file ) ) {
|
364 |
+
return false;
|
365 |
+
}
|
366 |
+
|
367 |
+
if ( 0 !== strpos( $file, CACHIFY_CACHE_DIR ) ) {
|
368 |
+
return false;
|
369 |
+
}
|
370 |
+
|
371 |
+
// If its just a single blog, the user has the right to delete this file.
|
372 |
+
// But also, if you are in the network admin, you should be able to delete all files.
|
373 |
+
if ( ! is_multisite() || is_network_admin() ) {
|
374 |
+
return true;
|
375 |
+
}
|
376 |
+
|
377 |
+
if ( is_dir( $file ) ) {
|
378 |
+
$file = trailingslashit( $file );
|
379 |
+
}
|
380 |
+
|
381 |
+
$ssl_prefix = is_ssl() ? 'https-' : '';
|
382 |
+
$current_blog = get_blog_details( get_current_blog_id() );
|
383 |
+
$blog_path = CACHIFY_CACHE_DIR . DIRECTORY_SEPARATOR . $ssl_prefix . $current_blog->domain . $current_blog->path;
|
384 |
+
|
385 |
+
if ( 0 !== strpos( $file, $blog_path ) ) {
|
386 |
+
return false;
|
387 |
+
}
|
388 |
+
|
389 |
+
// We are on a subdirectory installation and the current blog is in a subdirectory
|
390 |
+
if ( '/' !== $current_blog->path ) {
|
391 |
+
return true;
|
392 |
+
}
|
393 |
+
|
394 |
+
// If we are on the root blog in a subdirectory multisite we check if the current dir is the root dir
|
395 |
+
$root_site_dir = CACHIFY_CACHE_DIR . DIRECTORY_SEPARATOR . $ssl_prefix . DOMAIN_CURRENT_SITE . DIRECTORY_SEPARATOR;
|
396 |
+
if ( $root_site_dir === $file ) {
|
397 |
+
return false;
|
398 |
+
}
|
399 |
+
|
400 |
+
// If we are on the root blog in a subdirectory multisite, we check, if the current file
|
401 |
+
// is part of another blog.
|
402 |
+
global $wpdb;
|
403 |
+
$sql = $wpdb->prepare(
|
404 |
+
'select path from ' . $wpdb->base_prefix . 'blogs where domain = %s && blog_id != %d',
|
405 |
+
$current_blog->domain,
|
406 |
+
$current_blog->blog_id
|
407 |
+
);
|
408 |
+
$results = $wpdb->get_col( $sql );
|
409 |
+
foreach ( $results as $site ) {
|
410 |
+
$forbidden_path = CACHIFY_CACHE_DIR . DIRECTORY_SEPARATOR . $ssl_prefix . $current_blog->domain . $site;
|
411 |
+
if ( 0 === strpos( $file, $forbidden_path ) ) {
|
412 |
+
return false;
|
413 |
+
}
|
414 |
+
}
|
415 |
+
|
416 |
+
return true;
|
417 |
+
|
418 |
}
|
419 |
+
}
|
inc/cachify_memcached.class.php
CHANGED
@@ -1,72 +1,59 @@
|
|
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 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
private static $_memcached;
|
23 |
|
24 |
-
|
25 |
/**
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
{
|
36 |
-
return class_exists('Memcached') && isset($_SERVER['SERVER_SOFTWARE']) && strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'nginx') !== false;
|
37 |
}
|
38 |
|
39 |
-
|
40 |
/**
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
public static function stringify_method() {
|
50 |
return 'Memcached';
|
51 |
}
|
52 |
|
53 |
-
|
54 |
/**
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
public static function store_item($hash, $data, $lifetime)
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
}
|
71 |
|
72 |
/* Server connect */
|
@@ -77,24 +64,21 @@ final class Cachify_MEMCACHED {
|
|
77 |
/* Add item */
|
78 |
self::$_memcached->set(
|
79 |
self::_file_path(),
|
80 |
-
$data . self::
|
81 |
$lifetime
|
82 |
);
|
83 |
}
|
84 |
|
85 |
-
|
86 |
/**
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
public static function get_item($hash)
|
97 |
-
{
|
98 |
/* Server connect */
|
99 |
if ( ! self::_connect_server() ) {
|
100 |
return;
|
@@ -106,19 +90,16 @@ final class Cachify_MEMCACHED {
|
|
106 |
);
|
107 |
}
|
108 |
|
109 |
-
|
110 |
/**
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
public static function delete_item($hash, $url = '')
|
121 |
-
{
|
122 |
/* Server connect */
|
123 |
if ( ! self::_connect_server() ) {
|
124 |
return;
|
@@ -126,20 +107,17 @@ final class Cachify_MEMCACHED {
|
|
126 |
|
127 |
/* Delete */
|
128 |
self::$_memcached->delete(
|
129 |
-
self::_file_path($url)
|
130 |
);
|
131 |
}
|
132 |
|
133 |
-
|
134 |
/**
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
public static function clear_cache()
|
142 |
-
{
|
143 |
/* Server connect */
|
144 |
if ( ! self::_connect_server() ) {
|
145 |
return;
|
@@ -149,124 +127,109 @@ final class Cachify_MEMCACHED {
|
|
149 |
@self::$_memcached->flush();
|
150 |
}
|
151 |
|
152 |
-
|
153 |
/**
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
public static function print_cache()
|
161 |
-
{
|
162 |
return;
|
163 |
}
|
164 |
|
165 |
-
|
166 |
/**
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
public static function get_stats()
|
176 |
-
{
|
177 |
/* Server connect */
|
178 |
if ( ! self::_connect_server() ) {
|
179 |
-
|
180 |
}
|
181 |
|
182 |
-
/*
|
183 |
$data = self::$_memcached->getStats();
|
184 |
|
185 |
/* No stats? */
|
186 |
-
if ( empty($data) ) {
|
187 |
-
return
|
188 |
}
|
189 |
|
190 |
/* Get first key */
|
191 |
-
$data = $data[key($data)];
|
192 |
|
193 |
-
/*
|
194 |
-
if ( empty($data['bytes']) ) {
|
195 |
-
return
|
196 |
}
|
197 |
|
198 |
return $data['bytes'];
|
199 |
}
|
200 |
|
201 |
-
|
202 |
/**
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
private static function
|
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 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
|
|
|
|
234 |
|
235 |
-
private static function _file_path($path = NULL)
|
236 |
-
{
|
237 |
return trailingslashit(
|
238 |
sprintf(
|
239 |
'%s%s',
|
240 |
$_SERVER['HTTP_HOST'],
|
241 |
-
|
242 |
-
( $path ? $path : $_SERVER['REQUEST_URI'] ),
|
243 |
-
PHP_URL_PATH
|
244 |
-
)
|
245 |
)
|
246 |
);
|
247 |
}
|
248 |
|
249 |
-
|
250 |
/**
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
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 |
|
@@ -274,7 +237,7 @@ final class Cachify_MEMCACHED {
|
|
274 |
self::$_memcached = new Memcached();
|
275 |
|
276 |
/* Set options */
|
277 |
-
if ( defined('HHVM_VERSION') ) {
|
278 |
self::$_memcached->setOption( Memcached::OPT_COMPRESSION, false );
|
279 |
self::$_memcached->setOption( Memcached::OPT_BUFFER_WRITES, true );
|
280 |
self::$_memcached->setOption( Memcached::OPT_BINARY_PROTOCOL, true );
|
@@ -283,24 +246,24 @@ final class Cachify_MEMCACHED {
|
|
283 |
array(
|
284 |
Memcached::OPT_COMPRESSION => false,
|
285 |
Memcached::OPT_BUFFER_WRITES => true,
|
286 |
-
Memcached::OPT_BINARY_PROTOCOL => true
|
287 |
)
|
288 |
);
|
289 |
}
|
290 |
|
291 |
/* Connect */
|
292 |
self::$_memcached->addServers(
|
293 |
-
(array)apply_filters(
|
294 |
'cachify_memcached_servers',
|
295 |
array(
|
296 |
array(
|
297 |
'127.0.0.1',
|
298 |
-
11211
|
299 |
-
)
|
300 |
)
|
301 |
)
|
302 |
);
|
303 |
|
304 |
return true;
|
305 |
}
|
306 |
-
}
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
/**
|
4 |
* Cachify_MEMCACHED
|
5 |
*/
|
|
|
6 |
final class Cachify_MEMCACHED {
|
7 |
|
|
|
8 |
/**
|
9 |
+
* Memcached-Object
|
10 |
+
*
|
11 |
+
* @since 2.0.7
|
12 |
+
* @var object
|
13 |
+
*/
|
14 |
|
15 |
private static $_memcached;
|
16 |
|
|
|
17 |
/**
|
18 |
+
* Availability check
|
19 |
+
*
|
20 |
+
* @since 2.0.7
|
21 |
+
* @change 2.0.7
|
22 |
+
*
|
23 |
+
* @return boolean true/false TRUE when installed
|
24 |
+
*/
|
25 |
+
public static function is_available() {
|
26 |
+
return class_exists( 'Memcached' ) && isset( $_SERVER['SERVER_SOFTWARE'] ) && strpos( strtolower( $_SERVER['SERVER_SOFTWARE'] ), 'nginx' ) !== false;
|
|
|
|
|
27 |
}
|
28 |
|
|
|
29 |
/**
|
30 |
+
* Caching method as string
|
31 |
+
*
|
32 |
+
* @since 2.1.2
|
33 |
+
* @change 2.1.2
|
34 |
+
*
|
35 |
+
* @return string Caching method
|
36 |
+
*/
|
37 |
+
public static function stringify_method() {
|
|
|
38 |
return 'Memcached';
|
39 |
}
|
40 |
|
|
|
41 |
/**
|
42 |
+
* Store item in cache
|
43 |
+
*
|
44 |
+
* @since 2.0.7
|
45 |
+
* @change 2.3.0
|
46 |
+
*
|
47 |
+
* @param string $hash Hash of the entry [ignored].
|
48 |
+
* @param string $data Content of the entry.
|
49 |
+
* @param integer $lifetime Lifetime of the entry.
|
50 |
+
* @param bool $sigDetail Show details in signature.
|
51 |
+
*/
|
52 |
+
public static function store_item( $hash, $data, $lifetime, $sigDetail ) {
|
53 |
+
/* Do not store empty data. */
|
54 |
+
if ( empty( $data ) ) {
|
55 |
+
trigger_error( __METHOD__ . ": Empty input.", E_USER_WARNING );
|
56 |
+
return;
|
57 |
}
|
58 |
|
59 |
/* Server connect */
|
64 |
/* Add item */
|
65 |
self::$_memcached->set(
|
66 |
self::_file_path(),
|
67 |
+
$data . self::_cache_signature( $sigDetail ),
|
68 |
$lifetime
|
69 |
);
|
70 |
}
|
71 |
|
|
|
72 |
/**
|
73 |
+
* Read item from cache
|
74 |
+
*
|
75 |
+
* @since 2.0.7
|
76 |
+
* @change 2.0.7
|
77 |
+
*
|
78 |
+
* @param string $hash Hash of the entry.
|
79 |
+
* @return mixed Content of the entry
|
80 |
+
*/
|
81 |
+
public static function get_item( $hash ) {
|
|
|
|
|
82 |
/* Server connect */
|
83 |
if ( ! self::_connect_server() ) {
|
84 |
return;
|
90 |
);
|
91 |
}
|
92 |
|
|
|
93 |
/**
|
94 |
+
* Delete item from cache
|
95 |
+
*
|
96 |
+
* @since 2.0.7
|
97 |
+
* @change 2.0.7
|
98 |
+
*
|
99 |
+
* @param string $hash Hash of the entry.
|
100 |
+
* @param string $url URL of the entry [optional].
|
101 |
+
*/
|
102 |
+
public static function delete_item( $hash, $url = '' ) {
|
|
|
|
|
103 |
/* Server connect */
|
104 |
if ( ! self::_connect_server() ) {
|
105 |
return;
|
107 |
|
108 |
/* Delete */
|
109 |
self::$_memcached->delete(
|
110 |
+
self::_file_path( $url )
|
111 |
);
|
112 |
}
|
113 |
|
|
|
114 |
/**
|
115 |
+
* Clear the cache
|
116 |
+
*
|
117 |
+
* @since 2.0.7
|
118 |
+
* @change 2.0.7
|
119 |
+
*/
|
120 |
+
public static function clear_cache() {
|
|
|
|
|
121 |
/* Server connect */
|
122 |
if ( ! self::_connect_server() ) {
|
123 |
return;
|
127 |
@self::$_memcached->flush();
|
128 |
}
|
129 |
|
|
|
130 |
/**
|
131 |
+
* Print the cache
|
132 |
+
*
|
133 |
+
* @since 2.0.7
|
134 |
+
* @change 2.0.7
|
135 |
+
*/
|
136 |
+
public static function print_cache() {
|
|
|
|
|
137 |
return;
|
138 |
}
|
139 |
|
|
|
140 |
/**
|
141 |
+
* Get the cache size
|
142 |
+
*
|
143 |
+
* @since 2.0.7
|
144 |
+
* @change 2.0.7
|
145 |
+
*
|
146 |
+
* @return mixed Cache size
|
147 |
+
*/
|
148 |
+
public static function get_stats() {
|
|
|
|
|
149 |
/* Server connect */
|
150 |
if ( ! self::_connect_server() ) {
|
151 |
+
return null;
|
152 |
}
|
153 |
|
154 |
+
/* Info */
|
155 |
$data = self::$_memcached->getStats();
|
156 |
|
157 |
/* No stats? */
|
158 |
+
if ( empty( $data ) ) {
|
159 |
+
return null;
|
160 |
}
|
161 |
|
162 |
/* Get first key */
|
163 |
+
$data = $data[ key( $data ) ];
|
164 |
|
165 |
+
/* Empty */
|
166 |
+
if ( empty( $data['bytes'] ) ) {
|
167 |
+
return null;
|
168 |
}
|
169 |
|
170 |
return $data['bytes'];
|
171 |
}
|
172 |
|
|
|
173 |
/**
|
174 |
+
* Generate signature
|
175 |
+
*
|
176 |
+
* @since 2.0.7
|
177 |
+
* @change 2.3.0
|
178 |
+
*
|
179 |
+
* @param bool $detail Show details in signature.
|
180 |
+
* @return string Signature string
|
181 |
+
*/
|
182 |
+
private static function _cache_signature( $detail ) {
|
|
|
183 |
return sprintf(
|
184 |
"\n\n<!-- %s\n%s @ %s -->",
|
185 |
'Cachify | http://cachify.de',
|
186 |
+
( $detail ? 'Memcached' : __( 'Generated', 'cachify' ) ),
|
187 |
date_i18n(
|
188 |
'd.m.Y H:i:s',
|
189 |
+
current_time( 'timestamp' )
|
190 |
)
|
191 |
);
|
192 |
}
|
193 |
|
|
|
194 |
/**
|
195 |
+
* Path of cache file
|
196 |
+
*
|
197 |
+
* @since 2.0.7
|
198 |
+
* @change 2.0.7
|
199 |
+
*
|
200 |
+
* @param string $path Request URI or permalink [optional].
|
201 |
+
* @return string Path to cache file
|
202 |
+
*/
|
203 |
+
private static function _file_path( $path = null ) {
|
204 |
+
$path_parts = wp_parse_url( $path ? $path : $_SERVER['REQUEST_URI'] );
|
205 |
|
|
|
|
|
206 |
return trailingslashit(
|
207 |
sprintf(
|
208 |
'%s%s',
|
209 |
$_SERVER['HTTP_HOST'],
|
210 |
+
$path_parts['path']
|
|
|
|
|
|
|
211 |
)
|
212 |
);
|
213 |
}
|
214 |
|
|
|
215 |
/**
|
216 |
+
* Connect to Memcached server
|
217 |
+
*
|
218 |
+
* @since 2.0.7
|
219 |
+
* @change 2.1.8
|
220 |
+
*
|
221 |
+
* @hook array cachify_memcached_servers Array with memcached servers
|
222 |
+
*
|
223 |
+
* @return boolean true/false TRUE on success
|
224 |
+
*/
|
225 |
+
private static function _connect_server() {
|
|
|
|
|
226 |
/* Not enabled? */
|
227 |
if ( ! self::is_available() ) {
|
228 |
return false;
|
229 |
}
|
230 |
|
231 |
/* Already connected */
|
232 |
+
if ( is_object( self::$_memcached ) ) {
|
233 |
return true;
|
234 |
}
|
235 |
|
237 |
self::$_memcached = new Memcached();
|
238 |
|
239 |
/* Set options */
|
240 |
+
if ( defined( 'HHVM_VERSION' ) ) {
|
241 |
self::$_memcached->setOption( Memcached::OPT_COMPRESSION, false );
|
242 |
self::$_memcached->setOption( Memcached::OPT_BUFFER_WRITES, true );
|
243 |
self::$_memcached->setOption( Memcached::OPT_BINARY_PROTOCOL, true );
|
246 |
array(
|
247 |
Memcached::OPT_COMPRESSION => false,
|
248 |
Memcached::OPT_BUFFER_WRITES => true,
|
249 |
+
Memcached::OPT_BINARY_PROTOCOL => true,
|
250 |
)
|
251 |
);
|
252 |
}
|
253 |
|
254 |
/* Connect */
|
255 |
self::$_memcached->addServers(
|
256 |
+
(array) apply_filters(
|
257 |
'cachify_memcached_servers',
|
258 |
array(
|
259 |
array(
|
260 |
'127.0.0.1',
|
261 |
+
11211,
|
262 |
+
),
|
263 |
)
|
264 |
)
|
265 |
);
|
266 |
|
267 |
return true;
|
268 |
}
|
269 |
+
}
|
inc/setup/cachify.apc.htaccess.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Quit */
|
3 |
+
defined( 'ABSPATH' ) || exit;
|
4 |
+
|
5 |
+
$beginning = '<Files index.php>
|
6 |
+
php_value auto_prepend_file ';
|
7 |
+
|
8 |
+
$ending = '/cachify/apc/proxy.php
|
9 |
+
</Files>';
|
10 |
+
|
11 |
+
?>
|
12 |
+
|
13 |
+
<table class="form-table">
|
14 |
+
<tr>
|
15 |
+
<th>
|
16 |
+
<?php esc_html_e( '.htaccess APC setup', 'cachify' ); ?>
|
17 |
+
</th>
|
18 |
+
<td>
|
19 |
+
<label for="cachify_setup">
|
20 |
+
<?php esc_html_e( 'Please add the following lines to your .htaccess file', 'cachify' ); ?>
|
21 |
+
</label>
|
22 |
+
</td>
|
23 |
+
</tr>
|
24 |
+
</table>
|
25 |
+
|
26 |
+
<div style="background:#fff;border:1px solid #ccc;padding:10px 20px">
|
27 |
+
<pre style="white-space: pre-wrap"><?php echo sprintf( '%s%s%s',
|
28 |
+
$beginning,
|
29 |
+
WP_PLUGIN_DIR,
|
30 |
+
$ending ); ?></pre>
|
31 |
+
</div>
|
inc/setup/cachify.apc.nginx.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Quit */
|
3 |
+
defined( 'ABSPATH' ) || exit;
|
4 |
+
|
5 |
+
$beginning = 'location ~ .php {
|
6 |
+
include fastcgi_params;
|
7 |
+
fastcgi_pass 127.0.0.1:9000;
|
8 |
+
<strong>fastcgi_param PHP_VALUE auto_prepend_file=';
|
9 |
+
|
10 |
+
$ending = '/cachify/apc/proxy.php</strong>;
|
11 |
+
|
12 |
+
location ~ /wp-admin/ {
|
13 |
+
include fastcgi_params;
|
14 |
+
fastcgi_pass 127.0.0.1:9000;
|
15 |
+
<strong>fastcgi_param PHP_VALUE auto_prepend_file=</strong>;
|
16 |
+
}
|
17 |
+
}';
|
18 |
+
|
19 |
+
?>
|
20 |
+
|
21 |
+
<table class="form-table">
|
22 |
+
<tr>
|
23 |
+
<th>
|
24 |
+
<?php esc_html_e( 'nginx APC setup', 'cachify' ); ?>
|
25 |
+
</th>
|
26 |
+
<td>
|
27 |
+
<label for="cachify_setup">
|
28 |
+
<?php esc_html_e( 'Please add the following lines to your nginx PHP configuration', 'cachify' ); ?>
|
29 |
+
</label>
|
30 |
+
</td>
|
31 |
+
</tr>
|
32 |
+
</table>
|
33 |
+
|
34 |
+
<div style="background:#fff;border:1px solid #ccc;padding:10px 20px">
|
35 |
+
<pre style="white-space: pre-wrap"><?php echo sprintf( '%s%s%s',
|
36 |
+
$beginning,
|
37 |
+
WP_PLUGIN_DIR,
|
38 |
+
$ending ); ?></pre>
|
39 |
+
</div>
|
40 |
+
|
41 |
+
<small>(<?php esc_html_e( 'You might need to adjust the non-highlighted lines to your needs.', 'cachify' ); ?>)</small>
|
inc/setup/cachify.hdd.htaccess.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Quit */
|
3 |
+
defined( 'ABSPATH' ) || exit;
|
4 |
+
|
5 |
+
$beginning = '# BEGIN CACHIFY
|
6 |
+
<IfModule mod_rewrite.c>
|
7 |
+
# ENGINE ON
|
8 |
+
RewriteEngine on
|
9 |
+
|
10 |
+
# set hostname directory
|
11 |
+
RewriteCond %{HTTPS} on
|
12 |
+
RewriteRule .* - [E=CACHIFY_HOST:https-%{HTTP_HOST}]
|
13 |
+
RewriteCond %{HTTPS} off
|
14 |
+
RewriteRule .* - [E=CACHIFY_HOST:%{HTTP_HOST}]
|
15 |
+
|
16 |
+
# set subdirectory
|
17 |
+
RewriteCond %{REQUEST_URI} /$
|
18 |
+
RewriteRule .* - [E=CACHIFY_DIR:%{REQUEST_URI}]
|
19 |
+
RewriteCond %{REQUEST_URI} ^$
|
20 |
+
RewriteRule .* - [E=CACHIFY_DIR:/]
|
21 |
+
|
22 |
+
# gzip
|
23 |
+
RewriteRule .* - [E=CACHIFY_SUFFIX:]
|
24 |
+
<IfModule mod_mime.c>
|
25 |
+
RewriteCond %{HTTP:Accept-Encoding} gzip
|
26 |
+
RewriteRule .* - [E=CACHIFY_SUFFIX:.gz]
|
27 |
+
AddType text/html .gz
|
28 |
+
AddEncoding gzip .gz
|
29 |
+
</IfModule>
|
30 |
+
|
31 |
+
# Main Rules
|
32 |
+
RewriteCond %{REQUEST_METHOD} !=POST
|
33 |
+
RewriteCond %{QUERY_STRING} =""
|
34 |
+
RewriteCond %{REQUEST_URI} !^/(wp-admin|wp-content/cache)/.*
|
35 |
+
RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_
|
36 |
+
RewriteCond ';
|
37 |
+
|
38 |
+
$middle = '/cache/cachify/%{ENV:CACHIFY_HOST}%{ENV:CACHIFY_DIR}index.html -f
|
39 |
+
RewriteRule ^(.*) ';
|
40 |
+
|
41 |
+
$ending = '/cache/cachify/%{ENV:CACHIFY_HOST}%{ENV:CACHIFY_DIR}index.html%{ENV:CACHIFY_SUFFIX} [L]
|
42 |
+
</IfModule>
|
43 |
+
# END CACHIFY';
|
44 |
+
?>
|
45 |
+
|
46 |
+
<table class="form-table">
|
47 |
+
<tr>
|
48 |
+
<th>
|
49 |
+
<?php esc_html_e( '.htaccess HDD setup', 'cachify' ); ?>
|
50 |
+
</th>
|
51 |
+
<td>
|
52 |
+
<?php esc_html_e( 'Please add the following lines to your .htaccess file', 'cachify' ); ?>
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
|
56 |
+
<tr>
|
57 |
+
<th>
|
58 |
+
<?php esc_html_e( 'Notes', 'cachify' ); ?>
|
59 |
+
</th>
|
60 |
+
<td>
|
61 |
+
<ul style="list-style-type:circle">
|
62 |
+
<li>
|
63 |
+
<?php esc_html_e( 'Within .htaccess, the extension has a higher priority and must be placed above the WordPress Rewrite rules (marked mostly by # BEGIN WordPress … # END WordPress).', 'cachify' ); ?>
|
64 |
+
</li>
|
65 |
+
<li>
|
66 |
+
<?php esc_html_e( 'Changes to the .htaccess file can not be made if PHP is run as fcgi.', 'cachify' ); ?>
|
67 |
+
</li>
|
68 |
+
<li>
|
69 |
+
<?php esc_html_e( 'If there are partial errors in the redirects within the blog, the shutdown of the Apache Content Cache can help:', 'cachify' ); ?><br />
|
70 |
+
<pre><IfModule mod_cache.c>
|
71 |
+
CacheDisable /
|
72 |
+
</IfModule></pre>
|
73 |
+
</li>
|
74 |
+
</ul>
|
75 |
+
</td>
|
76 |
+
</tr>
|
77 |
+
</table>
|
78 |
+
|
79 |
+
<div style="background:#fff;border:1px solid #ccc;padding:10px 20px">
|
80 |
+
<pre style="white-space: pre-wrap"><?php echo sprintf( '%s%s%s%s%s',
|
81 |
+
$beginning,
|
82 |
+
WP_CONTENT_DIR,
|
83 |
+
$middle,
|
84 |
+
wp_make_link_relative( content_url() ),
|
85 |
+
$ending ); ?></pre>
|
86 |
+
</div>
|
inc/setup/cachify.hdd.nginx.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Quit */
|
3 |
+
defined( 'ABSPATH' ) || exit;
|
4 |
+
?>
|
5 |
+
|
6 |
+
<table class="form-table">
|
7 |
+
<tr>
|
8 |
+
<th>
|
9 |
+
<?php esc_html_e( 'nginx HDD setup', 'cachify' ); ?>
|
10 |
+
</th>
|
11 |
+
<td>
|
12 |
+
<label for="cachify_setup">
|
13 |
+
<?php esc_html_e( 'Please add the following lines to your nginx.conf', 'cachify' ); ?>
|
14 |
+
</label>
|
15 |
+
</td>
|
16 |
+
</tr>
|
17 |
+
|
18 |
+
<tr>
|
19 |
+
<th>
|
20 |
+
<?php esc_html_e( 'Notes', 'cachify' ); ?>
|
21 |
+
</th>
|
22 |
+
<td>
|
23 |
+
<ul style="list-style-type:circle">
|
24 |
+
<li>
|
25 |
+
<?php echo sprintf(
|
26 |
+
esc_html__( 'For domains with FQDN, the variable %s must be used instead of %s.', 'cachify' ),
|
27 |
+
'<code>${http_host}</code>',
|
28 |
+
'<code>${host}</code>'
|
29 |
+
); ?>
|
30 |
+
</li>
|
31 |
+
</ul>
|
32 |
+
</td>
|
33 |
+
</tr>
|
34 |
+
</table>
|
35 |
+
|
36 |
+
<div style="background:#fff;border:1px solid #ccc;padding:10px 20px"><pre style="white-space: pre-wrap">
|
37 |
+
## GZIP
|
38 |
+
gzip_static on;
|
39 |
+
|
40 |
+
## CHARSET
|
41 |
+
charset utf-8;
|
42 |
+
|
43 |
+
## INDEX LOCATION
|
44 |
+
location / {
|
45 |
+
if ( $query_string ) {
|
46 |
+
return 405;
|
47 |
+
}
|
48 |
+
if ( $request_method = POST ) {
|
49 |
+
return 405;
|
50 |
+
}
|
51 |
+
if ( $request_uri ~ /wp-admin/ ) {
|
52 |
+
return 405;
|
53 |
+
}
|
54 |
+
if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) {
|
55 |
+
return 405;
|
56 |
+
}
|
57 |
+
|
58 |
+
error_page 405 = @nocache;
|
59 |
+
|
60 |
+
try_files /wp-content/cache/cachify/https-${host}${uri}index.html /wp-content/cache/cachify/${host}${uri}index.html @nocache;
|
61 |
+
}
|
62 |
+
|
63 |
+
## NOCACHE LOCATION
|
64 |
+
location @nocache {
|
65 |
+
try_files $uri $uri/ /index.php?$args;
|
66 |
+
}
|
67 |
+
|
68 |
+
## PROTECT CACHE
|
69 |
+
location ~ /wp-content/cache {
|
70 |
+
internal;
|
71 |
+
}
|
72 |
+
</pre></div>
|
73 |
+
|
74 |
+
<small>(<?php esc_html_e( 'You might need to adjust the location directives to your needs.', 'cachify' ); ?>)</small>
|
inc/setup/cachify.memcached.nginx.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* Quit */
|
3 |
+
defined( 'ABSPATH' ) || exit;
|
4 |
+
?>
|
5 |
+
|
6 |
+
<table class="form-table">
|
7 |
+
<tr>
|
8 |
+
<th>
|
9 |
+
<?php esc_html_e( 'nginx Memcached setup', 'cachify' ); ?>
|
10 |
+
</th>
|
11 |
+
<td>
|
12 |
+
<label for="cachify_setup">
|
13 |
+
<?php esc_html_e( 'Please add the following lines to your nginx.conf', 'cachify' ); ?>
|
14 |
+
</label>
|
15 |
+
</td>
|
16 |
+
</tr>
|
17 |
+
|
18 |
+
<tr>
|
19 |
+
<th>
|
20 |
+
<?php esc_html_e( 'Notes', 'cachify' ); ?>
|
21 |
+
</th>
|
22 |
+
<td>
|
23 |
+
<ul style="list-style-type:circle">
|
24 |
+
<li>
|
25 |
+
<?php echo sprintf(
|
26 |
+
esc_html__( 'For domains with FQDN, the variable %s must be used instead of %s.', 'cachify' ),
|
27 |
+
'<code>${http_host}</code>',
|
28 |
+
'<code>${host}</code>'
|
29 |
+
); ?>
|
30 |
+
</li>
|
31 |
+
<li>
|
32 |
+
<?php echo sprintf(
|
33 |
+
esc_html__( 'If you have errors please try to change %1$s to %2$s This forces IPv4 because some servers that allow IPv4 and IPv6 are configured to bind memcached to IPv4 only.', 'cachify' ),
|
34 |
+
'<code>memcached_pass localhost:11211;</code>',
|
35 |
+
'<code>memcached_pass 127.0.0.1:11211;</code>'
|
36 |
+
); ?>
|
37 |
+
</li>
|
38 |
+
</ul>
|
39 |
+
</td>
|
40 |
+
</tr>
|
41 |
+
</table>
|
42 |
+
|
43 |
+
<div style="background:#fff;border:1px solid #ccc;padding:10px 20px"><pre style="white-space: pre-wrap">
|
44 |
+
## GZIP
|
45 |
+
gzip_static on;
|
46 |
+
|
47 |
+
## CHARSET
|
48 |
+
charset utf-8;
|
49 |
+
|
50 |
+
## INDEX LOCATION
|
51 |
+
location / {
|
52 |
+
error_page 404 405 = @nocache;
|
53 |
+
|
54 |
+
if ( $query_string ) {
|
55 |
+
return 405;
|
56 |
+
}
|
57 |
+
if ( $request_method = POST ) {
|
58 |
+
return 405;
|
59 |
+
}
|
60 |
+
if ( $request_uri ~ "/wp-" ) {
|
61 |
+
return 405;
|
62 |
+
}
|
63 |
+
if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) {
|
64 |
+
return 405;
|
65 |
+
}
|
66 |
+
|
67 |
+
default_type text/html;
|
68 |
+
add_header X-Powered-By Cachify;
|
69 |
+
set $memcached_key $host$uri;
|
70 |
+
memcached_pass localhost:11211;
|
71 |
+
}
|
72 |
+
|
73 |
+
## NOCACHE LOCATION
|
74 |
+
location @nocache {
|
75 |
+
try_files $uri $uri/ /index.php?$args;
|
76 |
+
}
|
77 |
+
</pre></div>
|
78 |
+
|
79 |
+
<small>(<?php esc_html_e( 'You might need to adjust the location directives to your needs.', 'cachify' ); ?>)</small>
|
js/post.js
DELETED
@@ -1,44 +0,0 @@
|
|
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
DELETED
@@ -1,2 +0,0 @@
|
|
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()})});
|
|
|
|
readme.txt
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Cachify #
|
2 |
+
* Contributors: pluginkollektiv
|
3 |
+
* Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW
|
4 |
+
* Tags: acceleration, apc, cache, caching, compress, database cache, db-cache, disk cache, disk caching, google, hdd, html compression, memcached, minify, minimize, optimize, page cache, performance, quick cache, speed
|
5 |
+
* Stable tag: 2.3.0
|
6 |
+
* Requires at least: 4.4
|
7 |
+
* Tested up to: 5.4
|
8 |
+
* License: GPLv2 or later
|
9 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
Smart, efficient cache solution for WordPress. Use DB, HDD, APC or Memcached for storing your blog pages. Make WordPress faster!
|
12 |
+
|
13 |
+
## Description ##
|
14 |
+
*Cachify* optimizes your page loads by caching posts, pages and custom post types as static content. You can choose between caching via database, on the web server’s hard drive (HDD), Memcached (only on Nginx) or — thanks to APC (Alternative PHP Cache) — directly in the web server’s system cache. Whenever a page or post is loaded, it can be pulled directly from the cache. The amount of database queries and PHP requests will dramatically decrease towards zero, depending on the caching method you chose.
|
15 |
+
|
16 |
+
### Features ###
|
17 |
+
* Works with custom post types.
|
18 |
+
* Caching methods: DB, HDD, APC and Memcached.
|
19 |
+
* “Flush Cache” button in the WordPress toolbar.
|
20 |
+
* Ready for WordPress Multisite.
|
21 |
+
* Optional compression of HTML markup.
|
22 |
+
* White lists for posts and user agents.
|
23 |
+
* Manual and automatic cache reset.
|
24 |
+
* Automatic cache management.
|
25 |
+
* Dashboard widget for cached objects.
|
26 |
+
* Settings for Apache and Nginx servers.
|
27 |
+
* Extendability via hooks/filters.
|
28 |
+
|
29 |
+
### Support ###
|
30 |
+
* Community support via the [support forums on wordpress.org](https://wordpress.org/support/plugin/cachify)
|
31 |
+
* We don’t handle support via e-mail, Twitter, GitHub issues etc.
|
32 |
+
|
33 |
+
### Contribute ###
|
34 |
+
* Active development of this plugin is handled [on GitHub](https://github.com/pluginkollektiv/cachify).
|
35 |
+
* Pull requests for documented bugs are highly appreciated.
|
36 |
+
* If you think you’ve found a bug (e.g. you’re experiencing unexpected behavior), please post at the [support forums](https://wordpress.org/support/plugin/cachify) first.
|
37 |
+
* If you want to help us translate this plugin you can do so [on WordPress Translate](https://translate.wordpress.org/projects/wp-plugins/cachify).
|
38 |
+
|
39 |
+
### Credits ###
|
40 |
+
* Author: [Sergej Müller](https://sergejmueller.github.io/)
|
41 |
+
* Maintainers: [pluginkollektiv](http://pluginkollektiv.org)
|
42 |
+
|
43 |
+
|
44 |
+
## Installation ##
|
45 |
+
* If you don’t know how to install a plugin for WordPress, [here’s how](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
|
46 |
+
|
47 |
+
### Requirements ###
|
48 |
+
* PHP 5.2.4 or greater
|
49 |
+
* WordPress 3.8 or greater
|
50 |
+
* APC 3.1.4 or greater (optional)
|
51 |
+
* Memcached in Nginx (optional)
|
52 |
+
|
53 |
+
|
54 |
+
## Frequently Asked Questions ##
|
55 |
+
|
56 |
+
### No cache expiration option while using HDD cache? ###
|
57 |
+
The cache expiration can not be considered due to technical reasons. If the cache stock has to be emptied at certain time intervals, then it is recommended to call a prepared PHP file by a cronjob.
|
58 |
+
|
59 |
+
### PHP Fatal error: Cannot use output buffering in output buffering display handlers in Unknown on line 0 ###
|
60 |
+
This error message may occur after commissioning the caching plug-in. The hint appears because there are no cache files on the HDD for output. This is probably due to the fact that Cachify could not store files in the cache folder. Please check the write-permissions for the cache folder (found in the WordPress directory *wp-content*) and set them if necessary.
|
61 |
+
|
62 |
+
### My Website looks in some parts broken after activating Cachify! ###
|
63 |
+
Please make sure there is no issue that caused by the Cache minify feature. Just deactivate it or use HTML only. If the issue still exist please feel free to report it at the [support forums](https://wordpress.org/support/plugin/cachify). With this feature any unnecessary characters such as breaks and HTML comments are removed from the source code.
|
64 |
+
|
65 |
+
### Cachify HDD: Character encoding does not work correctly ###
|
66 |
+
If you use Cachify to store the cache on HDD there is no PHP to run. In the case of misconfigured servers, this can lead to incorrect display of the special characters on web pages. The error can be corrected by an extension of the system file .htaccess: *AddDefaultCharset UTF-8*
|
67 |
+
|
68 |
+
### Cachify with CDN support? ###
|
69 |
+
Currently the caching plugin for WordPress has no connection to a CDN provider. Although the Buzzword CDN (Content Delivery Network) is praised as a performance factor, CDN makes little sense for WordPress websites with a national audience. In this case, a home host could provide the requested files faster than a worldwide CDN service provider because the next node could be far away.
|
70 |
+
|
71 |
+
### PHP OPcache as a caching method? ###
|
72 |
+
Compared to APC (Alternative PHP Cache), PHP OPCache is not able to contain content with custom keys and values. Because of this Cachify can not consider the PHP OPCache as a caching method.
|
73 |
+
|
74 |
+
### When does Cachify automaticaly flush its cache? ###
|
75 |
+
* After publishing new posts
|
76 |
+
* After publishing new pages
|
77 |
+
* After publishing new custom post types
|
78 |
+
* After publishing new sheduled posts (only Cachify DB)
|
79 |
+
* After updating WordPress
|
80 |
+
* If you confirm the trash button on the adminbar
|
81 |
+
* After saving Cachify and wpSEO settings
|
82 |
+
|
83 |
+
### Which parts of the website are not cached by default? ###
|
84 |
+
* Password protected pages
|
85 |
+
* Feeds
|
86 |
+
* Trackbacks
|
87 |
+
* Robots
|
88 |
+
* Previews
|
89 |
+
* Mobile-themes (WP-Touch, Carrington, Jetpack Mobile)
|
90 |
+
* Search
|
91 |
+
* Error pages
|
92 |
+
|
93 |
+
### The cache folder is indexed by search engines! ###
|
94 |
+
To ensure that Google and other search engines do not index the static contents of the cache folder (otherwise there could be duplicate content), the robots.txt file which is located in the main directory of a WordPress installation should be expanded by disabling the path to the cache file (disallow ). This issue should only happen if you use a *static robots.txt* or you changed the *wp-content* location. And so might look a robots.txt:
|
95 |
+
|
96 |
+
`User-agent: *
|
97 |
+
Disallow: /wp-content/cache/cachify/
|
98 |
+
Allow: /`
|
99 |
+
|
100 |
+
A complete documentation is available in the [GitHub repository Wiki](https://github.com/pluginkollektiv/cachify/wiki).
|
101 |
+
|
102 |
+
## Changelog ##
|
103 |
+
|
104 |
+
### 2.2.4 ###
|
105 |
+
* Fixes caching for mixed HTTPS and HTTP setups
|
106 |
+
* Fixes an issue with the icon styling in the admin toolbar
|
107 |
+
* Ensures compatibility with the latest WordPress version
|
108 |
+
|
109 |
+
### 2.2.3 ###
|
110 |
+
* New: Generated a POT file
|
111 |
+
* New: Added German formal translation
|
112 |
+
* Updated, translated + formatted README.md
|
113 |
+
* Updated expired link URLs in plugin and languages files
|
114 |
+
* Updated [plugin authors](https://gist.github.com/glueckpress/f058c0ab973d45a72720)
|
115 |
+
|
116 |
+
### 2.2.2 ###
|
117 |
+
* Fix: parameter return by filter `dashboard_glance_items`
|
118 |
+
* Generous use of the filter `esc_html`
|
119 |
+
|
120 |
+
### 2.2.1 ###
|
121 |
+
* Fix for the PHP notice "Call to undefined function is_plugin_active_for_network" on WordPress Multisite
|
122 |
+
|
123 |
+
### 2.2.0 ###
|
124 |
+
* Toolbar: Display of the "Flush the cachify cache" button on the frontend
|
125 |
+
* Toolbar: Controlling the display of the "Flush the cachify cache" button via hook
|
126 |
+
|
127 |
+
For the complete changelog, check out our [GitHub repository](https://github.com/pluginkollektiv/cachify).
|
128 |
+
|
129 |
+
## Upgrade Notice ##
|
130 |
+
|
131 |
+
### 2.3.0 ###
|
132 |
+
To improve Cachify and make use of new core functions, we decided to drop support for WordPress 4.3 and older. Please make sure your WordPress is always up to date.
|
133 |
+
|
134 |
+
## Screenshots ##
|
135 |
+
1. Cachify Dashboard Widget
|
136 |
+
2. Cachify settings
|
137 |
+
3. Flush Cache button in admin bar
|