feat: caching, optimization, legal pages & footer

- WP Super Cache enabled (PHP mode, gzip, Nginx compatible)
- Autoptimize: CSS/HTML minification + deferred JS + Google Fonts optimization
- Cookie Notice: GDPR/LOPD banner styled with brand colors (navy/burgundy/gold)
- Legal pages: Aviso Legal, Política de Privacidad, Política de Cookies (ES)
- MU-plugin: custom footer with legal links + Cloud Host credit
- Footer: copyright, legal nav, Hosted & Maintained by Cloud Host (cloudhost.es)
- Security: X-Frame-Options, X-Content-Type, Referrer-Policy headers
- Security: XML-RPC disabled, REST user enumeration blocked
- Performance: emoji scripts removed, post revisions limited to 3
This commit is contained in:
Malin
2026-05-19 19:58:11 +02:00
parent 67241f537f
commit 6daabcab65
277 changed files with 96841 additions and 0 deletions

View File

@@ -0,0 +1,355 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <https://www.gnu.org/licenses/>.
===================================
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Moe Ghoul>, 1 April 1989
Moe Ghoul, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,47 @@
# Security Policy
Full details of the Automattic Security Policy can be found on [automattic.com](https://automattic.com/security/).
## Supported Versions
Generally, only the latest version of Jetpack and its associated plugins have continued support. If a critical vulnerability is found in the current version of a plugin, we may opt to backport any patches to previous versions.
## Reporting a Vulnerability
Our HackerOne program covers the below plugin software, as well as a variety of related projects and infrastructure:
* [Jetpack](https://jetpack.com/)
* Jetpack Backup
* Jetpack Boost
* Jetpack CRM
* Jetpack Protect
* Jetpack Search
* Jetpack Social
* Jetpack VideoPress
**For responsible disclosure of security issues and to be eligible for our bug bounty program, please submit your report via the [HackerOne](https://hackerone.com/automattic) portal.**
Our most critical targets are:
* Jetpack and the Jetpack composer packages (all within this repo)
* Jetpack.com -- the primary marketing site.
* cloud.jetpack.com -- a management site.
* wordpress.com -- the shared management site for both Jetpack and WordPress.com sites.
For more targets, see the `In Scope` section on [HackerOne](https://hackerone.com/automattic).
_Please note that the **WordPress software is a separate entity** from Automattic. Please report vulnerabilities for WordPress through [the WordPress Foundation's HackerOne page](https://hackerone.com/wordpress)._
## Guidelines
We're committed to working with security researchers to resolve the vulnerabilities they discover. You can help us by following these guidelines:
* Follow [HackerOne's disclosure guidelines](https://www.hackerone.com/disclosure-guidelines).
* Pen-testing Production:
* Please **setup a local environment** instead whenever possible. Most of our code is open source (see above).
* If that's not possible, **limit any data access/modification** to the bare minimum necessary to reproduce a PoC.
* **_Don't_ automate form submissions!** That's very annoying for us, because it adds extra work for the volunteers who manage those systems, and reduces the signal/noise ratio in our communication channels.
* To be eligible for a bounty, all of these guidelines must be followed.
* Be Patient - Give us a reasonable time to correct the issue before you disclose the vulnerability.
We also expect you to comply with all applicable laws. You're responsible to pay any taxes associated with your bounties.

View File

@@ -0,0 +1,29 @@
<?php
// WP SUPER CACHE 1.2
function wpcache_broken_message() {
global $wp_cache_config_file;
if ( isset( $wp_cache_config_file ) == false ) {
return '';
}
$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
$xmlrpc_request = defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST;
$rest_request = defined( 'REST_REQUEST' ) && REST_REQUEST;
$robots_request = strpos( $_SERVER['REQUEST_URI'], 'robots.txt' ) != false;
$skip_output = ( $doing_ajax || $xmlrpc_request || $rest_request || $robots_request );
if ( false == strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) && ! $skip_output ) {
echo '<!-- WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory. -->';
}
}
if ( false == defined( 'WPCACHEHOME' ) ) {
define( 'ADVANCEDCACHEPROBLEM', 1 );
} elseif ( ! include_once WPCACHEHOME . 'wp-cache-phase1.php' ) {
if ( ! @is_file( WPCACHEHOME . 'wp-cache-phase1.php' ) ) {
define( 'ADVANCEDCACHEPROBLEM', 1 );
}
}
if ( defined( 'ADVANCEDCACHEPROBLEM' ) ) {
register_shutdown_function( 'wpcache_broken_message' );
}

View File

@@ -0,0 +1,10 @@
<svg width="177" height="7" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#footer-automattic_svg__clip0)" fill="#000" fill-opacity="0.8">
<path d="M59.878 7c-2.38 0-3.909-1.668-3.909-3.39v-.22c0-1.76 1.548-3.39 3.909-3.39 2.379 0 3.927 1.63 3.927 3.39v.22c0 1.722-1.548 3.39-3.927 3.39zm2.662-3.592c0-1.264-.944-2.382-2.662-2.382-1.719 0-2.644 1.118-2.644 2.382v.165c0 1.265.944 2.4 2.644 2.4 1.7 0 2.662-1.135 2.662-2.4v-.165zM33.045 6.743l-.887-1.612H28.21l-.85 1.612H26.04L29.646.238h1.039l3.682 6.505h-1.322zm-2.889-5.24l-1.454 2.73h2.965l-1.511-2.73zM40.107 7c-2.398 0-3.53-1.264-3.53-2.969V.238h1.245v3.83c0 1.21.813 1.924 2.36 1.924 1.587 0 2.248-.715 2.248-1.924V.238h1.265v3.793C43.695 5.644 42.638 7 40.107 7zM50.72 1.246v5.497h-1.266V1.246h-2.926V.238h7.118v1.008H50.72zm24.302 5.497V1.594l-.34.568-2.814 4.581h-.623l-2.776-4.58-.34-.569v5.15h-1.227V.237h1.737l2.644 4.471.321.55.321-.55L74.55.24h1.718v6.504h-1.246zm10.782 0l-.887-1.612H80.97l-.85 1.612h-1.322L82.425.238h1.039l3.682 6.505h-1.34zm-2.889-5.24l-1.454 2.73h2.965l-1.511-2.73zm9.31-.257v5.497h-1.266V1.246h-2.927V.238h7.12v1.008h-2.928zm9.233 0v5.497h-1.265V1.246h-2.927V.238h7.119v1.008h-2.927zm6.043 5.497v-5.9c.509 0 .698-.257.698-.623h.529v6.505l-1.227.018zm11.084-4.672c-.604-.532-1.492-1.045-2.682-1.045-1.793 0-2.794 1.191-2.794 2.437v.129c0 1.227 1.019 2.382 2.889 2.382 1.114 0 2.039-.513 2.625-1.045l.755.77c-.737.696-1.983 1.301-3.456 1.301-2.53 0-4.078-1.594-4.078-3.353v-.22c0-1.76 1.68-3.427 4.135-3.427 1.416 0 2.7.568 3.399 1.301l-.793.77zm-57.876.201c.226.147.283.44.15.66l-1.151 1.722a.501.501 0 01-.68.147.486.486 0 01-.151-.66l1.152-1.722a.485.485 0 01.68-.147zM7.081 6.725l-.887-1.63H2.209l-.868 1.63H0L3.663.147h1.058l3.72 6.578H7.08zM4.154 1.43L2.681 4.196h3.003L4.154 1.43zm11.481 5.296l-4.4-4.398-.434-.458v4.875H9.536V.147h1.227l4.268 4.398.434.476V.147h1.265v6.578h-1.095zM135.938 6.78l-.907-1.63h-3.984l-.868 1.63h-1.341L132.52.183h1.058l3.738 6.597h-1.378zm-2.927-5.314l-1.473 2.767h3.003l-1.53-2.767zm5.401 5.314V.183h1.284V6.78h-1.284zm9.063 0c-.34 0-.491-.458-.547-1.063l-.038-.678c-.038-.66-.321-.934-1.586-.934h-2.417V6.78h-1.265V.183h3.701c2.039 0 2.964.788 2.964 1.814 0 .715-.377 1.411-1.699 1.65 1.322.091 1.605.678 1.624 1.447l.019.55c.019.458.094.788.415 1.118v.018h-1.171zm-.472-4.618c0-.476-.396-.934-1.491-.934h-2.606v1.979h2.719c.944 0 1.378-.44 1.378-.953v-.092zm3.078 4.618V.183h1.284v5.57h5.325V6.78h-6.609zm7.912 0V.183h1.284V6.78h-1.284zm9.347 0l-4.418-4.416-.435-.458V6.78h-1.284V.183h1.228l4.286 4.416.434.477V.183h1.284V6.78h-1.095zm3.04 0V.183h6.175V1.21h-4.91v1.686h3.777v1.008h-3.777v1.85h4.91V6.78h-6.175z"></path>
</g>
<defs>
<clipPath id="footer-automattic_svg__clip0">
<path fill="#fff" d="M0 0h176.556v7H0z"></path>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

View File

@@ -0,0 +1,14 @@
<svg width="513" height="400" viewBox="0 0 513 400" fill="none" xmlns="http://www.w3.org/2000/svg">
<g filter="url(#filter0_f_2285_9948)">
<path opacity="0.7" d="M505.462 -126.766C530.541 -119.966 549.288 -98.8259 572.421 -86.2516C600.401 -71.0427 638.717 -72.4006 656.759 -44.5276C674.393 -17.2838 665.913 20.8197 663.238 54.0552C660.751 84.9436 650.487 113.365 641.675 142.841C632.059 175.007 630.926 212.795 608.725 236.396C586.471 260.054 552.462 263.253 522.033 270.029C492.682 276.566 463.078 280.134 433.434 275.432C402.994 270.605 372.263 262.269 347.494 242.349C322.667 222.382 304.977 193.366 292.881 162.392C281.191 132.458 280.938 99.6507 279.082 67.1702C277.181 33.9036 268.485 -1.53342 281.799 -31.5256C295.088 -61.4623 324.768 -77.8611 350.985 -94.8026C374.635 -110.085 400.357 -119.998 427.357 -125.585C453.264 -130.946 479.871 -133.705 505.462 -126.766Z" fill="#F5E6B3"/>
<path opacity="0.7" d="M274.015 156.173C295.086 169.132 307.167 193.384 321.975 214.247C336.016 234.031 352.197 252.418 359.227 276.233C366.356 300.379 368.273 326.743 362.435 351.298C356.74 375.254 340.991 394.185 326.63 413.345C312.893 431.674 295.965 445.599 279.86 461.47C259.756 481.283 245.911 513.006 219.385 519.036C193.402 524.943 169.073 503.68 144.71 492.194C120.547 480.803 90.952 475.33 76.2142 451.541C61.3709 427.582 68.762 395.334 66.8348 366.495C65.2206 342.34 64.3226 318.928 65.737 294.759C67.2819 268.358 62.3709 239.32 75.5755 217.13C88.7931 194.918 115.438 188.59 136.618 175.644C157.993 162.579 177.206 143.602 201.505 140.158C226.271 136.649 252.261 142.795 274.015 156.173Z" fill="#CED9F2"/>
<path d="M549.377 206.234C594.702 223.625 610.9 283.303 639.95 325.028C666.696 363.443 704.795 395.077 713.74 442.307C722.685 489.54 697.844 534.7 688.591 581.863C678.121 635.231 687.426 696.612 655.585 738.726C623.071 781.732 567.997 793.298 518.428 806.93C467.16 821.029 413.471 836.097 362.916 819.213C311.973 802.2 266.336 763.635 239.174 713.667C213.549 666.525 223.51 608.177 218.559 553.647C214.133 504.904 202.281 457.338 211.548 409.411C221.467 358.118 235.699 302.891 273.35 270.285C310.684 237.954 363.969 247.851 410.604 237.03C457.576 226.13 504.076 188.853 549.377 206.234Z" fill="#069E08" fill-opacity="0.11"/>
</g>
<defs>
<filter id="filter0_f_2285_9948" x="-19.4263" y="-215.362" width="819.537" height="1126.51" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
<feGaussianBlur stdDeviation="42.2297" result="effect1_foregroundBlur_2285_9948"/>
</filter>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,17 @@
<svg width="283" height="36" viewBox="0 0 283 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M149.377 15.281C149.927 15.3609 150.42 15.5074 150.855 15.7204C151.299 15.9335 151.676 16.2086 151.987 16.546C152.306 16.8744 152.55 17.2694 152.719 17.731C152.888 18.1837 152.972 18.703 152.972 19.2889C152.972 19.7061 152.91 20.1455 152.786 20.6071C152.661 21.0598 152.453 21.5036 152.16 21.9386C151.876 22.3647 151.498 22.7597 151.028 23.1236C150.566 23.4876 149.989 23.785 149.297 24.0158C148.764 24.1933 148.174 24.3176 147.526 24.3886C146.878 24.4596 146.101 24.4951 145.196 24.4951H140.589V6.67944H145.036C145.444 6.67944 145.813 6.68832 146.141 6.70607C146.479 6.71495 146.785 6.7327 147.06 6.75933C147.344 6.78596 147.606 6.82147 147.846 6.86586C148.085 6.90136 148.312 6.94575 148.525 6.99901C149.084 7.14991 149.59 7.35852 150.043 7.62482C150.504 7.88225 150.895 8.19293 151.214 8.55688C151.534 8.92083 151.778 9.3336 151.947 9.79519C152.124 10.2568 152.213 10.7583 152.213 11.2998C152.213 11.7348 152.16 12.152 152.053 12.5514C151.956 12.9509 151.791 13.3193 151.561 13.6566C151.339 13.9939 151.046 14.2957 150.682 14.562C150.327 14.8283 149.892 15.0502 149.377 15.2278V15.281ZM146.061 14.3889C146.487 14.3889 146.856 14.3712 147.167 14.3357C147.477 14.2913 147.757 14.2291 148.005 14.1492C148.671 13.9273 149.155 13.5811 149.457 13.1107C149.767 12.6402 149.923 12.0854 149.923 11.4463C149.923 10.7894 149.763 10.2523 149.443 9.83513C149.124 9.41793 148.622 9.10724 147.939 8.90307C147.602 8.80543 147.211 8.73885 146.767 8.70335C146.323 8.65896 145.8 8.63677 145.196 8.63677H142.759V14.3889H146.061ZM142.759 16.3462V22.5378H145.382C146.004 22.5378 146.581 22.5112 147.113 22.4579C147.646 22.3958 148.099 22.3025 148.471 22.1783C148.88 22.0451 149.226 21.8765 149.51 21.6723C149.794 21.4593 150.02 21.2285 150.189 20.9799C150.367 20.7225 150.491 20.4517 150.562 20.1677C150.642 19.8836 150.682 19.5951 150.682 19.3022C150.682 18.9649 150.642 18.6498 150.562 18.3568C150.482 18.055 150.349 17.7887 150.162 17.5579C149.985 17.3182 149.745 17.1096 149.443 16.9321C149.151 16.7546 148.782 16.617 148.338 16.5193C148.072 16.4572 147.766 16.4128 147.42 16.3862C147.082 16.3596 146.661 16.3462 146.155 16.3462H142.759Z" fill="black"/>
<path d="M165.226 18.1837C165.226 17.4026 165.128 16.7102 164.933 16.1066C164.746 15.4941 164.48 14.9792 164.134 14.562C163.796 14.1359 163.393 13.8164 162.922 13.6033C162.452 13.3814 161.937 13.2704 161.378 13.2704C160.818 13.2704 160.303 13.3814 159.833 13.6033C159.363 13.8164 158.954 14.1359 158.608 14.562C158.271 14.9792 158.004 15.4941 157.809 16.1066C157.623 16.7102 157.529 17.4026 157.529 18.1837C157.529 18.956 157.623 19.6484 157.809 20.2609C158.004 20.8645 158.275 21.3749 158.621 21.7921C158.967 22.2093 159.376 22.5289 159.846 22.7508C160.317 22.9639 160.832 23.0704 161.391 23.0704C161.95 23.0704 162.461 22.9639 162.922 22.7508C163.393 22.5289 163.796 22.2093 164.134 21.7921C164.48 21.3749 164.746 20.8645 164.933 20.2609C165.128 19.6484 165.226 18.956 165.226 18.1837ZM167.383 18.1837C167.383 19.1779 167.241 20.0834 166.957 20.9C166.673 21.7167 166.269 22.4179 165.745 23.0038C165.23 23.5808 164.604 24.0291 163.867 24.3486C163.131 24.6682 162.305 24.828 161.391 24.828C160.45 24.828 159.607 24.6682 158.861 24.3486C158.124 24.0291 157.494 23.5808 156.97 23.0038C156.455 22.4179 156.06 21.7167 155.785 20.9C155.51 20.0834 155.372 19.1779 155.372 18.1837C155.372 17.1807 155.514 16.2708 155.798 15.4541C156.083 14.6375 156.482 13.9362 156.997 13.3503C157.521 12.7645 158.151 12.3118 158.888 11.9922C159.633 11.6726 160.463 11.5128 161.378 11.5128C162.31 11.5128 163.148 11.6726 163.894 11.9922C164.64 12.3118 165.27 12.7645 165.785 13.3503C166.3 13.9362 166.695 14.6375 166.97 15.4541C167.245 16.2708 167.383 17.1807 167.383 18.1837Z" fill="black"/>
<path d="M179.357 18.1837C179.357 17.4026 179.259 16.7102 179.064 16.1066C178.877 15.4941 178.611 14.9792 178.265 14.562C177.928 14.1359 177.524 13.8164 177.053 13.6033C176.583 13.3814 176.068 13.2704 175.509 13.2704C174.949 13.2704 174.435 13.3814 173.964 13.6033C173.494 13.8164 173.085 14.1359 172.739 14.562C172.402 14.9792 172.135 15.4941 171.94 16.1066C171.754 16.7102 171.661 17.4026 171.661 18.1837C171.661 18.956 171.754 19.6484 171.94 20.2609C172.135 20.8645 172.406 21.3749 172.752 21.7921C173.099 22.2093 173.507 22.5289 173.977 22.7508C174.448 22.9639 174.963 23.0704 175.522 23.0704C176.081 23.0704 176.592 22.9639 177.053 22.7508C177.524 22.5289 177.928 22.2093 178.265 21.7921C178.611 21.3749 178.877 20.8645 179.064 20.2609C179.259 19.6484 179.357 18.956 179.357 18.1837ZM181.514 18.1837C181.514 19.1779 181.372 20.0834 181.088 20.9C180.804 21.7167 180.4 22.4179 179.876 23.0038C179.361 23.5808 178.735 24.0291 177.999 24.3486C177.262 24.6682 176.436 24.828 175.522 24.828C174.581 24.828 173.738 24.6682 172.992 24.3486C172.255 24.0291 171.625 23.5808 171.101 23.0038C170.586 22.4179 170.191 21.7167 169.916 20.9C169.641 20.0834 169.504 19.1779 169.504 18.1837C169.504 17.1807 169.646 16.2708 169.93 15.4541C170.214 14.6375 170.613 13.9362 171.128 13.3503C171.652 12.7645 172.282 12.3118 173.019 11.9922C173.764 11.6726 174.594 11.5128 175.509 11.5128C176.441 11.5128 177.28 11.6726 178.025 11.9922C178.771 12.3118 179.401 12.7645 179.916 13.3503C180.431 13.9362 180.826 14.6375 181.101 15.4541C181.376 16.2708 181.514 17.1807 181.514 18.1837Z" fill="black"/>
<path d="M185.698 15.2145C185.698 15.5606 185.774 15.8447 185.925 16.0666C186.076 16.2885 186.275 16.4705 186.524 16.6125C186.781 16.7457 187.074 16.8567 187.403 16.9454C187.74 17.0342 188.086 17.1141 188.441 17.1851C188.93 17.2916 189.391 17.4115 189.826 17.5446C190.261 17.6689 190.661 17.8597 191.025 18.1172C191.397 18.3746 191.695 18.7252 191.917 19.1691C192.147 19.604 192.263 20.1721 192.263 20.8734C192.263 21.5125 192.139 22.0806 191.89 22.5777C191.641 23.066 191.291 23.4787 190.838 23.816C190.385 24.1445 189.844 24.393 189.214 24.5617C188.583 24.7392 187.891 24.828 187.136 24.828C186.675 24.828 186.253 24.8014 185.872 24.7481C185.499 24.7037 185.166 24.6416 184.873 24.5617C184.589 24.4907 184.345 24.4152 184.141 24.3353C183.936 24.2554 183.768 24.18 183.635 24.109V22.378C184.167 22.591 184.695 22.7597 185.219 22.884C185.743 23.0083 186.32 23.0704 186.95 23.0704C187.447 23.0704 187.895 23.026 188.295 22.9372C188.694 22.8485 189.036 22.7198 189.32 22.5511C189.613 22.3736 189.835 22.1561 189.986 21.8987C190.146 21.6324 190.226 21.3261 190.226 20.9799C190.226 20.6248 190.155 20.3319 190.013 20.1011C189.871 19.8703 189.68 19.6795 189.44 19.5286C189.2 19.3777 188.921 19.2534 188.601 19.1557C188.29 19.0581 187.962 18.9693 187.616 18.8894C187.163 18.7918 186.702 18.6764 186.231 18.5432C185.769 18.4101 185.348 18.2237 184.966 17.984C184.584 17.7443 184.274 17.4203 184.034 17.012C183.803 16.5948 183.688 16.0622 183.688 15.4142C183.688 14.7484 183.808 14.1714 184.047 13.6832C184.287 13.195 184.611 12.7911 185.019 12.4715C185.428 12.152 185.903 11.9123 186.444 11.7525C186.986 11.5927 187.558 11.5128 188.162 11.5128C188.863 11.5128 189.511 11.5794 190.106 11.7126C190.709 11.8457 191.255 12.0144 191.744 12.2185V13.9761C191.211 13.772 190.669 13.6078 190.119 13.4835C189.578 13.3503 189.018 13.2793 188.441 13.2704C187.953 13.2704 187.536 13.3193 187.19 13.4169C186.844 13.5146 186.56 13.6521 186.338 13.8297C186.116 13.9983 185.951 14.2025 185.845 14.4422C185.747 14.673 185.698 14.9304 185.698 15.2145Z" fill="black"/>
<path d="M201.654 24.5217C201.476 24.5928 201.205 24.6593 200.842 24.7215C200.478 24.7836 200.043 24.8191 199.537 24.828C198.871 24.828 198.294 24.7437 197.806 24.575C197.317 24.4152 196.909 24.1844 196.581 23.8826C196.261 23.5719 196.021 23.1991 195.862 22.7641C195.702 22.3292 195.622 21.8454 195.622 21.3128V13.6166H193.185V11.8457H195.622V8.38378H197.686V11.8457H201.467V13.6166H197.686V20.9932C197.686 21.2862 197.726 21.5569 197.806 21.8055C197.894 22.054 198.028 22.2715 198.205 22.4579C198.392 22.6354 198.627 22.7775 198.911 22.884C199.195 22.9816 199.537 23.0304 199.936 23.0304C200.211 23.0304 200.5 23.0083 200.802 22.9639C201.112 22.9195 201.396 22.8618 201.654 22.7908V24.5217Z" fill="black"/>
<path d="M18.0007 36C27.9421 36 36.0013 27.9408 36.0013 17.9993C36.0013 8.05791 27.9421 0 18.0007 0C8.05924 0 0 8.05924 0 18.0007C0 27.9421 8.05924 36 18.0007 36Z" fill="#069E08"/>
<path d="M18.8938 14.9774V32.4276L27.8941 14.9774H18.8938V14.9774Z" fill="white"/>
<path d="M17.073 20.9892V3.57239L8.1073 20.9892H17.073Z" fill="white"/>
<path d="M46.4773 29.8856C45.9615 29.0952 45.4816 28.306 45.0004 27.5502C47.5424 26.004 48.4008 24.7683 48.4008 22.4315V8.93105H45.4123V6.35571H51.7679V21.7451C51.7679 25.6614 50.6349 27.8595 46.4773 29.8856Z" fill="black"/>
<path d="M73.101 20.68C73.101 21.985 74.0288 22.1223 74.6473 22.1223C75.2658 22.1223 76.1589 21.9157 76.8454 21.7104V24.1151C75.883 24.4244 74.8872 24.6643 73.5129 24.6643C71.864 24.6643 69.9405 24.0458 69.9405 21.1599V14.0831H68.189V11.6437H69.9405V8.03796H73.101V11.645H77.0853V14.0844H73.101V20.68Z" fill="black"/>
<path d="M79.6967 31.088V11.6104H82.7199V12.7781C83.9222 11.8503 85.2619 11.2665 86.9108 11.2665C89.762 11.2665 92.0295 13.2593 92.0295 17.5528C92.0295 21.8131 89.5568 24.6297 85.4685 24.6297C84.4728 24.6297 83.6823 24.4924 82.8572 24.3204V31.0533H79.6967V31.088V31.088ZM86.0857 13.8778C85.1579 13.8778 83.9902 14.3244 82.8905 15.2868V21.9171C83.577 22.0543 84.2995 22.157 85.2605 22.157C87.4933 22.157 88.765 20.748 88.765 17.7941C88.765 15.0802 87.8372 13.8778 86.0857 13.8778Z" fill="black"/>
<path d="M104.464 24.3551H101.51V22.9461H101.44C100.41 23.7366 99.1383 24.595 97.2494 24.595C95.6005 24.595 93.8143 23.3927 93.8143 20.9533C93.8143 17.6902 96.5963 17.0717 98.5544 16.7971L101.336 16.4198V16.0426C101.336 14.3244 100.65 13.7752 99.0343 13.7752C98.2439 13.7752 96.3897 14.0151 94.8781 14.6336L94.6035 12.0916C95.9778 11.6104 97.8666 11.2678 99.4475 11.2678C102.539 11.2678 104.532 12.5048 104.532 16.1799V24.3551H104.464V24.3551ZM101.303 18.4126L98.6917 18.8245C97.9013 18.9272 97.0775 19.4084 97.0775 20.5761C97.0775 21.6065 97.6613 22.1903 98.5198 22.1903C99.4475 22.1903 100.443 21.6411 101.302 21.0226V18.4126H101.303Z" fill="black"/>
<path d="M117.517 23.9432C116.212 24.3898 115.045 24.6644 113.566 24.6644C108.826 24.6644 106.936 21.9504 106.936 18.0007C106.936 13.8445 109.547 11.2678 113.772 11.2678C115.351 11.2678 116.314 11.5424 117.379 11.8863V14.5656C116.451 14.2217 115.111 13.8445 113.806 13.8445C111.883 13.8445 110.234 14.8749 110.234 17.8288C110.234 21.0919 111.883 22.089 113.978 22.089C114.974 22.089 116.074 21.8824 117.551 21.2986V23.9432H117.517Z" fill="black"/>
<path d="M123.495 17.1076C123.769 16.7983 123.976 16.4891 127.96 11.645H132.082L126.929 17.6914L132.562 24.3897H128.44L123.528 18.3433V24.3897H120.369V6.35571H123.529V17.1076H123.495Z" fill="black"/>
<path d="M65.8176 23.9432C64.1686 24.4591 62.7597 24.6643 61.1108 24.6643C57.0572 24.6643 54.5498 22.6382 54.5498 17.8968C54.5498 14.427 56.6799 11.2665 60.7669 11.2665C64.8205 11.2665 66.2294 14.0831 66.2294 16.7624C66.2294 17.6555 66.1601 18.1367 66.1268 18.6512H57.9516C58.0209 21.4332 59.6005 22.0863 61.9705 22.0863C63.2755 22.0863 64.4432 21.7771 65.7842 21.2959V23.9405H65.8176V23.9432ZM62.933 16.5571C62.933 15.0108 62.4171 13.6712 60.7349 13.6712C59.1553 13.6712 58.1929 14.8042 57.9862 16.5571H62.933V16.5571Z" fill="black"/>
</svg>

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -0,0 +1,235 @@
<?php
/**
* Code to handle migration from WP Super Cache to Jetpack Boost.
*
* @package WP_Super_Cache
*/
// Minimum version of Jetpack Boost required for compatibility.
if ( ! defined( 'MINIMUM_BOOST_VERSION' ) ) {
define( 'MINIMUM_BOOST_VERSION', '3.4.5' );
}
/**
* Get shared configuration for each migration button.
*/
function wpsc_get_boost_migration_config() {
return array(
'install_url' => wp_nonce_url( admin_url( 'update.php?action=install-plugin&plugin=jetpack-boost' ), 'install-plugin_jetpack-boost' ),
'activate_url' => admin_url( 'plugins.php' ),
'is_installed' => wpsc_is_boost_installed(),
);
}
/**
* Display an admin notice to install Jetpack Boost.
*/
function wpsc_jetpack_boost_notice() {
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpsupercache' ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
return;
}
// hide the admin notice if Jetpack Boost Cache is already used.
if ( 'BOOST' === wpsc_identify_advanced_cache() ) {
return;
}
// Don't show the banner if the banner has been dismissed.
$is_dismissed = '1' === get_user_option( 'wpsc_dismissed_boost_admin_notice' );
if ( $is_dismissed ) {
return;
}
// Don't show the admin notice if Jetpack Boost is too old.
if ( ! wpsc_is_boost_current() ) {
return;
}
// Don't show the banner if Super Cache is using features that Boost doesn't support.
if ( ! wpsc_is_boost_compatible() ) {
return;
}
$config = wpsc_get_boost_migration_config();
$button_url = $config['is_installed'] ? $config['activate_url'] : $config['install_url'];
$button_class = $config['is_installed'] ? 'wpsc-activate-boost-button' : 'wpsc-install-boost-button';
?>
<div id="wpsc-notice-boost-migrate" class="notice boost-notice notice-success is-dismissible">
<h3>
<?php esc_html_e( 'Migrate to Jetpack Boost', 'wp-super-cache' ); ?>
</h3>
<p>
<?php esc_html_e( 'Your WP Super Cache setup is compatible with Boost\'s new caching feature. Continue to cache as you currently do and enhance your site\'s speed using our highly-rated performance solutions.', 'wp-super-cache' ); ?>
</p>
<p>
<div class="wpsc-boost-migration-error" style="display:none; color:red; margin-bottom: 20px;"></div>
<a data-source='notice' class='wpsc-boost-migration-button button button-primary <?php echo esc_attr( $button_class ); ?>' href="<?php echo esc_url( $button_url ); ?>">
<div class="spinner" style="display:none; margin-top: 8px"></div>
<label><?php esc_html_e( 'Migrate now', 'wp-super-cache' ); ?></label>
</a>
</p>
</div>
<?php
}
add_action( 'admin_notices', 'wpsc_jetpack_boost_notice' );
/**
* Dismiss the migration admin notice by setting a user option flag.
*/
function wpsc_dismiss_boost_notice() {
update_user_option( get_current_user_id(), 'wpsc_dismissed_boost_admin_notice', '1' );
}
/**
* Handler called by AJAX to dismiss the admin notice.
*/
function wpsc_dismiss_boost_notice_ajax_handler() {
check_ajax_referer( 'wpsc_dismiss_boost_notice', 'nonce' );
wpsc_dismiss_boost_notice();
wp_die();
}
add_action( 'wp_ajax_wpsc_dismiss_boost_notice', 'wpsc_dismiss_boost_notice_ajax_handler' );
/**
* Dismiss the admin notice if the Jetpack Boost plugin is activated.
*/
function wpsc_dismiss_notice_on_activation() {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
wpsc_dismiss_boost_notice();
}
add_action( 'wp_ajax_wpsc_activate_boost', 'wpsc_dismiss_notice_on_activation' );
/**
* Add a notice to the settings page if the Jetpack Boost cache module is detected.
* The notice contains instructions on how to disable the Boost Cache module.
*/
function wpsc_deactivate_boost_cache_notice() {
global $wpsc_advanced_cache_filename;
?>
<div style="width: 50%" class="notice notice-error"><h2><?php esc_html_e( 'Warning! Jetpack Boost Cache Detected', 'wp-super-cache' ); ?></h2>
<?php // translators: %s is the filename of the advanced-cache.php file ?>
<p><?php printf( esc_html__( 'The file %s was created by the Jetpack Boost plugin.', 'wp-super-cache' ), esc_html( $wpsc_advanced_cache_filename ) ); ?></p>
<p><?php esc_html_e( 'You can use Jetpack Boost and WP Super Cache at the same time but only if the Cache Site Pages module in Boost is disabled. To use WP Super Cache for caching:', 'wp-super-cache' ); ?></p>
<ol>
<?php // translators: %s is a html link to the Boost settings page ?>
<li><?php printf( esc_html__( 'Deactivate the "Cache Site Pages" module of Jetpack Boost on the %s page.', 'wp-super-cache' ), '<a href="' . esc_url( admin_url( 'admin.php?page=jetpack-boost' ) ) . '">' . esc_html__( 'Boost Settings', 'wp-super-cache' ) . '</a>' ); ?></li>
<li><?php esc_html_e( 'Reload this page to configure WP Super Cache.', 'wp-super-cache' ); ?></li>
<li><?php esc_html_e( 'You can continue to use the other features of Jetpack Boost.', 'wp-super-cache' ); ?></li>
</ol>
</div>
<?php
set_transient( 'wpsc_boost_cache_notice_displayed', true, WEEK_IN_SECONDS );
}
/**
* Tell Jetpack when the cache is moved from Jetpack Boost to WP Super Cache.
*/
function wpsc_track_move_from_boost() {
if ( ! get_transient( 'wpsc_boost_cache_notice_displayed' ) ) {
return;
}
delete_transient( 'wpsc_boost_cache_notice_displayed' );
do_action( 'jb_cache_moved_to_wpsc' );
}
add_action( 'wpsc_created_advanced_cache', 'wpsc_track_move_from_boost' );
/**
* Notify Jetpack Boost that Boost Cache will be used instead of WP Super Cache.
*
* @param string $source The source of the migration: 'notice', 'banner', 'try_button'.
*/
function wpsc_notify_migration_to_boost( $source ) {
if ( ! in_array( $source, array( 'notice', 'banner', 'try_button' ), true ) ) {
return;
}
set_transient( 'jb_cache_moved_to_boost', $source, WEEK_IN_SECONDS );
}
/**
* Check if Jetpack Boost is compatible with WP Super Cache.
*
* @return bool
*/
function wpsc_is_boost_compatible() {
if ( ! empty( $GLOBALS['wp_cache_mobile_enabled'] ) ) {
return false;
}
if ( isset( $GLOBALS['wp_super_cache_late_init'] ) && $GLOBALS['wp_super_cache_late_init'] === 1 ) {
return false;
}
if ( ! empty( $GLOBALS['wpsc_rejected_cookies'] ) ) {
return false;
}
if ( isset( $GLOBALS['wp_cache_not_logged_in'] ) && $GLOBALS['wp_cache_not_logged_in'] !== 2 ) {
return false;
}
if ( isset( $GLOBALS['wp_cache_preload_on'] ) && $GLOBALS['wp_cache_preload_on'] === 1 ) {
return false;
}
if ( ! empty( $GLOBALS['wp_cache_no_cache_for_get'] ) ) {
return false;
}
if ( ! empty( $GLOBALS['wpsc_save_headers'] ) ) {
return false;
}
if ( isset( $GLOBALS['wp_cache_make_known_anon'] ) && $GLOBALS['wp_cache_make_known_anon'] === 1 ) {
return false;
}
if ( ! empty( $GLOBALS['wp_cache_mfunc_enabled'] ) ) {
return false;
}
if ( isset( $GLOBALS['wp_cache_clear_on_post_edit'] ) && $GLOBALS['wp_cache_clear_on_post_edit'] === 1 ) {
return false;
}
if ( ! empty( $GLOBALS['wp_cache_front_page_checks'] ) ) {
return false;
}
if ( is_array( $GLOBALS['wp_cache_pages'] ) && array_sum( $GLOBALS['wp_cache_pages'] ) ) {
return false;
}
$default_cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );
if ( is_array( $GLOBALS['cache_acceptable_files'] ) && array_diff( $GLOBALS['cache_acceptable_files'], $default_cache_acceptable_files ) ) {
return false;
}
$default_cache_rejected_uri = array( 'wp-.*\\.php', 'index\\.php' );
if ( is_array( $GLOBALS['cache_rejected_uri'] ) && array_diff( $GLOBALS['cache_rejected_uri'], $default_cache_rejected_uri ) ) {
return false;
}
if ( is_array( $GLOBALS['cache_rejected_user_agent'] ) && array_diff( $GLOBALS['cache_rejected_user_agent'], array( '' ) ) ) {
return false;
}
return true;
}
/**
* Check if the Jetpack Boost that is installed is current.
*
* @return bool True if Jetpack Boost is same as or newer than version 3.4.0
*/
function wpsc_is_boost_current() {
if ( defined( 'JETPACK_BOOST_VERSION' ) ) {
return version_compare( (string) JETPACK_BOOST_VERSION, MINIMUM_BOOST_VERSION, '>=' );
} else {
return true; // don't care if Boost is not installed
}
}

View File

@@ -0,0 +1,37 @@
/* global wpsc_ajax */
( function ( $ ) {
$( document ).ready( function () {
$( '#wp-admin-bar-delete-cache' ).on( 'click', function () {
$( '#wp-admin-bar-delete-cache' ).fadeOut( 'slow' );
$.ajax( {
type: 'post',
dataType: 'json',
url: wpsc_ajax.ajax_url,
data: {
// wp ajax action
action: 'ajax-delete-cache',
path: wpsc_ajax.path,
admin: wpsc_ajax.admin,
// send the nonce along with the request
nonce: wpsc_ajax.nonce,
},
success: function () {
if ( wpsc_ajax.admin === '1' ) {
// eslint-disable-next-line no-console
console.log( 'Deleted entire cache' );
} else {
// eslint-disable-next-line no-console
console.log( 'Deleted cache for this page and reloading' );
}
window.location.reload();
},
complete: function () {
$( '#wp-admin-bar-delete-cache' ).fadeIn( 'slow' );
},
} );
return false;
} );
} );
} )( jQuery );

View File

@@ -0,0 +1,182 @@
<?php
if ( defined( 'WPSCDISABLEDELETEBUTTON' ) ) {
return;
}
/**
* Adds "Delete Cache" button in WP Toolbar.
*/
function wpsc_admin_bar_render( $wp_admin_bar ) {
if ( ! function_exists( 'current_user_can' ) || ! is_user_logged_in() ) {
return false;
}
$path_to_home = rtrim( (string) parse_url( get_option( 'home' ), PHP_URL_PATH ), '/' );
if ( ( is_singular() || is_archive() || is_front_page() || is_search() ) && current_user_can( 'delete_others_posts' ) ) {
$site_regex = preg_quote( $path_to_home, '`' );
$req_uri = preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER[ 'REQUEST_URI' ] );
$path = preg_replace( '`^' . $site_regex . '`', '', $req_uri );
$wp_admin_bar->add_menu( array(
'parent' => '',
'id' => 'delete-cache',
'title' => __( 'Delete Cache', 'wp-super-cache' ),
'meta' => array( 'title' => __( 'Delete cache of the current page', 'wp-super-cache' ) ),
'href' => wp_nonce_url( admin_url( 'index.php?action=delcachepage&path=' . rawurlencode( $path ) ), 'delete-cache-' . $path . '_0', 'nonce' )
) );
}
if ( is_admin() && ( wpsupercache_site_admin() || current_user_can( 'delete_others_posts' ) ) ) {
$wp_admin_bar->add_menu( array(
'parent' => '',
'id' => 'delete-cache',
'title' => __( 'Delete Cache', 'wp-super-cache' ),
'meta' => array( 'title' => __( 'Delete Super Cache cached files', 'wp-super-cache' ) ),
'href' => wp_nonce_url( admin_url( 'index.php?admin=1&action=delcachepage&path=' . rawurlencode( trailingslashit( $path_to_home ) ) ), 'delete-cache-' . trailingslashit( $path_to_home ) . '_1', 'nonce' )
) );
}
}
add_action( 'admin_bar_menu', 'wpsc_admin_bar_render', 99 );
function wpsc_delete_cache_scripts() {
if ( ! is_user_logged_in() ) {
return;
}
if (
is_plugin_active( 'amp/amp.php' ) ||
( function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() )
) {
wp_cache_debug( 'AMP detected. Not loading Delete Cache button JavaScript.' );
return;
}
$path_to_home = rtrim( (string) parse_url( get_option( 'home' ), PHP_URL_PATH ), '/' );
wp_enqueue_script( 'delete-cache-button', plugins_url( '/delete-cache-button.js', __FILE__ ), array('jquery'), '1.0', 1 );
if ( ( is_singular() || is_archive() || is_front_page() || is_search() ) && current_user_can( 'delete_others_posts' ) ) {
$site_regex = preg_quote( $path_to_home, '`' );
$req_uri = preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER[ 'REQUEST_URI' ] );
$path_to_home = preg_replace( '`^' . $site_regex . '`', '', $req_uri );
$admin = 0;
} else {
$admin = 1;
}
if ( $path_to_home === '' ) {
$path_to_home = '/';
}
$nonce = wp_create_nonce( 'delete-cache-' . $path_to_home . '_' . $admin );
wp_localize_script( 'delete-cache-button', 'wpsc_ajax', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'path' => $path_to_home, 'admin' => $admin, 'nonce' => $nonce ) );
}
add_action( 'wp_ajax_ajax-delete-cache', 'wpsc_admin_bar_delete_cache_ajax' );
add_action( 'admin_enqueue_scripts', 'wpsc_delete_cache_scripts' );
/**
* Delete cache for a specific page.
*/
function wpsc_admin_bar_delete_cache_ajax() {
// response output
header( "Content-Type: application/json" );
if ( ! wpsc_delete_cache_directory() ) {
if ( defined( 'WPSCDELETEERROR' ) ) {
return json_decode( constant( 'WPSCDELETEERROR' ) );
} else {
return false;
}
}
}
function wpsc_admin_bar_delete_cache() {
$referer = wp_get_referer();
if ( ! isset( $_GET['admin'] ) ) {
$_GET['admin'] = 0;
}
foreach( array( 'path', 'nonce', 'admin' ) as $part ) {
if ( isset( $_GET[ $part ] ) ) {
$_POST[ $part ] = $_GET[ $part ];
}
}
wpsc_delete_cache_directory();
$req_path = isset( $_POST['path'] ) ? sanitize_text_field( stripslashes( $_POST['path'] ) ) : '';
$valid_nonce = ( $req_path && isset( $_POST['nonce'] ) ) ? wp_verify_nonce( $_POST['nonce'], 'delete-cache-' . $_POST['path'] . '_' . $_POST['admin'] ) : false;
if (
$valid_nonce
&& $referer
&& $req_path
&& (
false !== stripos( $referer, $req_path )
|| 0 === stripos( $referer, wp_login_url() )
)
) {
/**
* Hook into the cache deletion process after a successful cache deletion from the admin bar button.
*
* @since 1.9
*
* @param string $req_path Path of the page where the cache flush was requested.
* @param string $referer Referer URL.
*/
do_action( 'wpsc_after_delete_cache_admin_bar', $req_path, $referer );
if ( $_POST['admin'] ) {
wp_safe_redirect( $referer );
} else {
wp_safe_redirect( esc_url_raw( home_url( $req_path ) ) );
}
exit( 0 );
} else {
die( "Oops. Problem with nonce. Please delete cached page from settings page." );
}
}
if ( 'delcachepage' === filter_input( INPUT_GET, 'action' ) ) {
add_action( 'admin_init', 'wpsc_admin_bar_delete_cache' );
}
function wpsc_delete_cache_directory() {
if ( ! current_user_can( 'delete_others_posts' ) ) {
return false;
}
$req_path = isset( $_POST['path'] ) ? sanitize_text_field( stripslashes( $_POST['path'] ) ) : '';
$valid_nonce = ( $req_path && isset( $_POST['nonce'] ) ) ? wp_verify_nonce( $_POST['nonce'], 'delete-cache-' . $_POST['path'] . '_' . $_POST['admin'] ) : false;
if ( ! $valid_nonce ) {
wp_cache_debug( 'wpsc_delete_cache_directory: nonce was not valid' );
return false;
}
$path = realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $req_path ) ) ) );
if ( $path ) {
if ( isset( $_POST['admin'] ) && (int) $_POST['admin'] === 1 ) {
global $file_prefix;
wp_cache_debug( 'Cleaning cache for this site.' );
wp_cache_clean_cache( $file_prefix );
return;
}
$path = trailingslashit( $path );
$supercachepath = realpath( get_supercache_dir() );
if ( false === wp_cache_confirm_delete( $path ) || ! str_starts_with( $path, $supercachepath ) ) {
wp_cache_debug( 'Could not delete directory: ' . $path );
define( 'WPSCDELETEERROR', 'Could not delete directory' );
return false;
}
wp_cache_debug( 'Deleting cache files in directory: ' . $path );
wpsc_delete_files( $path );
return;
} else {
wp_cache_debug( 'wpsc_delete_cache_directory: Could not delete directory. It does not exist: ' . esc_attr( $_POST['path'] ) );
}
}

View File

@@ -0,0 +1,30 @@
<?php
// phpcs:disable WordPress.Security.NonceVerification.Recommended
function wpsc_preload_notification_scripts() {
if (
isset( $_GET['page'] ) && $_GET['page'] === 'wpsupercache' &&
isset( $_GET['tab'] ) && $_GET['tab'] === 'preload'
) {
wp_enqueue_script(
'preload-notification',
plugins_url( '/js/preload-notification.js', __DIR__ ),
array( 'jquery', 'wp-i18n' ),
WPSC_VERSION_ID,
true
);
wp_localize_script(
'preload-notification',
'wpsc_preload_ajax',
array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'wpsc-get-preload-status' ),
'preload_status' => wpsc_get_preload_status( true ),
)
);
}
}
add_action( 'admin_footer', 'wpsc_preload_notification_scripts' );

View File

@@ -0,0 +1,146 @@
/**
* Handle the buttons for the Boost migration.
* @param {jQuery} $ - jQuery
*/
( $ => {
$( document ).ready( function () {
// Don't run on versions of WordPress too old for the block editor and the translation methods it brings.
// All the install / activate options are plain links with meaningful destinations anyway.
if ( ! window.wp || ! window.wp.i18n ) {
return;
}
const { __, sprintf } = window.wp.i18n;
const ajaxurl = window.ajaxurl;
const wpscAdmin = window.wpscAdmin;
const setupBoostButton = $target => {
if ( ! $target.hasClass( 'wpsc-boost-migration-button' ) ) {
// eslint-disable-next-line no-console
console.warn( 'Unexpected button clicked for Boost migration.' );
return;
}
const $label = $target.find( 'label' );
const $spinner = $target.find( '.spinner' );
const $errorMessage = $target.prev( '.wpsc-boost-migration-error' );
const source = $target.attr( 'data-source' );
const originalText = $label.text();
// Helper function to show an error.
const showError = err => {
reset();
$errorMessage
.text(
err ||
__( 'An error occurred while trying to activate Jetpack Boost', 'wp-super-cache' )
)
.show();
};
// Helper function to show Boost Banner work in progress.
const showBusy = action => {
$target.attr( 'disabled', true );
$label.text( action );
$spinner.addClass( 'is-active' ).show();
};
// Helper function to reset Boost Banner button.
const reset = () => {
$target.attr( 'disabled', false );
$label.text( originalText );
$spinner.removeClass( 'is-active' ).hide();
};
// Activate Jetpack Boost.
const activateBoost = () => {
showBusy( __( 'Activating…', 'wp-super-cache' ) );
$.post( ajaxurl, {
action: 'wpsc_activate_boost',
_ajax_nonce: wpscAdmin.boostActivateNonce,
source: source,
} )
.done( response => {
if ( response.success ) {
$label.text( 'Success! Sending you to Jetpack Boost...' );
$spinner.hide();
window.location.href = 'admin.php?page=jetpack-boost';
} else {
showError( response.data );
}
} )
.fail( response => {
showError(
sprintf(
/* translators: %d is an HTTP error code */
__( 'Failed to activate Jetpack Boost: HTTP %d error received', 'wp-super-cache' ),
response.status
)
);
} );
};
const installBoost = () => {
showBusy( __( 'Installing…', 'wp-super-cache' ) );
$.post( ajaxurl, {
action: 'wpsc_install_plugin',
_ajax_nonce: wpscAdmin.boostInstallNonce,
slug: 'jetpack-boost',
} )
.done( response => {
if ( response.success ) {
activateBoost();
} else {
showError( response.data );
}
} )
.fail( response => {
showError(
sprintf(
/* translators: %d is an HTTP error code */
__( 'Failed to install Jetpack Boost: HTTP %d error received', 'wp-super-cache' ),
response.status
)
);
} );
};
return {
installBoost,
activateBoost,
};
};
// One-click install for Boost.
$( '.wpsc-install-boost-button' ).on( 'click', event => {
event.preventDefault();
const boostActivation = setupBoostButton( $( event.currentTarget ) );
boostActivation.installBoost();
} );
// Handle activate button click.
$( '.wpsc-activate-boost-button' ).on( 'click', event => {
event.preventDefault();
const boostActivation = setupBoostButton( $( event.currentTarget ) );
boostActivation.activateBoost();
} );
// Dismiss Boost banner.
$( '.wpsc-boost-dismiss' ).on( 'click', () => {
$( '.wpsc-boost-banner' ).fadeOut( 'slow' );
$.post( ajaxurl, {
action: 'wpsc-hide-boost-banner',
nonce: wpscAdmin.boostDismissNonce,
} );
} );
// Dismiss admin notice
$( '.boost-notice' ).on( 'click', '.notice-dismiss', event => {
event.preventDefault();
$.post( ajaxurl, {
action: 'wpsc_dismiss_boost_notice',
_ajax_nonce: wpscAdmin.boostNoticeDismissNonce,
} );
} );
} );
} )( jQuery );

View File

@@ -0,0 +1,122 @@
jQuery( document ).ready( function () {
const { __, sprintf } = window.wp.i18n;
// Set how often to check when a preload job is running
const ACTIVE_INTERVAL = 3000;
// Set how often to check when no preload job is running
const INACTIVE_INTERVAL = 30000;
// Get a reference to the log element and the previous log entry
const preloadInfoPanel = jQuery( '#wpsc-preload-status' );
// Abort early if no info panel exists.
if ( ! preloadInfoPanel.length ) {
return;
}
update_preload_status( window.wpsc_preload_ajax.preload_status );
/**
* Schedule the next preload status update.
*
* @param {number} time - time in milliseconds to wait before updating.
*/
function schedule_preload_update( time ) {
setTimeout( () => {
jQuery.post(
window.wpsc_preload_ajax.ajax_url,
{
action: 'wpsc_get_preload_status',
_ajax_nonce: window.wpsc_preload_ajax.nonce,
},
json => {
if ( ! json || ! json.success ) {
return;
}
update_preload_status( json.data );
}
);
}, time );
}
/**
* Update displayed preload status using the provided data.
*
* @param {object} data - description of the preload status.
*/
function update_preload_status( data ) {
// Bail early if no data is available. But try again in a few seconds.
if ( ! data || ( ! data.running && ! data.next && ! data.previous ) ) {
schedule_preload_update( ACTIVE_INTERVAL );
return;
}
preloadInfoPanel.empty();
let nextPreloadTime = data.running ? ACTIVE_INTERVAL : INACTIVE_INTERVAL;
if ( data.running ) {
const panel = jQuery( '<div class="notice notice-warning">' );
panel.append(
jQuery( '<p>' ).append( jQuery( '<b>' ).text( __( 'Preloading', 'wp-super-cache' ) ) )
);
panel.append(
jQuery( '<p>' ).text( __( 'Preloading is currently running.', 'wp-super-cache' ) )
);
const ul = panel.append( jQuery( '<ul>' ) );
for ( const entry of data.history ) {
ul.append( jQuery( '<li>' ).text( entry.group + ' ' + entry.progress + ': ' + entry.url ) );
}
preloadInfoPanel.append( panel );
} else if ( data.next || data.previous ) {
const panel = jQuery( '<div class="notice notice-info">' );
if ( data.next ) {
const diff = Math.max( 0, data.next - Math.floor( Date.now() / 1000 ) );
const seconds = diff % 60;
const minutes = Math.floor( diff / 60 ) % 60;
const hours = Math.floor( diff / 3600 ) % 24;
const days = Math.floor( diff / 86400 );
// If we're preloading within the next minute, start loading faster.
if ( minutes + hours === 0 ) {
nextPreloadTime = ACTIVE_INTERVAL;
}
const p = jQuery( '<p>' );
p.append(
jQuery( '<b>' ).html(
sprintf(
/* Translators: 1: Number of days, 2: Number of hours, 3: Number of minutes, 4: Number of seconds */
__(
'<b>Next preload scheduled</b> in %1$s days, %2$s hours, %3$s minutes and %4$s seconds.',
'wp-super-cache'
),
days,
hours,
minutes,
seconds
)
)
);
panel.append( p );
}
if ( data.previous ) {
const p = jQuery( '<p>' );
p.append( jQuery( '<b>' ).text( __( 'Last preload finished:', 'wp-super-cache' ) + ' ' ) );
p.append( jQuery( '<span>' ).text( new Date( data.previous * 1000 ).toLocaleString() ) );
panel.append( p );
}
preloadInfoPanel.append( panel );
}
schedule_preload_update( nextPreloadTime );
}
} );

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,388 @@
<?php
/* Taken from OSSDL CDN off-linker, a plugin by W-Mark Kubacki and used with permission */
if ( ! isset( $ossdlcdn ) ) {
$ossdlcdn = 1; // have to default to on for existing users.
}
if ( 1 === $ossdlcdn && ! is_admin() ) {
add_action( 'init', 'do_scossdl_off_ob_start' );
}
/**
* Set up some defaults.
*
* @global string $ossdl_off_blog_url
* @global string $ossdl_off_cdn_url
* @global string $ossdl_cname
* @global int $ossdl_https
* @global array $ossdl_off_include_dirs
* @global array $ossdl_off_excludes
* @global array $ossdl_arr_of_cnames
*
* @return void
*/
function scossdl_off_get_options() {
global $ossdl_off_blog_url, $ossdl_off_cdn_url, $ossdl_cname, $ossdl_https;
global $ossdl_off_include_dirs, $ossdl_off_excludes, $ossdl_arr_of_cnames;
$ossdl_off_blog_url = get_option( 'ossdl_off_blog_url' );
if ( false === $ossdl_off_blog_url ) {
$ossdl_off_blog_url = untrailingslashit( get_site_url() );
add_option( 'ossdl_off_blog_url', $ossdl_off_blog_url );
}
if ( has_filter( 'ossdl_off_blog_url' ) ) {
$ossdl_off_blog_url = untrailingslashit( apply_filters( 'ossdl_off_blog_url', $ossdl_off_blog_url ) );
}
$ossdl_off_cdn_url = get_option( 'ossdl_off_cdn_url' );
if ( false === $ossdl_off_cdn_url ) {
$ossdl_off_cdn_url = untrailingslashit( get_site_url() );
add_option( 'ossdl_off_cdn_url', $ossdl_off_cdn_url );
}
$include_dirs = get_option( 'ossdl_off_include_dirs' );
if ( false !== $include_dirs ) {
$ossdl_off_include_dirs = array_filter( array_map( 'trim', explode( ',', $include_dirs ) ) );
} else {
$ossdl_off_include_dirs = scossdl_off_default_inc_dirs();
add_option( 'ossdl_off_include_dirs', implode( ',', $ossdl_off_include_dirs ) );
}
$exclude = get_option( 'ossdl_off_exclude' );
if ( false !== $exclude ) {
$ossdl_off_excludes = array_filter( array_map( 'trim', explode( ',', $exclude ) ) );
} else {
$ossdl_off_excludes = array( '.php' );
add_option( 'ossdl_off_exclude', implode( ',', $ossdl_off_excludes ) );
}
$ossdl_cname = get_option( 'ossdl_cname' );
if ( false !== $ossdl_cname ) {
$ossdl_cname = trim( $ossdl_cname );
} else {
$ossdl_cname = '';
add_option( 'ossdl_cname', $ossdl_cname );
}
$ossdl_arr_of_cnames = array_filter( array_map( 'trim', explode( ',', $ossdl_cname ) ) );
$ossdl_https = intval( get_option( 'ossdl_https' ) );
}
/**
* Get default directories.
*
* @return array
*/
function scossdl_off_default_inc_dirs() {
$home_path = trailingslashit( (string) parse_url( get_option( 'siteurl' ), PHP_URL_PATH ) );
$inc_dirs = array();
foreach ( array( content_url(), includes_url() ) as $dir ) {
$dir = wp_make_link_relative( $dir );
$dir = preg_replace( '`^' . preg_quote( $home_path, '`' ) . '`', '', $dir );
$inc_dirs[] = trim( $dir, '/' );
}
return $inc_dirs;
}
/**
* Determines whether to exclude a match.
*
* @param string $match URI to examine.
* @param array $excludes Array of "badwords".
*
* @return boolean true if to exclude given match from rewriting.
*/
function scossdl_off_exclude_match( $match, $excludes ) {
foreach ( $excludes as $badword ) {
if ( false !== stripos( $match, $badword ) ) {
return true;
}
}
return false;
}
/**
* Compute string modulo, based on SHA1 hash
*
* @param string $str The string.
* @param int $mod The divisor.
*
* @return int The remainder.
*/
function scossdl_string_mod( $str, $mod ) {
/**
* The full SHA1 is too large for PHP integer types.
* This should be enough for our purpose.
*/
$num = hexdec( substr( sha1( $str ), 0, 5 ) );
return $num % $mod;
}
/**
* Rewriter of URLs, used as replace-callback.
*
* Called by #scossdl_off_filter.
*/
function scossdl_off_rewriter( $match ) {
global $ossdl_off_blog_url, $ossdl_https, $ossdl_off_excludes, $ossdl_arr_of_cnames;
static $count_cnames = null, $include_dirs = null;
// Set up static variables. Run once only.
if ( ! isset( $count_cnames ) ) {
$count_cnames = count( $ossdl_arr_of_cnames );
$include_dirs = scossdl_off_additional_directories();
}
if ( $ossdl_https && str_starts_with( $match[0], 'https' ) ) {
return $match[0];
}
if ( scossdl_off_exclude_match( $match[0], $ossdl_off_excludes ) ) {
return $match[0];
}
if ( preg_match( '`(' . $include_dirs . ')`', $match[0] ) ) {
$offset = scossdl_string_mod( $match[1], $count_cnames );
return str_replace( $ossdl_off_blog_url, $ossdl_arr_of_cnames[ $offset ], $match[0] );
}
return $match[0];
}
/**
* Creates a regexp compatible pattern from the directories to be included in matching.
*
* @return String with the pattern with {@literal |} as prefix, or empty
*/
function scossdl_off_additional_directories() {
global $ossdl_off_include_dirs;
$arr_dirs = array();
foreach ( $ossdl_off_include_dirs as $dir ) {
$arr_dirs[] = preg_quote( trim( $dir ), '`' );
}
return implode( '|', $arr_dirs );
}
/**
* Output filter which runs the actual plugin logic.
*
* @param string $content The content of the output buffer.
*
* @return string The rewritten content.
*/
function scossdl_off_filter( $content ) {
global $ossdl_off_blog_url, $ossdl_off_cdn_url;
global $ossdl_off_include_dirs, $ossdl_off_excludes, $ossdl_arr_of_cnames;
if ( empty( $content ) || empty( $ossdl_off_cdn_url ) ||
$ossdl_off_blog_url === $ossdl_off_cdn_url
) {
return $content; // no rewrite needed.
}
if ( empty( $ossdl_off_include_dirs ) || ! is_array( $ossdl_off_include_dirs ) ) {
$ossdl_off_include_dirs = scossdl_off_default_inc_dirs();
}
if ( empty( $ossdl_off_excludes ) || ! is_array( $ossdl_off_excludes ) ) {
$ossdl_off_excludes = array();
}
if ( ! in_array( $ossdl_off_cdn_url, (array) $ossdl_arr_of_cnames, true ) ) {
$ossdl_arr_of_cnames = array_merge( array( $ossdl_off_cdn_url ), (array) $ossdl_arr_of_cnames );
}
$ossdl_arr_of_cnames = apply_filters( 'wpsc_cdn_urls', $ossdl_arr_of_cnames );
$dirs = scossdl_off_additional_directories();
$regex = '`(?<=[(\"\'])' . preg_quote( $ossdl_off_blog_url, '`' ) . '/(?:((?:' . $dirs . ')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])`';
return preg_replace_callback( $regex, 'scossdl_off_rewriter', $content );
}
/**
* Registers scossdl_off_filter as output buffer, if needed.
*/
function do_scossdl_off_ob_start() {
global $ossdl_off_blog_url, $ossdl_off_cdn_url;
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
return;
}
scossdl_off_get_options();
if ( ! empty( $ossdl_off_cdn_url ) &&
$ossdl_off_blog_url !== $ossdl_off_cdn_url
) {
add_filter( 'wp_cache_ob_callback_filter', 'scossdl_off_filter' );
}
}
/**
* Update CDN settings to the options database table.
*/
function scossdl_off_update() {
if ( isset( $_POST['action'], $_POST['_wpnonce'] )
&& 'update_ossdl_off' === $_POST['action'] // WPCS: sanitization ok.
&& wp_verify_nonce( $_POST['_wpnonce'], 'wp-cache' )
) {
update_option( 'ossdl_off_cdn_url', untrailingslashit( wp_unslash( $_POST['ossdl_off_cdn_url'] ) ) ); // WPSC: sanitization ok.
update_option( 'ossdl_off_blog_url', untrailingslashit( wp_unslash( $_POST['ossdl_off_blog_url'] ) ) ); // WPSC: sanitization ok.
if ( empty( $_POST['ossdl_off_include_dirs'] ) ) {
$include_dirs = implode( ',', scossdl_off_default_inc_dirs() );
} else {
$include_dirs = sanitize_text_field( wp_unslash( $_POST['ossdl_off_include_dirs'] ) ); // WPSC: validation ok,sanitization ok.
}
update_option( 'ossdl_off_include_dirs', $include_dirs );
update_option( 'ossdl_off_exclude', sanitize_text_field( wp_unslash( $_POST['ossdl_off_exclude'] ) ) ); // WPSC: sanitization ok.
update_option( 'ossdl_cname', sanitize_text_field( wp_unslash( $_POST['ossdl_cname'] ) ) ); // WPSC: sanitization ok.
$ossdl_https = empty( $_POST['ossdl_https'] ) ? 0 : 1;
$ossdlcdn = empty( $_POST['ossdlcdn'] ) ? 0 : 1;
update_option( 'ossdl_https', $ossdl_https );
wp_cache_setting( 'ossdlcdn', $ossdlcdn );
}
}
/**
* Show CDN settings.
*/
function scossdl_off_options() {
global $ossdlcdn, $ossdl_off_blog_url, $ossdl_off_cdn_url, $ossdl_cname, $ossdl_https;
global $ossdl_off_include_dirs, $ossdl_off_excludes;
scossdl_off_update();
scossdl_off_get_options();
$example_cdn_uri = ( is_ssl() ? 'https' : 'http' ) . '://cdn.' . preg_replace( '`^(https?:)?//(www\.)?`', '', get_site_url() );
$example_cnames = str_replace( '://cdn.', '://cdn1.', $example_cdn_uri );
$example_cnames .= ',' . str_replace( '://cdn.', '://cdn2.', $example_cdn_uri );
$example_cnames .= ',' . str_replace( '://cdn.', '://cdn3.', $example_cdn_uri );
$example_cdn_uri = ( get_site_url() === $ossdl_off_cdn_url ) ? $example_cdn_uri : $ossdl_off_cdn_url;
$example_cdn_uri .= '/wp-includes/js/jquery/jquery-migrate.js';
$example_cdn_uri = esc_url( $example_cdn_uri );
?>
<div class="wpsc-card">
<h3><?php _e( 'Jetpack CDN' ); ?></h3>
<p><?php printf(
__( 'The free %1$sJetpack plugin%2$s has a %3$sSite Accelerator%2$s feature that is easier to use than the CDN functionality in this plugin. However files will be cached "forever" and will not update if you update the local file. Files will need to be renamed to refresh them. The %3$sJetpack documentation%2$s explains more about this.', 'wp-super-cache' ),
'<a href="https://jetpack.com/">',
'</a>',
'<a href="https://jetpack.com/support/site-accelerator/">'
); ?></p>
<?php
if ( class_exists( 'Jetpack' ) ) {
if ( Jetpack::is_module_active( 'photon' ) ) {
?><p><strong><?php printf(
__( 'You already have Jetpack installed and %1$sSite Accelerator%2$s enabled on this blog. The CDN here is disabled to avoid conflicts with Jetpack.', 'wp-super-cache' ),
'<a href="https://jetpack.com/support/site-accelerator/">',
'</a>'
); ?></strong></p><?php
} else {
?><p><?php printf(
__( 'You already have Jetpack installed but %1$sSite Accelerator%2$s is disabled on this blog. Enable it on the %3$sJetpack settings page%2$s.', 'wp-super-cache' ),
'<a href="https://jetpack.com/support/site-accelerator/">',
'</a>',
'<a href="' . admin_url( 'admin.php?page=jetpack#/settings' ) . '">'
); ?></p><?php
}
} else {
?><p><strong><?php printf(
__( '%1$sJetpack%2$s was not found on your site but %3$syou can install it%2$s. The Site Accelerator feature is free to use on any WordPress site and offers the same benefit as other CDN services. You should give it a try!', 'wp-super-cache' ),
'<a href="https://jetpack.com/">',
'</a>',
'<a href="' . admin_url( 'plugin-install.php?s=jetpack&tab=search&type=term' ) . '">'
); ?></strong></p><?php
}
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
echo '</div>'; // close wpsc-card
return;
}
?>
<h3><?php _e( 'Simple CDN' ); ?></h3>
<p><?php _e( 'Your website probably uses lots of static files. Image, Javascript and CSS files are usually static files that could just as easily be served from another site or CDN. Therefore, this plugin replaces any links in the <code>wp-content</code> and <code>wp-includes</code> directories (except for PHP files) on your site with the URL you provide below. That way you can either copy all the static content to a dedicated host or mirror the files to a CDN by <a href="https://www.google.com/search?q=cdn+origin+pull" target="_blank">origin pull</a>.', 'wp-super-cache' ); ?></p>
<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Test some static urls e.g., %s to ensure your CDN service is fully working before saving changes.', 'wp-super-cache' ), '<code>' . esc_html( $example_cdn_uri ) . '</code>' ); ?></p>
<?php if ( get_home_url() !== $ossdl_off_blog_url ) { ?>
<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Your siteurl and homeurl are different. The plugin is using %s as the homepage URL of your site but if that is wrong please use the filter "ossdl_off_blog_url" to fix it.', 'wp-super-cache' ), '<code>' . esc_html( $ossdl_off_blog_url ) . '</code>' ); ?></p>
<?php } ?>
<p><?php esc_html_e( 'You can define different CDN URLs for each site on a multsite network.', 'wp-super-cache' ); ?></p>
<p><form method="post" action="">
<?php wp_nonce_field( 'wp-cache' ); ?>
<table class="form-table"><tbody>
<tr valign="top">
<td style='text-align: right'>
<input id='ossdlcdn' type="checkbox" name="ossdlcdn" value="1" <?php checked( $ossdlcdn ); ?> />
</td>
<th scope="row"><label for="ossdlcdn"><?php esc_html_e( 'Enable CDN Support', 'wp-super-cache' ); ?></label></th>
</tr>
<tr valign="top">
<th scope="row"><label for="ossdl_off_cdn_url"><?php esc_html_e( 'Site URL', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_off_blog_url" value="<?php echo esc_attr( untrailingslashit( $ossdl_off_blog_url ) ); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php _e( 'The URL of your site. No trailing <code>/</code> please.', 'wp-super-cache' ); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="ossdl_off_cdn_url"><?php esc_html_e( 'Off-site URL', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_off_cdn_url" value="<?php echo esc_attr( $ossdl_off_cdn_url ); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php printf( __( 'The new URL to be used in place of %1$s for rewriting. No trailing <code>/</code> please.<br />Example: <code>%2$s</code>.', 'wp-super-cache' ), esc_html( get_site_url() ), esc_html( $example_cdn_uri ) ); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="ossdl_off_include_dirs"><?php esc_html_e( 'Include directories', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_off_include_dirs" value="<?php echo esc_attr( implode( ',', $ossdl_off_include_dirs ) ); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php _e( 'Directories to include in static file matching. Use a comma as the delimiter. Default is <code>wp-content, wp-includes</code>, which will be enforced if this field is left empty.', 'wp-super-cache' ); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="ossdl_off_exclude"><?php esc_html_e( 'Exclude if substring', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_off_exclude" value="<?php echo esc_attr( implode( ',', $ossdl_off_excludes ) ); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php _e( 'Excludes something from being rewritten if one of the above strings is found in the URL. Use a comma as the delimiter like this, <code>.php, .flv, .do</code>, and always include <code>.php</code> (default).', 'wp-super-cache' ); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="ossdl_cname"><?php esc_html_e( 'Additional CNAMES', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_cname" value="<?php echo esc_attr( $ossdl_cname ); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php printf( __( 'These <a href="https://www.wikipedia.org/wiki/CNAME_record">CNAMES</a> will be used in place of %1$s for rewriting (in addition to the off-site URL above). Use a comma as the delimiter. For pages with a large number of static files, this can improve browser performance. CNAMEs may also need to be configured on your CDN.<br />Example: %2$s', 'wp-super-cache' ), esc_html( get_site_url() ), esc_html( $example_cnames ) ); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row" colspan='2'><label><input type='checkbox' name='ossdl_https' value='1' <?php checked( $ossdl_https ); ?> /><?php esc_html_e( 'Skip https URLs to avoid "mixed content" errors', 'wp-super-cache' ); ?></label></th>
</tr>
</tbody></table>
<input type="hidden" name="action" value="update_ossdl_off" />
<p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-super-cache' ); ?>" /></p>
</form></p>
<p>
<?php
printf(
/* Translators: placeholder is a link to OSSDL CDN Off Linker plugin on WordPress.org */
esc_html__( 'CDN functionality provided by %s by Mark Kubacki', 'wp-super-cache' ),
'<a href="https://wordpress.org/plugins/ossdl-cdn-off-linker/">OSSDL CDN Off Linker</a>'
);
?>
</p>
</div> <!-- Close .wpsc-card -->
<?php
}

View File

@@ -0,0 +1,424 @@
<div class="wpsc-settings-inner">
<?php
global $wp_cache_mod_rewrite, $wp_cache_mfunc_enabled, $wp_cache_mobile_enabled, $cache_enabled, $cache_path, $cache_time_interval, $cache_schedule_type;
$faq_url = 'https://jetpack.com/support/wp-super-cache/wp-super-cache-faq/';
$kses_allow_links = array( 'a' => array( 'href' => array() ) ); // Arguments for wp_kses to allow links.
if ( isset( $wp_cache_front_page_checks ) == false ) {
$wp_cache_front_page_checks = true;
}
echo '<div class="wpsc-card">';
echo '<form name="wp_manager" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) ) . '" method="post">';
wp_nonce_field( 'wp-cache' );
echo '<input type="hidden" name="action" value="scupdates" />';
?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="wp_cache_enabled"><?php _e( 'Caching', 'wp-super-cache' ); ?></label></th>
<td>
<fieldset>
<legend class="hidden"><?php _e( 'Caching', 'wp-super-cache' ); ?></legend>
<label><input type='checkbox' name='wp_cache_enabled' id='wp_cache_enabled' value='1' <?php checked( $cache_enabled, true ); ?>> <?php esc_html_e( 'Enable Caching', 'wp-super-cache' ); ?><br />
</fieldset>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'Cache Delivery Method', 'wp-super-cache' ); ?></th>
<td>
<fieldset>
<label><input type='radio' name='wp_cache_mod_rewrite' <?php if ( $wp_cache_mod_rewrite == 0 ) echo "checked"; ?> value='0'> <?php _e( '<acronym title="Use PHP to serve cached files">Simple</acronym>', 'wp-super-cache' ); echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?></label><br />
<label><input type='radio' name='wp_cache_mod_rewrite' <?php if ( $wp_cache_mod_rewrite == 1 ) echo "checked"; ?> value='1'> <?php _e( '<acronym title="Use mod_rewrite to serve cached files">Expert</acronym>', 'wp-super-cache' ); ?></label><br />
<em><small class='description'><?php _e( 'Expert caching requires changes to important server files and may require manual intervention if enabled.', 'wp-super-cache' ); ?></small></em>
<?php if ( $is_nginx ) { ?>
<em><small class='description'>
<?php
echo wp_kses(
sprintf(
/* Translators: placeholder is a link to a support document. */
__( 'Nginx rules can be found <a href="%s">here</a> but are not officially supported.', 'wp-super-cache' ),
'https://wordpress.org/documentation/article/nginx/#wp-super-cache-rules'
),
array(
'a' => array(
'href' => array(),
),
)
);
?>
</small></em>
<?php } ?>
</fieldset>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'Miscellaneous', 'wp-super-cache' ); ?></th>
<td>
<fieldset>
<legend class="hidden">Miscellaneous</legend>
<strong><?php echo __( 'Cache Restrictions', 'wp-super-cache' ); ?></strong><br />
<label><input type='radio' name='wp_cache_not_logged_in' <?php checked( $wp_cache_not_logged_in, 0 ); ?> value='0'> <?php echo __( 'Enable caching for all visitors.', 'wp-super-cache' ); ?></label><br />
<label><input type='radio' name='wp_cache_not_logged_in' <?php checked( $wp_cache_not_logged_in, 1 ); ?> value='1'> <?php echo __( 'Disable caching for visitors who have a cookie set in their browser.', 'wp-super-cache' ); ?></label><br />
<label><input type='radio' name='wp_cache_not_logged_in' <?php checked( $wp_cache_not_logged_in, 2 ); ?> value='2'> <?php echo __( 'Disable caching for logged in visitors.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br /><br />
<label><input type='checkbox' name='wp_cache_no_cache_for_get' <?php checked( $wp_cache_no_cache_for_get ); ?> value='1'> <?php _e( 'Don&#8217;t cache pages with GET parameters. (?x=y at the end of a url)', 'wp-super-cache' ); ?></label><br />
<?php if ( ! defined( 'WPSC_DISABLE_COMPRESSION' ) ) : ?>
<?php if ( ! function_exists( 'gzencode' ) ) : ?>
<em><?php esc_html_e( 'Warning! Compression is disabled as gzencode() function was not found.', 'wp-super-cache' ); ?></em><br />
<?php else : ?>
<label><input type='checkbox' name='cache_compression' <?php checked( $cache_compression ); ?> value='1'> <?php echo __( 'Compress pages so they&#8217;re served more quickly to visitors.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
<em><?php esc_html_e( 'Compression is disabled by default because some hosts have problems with compressed files. Switching it on and off clears the cache.', 'wp-super-cache' ); ?></em><br />
<?php endif; ?>
<?php endif; ?>
<label><input type='checkbox' name='cache_rebuild_files' <?php checked( $cache_rebuild_files ); ?> value='1'> <?php echo esc_html__( 'Cache rebuild. Serve a supercache file to anonymous users while a new file is being generated.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
<?php if ( $wp_cache_mod_rewrite ) { ?>
<br />
<p><strong><?php esc_html_e( 'Warning! The following settings are disabled because Expert caching is enabled.', 'wp-super-cache' ); ?></strong></p>
<br />
<?php } ?>
<label><input <?php disabled( $wp_cache_mod_rewrite ); ?> type='checkbox' name='wpsc_save_headers' <?php checked( $wpsc_save_headers ); ?> value='1' /> <?php esc_html_e( 'Cache HTTP headers with page content.', 'wp-super-cache' ); ?></label><br />
<label><input <?php disabled( $wp_cache_mod_rewrite ); ?> type='checkbox' name='wp_supercache_304' <?php checked( $wp_supercache_304 ); ?> value='1'> <?php echo esc_html__( '304 Browser caching. Improves site performance by checking if the page has changed since the browser last requested it.', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
<?php echo '<em>' . esc_html__( '304 support is disabled by default because some hosts have had problems with the headers used in the past.', 'wp-super-cache' ) . '</em><br />'; ?>
<label><input <?php disabled( $wp_cache_mod_rewrite ); ?> type='checkbox' name='wp_cache_make_known_anon' <?php checked( $wp_cache_make_known_anon ); ?> value='1'> <?php _e( 'Make known users anonymous so they&#8217;re served supercached static files.', 'wp-super-cache' ); ?></label><br />
</legend>
</fieldset>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php esc_html_e( 'Advanced', 'wp-super-cache' ); ?></th>
<td>
<fieldset>
<legend class="hidden">Advanced</legend>
<label>
<input
type='checkbox'
name='wp_cache_mfunc_enabled'
value='1'
<?php disabled( $wp_cache_mod_rewrite ); ?>
<?php checked( $wp_cache_mfunc_enabled ); ?>
>
<?php
echo wp_kses(
sprintf(
/* translators: %s is the URL of the FAQ */
__(
'Enable dynamic caching. (See <a href="%s">FAQ</a> or wp-super-cache/plugins/dynamic-cache-test.php for example code.)',
'wp-super-cache'
),
$faq_url
),
$kses_allow_links
);
?>
</label>
<br />
<label>
<input
type='checkbox'
name='wp_cache_mobile_enabled'
value='1'
<?php checked( $wp_cache_mobile_enabled ); ?>
>
<?php
echo wp_kses(
sprintf(
/* translators: %s is the URL of the FAQ */
__(
'Mobile device support. (External plugin or theme required. See the <a href="https://jetpack.com/support/wp-super-cache/wp-super-cache-faq/">FAQ</a> for further details.)',
'wp-super-cache'
),
$faq_url
),
$kses_allow_links
);
?>
</label>
<br />
<?php if ( $wp_cache_mobile_enabled ) {
echo '<blockquote><h5>' . __( 'Mobile Browsers', 'wp-super-cache' ) . '</h5>' . esc_html( $wp_cache_mobile_browsers ) . "<br /><h5>" . __( 'Mobile Prefixes', 'wp-super-cache' ) . "</h5>" . esc_html( $wp_cache_mobile_prefixes ) . "<br /></blockquote>";
} ?>
<label><input type='checkbox' name='wp_cache_disable_utf8' <?php if( $wp_cache_disable_utf8 ) echo "checked"; ?> value='1'> <?php _e( 'Remove UTF8/blog charset support from .htaccess file. Only necessary if you see odd characters or punctuation looks incorrect. Requires rewrite rules update.', 'wp-super-cache' ); ?></label><br />
<label><input type='checkbox' name='wp_cache_clear_on_post_edit' <?php if( $wp_cache_clear_on_post_edit ) echo "checked"; ?> value='1'> <?php _e( 'Clear all cache files when a post or page is published or updated.', 'wp-super-cache' ); ?></label><br />
<label><input type='checkbox' name='wp_cache_front_page_checks' <?php if( $wp_cache_front_page_checks ) echo "checked"; ?> value='1'> <?php _e( 'Extra homepage checks. (Very occasionally stops homepage caching)', 'wp-super-cache' ); ?></label><?php echo " <em>(" . __( "Recommended", "wp-super-cache" ) . ")</em>"; ?><br />
<label><input type='checkbox' name='wp_cache_refresh_single_only' <?php if( $wp_cache_refresh_single_only ) echo "checked"; ?> value='1'> <?php _e( 'Only refresh current page when comments made.', 'wp-super-cache' ); ?></label><br />
<label><input type='checkbox' name='wp_supercache_cache_list' <?php if( $wp_supercache_cache_list ) echo "checked"; ?> value='1'> <?php _e( 'List the newest cached pages on this page.', 'wp-super-cache' ); ?></label><br />
<?php if( false == defined( 'WPSC_DISABLE_LOCKING' ) ) { ?>
<label><input type='checkbox' name='wp_cache_mutex_disabled' <?php if( !$wp_cache_mutex_disabled ) echo "checked"; ?> value='0'> <?php _e( 'Coarse file locking. You do not need this as it will slow down your website.', 'wp-super-cache' ); ?></label><br />
<?php } ?>
<label><input type='checkbox' name='wp_super_cache_late_init' <?php if( $wp_super_cache_late_init ) echo "checked"; ?> value='1'> <?php _e( 'Late init. Display cached files after WordPress has loaded.', 'wp-super-cache' ); ?></label><br />
<?php printf( __( '<strong>DO NOT CACHE PAGE</strong> secret key: <a href="%s">%s</a>', 'wp-super-cache' ), trailingslashit( get_bloginfo( 'url' ) ) . "?donotcachepage={$cache_page_secret}", $cache_page_secret ); ?>
</fieldset>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="wp_cache_location"><?php _e( 'Cache Location', 'wp-super-cache' ); ?></label></th>
<td>
<fieldset>
<legend class="hidden">Cache Location</legend>
<input type='text' size=80 name='wp_cache_location' id='wp_cache_location' value='<?php echo esc_attr( $cache_path ); ?>' />
<p><?php printf( __( 'Change the location of your cache files. The default is WP_CONTENT_DIR . /cache/ which translates to %s.', 'wp-super-cache' ), WP_CONTENT_DIR . '/cache/' ); ?></p>
<ol>
<li><?php _e( 'Warning: do not use a shared directory like /tmp/ where other users on this server can modify files. Your cache files could be modified to deface your website.', 'wp-super-cache' ); ?></li>
<li><?php _e( 'You must give the full path to the directory.', 'wp-super-cache' ); ?></li>
<li><?php _e( 'If the directory does not exist, it will be created. Please make sure your web server user has write access to the parent directory. The parent directory must exist.', 'wp-super-cache' ); ?></li>
<li><?php _e( 'If the new cache directory does not exist, it will be created and the contents of the old cache directory will be moved there. Otherwise, the old cache directory will be left where it is.', 'wp-super-cache' ); ?></li>
<li><?php _e( 'Submit a blank entry to set it to the default directory, WP_CONTENT_DIR . /cache/.', 'wp-super-cache' ); ?></li>
<?php
if ( get_site_option( 'wp_super_cache_index_detected' ) && strlen( $cache_path ) > strlen( ABSPATH ) && ABSPATH == substr( $cache_path, 0, strlen( ABSPATH ) ) ) {
$msg = __( 'The plugin detected a bare directory index in your cache directory, which would let visitors see your cache files directly and might expose private posts.', 'wp-super-cache' );
if ( ! $is_nginx && $super_cache_enabled && $wp_cache_mod_rewrite == 1 ) {
$msg .= ' ' . __( 'You are using expert mode to serve cache files so the plugin has added <q>Options -Indexes</q> to the .htaccess file in the cache directory to disable indexes. However, if that does not work, you should contact your system administrator or support and ask for them to be disabled, or use simple mode and move the cache outside of the web root.', 'wp-super-cache' );
} else {
$msg .= ' <strong>' . sprintf( __( 'index.html files have been added in key directories, but unless directory indexes are disabled, it is probably better to store the cache files outside of the web root of %s', 'wp-super-cache' ), ABSPATH ) . '</strong>';
}
echo "<li>$msg</li>";
}
?>
<?php if ( $super_cache_enabled && $wp_cache_mod_rewrite == 1 ) { ?>
<li><?php printf( __( 'Since you are using mod_rewrite to serve cache files, you must choose a directory in your web root which is <q>%s</q> and update the mod_rewrite rules in the .htaccess file.', 'wp-super-cache' ), ABSPATH ); ?></li>
<?php } ?>
</ol>
</fieldset>
</td>
</tr>
</table>
<h4><?php esc_html_e( 'Note:', 'wp-super-cache' ); ?></h4>
<ol>
<li><?php esc_html_e( 'Uninstall this plugin on the plugins page. It will automatically clean up after itself. If manual intervention is required, then simple instructions are provided.', 'wp-super-cache' ); ?></li>
<li><?php printf( __( 'If uninstalling this plugin, make sure the directory <em>%s</em> is writeable by the webserver so the files <em>advanced-cache.php</em> and <em>cache-config.php</em> can be deleted automatically. (Making sure those files are writeable is probably a good idea!)', 'wp-super-cache' ), esc_attr( WP_CONTENT_DIR ) ); ?></li>
<li><?php printf( __( 'Please see the <a href="%1$s/wp-super-cache/readme.txt">readme.txt</a> for instructions on uninstalling this script. Look for the heading, "How to uninstall WP Super Cache".', 'wp-super-cache' ), plugins_url() ); ?></li>
<li>
<em>
<?php
echo wp_kses(
sprintf(
/* translators: %1$s is the URL for the documentation, %2$s is a link to the support forums. */
__(
'Need help? Check out <a href="%1$s">the documentation</a>. It includes installation documentation, a FAQ, and Troubleshooting tips. The <a href="%2$s">support forum</a> is also available. Your question may already have been answered.',
'wp-super-cache'
),
'https://jetpack.com/support/wp-super-cache/',
'https://wordpress.org/support/plugin/wp-super-cache/'
),
$kses_allow_links
);
?>
</em>
</li>
<li><?php _e( 'The location of the plugin configuration file can be changed by defining the WPCACHECONFIGPATH constant in wp-config.php. If not defined it will be set to WP_CONTENT_DIR.', 'wp-super-cache' ); ?></li>
</ol>
<?php
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_html__( 'Update Status', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
?>
</form>
</div>
<?php
if ( ! $GLOBALS['is_nginx'] && ! defined( 'WPSC_DISABLE_HTACCESS_UPDATE' ) && $GLOBALS['cache_enabled'] === true && $GLOBALS['wp_cache_mod_rewrite'] === 1 ) {
?>
<a name="modrewrite"></a><fieldset class="options">
<h4><?php _e( 'Mod Rewrite Rules', 'wp-super-cache' ); ?></h4>
<p><?php _e( 'When Expert cache delivery is enabled a file called <em>.htaccess</em> is modified. It should probably be in the same directory as your wp-config.php. This file has special rules that serve the cached files very quickly to visitors without ever executing PHP. The .htaccess file can be updated automatically, but if that fails, the rules will be displayed here and it can be edited by you. You will not need to update the rules unless a warning shows here.', 'wp-super-cache' ); ?></p>
<?php
extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
if ( strpos( $wprules, 'wordpressuser' ) ) { // Need to clear out old mod_rewrite rules
echo "<p><strong>" . __( 'Thank you for upgrading.', 'wp-super-cache' ) . "</strong> " . sprintf( __( 'The mod_rewrite rules changed since you last installed this plugin. Unfortunately, you must remove the old supercache rules before the new ones are updated. Refresh this page when you have edited your .htaccess file. If you wish to manually upgrade, change the following line: %1$s so it looks like this: %2$s The only changes are "HTTP_COOKIE" becomes "HTTP:Cookie" and "wordpressuser" becomes "wordpress". This is a WordPress 2.5 change but it&#8217;s backwards compatible with older versions if you&#8217;re brave enough to use them.', 'wp-super-cache' ), '<blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$</code></blockquote>', '<blockquote><code>RewriteCond %{HTTP:Cookie} !^.*wordpress.*$</code></blockquote>' ) . "</p>";
} else {
global $valid_nonce;
if ( ! isset( $_POST['updatehtaccess'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( $scrules == '' ) {
wpsc_update_htaccess_form( 0 ); // don't hide the update htaccess form
} else {
wpsc_update_htaccess_form();
}
} elseif ( $valid_nonce && isset( $_POST[ 'updatehtaccess' ] ) ) {
if ( add_mod_rewrite_rules() ) {
echo "<h5>" . __( 'Mod Rewrite rules updated!', 'wp-super-cache' ) . "</h5>";
echo "<p><strong>" . sprintf( __( '%s.htaccess has been updated with the necessary mod_rewrite rules. Please verify they are correct. They should look like this:', 'wp-super-cache' ), $home_path ) . "</strong></p>\n";
} else {
global $update_mod_rewrite_rules_error;
echo "<h5>" . __( 'Mod Rewrite rules must be updated!', 'wp-super-cache' ) . "</h5>";
echo "<p>" . sprintf( __( 'The plugin could not update %1$s.htaccess file: %2$s.<br /> The new rules go above the regular WordPress rules as shown in the code below:', 'wp-super-cache' ), $home_path, "<strong>" . $update_mod_rewrite_rules_error . "</strong>" ) . "</p>\n";
}
echo "<div style='overflow: auto; width: 800px; height: 400px; padding:0 8px;color:#4f8a10;background-color:#dff2bf;border:1px solid #4f8a10;'>";
echo "<p><pre>" . esc_html( $rules ) . "</pre></p>\n</div>";
} else {
?>
<p><?php printf( __( 'WP Super Cache mod rewrite rules were detected in your %s.htaccess file.<br /> Click the following link to see the lines added to that file. If you have upgraded the plugin, make sure these rules match.', 'wp-super-cache' ), $home_path ); ?></p>
<?php
if ( $rules != $scrules ) {
?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><?php _e( 'A difference between the rules in your .htaccess file and the plugin rewrite rules has been found. This could be simple whitespace differences, but you should compare the rules in the file with those below as soon as possible. Click the &#8217;Update Mod_Rewrite Rules&#8217; button to update the rules.', 'wp-super-cache' ); ?></p><?php
}
?><a href="javascript:toggleLayer('rewriterules');" class="button"><?php _e( 'View Mod_Rewrite Rules', 'wp-super-cache' ); ?></a><?php
wpsc_update_htaccess_form();
echo "<div id='rewriterules' style='display: none;'>";
if ( $rules != $scrules )
echo '<div style="background: #fff; border: 1px solid #333; margin: 2px;">' . wp_text_diff( $scrules, $rules, array( 'title' => __( 'Rewrite Rules', 'wp-super-cache' ), 'title_left' => __( 'Current Rules', 'wp-super-cache' ), 'title_right' => __( 'New Rules', 'wp-super-cache' ) ) ) . "</div>";
echo "<p><pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p>\n";
echo "<p>" . sprintf( __( 'Rules must be added to %s too:', 'wp-super-cache' ), WP_CONTENT_DIR . "/cache/.htaccess" ) . "</p>";
echo "<pre># BEGIN supercache\n" . esc_html( $gziprules ) . "# END supercache</pre></p>";
echo '</div>';
}
}
?></fieldset><?php
}
$timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
?>
<div class="wpsc-card">
<fieldset class="options">
<a name='expirytime'></a>
<h4><?php _e( 'Expiry Time &amp; Garbage Collection', 'wp-super-cache' ); ?></h4><?php
?><span id="utc-time"><?php printf( __( '<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>', 'wp-super-cache' ), date_i18n( $timezone_format, false, 'gmt' ) ); ?></span><?php
$current_offset = get_option('gmt_offset');
if ( get_option('timezone_string') || !empty($current_offset) ) {
?><span id="local-time"><?php printf( __( 'Local time is <code>%1$s</code>', 'wp-super-cache' ), date_i18n( $timezone_format ) ); ?></span><?php
}
$next_gc = wp_next_scheduled( 'wp_cache_gc' );
if ( $next_gc )
echo "<p>" . sprintf( __( 'Next scheduled garbage collection will be at <strong>%s UTC</strong>', 'wp-super-cache' ), date_i18n( $timezone_format, $next_gc, 'gmt' ) ) . "</p>";
if ( $wp_cache_preload_on )
echo "<p>" . __( 'Warning! <strong>PRELOAD MODE</strong> activated. Supercache files will not be deleted regardless of age.', 'wp-super-cache' ) . "</p>";
echo "<script type='text/javascript'>";
echo "jQuery(function () {
jQuery('#cache_interval_time').on('click',function () {
jQuery('#schedule_interval').attr('checked', true);
});
jQuery('#cache_scheduled_time').on('click',function () {
jQuery('#schedule_time').attr('checked', true);
});
jQuery('#cache_scheduled_select').on('click',function () {
jQuery('#schedule_time').attr('checked', true);
});
});";
echo "</script>";
echo '<form name="wp_edit_max_time" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#expirytime' ) . '" method="post">';
echo '<input name="action" value="expirytime" type="hidden" />';
echo '<table class="form-table">';
echo '<tr><td><label for="wp_max_time"><strong>' . __( 'Cache Timeout', 'wp-super-cache' ) . '</strong></label></td>';
echo "<td><input type='text' id='wp_max_time' size=6 name='wp_max_time' value='" . esc_attr( $cache_max_time ) . "' /> " . __( "seconds", 'wp-super-cache' ) . "</td></tr>\n";
echo "<tr><td></td><td>" . __( 'How long should cached pages remain fresh? Set to 0 to disable garbage collection. A good starting point is 3600 seconds.', 'wp-super-cache' ) . "</td></tr>\n";
echo '<tr><td valign="top"><strong>' . esc_html__( 'Scheduler', 'wp-super-cache' ) . '</strong></td><td><table cellpadding=0 cellspacing=0><tr><td valign="top"><input type="radio" id="schedule_interval" name="cache_schedule_type" value="interval" ' . checked( 'interval', $cache_schedule_type, false ) . ' /></td><td valign="top"><label for="schedule_interval">' . esc_html__( 'Timer:', 'wp-super-cache' ) . '</label></td>';
echo "<td><input type='text' id='cache_interval_time' size=6 name='cache_time_interval' value='" . esc_attr( $cache_time_interval ) . "' /> " . esc_html__( 'seconds', 'wp-super-cache' ) . '<br />' . esc_html__( 'How often to check for stale cached files.', 'wp-super-cache' ) . '</td></tr>';
echo '<tr><td valign="top"><input type="radio" id="schedule_time" name="cache_schedule_type" value="time" ' . checked( 'time', $cache_schedule_type, false ) . ' /></td><td valign="top"><label for="schedule_time">' . __( 'Clock:', 'wp-super-cache' ) . '</label></td>';
echo "<td><input type=\"text\" size=5 id='cache_scheduled_time' name='cache_scheduled_time' value=\"" . esc_attr( $cache_scheduled_time ) . "\" /> " . __( "HH:MM", 'wp-super-cache' ) . "<br />" . __( 'Check for stale cached files at this time <strong>(UTC)</strong> or starting at this time every <em>interval</em> below.', 'wp-super-cache' ) . "</td></tr>";
$schedules = wp_get_schedules();
echo "<tr><td><br /></td><td><label for='cache_scheduled_select'>" . __( 'Interval:', 'wp-super-cache' ) . "</label></td><td><select id='cache_scheduled_select' name='cache_schedule_interval' size=1>";
foreach( $schedules as $desc => $details ) {
echo "<option value='$desc' " . selected( $desc, $cache_schedule_interval, false ) . " /> {$details[ 'display' ]}</option>";
}
echo "</select></td></tr>";
echo '</table></td></tr>';
echo '<tr><td><label for="cache_gc_email_me"><strong>' . __( 'Notification Emails', 'wp-super-cache' ) . '</strong></label></td>';
echo "<td><input type='checkbox' id='cache_gc_email_me' name='cache_gc_email_me' " . checked( $cache_gc_email_me, 1, false ) . " /> " . __( 'Email me when the garbage collection runs.', 'wp-super-cache' ) . "</td></tr>\n";
echo "</table>\n";
echo "<h5>" . __( 'Garbage Collection', 'wp-super-cache' ) . "</h5>";
echo "<ol><li>" . __( '<em>Garbage collection</em> is the simple act of throwing out your garbage. For this plugin that would be old or <em>stale</em> cached files that may be out of date. New cached files are described as <em>fresh</em>.', 'wp-super-cache' ) . "</li>\n";
echo "<li>" . __( 'Cached files are fresh for a limited length of time. You can set that time in the <em>Cache Timeout</em> text box on this page.', 'wp-super-cache' ) . "</li>\n";
echo "<li>" . __( 'Stale cached files are not removed as soon as they become stale. They have to be removed by the garbage collecter. That is why you have to tell the plugin when the garbage collector should run.', 'wp-super-cache' ) . "</li>\n";
echo "<li>" . __( 'Use the <em>Timer</em> or <em>Clock</em> schedulers to define when the garbage collector should run.', 'wp-super-cache' ) . "</li>\n";
echo "<li>" . __( 'The <em>Timer</em> scheduler tells the plugin to run the garbage collector at regular intervals. When one garbage collection is done, the next run is scheduled.', 'wp-super-cache' ) . "</li>\n";
echo "<li>" . __( 'Or, the <em>Clock</em> scheduler allows the garbage collection to run at specific times. If set to run hourly or twice daily, the garbage collector will be first scheduled for the time you enter here. It will then run again at the indicated interval. If set to run daily, it will run once a day at the time specified.', 'wp-super-cache' ) . "</li>\n";
echo "</ol>";
echo "<p>" . __( 'There are no best garbage collection settings but here are a few scenarios. Garbage collection is separate to other actions that clear our cached files like leaving a comment or publishing a post.', 'wp-super-cache' ) . "</p>\n";
echo "<ol>";
echo "<li>" . __( 'Sites that want to serve lots of newly generated data should set the <em>Cache Timeout</em> to 60 and use the <em>Timer</em> scheduler set to 90 seconds.', 'wp-super-cache' ) . "</li>\n";
echo "<li>" . __( 'Sites with widgets and rss feeds in their sidebar should probably use a timeout of 3600 seconds and set the timer to 600 seconds. Stale files will be caught within 10 minutes of going stale.', 'wp-super-cache' ) . "</li>\n";
echo "<li>" . __( 'Sites with lots of static content, no widgets or rss feeds in their sidebar can use a timeout of 86400 seconds or even more and set the timer to something equally long.', 'wp-super-cache' ) . "</li>\n";
echo "<li>" . __( 'Sites where an external data source updates at a particular time every day should set the timeout to 86400 seconds and use the Clock scheduler set appropriately.', 'wp-super-cache' ) . "</li>\n";
echo "</ol>";
echo "<p>" . __( 'Checking for and deleting expired files is expensive, but it&#8217;s expensive leaving them there too. On a very busy site, you should set the expiry time to <em>600 seconds</em>. Experiment with different values and visit this page to see how many expired files remain at different times during the day.', 'wp-super-cache' ) . "</p>";
echo "<p>" . __( 'Set the expiry time to 0 seconds to disable garbage collection.', 'wp-super-cache' ) . "</p>";
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Change Expiration', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
?>
</fieldset>
</div>
<?php
// Accepted Filenames
echo '<div class="wpsc-card">';
echo '<a name="files"></a><fieldset class="options"><h4>' . __( 'Accepted Filenames &amp; Rejected URIs', 'wp-super-cache' ) . '</h4>';
echo '<a name="rejectpages"></a>';
echo '<p>' . __( 'Do not cache the following page types. See the <a href="https://codex.wordpress.org/Conditional_Tags">Conditional Tags</a> documentation for a complete discussion on each type.', 'wp-super-cache' ) . '</p>';
echo '<form name="wp_edit_rejected_pages" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#rejectpages' ) . '" method="post">';
echo '<input type="hidden" name="wp_edit_rejected_pages" value="1" />';
echo '<label><input type="checkbox" value="1" name="wp_cache_pages[single]" ' . checked( 1, $wp_cache_pages[ 'single' ], false ) . ' /> ' . __( 'Single Posts', 'wp-super-cache' ) . ' (is_single)</label><br />';
echo '<label><input type="checkbox" value="1" name="wp_cache_pages[pages]" ' . checked( 1, $wp_cache_pages[ 'pages' ], false ) . ' /> ' . __( 'Pages', 'wp-super-cache' ) . ' (is_page)</label><br />';
echo '<label><input type="checkbox" value="1" name="wp_cache_pages[frontpage]" ' . checked( 1, $wp_cache_pages[ 'frontpage' ], false ) . ' /> ' . __( 'Front Page', 'wp-super-cache' ) . ' (is_front_page)</label><br />';
echo '&nbsp;&nbsp;<label><input type="checkbox" value="1" name="wp_cache_pages[home]" ' . checked( 1, $wp_cache_pages[ 'home' ], false ) . ' /> ' . __( 'Home', 'wp-super-cache' ) . ' (is_home)</label><br />';
echo '<label><input type="checkbox" value="1" name="wp_cache_pages[archives]" ' . checked( 1, $wp_cache_pages[ 'archives' ], false ) . ' /> ' . __( 'Archives', 'wp-super-cache' ) . ' (is_archive)</label><br />';
echo '&nbsp;&nbsp;<label><input type="checkbox" value="1" name="wp_cache_pages[tag]" ' . checked( 1, $wp_cache_pages[ 'tag' ], false ) . ' /> ' . __( 'Tags', 'wp-super-cache' ) . ' (is_tag)</label><br />';
echo '&nbsp;&nbsp;<label><input type="checkbox" value="1" name="wp_cache_pages[category]" ' . checked( 1, $wp_cache_pages[ 'category' ], false ) . ' /> ' . __( 'Category', 'wp-super-cache' ) . ' (is_category)</label><br />';
echo '<label><input type="checkbox" value="1" name="wp_cache_pages[feed]" ' . checked( 1, $wp_cache_pages[ 'feed' ], false ) . ' /> ' . __( 'Feeds', 'wp-super-cache' ) . ' (is_feed)</label><br />';
echo '<label><input type="checkbox" value="1" name="wp_cache_pages[search]" ' . checked( 1, $wp_cache_pages[ 'search' ], false ) . ' /> ' . __( 'Search Pages', 'wp-super-cache' ) . ' (is_search)</label><br />';
echo '<label><input type="checkbox" value="1" name="wp_cache_pages[author]" ' . checked( 1, $wp_cache_pages[ 'author' ], false ) . ' /> ' . __( 'Author Pages', 'wp-super-cache' ) . ' (is_author)</label><br />';
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Settings', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
echo '</div>';
// Rejected URL strings
echo '<div class="wpsc-card">';
echo '<a name="rejecturi"></a><fieldset class="options"><h4>' . __( 'Rejected URL Strings', 'wp-super-cache' ) . '</h4>';
echo '<form name="wp_edit_rejected" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#rejecturi' ) . '" method="post">';
echo "<p>" . __( 'Add here strings (not a filename) that forces a page not to be cached. For example, if your URLs include year and you dont want to cache last year posts, it&#8217;s enough to specify the year, i.e. &#8217;/2004/&#8217;. WP-Cache will search if that string is part of the URI and if so, it will not cache that page.', 'wp-super-cache' ) . "</p>\n";
echo '<textarea name="wp_rejected_uri" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
foreach( $cache_rejected_uri as $file ) {
echo esc_html( $file ) . "\n";
}
echo '</textarea> ';
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Strings', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
echo "</form>\n";
echo '</div>';
// Rejected Cookies
echo '<div class="wpsc-card">';
echo '<a name="rejectcookies"></a><fieldset class="options"><h4>' . __( 'Rejected Cookies', 'wp-super-cache' ) . '</h4>';
echo '<form name="wp_edit_rejected_cookies" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#rejectcookies' ) . '" method="post">';
echo "<p>" . __( 'Do not cache pages when these cookies are set. Add the cookie names here, one per line. Matches on fragments, so "test" will match "WordPress_test_cookie". (Simple caching only)', 'wp-super-cache' ) . "</p>\n";
echo '<textarea name="wp_rejected_cookies" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
foreach ( (array) $wpsc_rejected_cookies as $file) {
echo esc_html( $file ) . "\n";
}
echo '</textarea> ';
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
echo '</div>';
// Always Cache Filenames
echo '<div class="wpsc-card">';
echo '<a name="cancache"></a><fieldset class="options"><h4>' . __( 'Always Cache Filenames', 'wp-super-cache' ) . '</h4>';
echo '<div style="clear:both"></div><form name="wp_edit_accepted" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#cancache' ) . '" method="post">';
echo "<p>" . __( 'Add here those filenames that can be cached, even if they match one of the rejected substring specified above.', 'wp-super-cache' ) . "</p>\n";
echo '<textarea name="wp_accepted_files" cols="40" rows="8" style="width: 50%; font-size: 12px;" class="code">';
foreach ($cache_acceptable_files as $file) {
echo esc_html($file) . "\n";
}
echo '</textarea> ';
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Files', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
echo '</div>';
echo '</fieldset>';
echo '</div>';

View File

@@ -0,0 +1,74 @@
<div class="wpsc-settings-inner">
<?php
extract( wpsc_update_debug_settings() ); // $wp_super_cache_debug, $wp_cache_debug_log, $wp_cache_debug_ip, $wp_super_cache_comments, $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug, $wp_cache_debug_username
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
echo '<a name="debug"></a>';
echo '<fieldset class="options">';
echo '<div class="wpsc-card">';
echo '<p>' . __( 'Fix problems with the plugin by debugging it here. It will log to a file in your cache directory.', 'wp-super-cache' ) . '</p>';
// $wp_cache_debug_log is declared when this file is included.
// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username
}
// $cache_path and $wp_cache_debug_log is declared when this file is included.
// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
$log_file_link = "<a href='" . home_url( str_replace( get_home_path(), '', "{$cache_path}view_{$wp_cache_debug_log}?wp-admin=1&wp-json=1&filter=" ) ) . "'>$wp_cache_debug_log</a>";
if ( $wp_super_cache_debug == 1 ) {
echo "<p>" . sprintf( __( 'Currently logging to: %s', 'wp-super-cache' ), $log_file_link ) . "</p>";
} else {
echo "<p>" . sprintf( __( 'Last Logged to: %s', 'wp-super-cache' ), $log_file_link ) . "</p>";
}
echo "<p>" . sprintf( __( 'Username/Password: %s', 'wp-super-cache' ), $wp_cache_debug_username ) . "</p>";
echo '<form name="wpsc_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
wp_nonce_field('wp-cache');
echo "<input type='hidden' name='wpsc_delete_log' value='1' />";
submit_button( __( 'Delete', 'wp-super-cache' ), 'delete', 'wpsc_delete_log_form', false );
echo "</form>";
echo '<form name="wpsc_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
if ( ! isset( $wp_super_cache_debug ) || $wp_super_cache_debug == 0 ) {
$debug_status_message = __( 'Enable Logging', 'wp-super-cache' );
$not_status = 1;
} else {
$debug_status_message = __( 'Disable Logging', 'wp-super-cache' );
$not_status = 0;
}
echo "<input type='hidden' name='wp_super_cache_debug' value='" . $not_status . "' />";
wp_nonce_field('wp-cache');
submit_button( $debug_status_message, 'primary', 'wpsc_log_status', true );
echo "</form>";
echo '</div>';
echo '<div class="wpsc-card">';
echo '<form name="wp_cache_debug" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
echo "<input type='hidden' name='wp_cache_debug' value='1' /><br />";
echo "<table class='form-table'>";
echo "<tr><th>" . __( 'IP Address', 'wp-super-cache' ) . "</th><td> <input type='text' size='20' name='wp_cache_debug_ip' value='{$wp_cache_debug_ip}' /> " . sprintf( __( '(only log requests from this IP address. Your IP is %s)', 'wp-super-cache' ), $_SERVER[ 'REMOTE_ADDR' ] ) . "</td></tr>";
echo "<tr><th valign='top'>" . __( 'Cache Status Messages', 'wp-super-cache' ) . "</th><td><input type='checkbox' name='wp_super_cache_comments' value='1' " . checked( 1, $wp_super_cache_comments, false ) . " /> " . __( 'enabled', 'wp-super-cache' ) . "<br />";
echo __( 'Display comments at the end of every page like this:', 'wp-super-cache' ) . "<br />";
echo "<pre>&lt;!-- Dynamic page generated in 0.450 seconds. -->
&lt;!-- Cached page generated by WP-Super-Cache on " . date( "Y-m-d H:i:s", time() ) . " -->
&lt;!-- super cache --></pre></td></tr>";
echo "</table>\n";
if ( isset( $wp_super_cache_advanced_debug ) ) {
echo "<h5>" . __( 'Advanced', 'wp-super-cache' ) . "</h5><p>" . __( 'In very rare cases two problems may arise on some blogs:<ol><li> The front page may start downloading as a zip file.</li><li> The wrong page is occasionally cached as the front page if your blog uses a static front page and the permalink structure is <em>/%category%/%postname%/</em>.</li></ol>', 'wp-super-cache' ) . '</p>';
echo "<p>" . __( 'I&#8217;m 99% certain that they aren&#8217;t bugs in WP Super Cache and they only happen in very rare cases but you can run a simple check once every 5 minutes to verify that your site is ok if you&#8217;re worried. You will be emailed if there is a problem.', 'wp-super-cache' ) . "</p>";
echo "<table class='form-table'>";
echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_check' value='1' " . checked( 1, $wp_super_cache_front_page_check, false ) . " /> " . __( 'Check front page every 5 minutes.', 'wp-super-cache' ) . "</td></tr>";
echo "<tr><td valign='top'>" . __( 'Front page text', 'wp-super-cache' ) . "</td><td> <input type='text' size='30' name='wp_super_cache_front_page_text' value='{$wp_super_cache_front_page_text}' /> (" . __( 'Text to search for on your front page. If this text is missing, the cache will be cleared. Leave blank to disable.', 'wp-super-cache' ) . ")</td></tr>";
echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_clear' value='1' " . checked( 1, $wp_super_cache_front_page_clear, false ) . " /> " . __( 'Clear cache on error.', 'wp-super-cache' ) . "</td></tr>";
echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_notification' value='1' " . checked( 1, $wp_super_cache_front_page_notification, false ) . " /> " . __( 'Email the blog admin when checks are made. (useful for testing)', 'wp-super-cache' ) . "</td></tr>";
echo "</table>\n";
}
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Settings', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
echo '</div>';
echo '</fieldset>';
echo '</div>';

View File

@@ -0,0 +1,191 @@
<div class="wpsc-settings-inner">
<?php
global $wpsc_promo_links;
echo '<div class="wpsc-card">';
echo '<form name="wp_manager" action="' . esc_url_raw( add_query_arg( 'tab', 'easy', $admin_url ) ) . '" method="post">';
echo '<input type="hidden" name="action" value="easysetup" />';
wp_nonce_field( 'wp-cache' );
?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="wp_cache_status"><?php esc_html_e( 'Caching', 'wp-super-cache' ); ?></label></th>
<td>
<fieldset>
<label><input type='radio' name='wp_cache_easy_on' value='1' <?php checked( $cache_enabled ); ?> ><?php echo esc_html__( 'Caching On', 'wp-super-cache' ) . ' <em>(' . esc_html__( 'Recommended', 'wp-super-cache' ) . ')</em>'; ?></label><br />
<label><input type='radio' name='wp_cache_easy_on' value='0' <?php checked( ! $cache_enabled ); ?> ><?php esc_html_e( 'Caching Off', 'wp-super-cache' ); ?></label><br />
</fieldset>
</td>
</tr>
</table>
<p><?php _e( 'The following recommended settings will be enabled:', 'wp-super-cache' ); ?></p>
<ol>
<li><?php _e( 'Caching disabled for logged in visitors.', 'wp-super-cache' ); ?></li>
<li><?php _e( 'Simple caching.', 'wp-super-cache' ); ?></li>
<li><?php _e( 'Cache Rebuild.', 'wp-super-cache' ); ?></li>
<li><?php _e( 'Interval garbage collection every 10 minutes with a cache lifetime of 30 minutes (if not configured already).', 'wp-super-cache' ); ?></li>
</ol>
<p><?php _e( 'These settings can be modified on the Advanced Settings page.', 'wp-super-cache' ); ?></p>
<?php
if ( ! $is_nginx && $cache_enabled && ! $wp_cache_mod_rewrite ) {
$scrules = trim( implode( "\n", extract_from_markers( trailingslashit( get_home_path() ) . '.htaccess', 'WPSuperCache' ) ) );
if ( ! empty( $scrules ) ) {
echo '<p><strong>' . esc_html__( 'Notice: Simple caching enabled but Supercache mod_rewrite rules from expert mode detected. Cached files will be served using those rules. If your site is working ok, please ignore this message. Otherwise, you can edit the .htaccess file in the root of your install and remove the SuperCache rules.', 'wp-super-cache' ) . '</strong></p>';
}
}
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_html__( 'Update Status', 'wp-super-cache' ) . '" />';
if ( wpsc_is_boost_current() ) {
$config = wpsc_get_boost_migration_config();
$button_url = $config['is_installed'] ? $config['activate_url'] : $config['install_url'];
$button_class = $config['is_installed'] ? 'wpsc-activate-boost-button' : 'wpsc-install-boost-button';
$button_label = esc_html__( 'Try Jetpack Boost', 'wp-super-cache' );
if ( wpsc_is_boost_active() && wpsc_is_boost_installed() ) {
$button_url = esc_url( admin_url( 'admin.php?page=jetpack-boost' ) );
$button_class = '';
$button_label = esc_html__( 'Jetpack Boost Dashboard', 'wp-super-cache' );
}
echo "<a style='margin-left: 12px;' data-source='try_button' class='button button-secondary " . esc_attr( $button_class ) . " wpsc-boost-migration-button' href='" . esc_url( $button_url ) . "'>";
echo '<div class="spinner" style="display:none;"></div>';
echo '<label>';
echo esc_html( $button_label );
echo '</label>';
echo '</a>';
}
echo '</div></form>';
echo '</div>';
if ( $cache_enabled ) {
echo '<div class="wpsc-card">';
echo '<h4>' . esc_html__( 'Cache Tester', 'wp-super-cache' ) . '</h4>';
echo '<p>' . esc_html__( 'Test your cached website by clicking the test button below.', 'wp-super-cache' ) . '</p>';
echo '<p>' . __( 'Note: if you use Cloudflare or other transparent front-end proxy service this test may fail.<ol><li> If you have Cloudflare minification enabled this plugin may detect differences in the pages and report an error.</li><li> Try using the development mode of Cloudflare to perform the test. You can disable development mode afterwards if the test succeeds.</li></ol>', 'wp-super-cache' ) . '</p>';
if ( array_key_exists( 'action', $_POST ) && 'test' === $_POST['action'] && $valid_nonce ) {
$url = trailingslashit( get_bloginfo( 'url' ) );
if ( isset( $_POST['httponly'] ) ) {
$url = str_replace( 'https://', 'http://', $url );
}
$test_messages = array( esc_html__( 'Fetching %s to prime cache: ', 'wp-super-cache' ), esc_html__( 'Fetching first copy of %s: ', 'wp-super-cache' ), esc_html__( 'Fetching second copy of %s: ', 'wp-super-cache' ) );
$c = 0;
$cache_test_error = false;
$page = array();
foreach ( $test_messages as $message ) {
echo '<p>' . sprintf( $message, $url );
$page[ $c ] = wp_remote_get( $url, array( 'timeout' => 60, 'blocking' => true ) );
if ( ! is_wp_error( $page[ $c ] ) ) {
$fp = fopen( $cache_path . $c . '.html', 'w' );
fwrite( $fp, $page[ $c ]['body'] );
fclose( $fp );
echo '<span style="color: #0a0; font-weight: bold;">' . esc_html__( 'OK', 'wp-super-cache' ) . "</span> (<a href='" . esc_url_raw( WP_CONTENT_URL . '/cache/' . $c . '.html' ) . "'>" . $c . '.html</a>)</p>';
sleep( 1 );
} else {
$cache_test_error = true;
echo '<span style="color: #a00; font-weight: bold;">' . esc_html__( 'FAILED', 'wp-super-cache' ) . '</span></p>';
$errors = '';
$messages = '';
foreach ( $page[ $c ]->get_error_codes() as $code ) {
$severity = $page[ $c ]->get_error_data( $code );
foreach ( $page[ $c ]->get_error_messages( $code ) as $err ) {
$errors .= $severity . ': ' . $err . "<br />\n";
}
}
if ( ! empty( $errors ) ) {
echo '<p>' . sprintf( __( '<strong>Errors:</strong> %s', 'wp-super-cache' ), $errors ) . '</p>';
}
}
++$c;
}
if ( false == $cache_test_error ) {
echo '<ul><li>' . sprintf( esc_html__( 'Page %d: %d (%s)', 'wp-super-cache' ), 1, intval( $page[1]['response']['code'] ), esc_attr( $page[1]['response']['message'] ) ) . '</li>';
echo '<li>' . sprintf( esc_html__( 'Page %d: %d (%s)', 'wp-super-cache' ), 2, intval( $page[2]['response']['code'] ), esc_attr( $page[2]['response']['message'] ) ) . '</li></ul>';
}
if ( false == $cache_test_error && preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[1]['body'], $matches1 ) &&
preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[2]['body'], $matches2 ) && $matches1[2] == $matches2[2]
) {
echo '<p>' . sprintf( esc_html__( 'Page 1: %s', 'wp-super-cache' ), $matches1[2] ) . '</p>';
echo '<p>' . sprintf( esc_html__( 'Page 2: %s', 'wp-super-cache' ), $matches2[2] ) . '</p>';
echo '<p><span style="color: #0a0; font-weight: bold;">' . esc_html__( 'The timestamps on both pages match!', 'wp-super-cache' ) . '</span></p>';
} else {
echo '<p><strong>' . esc_html__( 'The pages do not match! Timestamps differ or were not found!', 'wp-super-cache' ) . '</strong></p>';
echo '<p>' . esc_html__( 'Things you can do:', 'wp-super-cache' ) . '</p>';
echo '<ol><li>' . esc_html__( 'Load your homepage in a logged out browser, check the timestamp at the end of the html source. Load the page again and compare the timestamp. Caching is working if the timestamps match.', 'wp-super-cache' ) . '</li>';
echo '<li>' . esc_html__( 'Enable logging on the Debug page here. That should help you track down the problem.', 'wp-super-cache' ) . '</li>';
echo '<li>' . esc_html__( 'You should check Page 1 and Page 2 above for errors. Your local server configuration may not allow your website to access itself.', 'wp-super-cache' ) . '</li>';
echo '</ol>';
}
}
echo '<form name="cache_tester" action="' . esc_url_raw( add_query_arg( 'tab', 'easy', $admin_url ) ) . '" method="post">';
echo '<input type="hidden" name="action" value="test" />';
if ( ! empty( $_SERVER['HTTPS'] ) && 'on' === strtolower( $_SERVER['HTTPS'] ) ) {
echo '<input type="checkbox" name="httponly" checked="checked" value="1" /> ' . esc_html__( 'Send non-secure (non https) request for homepage', 'wp-super-cache' );
}
if ( isset( $wp_super_cache_comments ) && $wp_super_cache_comments == 0 ) {
echo '<p>' . __( '<strong>Warning!</strong> Cache comments are currently disabled. Please go to the Debug page and enable Cache Status Messages there. You should clear the cache before testing.', 'wp-super-cache' ) . '</p>';
echo '<div class="submit"><input disabled style="color: #aaa" class="button-secondary" type="submit" name="test" value="' . esc_html__( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
} else {
echo '<div class="submit"><input class="button-secondary" type="submit" name="test" value="' . __( 'Test Cache', 'wp-super-cache' ) . '" /></div>';
}
wp_nonce_field( 'wp-cache' );
echo '</form>';
echo '</div>';
}
echo '<div class="wpsc-card">';
echo '<h4>' . esc_html__( 'Delete Cached Pages', 'wp-super-cache' ) . '</h4>';
echo '<p>' . esc_html__( 'Cached pages are stored on your server as html and PHP files. If you need to delete them, use the button below.', 'wp-super-cache' ) . '</p>';
echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) ) . '" method="post">';
echo '<input type="hidden" name="wp_delete_cache" />';
echo '<div class="submit"><input id="deletepost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . esc_html__( 'Delete Cache', 'wp-super-cache' ) . ' " /></div>';
wp_nonce_field( 'wp-cache' );
echo "</form>\n";
echo '</div>';
if ( is_multisite() && wpsupercache_site_admin() ) {
echo '<div class="wpsc-card">';
echo '<form name="wp_cache_content_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'contents', $admin_url ) . '#listfiles' ) . '" method="post">';
echo '<input type="hidden" name="wp_delete_all_cache" />';
echo '<div class="submit"><input id="deleteallpost" class="button-secondary" type="submit" ' . SUBMITDISABLED . 'value="' . esc_html__( 'Delete Cache On All Blogs', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
echo "</form><br />\n";
echo '</div>';
}
?>
<div class="wpsc-card">
<h4 class="clear"><?php esc_html_e( 'Recommended Links and Plugins', 'wp-super-cache' ); ?></h4>
<p><?php esc_html_e( 'Caching is only one part of making a website faster. Here are some other plugins that will help:', 'wp-super-cache' ); ?></p>
<ul style="list-style: square; margin-left: 2em;">
<li>
<?php
echo \wp_kses(
\sprintf(
/* translators: %s: Link URL for Jetpack Boost. */
__( '<a href="%s">Jetpack Boost</a> helps speed up your website by generating critical CSS, defering Javascript and much more.', 'wp-super-cache' ),
$wpsc_promo_links['boost']
),
'a'
);
?>
</li>
<li>
<?php
printf(
/* translators: %s: HTML Link to Jetpack website. */
esc_html__( '%s provides everything you need to build a successful WordPress website including an image/photo CDN (free) and a video hosting service (paid).', 'wp-super-cache' ),
'<a href="' . esc_url( $wpsc_promo_links['jetpack'] ) . '">Jetpack</a>'
);
?>
</li>
<?php // translators: this is a html link to the GTMetrix website. ?>
<li><?php printf( esc_html__( 'See how your site performs by doing a %s analysis of it.', 'wp-super-cache' ), '<a href="https://gtmetrix.com/">GTMetrix</a>' ); ?></li>
<?php // translators: this is a html link to the Memcached plugin. ?>
<li><?php printf( esc_html__( 'Advanced users only: Install an object cache like %s.', 'wp-super-cache' ), '<a href="https://wordpress.org/plugins/memcached/">Memcached</a>' ); ?></li>
<li><?php printf( __( '<a href="%s">WP Crontrol</a> is a useful plugin to use when trying to debug garbage collection and preload problems.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-crontrol/' ); ?></li>
</ul>
<p><?php esc_html_e( "* The links above (apart from Jetpack and Jetpack Boost) go to websites outside the author's control. Caution is advised when testing any new software.", 'wp-super-cache' ); ?></p>
</div>
</div>

View File

@@ -0,0 +1,81 @@
<div class="wpsc-card">
<a name='lockdown'></a>
<fieldset class="options">
<h4><?php _e( 'Lock Down:', 'wp-super-cache' ); ?> <?php echo $wp_lock_down == '0' ? '<span style="color:red">' . __( 'Disabled', 'wp-super-cache' ) . '</span>' : '<span style="color:green">' . __( 'Enabled', 'wp-super-cache' ) . '</span>'; ?></h4>
<p><?php _e( 'Prepare your server for an expected spike in traffic by enabling the lock down. When this is enabled, new comments on a post will not refresh the cached static files.', 'wp-super-cache' ); ?></p>
<p><?php _e( 'Developers: Make your plugin lock down compatible by checking the "WPLOCKDOWN" constant. The following code will make sure your plugin respects the WPLOCKDOWN setting.', 'wp-super-cache' ); ?>
<blockquote><code>if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) {
&nbsp;&nbsp;&nbsp;&nbsp;echo "<?php _e( 'Sorry. My blog is locked down. Updates will appear shortly', 'wp-super-cache' ); ?>";
}</code></blockquote>
<?php
if( $wp_lock_down == '1' ) {
?><p><?php _e( 'WordPress is locked down. Super Cache static files will not be deleted when new comments are made.', 'wp-super-cache' ); ?></p><?php
} else {
?><p><?php _e( 'WordPress is not locked down. New comments will refresh Super Cache static files as normal.', 'wp-super-cache' ); ?></p><?php
}
$new_lockdown = $wp_lock_down == '1' ? '0' : '1';
$new_lockdown_desc = $wp_lock_down == '1' ? __( 'Disable', 'wp-super-cache' ) : __( 'Enable', 'wp-super-cache' );
echo '<form name="wp_lock_down" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#lockdown' ) . '" method="post">';
echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_attr( $new_lockdown_desc . ' ' . __( 'Lock Down', 'wp-super-cache' ) ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
echo '</form>';
?></fieldset><?php
if( $cache_enabled == true && $super_cache_enabled == true ) {
?><a name='direct'></a>
<fieldset class="options">
<h4><?php _e( 'Directly Cached Files', 'wp-super-cache' ); ?></h4><?php
$cached_direct_pages = wpsc_update_direct_pages();
$readonly = '';
if( !is_writeable_ACLSafe( ABSPATH ) ) {
$readonly = 'READONLY';
?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><strong><?php _e( 'Warning!', 'wp-super-cache' ); ?></strong> <?php printf( __( 'You must make %s writable to enable this feature. As this is a security risk, please make it read-only after your page is generated.', 'wp-super-cache' ), ABSPATH ); ?></p><?php
} else {
$abspath_stat = stat(ABSPATH . '/');
$abspath_mode = decoct( $abspath_stat[ 'mode' ] & 0777 );
if ( substr( $abspath_mode, -2 ) == '77' ) {
?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><strong><?php _e( 'Warning!', 'wp-super-cache' ); ?></strong> <?php printf( __( '%s is writable. Please make it readonly after your page is generated as this is a security risk.', 'wp-super-cache' ), ABSPATH ); ?></p><?php
}
}
echo '<form name="direct_page" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#direct' ) . '" method="post">';
if( is_array( $cached_direct_pages ) ) {
$out = '';
foreach( $cached_direct_pages as $page ) {
if( $page == '' )
continue;
$generated = '';
if( is_file( ABSPATH . $page . '/index.html' ) )
$generated = '<input class="button-secondary" type="Submit" name="deletepage" value="' . $page . '">';
$out .= "<tr><td><input type='text' $readonly name='direct_pages[]' size='30' value='$page' /></td><td>$generated</td></tr>";
}
if( $out != '' ) {
?><table><tr><th><?php _e( 'Existing direct page', 'wp-super-cache' ); ?></th><th><?php _e( 'Delete cached file', 'wp-super-cache' ); ?></th></tr><?php
echo "$out</table>";
}
}
if ( 'READONLY' !== $readonly ) {
echo esc_html__( 'Add direct page:', 'wp-super-cache' ) . '<input type="text" name="new_direct_page" size="30" value="" />';
}
echo '<p>' . sprintf(
esc_html__( 'Directly cached files are files created directly off %s where your blog lives. This feature is only useful if you are expecting a major Digg or Slashdot level of traffic to one post or page.', 'wp-super-cache' ),
esc_attr( ABSPATH )
) . '</p>';
if ( 'READONLY' !== $readonly ) {
echo '<p>' . sprintf( __( 'For example: to cache <em>%1$sabout/</em>, you would enter %1$sabout/ or /about/. The cached file will be generated the next time an anonymous user visits that page.', 'wp-super-cache' ),
esc_attr( trailingslashit( get_option( 'home' ) ) )
) . '</p>';
echo '<p>' . esc_html__( 'Make the textbox blank to remove it from the list of direct pages and delete the cached file.', 'wp-super-cache' ) . '</p>';
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_attr__( 'Update Direct Pages', 'wp-super-cache' ) . '" /></div>';
}
wp_nonce_field( 'wp-cache' );
echo '</form>';
?>
</fieldset>
<?php
} // if $super_cache_enabled
echo '</div>';

View File

@@ -0,0 +1,111 @@
<div class="wpsc-settings-inner">
<?php
global $wp_cache_preload_posts;
echo '<a name="preload"></a>';
if ( ! $cache_enabled || ! $super_cache_enabled || true === defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
wp_admin_notice(
esc_html__( 'Preloading of cache disabled. Please make sure simple or expert mode is enabled or talk to your host administrator.', 'wp-super-cache' ),
array(
'type' => 'warning',
)
);
return;
}
$count = wpsc_post_count();
$min_refresh_interval = wpsc_get_minimum_preload_interval();
echo '<div class="wpsc-card">';
echo '<p>' . __( 'This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now.', 'wp-super-cache' ) . '</p>';
echo '<p>' . __( 'Preloading creates lots of files however. Caching is done from the newest post to the oldest so please consider only caching the newest if you have lots (10,000+) of posts. This is especially important on shared hosting.', 'wp-super-cache' ) . '</p>';
echo '<p>' . __( 'In &#8217;Preload Mode&#8217; regular garbage collection will be disabled so that old cache files are not deleted. This is a recommended setting when the cache is preloaded.', 'wp-super-cache' ) . '</p>';
echo '<form name="cache_filler" action="' . esc_url_raw( add_query_arg( 'tab', 'preload', $admin_url ) ) . '" method="POST">';
echo '<input type="hidden" name="action" value="preload" />';
echo '<input type="hidden" name="page" value="wpsupercache" />';
echo '</div>';
echo '<div class="wpsc-card">';
echo '<p>' . sprintf( __( 'Refresh preloaded cache files every %s minutes. (0 to disable, minimum %d minutes.)', 'wp-super-cache' ), "<input type='text' size=4 name='wp_cache_preload_interval' value='" . (int) $wp_cache_preload_interval . "' />", $min_refresh_interval ) . '</p>';
if ( $count > 100 ) {
$step = (int)( $count / 10 );
$select = "<select name='wp_cache_preload_posts' size=1>";
$select .= "<option value='all' ";
if ( ! isset( $wp_cache_preload_posts ) || $wp_cache_preload_posts == 'all' ) {
$checked = 'selectect=1 ';
$best = 'all';
} else {
$checked = ' ';
$best = $wp_cache_preload_posts;
}
$select .= "{$checked}>" . __( 'all', 'wp-super-cache' ) . "</option>";
$options = array();
for( $c = $step; $c < $count; $c += $step ) {
$checked = ' ';
if ( $best == $c )
$checked = 'selected=1 ';
$options[ $c ] = "<option value='$c'{$checked}>$c</option>";
}
if ( ! isset( $options[ $wp_cache_preload_posts ] ) ) {
$options[ $wp_cache_preload_posts ] = "<option value='$wp_cache_preload_posts' selected=1>$wp_cache_preload_posts</option>";
}
ksort( $options );
$select .= implode( "\n", $options );
$checked = ' ';
if ( $best == $count )
$checked = 'selected=1 ';
$select .= "<option value='$count'{$checked}>$count</option>";
$select .= "</select>";
echo '<p>' . sprintf( __( 'Preload %s posts.', 'wp-super-cache' ), $select ) . '</p>';
} else {
echo '<input type="hidden" name="wp_cache_preload_posts" value="' . $count . '" />';
}
echo '<input type="checkbox" name="wp_cache_preload_on" value="1" ';
echo $wp_cache_preload_on == 1 ? 'checked=1' : '';
echo ' /> ' . __( 'Preload mode (garbage collection disabled. Recommended.)', 'wp-super-cache' ) . '<br />';
echo '<input type="checkbox" name="wp_cache_preload_taxonomies" value="1" ';
echo $wp_cache_preload_taxonomies == 1 ? 'checked=1' : '';
echo ' /> ' . __( 'Preload tags, categories and other taxonomies.', 'wp-super-cache' ) . '<br />';
echo __( 'Send me status emails when files are refreshed.', 'wp-super-cache' ) . '<br />';
if ( !isset( $wp_cache_preload_email_volume ) )
$wp_cache_preload_email_volume = 'none';
echo '<select type="select" name="wp_cache_preload_email_volume">';
echo '<option value="none" ' . selected( 'none', $wp_cache_preload_email_volume ) . '>' . esc_html__( 'No Emails', 'wp-super-cache' ) . '</option>';
// translators: %d is the number of posts
echo '<option value="many" ' . selected( 'many', $wp_cache_preload_email_volume ) . '>' . esc_html( sprintf( __( 'Many emails, 2 emails per %d posts.', 'wp-super-cache' ), WPSC_PRELOAD_POST_COUNT ) ) . '</option>';
// translators: %d is the number of posts
echo '<option value="medium" ' . selected( 'medium', $wp_cache_preload_email_volume ) . '>' . esc_html( sprintf( __( 'Medium, 1 email per %d posts.', 'wp-super-cache' ), WPSC_PRELOAD_POST_COUNT ) ) . '</option>';
echo '<option value="less" ' . selected( 'less', $wp_cache_preload_email_volume ) . '>' . esc_html__( 'Less emails, 1 at the start and 1 at the end of preloading all posts.', 'wp-super-cache' ) . '</option>';
echo "</select>";
if (
wp_next_scheduled( 'wp_cache_preload_hook' )
|| wp_next_scheduled( 'wp_cache_full_preload_hook' )
|| wpsc_is_preload_active()
) {
$currently_preloading = true;
}
echo '<div class="submit"><input class="button-primary" type="submit" name="preload" value="' . __( 'Save Settings', 'wp-super-cache' ) . '" />';
echo '</div>';
wp_nonce_field( 'wp-cache' );
echo '</form>';
echo '<form name="do_preload" action="' . esc_url_raw( add_query_arg( 'tab', 'preload', $admin_url ) ) . '" method="POST">';
echo '<input type="hidden" name="action" value="preload" />';
echo '<input type="hidden" name="page" value="wpsupercache" />';
echo '<div class="submit">';
if ( false == $currently_preloading ) {
echo '<input class="button-primary" type="submit" name="preload_now" value="' . __( 'Preload Cache Now', 'wp-super-cache' ) . '" />';
} else {
echo '<input class="button-primary" type="submit" name="preload_off" value="' . __( 'Cancel Cache Preload', 'wp-super-cache' ) . '" />';
}
echo '</div>';
wp_nonce_field( 'wp-cache' );
echo '</form>';
echo '</div>';
echo '</div>';

View File

@@ -0,0 +1,16 @@
<div class="wpsc-card">
<?php
echo '<a name="useragents"></a><fieldset class="options"><h4>' . __( 'Rejected User Agents', 'wp-super-cache' ) . '</h4>';
echo "<p>" . __( 'Strings in the HTTP &#8217;User Agent&#8217; header that prevent WP-Cache from caching bot, spiders, and crawlers&#8217; requests. Note that super cached files are still sent to these agents if they already exists.', 'wp-super-cache' ) . "</p>\n";
echo '<form name="wp_edit_rejected_user_agent" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#useragents' ) . '" method="post">';
echo '<textarea name="wp_rejected_user_agent" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
foreach( $cache_rejected_user_agent as $ua ) {
echo esc_html( $ua ) . "\n";
}
echo '</textarea> ';
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save UA Strings', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo '</form>';
echo "</fieldset>\n";
?>
</div>

View File

@@ -0,0 +1,11 @@
<div class="wpsc-card">
<?php
echo '<fieldset class="options"><h4>' . __( 'Fix Configuration', 'wp-super-cache' ) . '</h4>';
echo '<form name="wp_restore" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#top' ) . '" method="post">';
echo '<input type="hidden" name="wp_restore_config" />';
echo '<div class="submit"><input class="button-secondary" type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="' . __( 'Restore Default Configuration', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
echo '</fieldset>';
?>
</div>

View File

@@ -0,0 +1,16 @@
<div class="wpsc-card">
<?php
echo '<a name="trackingparameters"></a><fieldset class="options"><h4>' . __( 'Tracking Parameters', 'wp-super-cache' ) . '</h4>';
echo '<form name="edit_tracking_parameters" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#trackingparameters' ) . '" method="post">';
echo "<p>" . __( 'Tracking parameters to ignore when caching. Visitors from Facebook, Twitter and elsewhere to your website will go to a URL with tracking parameters added. This setting allows the plugin to ignore those parameters and show an already cached page. Any actual tracking by Google Analytics or other Javascript based code should still work as the URL of the page is not modified.', 'wp-super-cache' ) . "</p>\n";
echo '<textarea name="tracking_parameters" cols="20" rows="10" style="width: 50%; font-size: 12px;" class="code">';
foreach ( $wpsc_tracking_parameters as $parameter) {
echo esc_html( $parameter ) . "\n";
}
echo '</textarea> ';
echo "<p><label><input type='checkbox' name='wpsc_ignore_tracking_parameters' value='1' " . checked( 1, $wpsc_ignore_tracking_parameters, false ) . " /> " . __( 'Enable', 'wp-super-cache' ) . "</label></p>";
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
?>
</div>

View File

@@ -0,0 +1,64 @@
<?php
function awaitingmoderation_action( $buffer ) {
$buffer = str_replace( __( 'Your comment is awaiting moderation.', 'wp-super-cache' ), '', $buffer );
return $buffer;
}
function awaitingmoderation_actions() {
global $cache_awaitingmoderation;
if ( '1' === $cache_awaitingmoderation ) {
add_filter( 'wpsupercache_buffer', 'awaitingmoderation_action' );
}
}
add_cacheaction( 'add_cacheaction', 'awaitingmoderation_actions' );
// Your comment is awaiting moderation.
function wp_supercache_awaitingmoderation_admin() {
global $cache_awaitingmoderation, $wp_cache_config_file, $valid_nonce;
$cache_awaitingmoderation = '' === $cache_awaitingmoderation ? '0' : $cache_awaitingmoderation;
if ( isset( $_POST['cache_awaitingmoderation'] ) && $valid_nonce ) {
$cache_awaitingmoderation = (int) $_POST['cache_awaitingmoderation'];
wp_cache_replace_line( '^ *\$cache_awaitingmoderation', "\$cache_awaitingmoderation = '$cache_awaitingmoderation';", $wp_cache_config_file );
$changed = true;
} else {
$changed = false;
}
$id = 'awaitingmoderation-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<h4><?php _e( 'Awaiting Moderation', 'wp-super-cache' ); ?></h4>
<form name="wp_manager" action="" method="post">
<label><input type="radio" name="cache_awaitingmoderation" value="1" <?php if ( $cache_awaitingmoderation ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_awaitingmoderation" value="0" <?php if ( ! $cache_awaitingmoderation ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
<p><?php _e( 'Enables or disables plugin to Remove the text "Your comment is awaiting moderation." when someone leaves a moderated comment.', 'wp-super-cache' ); ?></p>
<?php
if ( $changed ) {
if ( $cache_awaitingmoderation ) {
$status = __( 'enabled', 'wp-super-cache' );
} else {
$status = __( 'disabled', 'wp-super-cache' );
}
echo '<p><strong>' . sprintf( __( 'Awaiting Moderation is now %s', 'wp-super-cache' ), $status ) . '</strong></p>';
}
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
?>
</form>
</fieldset>
<?php
}
add_cacheaction( 'cache_admin_page', 'wp_supercache_awaitingmoderation_admin' );
function wpsc_awaiting_moderation_list( $list ) {
$list['awaitingmoderation'] = array(
'key' => 'awaitingmoderation',
'url' => '',
'title' => __( 'Awaiting Moderation', 'wp-super-cache' ),
'desc' => __( 'Enables or disables plugin to Remove the text "Your comment is awaiting moderation." when someone leaves a moderated comment.', 'wp-super-cache' ),
);
return $list;
}
add_cacheaction( 'wpsc_filter_list', 'wpsc_awaiting_moderation_list' );

View File

@@ -0,0 +1,98 @@
<?php
function wp_supercache_badbehaviour( $file ) {
global $cache_badbehaviour;
if ( 1 !== $cache_badbehaviour ) {
return $file;
}
wp_supercache_badbehaviour_include();
return $file;
}
add_cacheaction( 'wp_cache_served_cache_file', 'wp_supercache_badbehaviour' );
function wp_supercache_badbehaviour_include() {
$bbfile = get_bb_file_loc();
if ( ! $bbfile ) {
require_once $bbfile;
}
}
function get_bb_file_loc() {
global $cache_badbehaviour_file;
if ( $cache_badbehaviour_file ) {
return $cache_badbehaviour_file;
}
if ( file_exists( WP_CONTENT_DIR . '/plugins/bad-behavior/bad-behavior-generic.php' ) ) {
$bbfile = WP_CONTENT_DIR . '/plugins/bad-behavior/bad-behavior-generic.php';
} elseif ( file_exists( WP_CONTENT_DIR . '/plugins/Bad-Behavior/bad-behavior-generic.php' ) ) {
$bbfile = WP_CONTENT_DIR . '/plugins/Bad-Behavior/bad-behavior-generic.php';
} else {
$bbfile = false;
}
return $bbfile;
}
function wp_supercache_badbehaviour_admin() {
global $cache_badbehaviour, $wp_cache_config_file, $valid_nonce;
$cache_badbehaviour = '' === $cache_badbehaviour ? 0 : $cache_badbehaviour;
if ( 'no' === $cache_badbehaviour ) {
$cache_badbehaviour = 0;
}
$err = false;
$changed = false;
if ( isset( $_POST['cache_badbehaviour'] ) && $valid_nonce ) {
$bbfile = get_bb_file_loc();
if ( ! $bbfile ) {
$_POST['cache_badbehaviour'] = 0;
$err = __( 'Bad Behaviour not found. Please check your install.', 'wp-super-cache' );
}
$cache_badbehaviour = (int) $_POST['cache_badbehaviour'];
wp_cache_replace_line( '^ *\$cache_compression', "\$cache_compression = 0;", $wp_cache_config_file );
wp_cache_replace_line( '^ *\$cache_badbehaviour', "\$cache_badbehaviour = $cache_badbehaviour;", $wp_cache_config_file );
wp_cache_replace_line( '^ *\$cache_badbehaviour_file', "\$cache_badbehaviour_file = '$bbfile';", $wp_cache_config_file );
$changed = true;
}
$id = 'badbehavior-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<h4><?php _e( 'Bad Behavior', 'wp-super-cache' ); ?></h4>
<form name="wp_manager" action="" method="post">
<label><input type="radio" name="cache_badbehaviour" value="1" <?php if ( $cache_badbehaviour ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_badbehaviour" value="0" <?php if ( ! $cache_badbehaviour ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
<p><?php _e( '', 'wp-super-cache' ); ?></p><?php
echo '<p>' . sprintf( __( '(Only WPCache caching supported, disabled compression and requires <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> in "%s/plugins/bad-behavior/") ', 'wp-super-cache' ), WP_CONTENT_DIR ) . '</p>';
if ( $changed ) {
if ( $cache_badbehaviour ) {
$status = __( 'enabled', 'wp-super-cache' );
} else {
$status = __( 'disable', 'wp-super-cache' );
}
echo '<p><strong>' . sprintf( __( 'Bad Behavior support is now %s', 'wp-super-cache' ), $status ) . '</strong></p>';
}
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
?>
</form>
</fieldset>
<?php
if ( $err ) {
echo '<p><strong>' . __( 'Warning!', 'wp-super-cache' ) . "</strong> $err</p>";
}
}
add_cacheaction( 'cache_admin_page', 'wp_supercache_badbehaviour_admin' );
function wpsc_badbehaviour_list( $list ) {
$list['badbehaviour'] = array(
'key' => 'badbehaviour',
'url' => 'http://www.bad-behavior.ioerror.us/',
'title' => __( 'Bad Behavior', 'wp-super-cache' ),
'desc' => sprintf( __( 'Support for Bad Behavior. (Only WPCache caching supported, disabled compression and requires Bad Behavior in "%s/plugins/bad-behavior/") ', 'wp-super-cache' ), WP_CONTENT_DIR ),
);
return $list;
}
add_cacheaction( 'wpsc_filter_list', 'wpsc_badbehaviour_list' );

View File

@@ -0,0 +1,137 @@
<?php
function domain_mapping_gc_cache( $function, $directory ) {
global $cache_path;
if ( ! function_exists( 'domain_mapping_warning' ) ) {
return;
}
$siteurl = domain_mapping_siteurl( false );
if ( ! $siteurl ) {
return;
}
$sitedir = trailingslashit( preg_replace( '`^(https?:)?//`', '', $siteurl ) );
if ( 'homepage' === $directory ) {
$directory = '';
}
switch ( $function ) {
case 'rebuild':
wpsc_rebuild_files( $cache_path . 'supercache/' . $sitedir . $directory );
break;
case 'prune':
wpsc_delete_files( $cache_path . 'supercache/' . $sitedir . $directory );
break;
}
}
function domain_mapping_supercachedir( $dir ) {
global $cache_path;
if ( ! function_exists( 'domain_mapping_warning' ) ) {
return $dir;
}
$siteurl = domain_mapping_siteurl( false );
if ( ! $siteurl ) {
return $dir;
}
$sitedir = trailingslashit( preg_replace( '`^(https?:)?//`', '', $siteurl ) );
return trailingslashit( $cache_path . 'supercache/' . $sitedir );
}
function domain_mapping_actions() {
global $cache_domain_mapping;
$cache_domain_mapping = (int) $cache_domain_mapping;
if ( 1 !== $cache_domain_mapping ) {
return;
}
add_filter( 'wp_super_cache_supercachedir', 'domain_mapping_supercachedir' );
add_action( 'gc_cache', 'domain_mapping_gc_cache', 10, 2 );
}
add_cacheaction( 'add_cacheaction', 'domain_mapping_actions' );
function wp_supercache_domain_mapping_admin() {
global $cache_domain_mapping, $wp_cache_config_file, $valid_nonce;
$requested_state = isset( $_POST['cache_domain_mapping'] ) ? (int) $_POST['cache_domain_mapping'] : null;
$cache_domain_mapping = (int) $cache_domain_mapping;
$changed = false;
if ( null !== $requested_state && $valid_nonce ) {
$cache_domain_mapping = $requested_state;
wp_cache_replace_line( '^\s*\$cache_domain_mapping\s*=', '$cache_domain_mapping = ' . $cache_domain_mapping . ';', $wp_cache_config_file );
$changed = true;
}
$id = 'domain_mapping-section';
?>
<fieldset id="<?php echo esc_attr( $id ); ?>" class="options">
<h4><?php esc_html_e( 'Domain Mapping', 'wp-super-cache' ); ?></h4>
<form name="wp_manager" action="" method="post">
<label><input type="radio" name="cache_domain_mapping" value="1" <?php checked( $cache_domain_mapping ); ?>/> <?php esc_html_e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_domain_mapping" value="0" <?php checked( ! $cache_domain_mapping ); ?>/> <?php esc_html_e( 'Disabled', 'wp-super-cache' ); ?></label>
<?php
echo '<p>' . __( 'Provides support for <a href="https://wordpress.org/plugins/wordpress-mu-domain-mapping/">Domain Mapping</a> plugin to map multiple domains to a blog.', 'wp-super-cache' ) . '</p>';
if ( $changed ) {
echo '<p><strong>' . sprintf(
esc_html__( 'Domain Mapping support is now %s', 'wp-super-cache' ),
esc_html( $cache_domain_mapping ? __( 'enabled', 'wp-super-cache' ) : __( 'disabled', 'wp-super-cache' ) )
) . '</strong></p>';
}
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . ' type="submit" value="' . esc_html__( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
?>
</form>
</fieldset>
<?php
}
add_cacheaction( 'cache_admin_page', 'wp_supercache_domain_mapping_admin' );
function wp_supercache_domain_mapping_notice() {
global $cache_enabled;
if ( $cache_enabled ) {
echo '<div class="error"><p><strong>' . esc_html__( 'Domain Mapping plugin detected! Please go to the Supercache plugins page and enable the domain mapping helper plugin.', 'wp-super-cache' ) . '</strong></p></div>';
}
}
function wp_supercache_domain_mapping_exists() {
global $cache_domain_mapping;
$cache_domain_mapping = (int) $cache_domain_mapping;
if ( 1 === $cache_domain_mapping ) {
return;
}
if ( is_admin() && function_exists( 'domain_mapping_warning' ) ) {
add_action( 'admin_notices', 'wp_supercache_domain_mapping_notice' );
}
}
if ( isset( $_GET['page'] ) && 'wpsupercache' === $_GET['page'] ) {
add_cacheaction( 'add_cacheaction', 'wp_supercache_domain_mapping_exists' );
}
function wpsc_domain_mapping_list( $list ) {
$list['domain_mapping'] = array(
'key' => 'domain_mapping',
'url' => 'https://wordpress.org/plugins/wordpress-mu-domain-mapping/',
'title' => esc_html__( 'Domain Mapping', 'wp-super-cache' ),
'desc' => esc_html__( 'Provides support for Domain Mapping plugin to map multiple domains to a blog.', 'wp-super-cache' ),
);
return $list;
}
add_cacheaction( 'wpsc_filter_list', 'wpsc_domain_mapping_list' );

View File

@@ -0,0 +1,187 @@
<?php
/*
* On the Advanced Settings page enable "Enable dynamic caching" and clear
* the cache.
*
* Plugin authors: NEVER define the template tag for your users. Make them
* choose one so it will be unique to their site.
*
* There are two examples in this file. Both use template tags that must be
* kept secret.
*
* GLOSSARY:
*
* Dynamic content: the text or widget you want to show visitors to your site
* that changes every time it's viewed.
* Placeholder/template tag: the string of random characters placed in your
* theme file or printed in an action where the dynamic content will go.
* Output buffer (ob): any text that is printed by PHP to be sent to the browser
* but captured by PHP for further manipulation.
* OB Callback function: A function that is called when the output buffer is
* filled with a html page. The contents of the page are passed to the function
* for processing.
*
* **** MAKE SURE YOU KEEP THE TEMPLATE TAG SECRET ****
* You should probably add 'deny from all' to the .htaccess in the cache directory
* so visitors can't directly load any cached html files and discover the secret
* tag. Or you can move the cache directory out of the web path and set the
* cache location to that new directory on the advanced settings page.
*
*/
/*
* EXAMPLE 1
* http://ocaoimh.ie/2013/10/21/shiny-new-dynamic-content-wp-super-cache/
* Replace a string in your theme with the dynamic content.
*
* dynamic_cache_test_init()
* This function is the first one to be called. This function hooks
* dynamic_cache_test_template() to the WordPress action, wp_footer.
* This script is loaded before WordPress is and the add_action()
* function isn't defined at this time.
* This init function hooks onto the cache action "add_cacheaction"
* that fires after WordPress (and add_action) is loaded.
*
*
* dynamic_cache_test_template_tag()
* This function hooks on to wp_footer and displays the secret template
* tag that will be replaced by our dynamic content on each page view.
*
*
* dynamic_cache_test_filter()
* This function hooks on to the filter through which all the cached data
* sent to visitors is sent.
* In this simple example the template tag is replaced by a html comment
* containing the text "Hello world at " and the current server time.
* If you want to use the output of a WordPress plugin or command you
* must enable "late init" on the settings page. Each time you reload
* the cached page this time will change. View the page source to examine
* this text.
*
* Chronology of a request:
* 1. dynamic_cache_test_init() hooks dynamic_cache_test_template_tag() on
* to the wp_footer action. dynamic_cache_test_filter() is hooked on to
* the wpsc_cachedata filter.
* 2. An output buffer is created by WP Super Cache.
* 3. Most of the page is generated by WordPress.
* 4. The wp_footer action fires and the TAG is printed to the page.
* 5. Processing continues and the page is created.
* 6. The output buffer finishes. A WP Super Cache callback function runs
* and saves the output buffer to a cache file. The wpsc_cachedata
* filter is called.
* 7. The function dynamic_cache_test_filter() runs and replaces the TAG in
* the buffer with the "Hello world" string.
* 8. The output buffer is pushed to the browser to be displayed.
*/
define( 'DYNAMIC_CACHE_TEST_TAG', '' ); // Change this to a secret placeholder tag.
if ( '' !== DYNAMIC_CACHE_TEST_TAG ) {
function dynamic_cache_test_safety( $safety ) {
return 1;
}
add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_cache_test_safety' );
function dynamic_cache_test_filter( $cachedata ) {
return str_replace( DYNAMIC_CACHE_TEST_TAG, '<!-- Hello world at ' . date( 'H:i:s' ) . ' -->', $cachedata );
}
add_cacheaction( 'wpsc_cachedata', 'dynamic_cache_test_filter' );
function dynamic_cache_test_template_tag() {
echo DYNAMIC_CACHE_TEST_TAG; // This is the template tag.
}
function dynamic_cache_test_init() {
add_action( 'wp_footer', 'dynamic_cache_test_template_tag' );
}
add_cacheaction( 'add_cacheaction', 'dynamic_cache_test_init' );
}
/*
* EXAMPLE 2
*
* This is going to be complicated. Hang on!
*
* When the cache file for a new page is generated the plugin uses an output
* buffer to capture the page. A callback function processes the buffer and
* writes to the cache file. The placeholder tag for any dynamic content has
* to be written to that cache file but also, it has to be replaced with
* dynamic content before the page is shown to the user.
* More on output buffers here: http://php.net/ob_start
*
* Unfortunately an extra output buffer is often required when capturing dynamic
* content such as sidebar widgets. Due to a quirk of the way PHP works it's
* not possible to have an output buffer run in an output buffer callback. That
* dynamic content has to be generated before the callback function is reached.
* The following error occurs when an output buffer is created in the
* callback function of another output buffer:
* "PHP Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in..."
*
* In this example the function add_action() isn't available when this file is
* loaded so dynamic_output_buffer_init() is hooked on to the "add_cacheaction"
* cacheaction. That function then hooks dynamic_output_buffer_test() on to the
* familiar wp_footer action.
*
* The first time dynamic_output_buffer_test() runs it generates the dynamic
* content and captures it with ob_start() in the DYNAMIC_OB_TEXT constant.
*
* When the main WP Super Cache output buffer is ready the callback is called.
* This fires the wpsc_cachedata_safety filter. If the DYNAMIC_OB_TEXT constant
* is set, which means dynamic content is ready, then it returns 1, a signal
* that everything is ok.
* Finally, the wpsc_cachedata filter is run. The function
* dynamic_output_buffer_test() is hooked on to it. Since DYNAMIC_OB_TEXT is
* set it replaces the placeholder text with that constant.
* The resulting html is then sent to the browser.
*
* Already cached pages call the safety filter, and then the wpsc_cachedata
* filter so any hooked function must be ready to generate dynamic content. The
* very last line of dynamic_output_buffer_test() replaces the placeholder tag
* with the dynamic content in the cache file.
*
* Use an output buffer to capture dynamic content while the page is generated
* and insert into the right place:
* Remember to add the DYNAMIC_OUTPUT_BUFFER_TAG text (as defined below) to
* your theme where the dynamic content should be.
*
* dynamic_output_buffer_test() is a function that uses the wpsc_cachedata
* filter to add a small message and the current server time to every web
* page. The time increments on every reload.
*
*/
define( 'DYNAMIC_OUTPUT_BUFFER_TAG', '' ); // Change this to a secret placeholder tag.
if ( '' !== DYNAMIC_OUTPUT_BUFFER_TAG ) {
function dynamic_output_buffer_test( $cachedata = 0 ) {
if ( defined( 'DYNAMIC_OB_TEXT' ) ) {
return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, DYNAMIC_OB_TEXT, $cachedata );
}
ob_start();
// call the sidebar function, do something dynamic
echo '<p>This is a test. The current time on the server is: ' . date( 'H:i:s' ) . '</p>';
$text = ob_get_contents();
ob_end_clean();
if ( 0 === $cachedata ) { // called directly from the theme so store the output.
define( 'DYNAMIC_OB_TEXT', $text );
} else { // called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php.
return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, $text, $cachedata );
}
}
add_cacheaction( 'wpsc_cachedata', 'dynamic_output_buffer_test' );
function dynamic_output_buffer_init() {
add_action( 'wp_footer', 'dynamic_output_buffer_test' );
}
add_cacheaction( 'add_cacheaction', 'dynamic_output_buffer_init' );
function dynamic_output_buffer_test_safety( $safety ) {
if ( defined( 'DYNAMIC_OB_TEXT' ) ) {// this is set when you call dynamic_output_buffer_test() from the theme.
return 1; // ready to replace tag with dynamic content.
} else {
return 0; // tag cannot be replaced.
}
}
add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_output_buffer_test_safety' );
}

View File

@@ -0,0 +1,93 @@
<?php
if ( defined( 'WPCACHEHOME' ) ) {
if ( file_exists( WPCACHEHOME . '/src/device-detection/class-device-detection.php' ) ) {
require_once WPCACHEHOME . '/src/device-detection/class-device-detection.php';
}
}
function wp_super_cache_jetpack_admin() {
global $cache_jetpack, $wp_cache_config_file, $valid_nonce;
$cache_jetpack = '' === $cache_jetpack ? '0' : $cache_jetpack;
if ( isset( $_POST['cache_jetpack'] ) && $valid_nonce ) {
if ( $cache_jetpack === (int) $_POST['cache_jetpack'] ) {
$changed = false;
} else {
$changed = true;
}
$cache_jetpack = (int) $_POST['cache_jetpack'];
wp_cache_replace_line( '^ *\$cache_jetpack', "\$cache_jetpack = '$cache_jetpack';", $wp_cache_config_file );
if ( $changed && $cache_jetpack ) {
wp_cache_replace_line( '^ *\$wp_cache_mobile_enabled', '$wp_cache_mobile_enabled = 1;', $wp_cache_config_file );
wp_cache_replace_line( '^ *\$wp_cache_mod_rewrite', '$wp_cache_mod_rewrite = 0;', $wp_cache_config_file );
wp_cache_replace_line( '^ *\$super_cache_enabled', '$super_cache_enabled = 1;', $wp_cache_config_file );
}
}
$id = 'jetpack-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<h4><?php _e( 'Jetpack Mobile Theme', 'wp-super-cache' ); ?></h4>
<?php
if ( false === file_exists( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' ) ) {
echo '<strong>' . sprintf( __( 'Jetpack not found in %s. Install it and enable the mobile theme and this helper plugin to cache visits by mobile visitors.', 'wp-super-cache' ), dirname( WPCACHEHOME ) ) . '</strong>';
} else {
?>
<form name="wp_manager" action="" method="post">
<label><input type="radio" name="cache_jetpack" value="1" <?php if ( $cache_jetpack ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_jetpack" value="0" <?php if ( ! $cache_jetpack ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
<?php
echo '<p>' . __( 'Provides support for the <a href="https://wordpress.org/plugins/jetpack/">Jetpack</a> mobile theme and plugin. PHP caching mode and mobile support will be enabled too.', 'wp-super-cache' ) . '</p>';
if ( isset( $changed ) && $changed ) {
if ( $cache_jetpack ) {
$status = __( 'enabled', 'wp-super-cache' );
} else {
$status = __( 'disabled', 'wp-super-cache' );
}
echo '<p><strong>' . sprintf( __( 'Jetpack Mobile Theme support is now %s', 'wp-super-cache' ), $status ) . '</strong></p>';
}
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
?>
</form>
<?php } ?>
</fieldset>
<?php
}
add_cacheaction( 'cache_admin_page', 'wp_super_cache_jetpack_admin' );
function wp_super_cache_jetpack_cookie_check( $cache_key ) {
if ( isset ( $_COOKIE['akm_mobile'] ) ) {
if ( $_COOKIE['akm_mobile'] == 'true' ) {
return 'mobile';
} elseif ( $_COOKIE['akm_mobile'] == 'false' ) {
return 'normal';
}
}
if ( ! class_exists( 'Automattic\WPSC\Device_Detection' ) ) {
return 'normal';
}
if ( \Automattic\WPSC\Device_Detection::is_phone() ) {
return 'mobile';
} else {
return 'normal';
}
}
if ( isset( $cache_jetpack ) && '1' === $cache_jetpack ) {
add_cacheaction( 'wp_cache_check_mobile', 'wp_super_cache_jetpack_cookie_check' );
}
function wpsc_cache_jetpack_list( $list ) {
$list['jetpack'] = array(
'key' => 'jetpack',
'url' => 'https://wordpress.org/plugins/jetpack/',
'title' => __( 'Jetpack Mobile Theme', 'wp-super-cache' ),
'desc' => __( 'Provides support for the Jetpack mobile theme and plugin. PHP caching mode and mobile support will be enabled too.', 'wp-super-cache' ),
);
return $list;
}
add_cacheaction( 'wpsc_filter_list', 'wpsc_cache_jetpack_list' );

View File

@@ -0,0 +1,68 @@
<?php
if ( is_multisite() ) {
add_cacheaction( 'add_cacheaction', 'wp_super_cache_multisite_init' );
}
function wp_super_cache_multisite_init() {
add_filter( 'wpmu_blogs_columns', 'wp_super_cache_blogs_col' );
add_action( 'manage_sites_custom_column', 'wp_super_cache_blogs_field', 10, 2 );
add_action( 'init', 'wp_super_cache_override_on_flag', 9 );
}
function wp_super_cache_blogs_col( $col ) {
$col['wp_super_cache'] = __( 'Cached', 'wp-super-cache' );
return $col;
}
function wp_super_cache_blogs_field( $name, $blog_id ) {
if ( 'wp_super_cache' !== $name ) {
return false;
}
$blog_id = (int) $blog_id;
if ( isset( $_GET['id'], $_GET['action'], $_GET['_wpnonce'] )
&& $blog_id === filter_input( INPUT_GET, 'id', FILTER_VALIDATE_INT )
&& wp_verify_nonce( $_GET['_wpnonce'], 'wp-cache' . $blog_id )
) {
if ( 'disable_cache' === filter_input( INPUT_GET, 'action' ) ) {
add_blog_option( $blog_id, 'wp_super_cache_disabled', 1 );
} elseif ( 'enable_cache' === filter_input( INPUT_GET, 'action' ) ) {
delete_blog_option( $blog_id, 'wp_super_cache_disabled' );
}
}
if ( 1 === (int) get_blog_option( $blog_id, 'wp_super_cache_disabled' ) ) {
echo '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'enable_cache', 'id' => $blog_id ) ), 'wp-cache' . $blog_id ) . '">' . __( 'Enable', 'wp-super-cache' ) . '</a>';
} else {
echo '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'disable_cache', 'id' => $blog_id ) ), 'wp-cache' . $blog_id ) . '">' . __( 'Disable', 'wp-super-cache' ) . '</a>';
}
}
function wp_super_cache_multisite_notice() {
if ( 'wpsupercache' === filter_input( INPUT_GET, 'page' ) ) {
echo '<div class="error"><p><strong>' . __( 'Caching has been disabled on this blog on the Network Admin Sites page.', 'wp-super-cache' ) . '</strong></p></div>';
}
}
function wp_super_cache_override_on_flag() {
global $cache_enabled, $super_cache_enabled;
if ( true !== $cache_enabled ) {
return false;
}
if ( 1 === (int) get_option( 'wp_super_cache_disabled' ) ) {
$cache_enabled = false;
$super_cache_enabled = false;
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', 1 );
}
if ( ! defined( 'SUBMITDISABLED' ) ) {
define( 'SUBMITDISABLED', 'disabled style="color: #aaa" ' );
}
if ( is_admin() ) {
add_action( 'admin_notices', 'wp_super_cache_multisite_notice' );
}
}
}

View File

@@ -0,0 +1,142 @@
<?php
function wp_super_cache_wptouch_admin() {
global $cache_wptouch, $wp_cache_config_file, $valid_nonce;
$cache_wptouch = '' === $cache_wptouch ? '0' : $cache_wptouch;
if ( isset( $_POST['cache_wptouch'] ) && $valid_nonce ) {
if ( $cache_wptouch === (int) $_POST['cache_wptouch'] ) {
$changed = false;
} else {
$changed = true;
}
$cache_wptouch = (int) $_POST['cache_wptouch'];
wp_cache_replace_line( '^ *\$cache_wptouch', "\$cache_wptouch = '$cache_wptouch';", $wp_cache_config_file );
}
$id = 'wptouch-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<h4><?php _e( 'WPTouch', 'wp-super-cache' ); ?></h4>
<form name="wp_manager" action="" method="post">
<label><input type="radio" name="cache_wptouch" value="1" <?php if ( $cache_wptouch ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_wptouch" value="0" <?php if ( ! $cache_wptouch ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
<?php
echo '<p>' . __( 'Provides support for <a href="https://wordpress.org/plugins/wptouch/">WPTouch</a> mobile theme and plugin.', 'wp-super-cache' ) . '</p>';
if ( isset( $changed ) && $changed ) {
if ( $cache_wptouch ) {
$status = __( 'enabled', 'wp-super-cache' );
} else {
$status = __( 'disabled', 'wp-super-cache' );
}
echo '<p><strong>' . sprintf( __( 'WPTouch support is now %s', 'wp-super-cache' ), $status ) . '</strong></p>';
}
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
?>
</form>
</fieldset>
<?php
}
add_cacheaction( 'cache_admin_page', 'wp_super_cache_wptouch_admin' );
function wp_super_cache_wptouch_notice() {
global $cache_enabled;
if ( $cache_enabled ) {
echo '<div class="error"><p><strong>' . __( 'WPTouch plugin detected! Please go to the Supercache plugins page and enable the WPTouch helper plugin.', 'wp-super-cache' ) . '</strong></p></div>';
}
}
function wp_super_cache_wptouch_exists() {
global $cache_wptouch;
if ( '1' === $cache_wptouch ) {
return false;
}
if ( is_admin() && function_exists( 'wptouch_get_plugin_dir_name' ) ) {
add_action( 'admin_notices', 'wp_super_cache_wptouch_notice' );
}
}
if ( isset( $_GET['page'] ) && 'wpsupercache' === $_GET['page'] ) {
add_cacheaction( 'add_cacheaction', 'wp_super_cache_wptouch_exists' );
}
// disable mobile checking if.
function wp_super_cache_maybe_disable_wptouch( $t ) {
global $cache_wptouch, $wptouch_exclude_ua;
if ( '1' !== $cache_wptouch ) {
return false;
}
if ( ( isset( $_COOKIE['wptouch_switch_toggle'] ) && 'normal' === $_COOKIE['wptouch_switch_toggle'] ) ||
( isset( $_COOKIE['wptouch-pro-view'] ) && 'desktop' === $_COOKIE['wptouch-pro-view'] ) ) {
return true;
}
$ua = explode( ',', $wptouch_exclude_ua );
foreach ( $ua as $agent ) {
if ( preg_match( "#$agent#i", $_SERVER['HTTP_HOST'] ) ) {
return true; // disable mobile ua check if matches the exclude list in wptouch.
}
}
return false;
}
add_cacheaction( 'disable_mobile_check', 'wp_super_cache_maybe_disable_wptouch' );
function wp_super_cache_wptouch_browsers( $browsers ) {
global $wptouch_exclude_ua, $wp_cache_config_file;
if ( false === function_exists( 'bnc_wptouch_get_exclude_user_agents' ) || false === function_exists( 'bnc_wptouch_get_user_agents' ) ) {
return $browsers;
}
$browsers = implode( ',', bnc_wptouch_get_exclude_user_agents() ); // hack, support exclude agents too.
if ( $browsers !== $wptouch_exclude_ua ) {
wp_cache_replace_line( '^ *\$wptouch_exclude_ua', "\$wptouch_exclude_ua = '$browsers';", $wp_cache_config_file );
$wptouch_exclude_ua = $browsers;
}
return bnc_wptouch_get_user_agents();
}
function wp_super_cache_wptouch_prefixes( $prefixes ) {
return array(); // wptouch doesn't support UA prefixes.
}
function wp_super_cache_wptouch_cookie_check( $cache_key ) {
if ( false === isset( $_COOKIE['wptouch_switch_toggle'] ) ) {
return $cache_key;
}
if ( 'normal' === $_COOKIE['wptouch_switch_toggle'] || 'mobile' === $_COOKIE['wptouch_switch_toggle'] ) {
return $_COOKIE['wptouch_switch_toggle'];
}
if ( isset( $_COOKIE['wptouch-pro-view'] ) ) {
if ( 'desktop' === $_COOKIE['wptouch-pro-view'] ) {
return 'normal';
} else {
return $_COOKIE['wptouch-pro-view'];
}
}
return $cache_key;
}
if ( isset( $cache_wptouch ) && '1' === $cache_wptouch ) {
add_cacheaction( 'wp_super_cache_mobile_browsers', 'wp_super_cache_wptouch_browsers' );
add_cacheaction( 'wp_super_cache_mobile_prefixes', 'wp_super_cache_wptouch_prefixes' );
add_cacheaction( 'wp_cache_check_mobile', 'wp_super_cache_wptouch_cookie_check' );
}
function wpsc_wptouch_list( $list ) {
$list['wptouch'] = array(
'key' => 'wptouch',
'url' => 'https://wordpress.org/plugins/wptouch/',
'title' => __( 'WPTouch', 'wp-super-cache' ),
'desc' => __( 'Provides support for WPTouch mobile theme and plugin.', 'wp-super-cache' ),
);
return $list;
}
add_cacheaction( 'wpsc_filter_list', 'wpsc_wptouch_list' );

View File

@@ -0,0 +1,270 @@
=== WP Super Cache ===
Contributors: donncha, automattic, adnan007, dilirity, mikemayhem3030, pyronaur, thingalon
Tags: performance, caching, wp-cache, wp-super-cache, cache
Requires at least: 6.8
Requires PHP: 7.4
Tested up to: 6.9
Stable tag: 3.1.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
A very fast caching engine for WordPress that produces static html files.
## Description ##
This plugin generates static html files from your dynamic WordPress blog. After a html file is generated your webserver will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts.
The static html files will be served to the vast majority of your users:
* Users who are not logged in.
* Users who have not left a comment on your blog.
* Or users who have not viewed a password protected post.
99% of your visitors will be served static html files. One cached file can be served thousands of times. Other visitors will be served custom cached files tailored to their visit. If they are logged in, or have left comments those details will be displayed and cached for them.
The plugin serves cached files in 3 ways (ranked by speed):
1. Expert. The fastest method is by using Apache mod_rewrite (or whatever similar module your web server supports) to serve "supercached" static html files. This completely bypasses PHP and is extremely quick. If your server is hit by a deluge of traffic it is more likely to cope as the requests are "lighter". This does require the Apache mod_rewrite module (which is probably installed if you have custom permalinks) and a modification of your .htaccess file which is risky and may take down your site if modified incorrectly.
2. Simple. Supercached static files can be served by PHP and this is the recommended way of using the plugin. The plugin will serve a "supercached" file if it exists and it's almost as fast as the mod_rewrite method. It's easier to configure as the .htaccess file doesn't need to be changed. You still need a custom permalink. You can keep portions of your page dynamic in this caching mode.
3. WP-Cache caching. This is mainly used to cache pages for known users, URLs with parameters and feeds. Known users are logged in users, visitors who leave comments or those who should be shown custom per-user data. It's the most flexible caching method and slightly slower. WP-Cache caching will also cache visits by unknown users if supercaching is disabled. You can have dynamic parts to your page in this mode too. This mode is always enabled but you can disable caching for known users, URLs with parameters, or feeds separately. Set the constant "DISABLE_SUPERCACHE" to 1 in your wp-config.php if you want to only use WP-Cache caching.
If you're not comfortable with editing PHP files then use simple mode. It's easy to set up and very fast.
### Recommended Settings ###
1. Simple caching.
2. Compress pages.
3. Don't cache pages for known users.
4. Cache rebuild.
5. CDN support.
6. Extra homepage checks.
Garbage collection is the act of cleaning up cache files that are out of date and stale. There's no correct value for the expiry time but a good starting point is 1800 seconds.
Consider deleting the contents of the "Rejected User Agents" text box and allow search engines to cache files for you.
Preload as many posts as you can and enable "Preload Mode". Garbage collection of old cached files will be disabled. If you don't care about sidebar widgets updating often set the preload interval to 2880 minutes (2 days) so all your posts aren't recached very often. When the preload occurs the cache files for the post being refreshed is deleted and then regenerated. Afterwards a garbage collection of all old files is performed to clean out stale cache files.
Even with preload mode enabled cached files will still be deleted when posts are modified or comments made.
### Development ###
* Active development of this plugin is handled [on GitHub](https://github.com/Automattic/wp-super-cache).
* Translation of the plugin into different languages is on the [translation page](https://translate.wordpress.org/projects/wp-plugins/wp-super-cache).
### Documentation ###
If you need more information than the following, you can have a look at [the wiki](https://github.com/Automattic/wp-super-cache/wiki) or the [Developer documentation](https://odd.blog/wp-super-cache-developers/).
#### Preloading ####
You can generate cached files for the posts, categories and tags of your site by preloading. Preloading will visit each page of your site generating a cached page as it goes along, just like any other visitor to the site. Due to the sequential nature of this function, it can take some time to preload a complete site if there are many posts.
To make preloading more effective it can be useful to disable garbage collection so that older cache files are not deleted. This is done by enabling "Preload Mode" in the settings. Be aware however, that pages will go out of date eventually but that updates by submitting comments or editing posts will clear portions of the cache.
#### Garbage Collection ####
Your cache directory fills up over time, which takes up space on your server. If space is limited or billed by capacity, or if you worry that the cached pages of your site will go stale then garbage collection has to be done. Garbage collection happens on a regular basis and deletes old files in the cache directory. On the advanced settings page you can specify:
1. Cache timeout. How long cache files are considered fresh for. After this time they are stale and can be deleted.
2. Scheduler. Setup how often garbage collection should be done.
3. Notification emails. You can be informed on garbage collection job progress.
There's no right or wrong settings for garbage collection. It depends on your own site.
If your site gets regular updates, or comments then set the timeout to 1800 seconds, and set the timer to 600 seconds.
If your site is mostly static you can disable garbage collection by entering 0 as the timeout, or use a really large timeout value.
The cache directory, usually wp-content/cache/ is only for temporary files. Do not ever put important files or symlinks to important files or directories in that directory. They will be deleted if the plugin has write access to them.
#### CDN ####
A Content Delivery Network (CDN) is usually a network of computers situated around the world that will serve the content of your website faster by using servers close to you. Static files like images, Javascript and CSS files can be served through these networks to speed up how fast your site loads. You can also create a "poor man's CDN" by using a sub domain of your domain to serve static files too.
[OSSDL CDN off-linker](https://wordpress.org/plugins/ossdl-cdn-off-linker/) has been integrated into WP Super Cache to provide basic CDN support. It works by rewriting the URLs of files (excluding .php files) in wp-content and wp-includes on your server so they point at a different hostname. Many CDNs support [origin pull](https://www.google.com/search?hl=en&q=%22origin+pull%22). This means the CDN will download the file automatically from your server when it's first requested, and will continue to serve it for a configurable length of time before downloading it again from your server.
Configure this on the "CDN" tab of the plugin settings page. This is an advanced technique and requires a basic understanding of how your webserver or CDNs work. Please be sure to clear the file cache after you configure the CDN.
#### REST API ####
There are now REST API endpoints for accessing the settings of this plugin. You'll need to be authenticated as an admin user with permission to view the settings page to use it. This has not been documented yet but you can find all the code that deals with this in the "rest" directory.
#### Custom Caching ####
It is now possible to hook into the caching process using the add_cacheaction() function.
Three hooks are available:
1. 'wp_cache_get_cookies_values' - modify the key used by WP Cache.
2. 'add_cacheaction' - runs in phase2. Allows a plugin to add WordPress hooks.
3. 'cache_admin_page' - runs in the admin page. Use it to modify that page, perhaps by adding new configuration options.
There is one regular WordPress filter too. Use the "do_createsupercache" filter
to customize the checks made before caching. The filter accepts one parameter.
The output of WP-Cache's wp_cache_get_cookies_values() function.
WP Super Cache has its own plugin system, loaded before most of WordPress. Add your own plugin either by putting it in the wp-content/plugins/wp-super-cache-plugins directory, or by calling wpsc_add_plugin( $name ) with the full path to the plugin.
The cookies used to identify "known users" can be modified with wpsc_add_cookie( $name ) and wpsc_delete_cookie( $name ). See [plugins/searchengine.php](https://github.com/Automattic/wp-super-cache/blob/4cda5c0f2218e40e118232b5bf22d227fb3206b7/plugins/searchengine.php) as an example.
### Troubleshooting ###
If things don't work when you installed the plugin here are a few things to check:
1. Is wp-content writable by the web server?
2. Is there a wp-content/wp-cache-config.php ? If not, copy the file wp-super-cache/wp-cache-config-sample.php to wp-content/wp-cache-config.php and make sure WPCACHEHOME points at the right place.
3. Is there a wp-content/advanced-cache.php ? If not, then you must copy wp-super-cache/advanced-cache.php into wp-content/. You must edit the file and change the path so it points at the wp-super-cache folder.
4. If pages are not cached at all, remove wp-content/advanced-cache.php and recreate it, following the advice above.
5. Make sure the following line is in wp-config.php and it is ABOVE the "require_once(ABSPATH.'wp-settings.php');" line:
`define( 'WP_CACHE', true );`
6. Try the Settings->WP Super Cache page again and enable cache.
7. Look in wp-content/cache/supercache/. Are there directories and files there?
8. Anything in your php error_log?
9. If your browser keeps asking you to save the file after the super cache is installed you must disable Super Cache compression. Go to the Settings->WP Super Cache page and disable it there.
10. File locking errors such as "failed to acquire key 0x152b: Permission denied in..." or "Page not cached by WP Super Cache. Could not get mutex lock." are a sign that you may have to use file locking. Edit wp-content/wp-cache-config.php and uncomment "$use_flock = true" or set $sem_id to a different value. You can also disable file locking from the Admin screen as a last resort.
11. Make sure cache/wp_cache_mutex.lock is writable by the web server if using coarse file locking.
12. The cache folder cannot be put on an NFS or Samba or NAS share. It has to be on a local disk. File locking and deleting expired files will not work properly unless the cache folder is on the local machine.
13. Garbage collection of old cache files won't work if WordPress can't find wp-cron.php. Check your access_logs for wp-cron.php entries and that your hostname resolves to the external IP address other servers on the network/Internet use.
14. If old pages are being served to your visitors via the supercache, you may be missing Apache modules (or their equivalents if you don't use Apache). 3 modules are required: mod_mime, mod_headers and mod_expires. The last two are especially important for making sure browsers load new versions of existing pages on your site.
15. The error message, "WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed!" appears at the end of every page. Open the file wp-content/advanced-cache.php in your favourite editor. Is the path to wp-cache-phase1.php correct? This file will normally be in wp-content/plugins/wp-super-cache/. If it is not correct the caching engine will not load.
16. Caching doesn't work. The timestamp on my blog keeps changing when I reload. Check that the path in your .htaccess rules matches where the supercache directory is. You may have to hardcode it. Try disabling supercache mode.
17. If supercache cache files are generated but not served, check the permissions on all your wp-content/cache/supercache folders (and each of wp-content cache and supercache folders) and wp-content/cache/.htaccess. If your PHP runs as a different user to Apache and permissions are strict Apache may not be able to read the PHP generated cache files. To fix you must add the following line to your wp-config.php (Add it above the WP_CACHE define.) Then clear your cache.
`umask( 0022 );`
18. If you see garbage in your browser after enabling compression in the plugin, compression may already be enabled in your web server. In Apache you must disable mod_deflate, or in PHP zlib compression may be enabled. You can disable that in three ways. If you have root access, edit your php.ini and find the zlib.output_compression setting and make sure it's "Off" or add this line to your .htaccess:
`php_flag zlib.output_compression off`
If that doesn't work, add this line to your wp-config.php:
`ini_set('zlib.output_compression', 0);`
19. After uninstalling, your permalinks may break if you remove the WordPress mod_rewrite rules too. Regenerate those rules by visiting the Settings->Permalink page and saving that form again.
20. If your blog refuses to load make sure your wp-config.php is correct. Are you missing an opening or closing PHP tag?
21. Your front page is ok but posts and pages give a 404? Go to Settings->permalinks and click "Save" once you've selected a custom permalink structure. You may need to manually update your .htaccess file.
22. If certain characters do not appear correctly on your website your server may not be configured correctly. You need to tell visitors what character set is used. Go to Settings->Reading and copy the 'Encoding for pages and feeds' value. Edit the .htaccess file with all your Supercache and WordPress rewrite rules and add this at the top, replacing CHARSET with the copied value. (for example, 'UTF-8')
`AddDefaultCharset CHARSET`
23. The error message, "WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory." appears at the end of every page. You can delete wp-content/advanced-cache.php and reload the plugin settings page or edit wp-config.php and look for WPCACHEHOME and make sure it points at the wp-super-cache folder. This will normally be wp-content/plugins/wp-super-cache/ but you'll likely need the full path to that file (so it's easier to let the settings page fix it). If it is not correct the caching engine will not load.
24. If your server is running into trouble because of the number of semaphores used by the plugin it's because your users are using file locking which is not recommended (but is needed by a small number of users). You can globally disable file locking by defining the constant WPSC_DISABLE_LOCKING, or defining the constant WPSC_REMOVE_SEMAPHORE so that sem_remove() is called after every page is cached but that seems to cause problems for other processes requesting the same semaphore. Best to disable it.
25. Set the variable $htaccess_path in wp-config.php or wp-cache-config.php to the path of your global .htaccess if the plugin is looking for that file in the wrong directory. This might happen if you have WordPress installed in an unusual way.
## Installation ##
Install like any other plugin, directly from your plugins page but make sure you have custom permalinks enabled. Go to the plugin settings page at Settings->WP Super Cache and enable caching.
### How to uninstall WP Super Cache ###
Almost all you have to do is deactivate the plugin on the plugins page. The plugin should clean up most of the files it created and modified, but it doesn't as yet remove the mod_rewrite rules from the .htaccess file. Look for the section in that file marked by SuperCache BEGIN and END tags. The plugin doesn't remove those because some people add the WordPress rules in that block too.
To manually uninstall:
1. Turn off caching on the plugin settings page and clear the cache.
2. Deactivate the plugin on the plugins page.
3. Remove the WP_CACHE define from wp-config.php. It looks like `define( 'WP_CACHE', true );`
4. Remove the Super Cache mod_rewrite rules from your .htaccess file.
5. Remove the files wp-content/advanced-cache.php and wp-content/wp-cache-config.php
6. Remove the directory wp-content/cache/
7. Remove the directory wp-super-cache from your plugins directory.
### If all else fails and your site is broken ###
1. Remove the WP_CACHE define from wp-config.php. It looks like `define( 'WP_CACHE', true );`
2. Remove the rules (see above) that the plugin wrote to the .htaccess file in your root directory.
3. Delete the wp-super-cache folder in the plugins folder.
4. Optionally delete advanced-cache.php, wp-cache-config.php and the cache folder in wp-content/.
## Frequently Asked Questions ##
### How do I know my blog is being cached? ###
Go to Settings -> WP Super Cache and look for the "Cache Tester" form on the easy settings page. Click "Test Cache" and the plugin will request the front page of the site twice, comparing a timestamp on each to make sure they match.
If you want to do it manually, enable debugging in the plugin settings page and load the log file in a new browser tab. Then view your blog while logged in and logged out. You should see activity in the log. View the source of any page on your site. When a page is first created, you'll see the text "Dynamic page generated in XXXX seconds." and "Cached page generated by WP-Super-Cache on YYYY-MM-DD HH:MM:SS" at the end of the source code. On reload, a cached page will show the same timestamp so wait a few seconds before checking.
If Supercaching is disabled and you have compression enabled, the text "Compression = gzip" will be added. If compression is disabled and the page is served as a static html file, the text "super cache" will be added. The only other way to check if your cached file was served by PHP script or from the static cache is by looking at the HTTP headers. PHP cached pages will have the header "WP-Super-Cache: Served supercache file from PHP". WPCache cached files will have the header, "WP-Super-Cache: Served WPCache cache file". You should also check your cache directory in wp-content/cache/supercache/hostname/ for static cache files.
If the plugin rules are missing from your .htaccess file, the plugin will attempt to serve the super cached page if it's found. The header "WP-Super-Cache: Served supercache file from PHP" if this happens.
The pagespeed module for Apache may cause problems when testing. Disable it if you notice any problems running the cache tester.
### How do I disable Supercaching? ###
If you only want to use the WP-Cache engine then edit your wp-config.php or create an mu-plugin that sets the constant 'DISABLE_SUPERCACHE' to 1.
### WP-Cache vs Supercache files ###
All cache files are stored in wp-content/cache/supercache/HOSTNAME/ where HOSTNANE is your domain name. The files are stored in directories matching your site's permalink structure. Supercache files are index.html or some variant of that, depending on what type of visitor hit the blog. Other files are named wp-cache-XXXXXXXXXXXXXXXXX.php. Associated meta filesnames start with "meta". Those files contain information about the cached file. These files are generated by the "WPCache caching" engine in the plugin.
### Will comments and other dynamic parts of my blog update immediately? ###
Comments will show as soon as they are moderated, depending on the comment policy of the blog owner. Other dynamic elements on a page may not update unless they are written in Javascript, Flash, Java or another client side browser language. The plugin really produces static html pages. No PHP is executed when those pages are served. "Popularity Contest" is one such plugin that will not work.
### Will the Super Cache compression slow down my server? ###
No, it will do the opposite. Super Cache files are compressed and stored that way so the heavy compression is done only once. These files are generally much smaller and are sent to a visitor's browser much more quickly than uncompressed html. As a result, your server spends less time talking over the network which saves CPU time and bandwidth, and can also serve the next request much more quickly.
### How do I make certain parts of the page stay dynamic? ###
Note: this functionality is disabled by default. You will have to enable it on the Advanced Settings page.
There are 2 ways of doing this. You can use Javascript to draw the part of the page you want to keep dynamic. That's what Google Adsense and many widgets from external sites do and is the recommended way. Or you can use a WP Super Cache filter to do the job but you can't use mod_rewrite mode caching. You have to use the "simple" delivery method or disable supercaching.
WP Super Cache 1.4 introduced a cacheaction filter called wpsc_cachedata. The cached page to be displayed goes through this filter and allows modification of the page. If the page contains a placeholder tag the filter can be used to replace that tag with your dynamically generated html.
The function that hooks on to the wpsc_cachedata filter should be put in a file in the WP Super Cache plugins folder unless you use the late_init feature. An example plugin is included. Edit [dynamic-cache-test.php](http://svn.wp-plugins.org/wp-super-cache/trunk/plugins/dynamic-cache-test.php) to see the example code.
There are two example functions there. There's a simple function that replaces a string (or tag) you define when the cached page is served. The other example function uses an output buffer to generate the dynamic content. Due to a limitation in how PHP works the output buffer code MUST run before the wpsc_cachedata filter is hit, at least for when a page is cached. It doesn't matter when serving cached pages. See [this post](https://odd.blog/y/6j) for a more technical and longer explanation.
To execute WordPress functions you must enable the 'Late init' feature on the advanced settings page.
### How do I delay serving the cache until the "init" action fires? ###
Cached files are served before almost all of WordPress is loaded. While that's great for performance it's a pain when you want to extend the plugin using a core part of WordPress. Enable 'Late init' mode on the Advanced settings page and cached files will be served when "init" fires. WordPress and it's plugins will be loaded now.
### Why don't WP UserOnline, Popularity Contest, WP Postratings or plugin X not work or update on my blog now? ###
This plugin caches entire pages but some plugins think they can run PHP code every time a page loads. To fix this, the plugin needs to use Javascript/AJAX methods or the wpsc_cachedata filter described in the previous answer to update or display dynamic information.
### Why do my WP Super Cache plugins disappear when I upgrade the plugin? ###
WordPress deletes the plugin folder when it updates a plugin. This is the same with WP Super Cache so any modified files in wp-super-cache/plugins/ will be deleted. You can put your custom plugins in a different directory in a number of ways. You can define the variable $wp_cache_plugins_dir in wp-config.php or wp-content/wp-cache-config.php and point it at a directory outside of the wp-super-cache folder. The plugin will look there for it's plugins. Or if you distribute a plugin that needs to load early you can use the function `wpsc_add_plugin( $filename )` to add a new plugin wherever it may be. Use `wpsc_delete_plugin( $filename )` to remove the plugin file. See [#574](https://github.com/Automattic/wp-super-cache/pull/574/) or [this post](https://odd.blog/2017/10/25/writing-wp-super-cache-plugins/) on writing WP Super Cache plugins.
### What does the Cache Rebuild feature do? ###
When a visitor leaves a comment the cached file for that page is deleted and the next visitor recreates the cached page. A page takes time to load so what happens if it receives 100 visitors during this time? There won't be a cached page so WordPress will serve a fresh page for each user and the plugin will try to create a cached page for each of those 100 visitors causing a huge load on your server. This feature stops this happening. The cached page is not cleared when a comment is left. It is marked for rebuilding instead. The next visitor within the next 10 seconds will regenerate the cached page while the old page is served to the other 99 visitors. The page is eventually loaded by the first visitor and the cached page updated. See [this post](https://odd.blog/2009/01/23/wp-super-cache-089/) for more.
### Why doesn't the plugin cache requests by search engine bots by default? ###
Those bots usually only visit each page once and if the page is not popular there's no point creating a cache file that will sit idle on your server. However you can allow these visits to be cached by removing the list of bots from "Rejected User Agents" on the Advanced settings page.
### A category page is showing instead of my homepage ###
A tiny proportion of websites will have problems with the following configuration:
1. Uses a static page for the front page.
2. Uses /%category%/%postname%/ permalink structure.
Sometimes a category page is cached as the homepage of the site instead of the static page. I can't [replicate the problem](https://wordpress.org/support/topic/237415/page/2?replies=38) but a simple solution is to use the "Simple" mode. You can also enable "Extra homepage checks" on the Advanced Settings page.
### Why do I get warnings about caching from http://ismyblogworking.com/ ###
"Your blog doesn't support client caching (no 304 response to If-modified-since)."
"Your feed doesn't support caching (no 304 response to If-modified-since)"
Supercache doesn't support 304 header checks in Expert mode but does support it in Simple mode. This is caching done by your browser, not the server. It is a check your browser does to ask the server if an updated version of the current page is available. If not, it doesn't download the old version again. The page is still cached by your server, just not by your visitors' browsers.
Try the Cacheability Engine at http://www.ircache.net/cgi-bin/cacheability.py or https://redbot.org/ for further analysis.
### How should I best use the utm_source tracking tools in Google Analytics with this plugin? ###
That tracking adds a query string to each url linked from various sources like Twitter and feedreaders. Unfortunately it stops pages being supercached. See [Joost's comment here](https://odd.blog/remove-unused-utmsource-urls/#comment-672813) for how to turn it into an anchor tag which can be supercached.
### The plugin complains that wp-content is writable! htdocs is writable! ###
It's not good when the web server can write to these directories but sometimes shared hosting accounts are set up in this way to make administration easier. Use `chmod 755 directory` to fix the permissions or find the permissions section of your ftp client. This [Google search](https://www.google.com/search?sourceid=chrome&ie=UTF-8&q=ftp+fix+directory+permissions+755) will lead you to more information on this topic and there's also [this codex page](https://codex.wordpress.org/Changing_File_Permissions) too. Unfortunately some hosts require that those directories be writable. If that's the case just ignore this warning.
### How do I delete the WP_CACHE define from wp-config.php? ###
Load your desktop ftp client and connect to your site. Navigate to the root (or the directory below it) of your site where you'll find wp-config.php. Download that file and edit it in a text editor. Delete the line `define( 'WP_CACHE', true );` and save the file. Now upload it, overwriting the wp-config.php on your server.
### How do I delete the Super Cache rules from the .htaccess file? ###
Load your desktop ftp client and connect to your site. You may need to enable "Show hidden files" in the preferences of the ftp client. Navigate to the root of your site where you'll find the .htaccess file. Download that file and edit it in a text editor. Delete the lines between "# BEGIN WPSuperCache" and "# END WPSuperCache" and save the file. Now upload it, overwriting the .htaccess file on your server.
### How do I change file permissions? ###
This [page](https://codex.wordpress.org/Changing_File_Permissions) on the WordPress Codex explains everything you need to know about file permissions on your server and various ways of changing them.
### Why do I get load spikes when new posts are made? ###
You may have the "clear all cached files when new posts are made" option set. Clearing those files can take time plus your visitors will now be visiting uncached pages. Are you using Google Analytics campaign tracking with utm_source in the url? Those pages aren't cached. See the question, "How should I best use the utm_source tracking tools in Google Analytics with this plugin" above for how to use them properly.
Cached pages have to be refreshed when posts are made. Perhaps your server just isn't up to the job of serving the amount of traffic you get. Enable the "cache rebuild" feature as that may help.
### How many pages can I cache? ###
The only real limit are limits defined by your server. For example, EXT2 and EXT3 allow a maximum of 31,999 sub directories so if you have a flat permalink structure (like /%POSTNAME%/) and more than 32,000 posts you may run into problems. Likewise, if you run a multisite network and have more than 31,999 sites (blogs) you won't be able to cache all of them. Realistically if you had that many active sites you wouldn't be running on one server.
### I can see that the www version of my site is cached separately. How do I stop that? ###
WordPress should redirect to the canonical URL of your site but if it doesn't, add this to your .htaccess above the Supercache and WordPress rules. Change example.com to your own hostname.
`RewriteCond %{HTTP_HOST} www.example.com$ [NC]`
`RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]`
### How do I serve cached mobile pages to clients on small screens like phones and tablets? ###
Your theme is probably responsive which means it resizes the page to suit whatever device is displaying the page. If it's not responsive, you'll have to use a separate mobile plugin to render a page formatted for those visitors. The following plugins have been tested but YMMV depending on mobile client. You'll have to enable mobile browser support as well on the Advanced settings page.
* [Jetpack's Mobile Theme Module](https://wordpress.org/plugins/jetpack/)
* [WPTouch](https://wordpress.org/plugins/wptouch/)
* [WordPress Mobile Edition](https://wordpress.org/plugins/wordpress-mobile-edition/)
* [WordPress Mobile Pack](https://wordpress.org/plugins/wordpress-mobile-pack/) (can't have "Don't cache pages for known users." enabled)
== Changelog ==
### 3.1.0 - 2026-04-14
- Disable caching for wp_die() error pages
- Harden the plugin in various ways.
- Fix: use fileperms() instead of stat() and fix escaping
- Add WordPress.org Live Preview Blueprint.
- Minimum WordPress version bumped to 6.8.
- Device Detection: use an embedded version instead of the Composer dependency.
- Fix: str_starts_with() null deprecation on PHP 8.1+.
- Fix: handle array type for supercache_last_cached option.
--------
[See previous releases on GitHub.](https://github.com/Automattic/wp-super-cache/releases)

View File

@@ -0,0 +1,35 @@
<?php
class WP_Super_Cache_Rest_Delete_Cache extends WP_REST_Controller {
/**
* Get a collection of items
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$params = $request->get_json_params();
if ( isset( $params['id'] ) && is_numeric( $params['id'] ) ) {
wpsc_delete_post_cache( $params['id'] );
} elseif ( !empty( $params['expired'] ) ) {
global $file_prefix;
wp_cache_clean_expired( $file_prefix );
} elseif ( isset( $params['url'] ) ) {
global $cache_path;
$directory = $cache_path . 'supercache/' . $params[ 'url' ];
wpsc_delete_files( $directory );
prune_super_cache( $directory . '/page', true );
} else {
global $file_prefix;
wp_cache_clean_cache( $file_prefix, !empty( $params['all'] ) );
}
return rest_ensure_response( array( 'Cache Cleared' => true ) );
}
}

View File

@@ -0,0 +1,45 @@
<?php
class WP_Super_Cache_Rest_Get_Cache extends WP_REST_Controller {
/**
* Get a collection of items
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
global $valid_nonce;
$valid_nonce = true;
$_GET[ 'listfiles' ] = 1;
$sizes = wpsc_generate_sizes_array();
$supercachedir = get_supercache_dir();
$list = wpsc_dirsize( $supercachedir, $sizes );
$return_list = array();
foreach( $list as $type => $file_list ) {
foreach ( $file_list as $state => $value ) {
if ( is_array( $value ) ) {
foreach( $value as $filenames ) {
foreach( $filenames as $filename => $t ) {
if ( $type == 'wpcache' ) {
$filename = dirname( $filename );
}
if ( false == isset( $return_list[ $type ][ $state ] ) || false == in_array( $filename, $return_list[ $type ][ $state ] ) )
$return_list[ $type ][ $state ][] = $filename;
}
}
}
}
if ( isset ( $return_list[ $type ] ) ) {
$list[ $type ] = $return_list[ $type ];
}
unset( $return_list[ $type ] );
}
return rest_ensure_response( $list );
}
}

View File

@@ -0,0 +1,16 @@
<?php
class WP_Super_Cache_Rest_Get_Plugins extends WP_REST_Controller {
/**
* GET a list of plugins through the /plugins/ endpoint
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$list = wpsc_get_plugin_list();
return rest_ensure_response( $list );
}
}

View File

@@ -0,0 +1,208 @@
<?php
require_once __DIR__ . '/class.wp-super-cache-settings-map.php';
class WP_Super_Cache_Rest_Get_Settings extends WP_REST_Controller {
/**
* Get the settings.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$settings = array();
global $wp_cache_config_file;
if ( defined( 'WPLOCKDOWN' ) ) {
$config_file = file_get_contents( $wp_cache_config_file );
if ( ! str_contains( $config_file, "defined( 'WPLOCKDOWN' )" ) ) {
wp_cache_replace_line( '^.*WPLOCKDOWN', "if ( ! defined( 'WPLOCKDOWN' ) ) define( 'WPLOCKDOWN', " . $this->get_is_lock_down_enabled() . " );", $wp_cache_config_file );
}
}
if ( function_exists( "opcache_invalidate" ) ) {
@opcache_invalidate( $wp_cache_config_file );
}
include( $wp_cache_config_file );
foreach ( WP_Super_Cache_Settings_Map::$map as $name => $map ) {
if ( isset ( $map['get'] ) ) {
$get_method = $map['get'];
if ( method_exists( $this, $get_method ) ) {
$settings[ $name ] = $this->$get_method();
} elseif ( function_exists( $get_method ) ) {
$settings[ $name ] = $get_method();
}
} else if ( isset ( $map['option'] ) ) {
$settings[ $name ] = get_option( $map['option'] );
} elseif ( isset( $map['global'] ) ) {
if ( false == isset( $GLOBALS[ $map[ 'global' ] ] ) ) {
$settings[ $name ] = false;
} else {
$settings[ $name ] = $GLOBALS[ $map[ 'global' ] ];
}
}
}
return $this->prepare_item_for_response( $settings, $request );
}
/**
* @return string
*/
public function get_ossdl_off_blog_url() {
$url = get_option( 'ossdl_off_blog_url' );
if ( ! $url )
$url = apply_filters( 'ossdl_off_blog_url', untrailingslashit( get_option( 'siteurl' ) ) );
return $url;
}
/**
* @return string
*/
public function get_cache_path_url() {
global $cache_path;
return site_url( str_replace( ABSPATH, '', "{$cache_path}" ) );
}
/**
* @return string
*/
public function get_cache_type() {
global $wp_cache_config_file;
if ( function_exists( "opcache_invalidate" ) ) {
@opcache_invalidate( $wp_cache_config_file );
}
include( $wp_cache_config_file );
if ( $wp_cache_mod_rewrite == 1 ) {
return 'mod_rewrite';
} else {
return 'PHP';
}
}
/**
* Prepare the item for the REST response
*
* @param mixed $item WordPress representation of the item.
* @param WP_REST_Request $request Request object.
* @return mixed
*/
public function prepare_item_for_response( $item, $request ) {
$settings = array();
$integers = array( 'cache_max_time', 'preload_interval' );
$string_arrays = array( 'cache_stats', 'cache_acceptable_files', 'cache_rejected_uri', 'cache_rejected_user_agent',
'cache_direct_pages' );
foreach( $item as $key => $value ) {
if ( is_array( $value ) && false == in_array( $key, $string_arrays ) ) {
array_walk( $value, array( $this, 'make_array_bool' ) );
} elseif ( ( $value === 0 || $value === 1 ) && false == in_array( $key, $integers ) ) {
$value = (bool)$value;
}
$settings[ $key ] = $value;
}
$strings_to_bool = array( 'ossdl_https', 'refresh_current_only_on_comments' );
foreach( $strings_to_bool as $key ) {
if ( isset( $settings[ $key ] ) ) {
$settings[ $key ] = (bool)$settings[ $key ];
}
}
return rest_ensure_response( $settings );
}
/**
* @param mixed $value
* @param string $key
*/
public function make_array_bool( &$value, $key ) {
if ( $value == 0 || $value == 1 ) {
$value = (bool) $value;
}
}
/**
* @return bool
*/
protected function get_is_submit_enabled() {
global $wp_cache_config_file;
return is_writeable_ACLSafe( $wp_cache_config_file );
}
/**
* @return bool
*/
protected function get_is_preload_enabled() {
return false === defined( 'DISABLESUPERCACHEPRELOADING' );
}
/**
* @return false|int
*/
protected function get_next_gc() {
return wp_next_scheduled( 'wp_cache_gc' );
}
/**
* @return int
*/
protected function get_is_preload_active() {
if ( wp_next_scheduled( 'wp_cache_preload_hook' ) || wp_next_scheduled( 'wp_cache_full_preload_hook' ) ) {
return true;
} else {
return false;
}
}
/**
* @return int
*/
protected function get_minimum_preload_interval() {
global $wpdb;
$count = $this->get_post_count();
if ( $count > 1000 ) {
$min_refresh_interval = 720;
} else {
$min_refresh_interval = 30;
}
return $min_refresh_interval;
}
/**
* @return int
*/
protected function get_is_lock_down_enabled() {
if ( defined( 'WPLOCKDOWN' ) ) {
return constant( 'WPLOCKDOWN' ) ? 1 : 0;
}
return 0;
}
/**
* @return int
*/
protected function get_post_count() {
return wpsc_post_count();
}
/**
* @return string
*/
protected function get_default_cache_path() {
return WP_CONTENT_DIR . '/wp-cache/';
}
}

View File

@@ -0,0 +1,18 @@
<?php
class WP_Super_Cache_Rest_Get_Stats extends WP_REST_Controller {
/**
* Get the cache stats for the site.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
global $valid_nonce;
$_GET[ 'listfiles' ] = 1;
$valid_nonce = true;
return rest_ensure_response( wp_cache_regenerate_cache_file_stats() );
}
}

View File

@@ -0,0 +1,114 @@
<?php
class WP_Super_Cache_Rest_Get_Status extends WP_REST_Controller {
/**
* Get any status that might be visible.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$status = array();
include_once( ABSPATH . 'wp-admin/includes/file.php' ); // get_home_path()
include_once( ABSPATH . 'wp-admin/includes/misc.php' ); // extract_from_markers()
$this->add_rewrite_status( $status );
$this->add_cache_disabled_status( $status );
$this->add_compression_status( $status );
$this->add_php_mod_rewrite_status( $status );
$this->add_preload_status( $status );
if ( empty( $status ) ) {
return rest_ensure_response( new stdclass() );
} else {
return rest_ensure_response( $status );
}
}
/**
* @param array $status
*/
protected function add_preload_status( & $status ) {
global $wp_cache_config_file;
include( $wp_cache_config_file );
if ( false == $cache_enabled ) {
$status[ 'preload_disabled_cache_off' ] = true;
}
if ( false == $super_cache_enabled ) {
$status[ 'preload_disabled_supercache_off' ] = true;
}
if ( true === defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
$status[ 'preload_disabled_by_admin' ] = true;
}
}
/**
* @param array $status
*/
protected function add_php_mod_rewrite_status( & $status ) {
global $wp_cache_config_file;
include( $wp_cache_config_file );
if ( $cache_enabled && !$wp_cache_mod_rewrite ) {
$scrules = trim( implode( "\n", extract_from_markers( trailingslashit( get_home_path() ) . '.htaccess', 'WPSuperCache' ) ) );
if ( $scrules != '' ) {
$status[ 'php_mod_rewrite' ] = true;
}
}
}
/**
* @param array $status
*/
protected function add_cache_disabled_status( & $status ) {
global $wp_cache_config_file;
if ( ! is_writeable_ACLSafe( $wp_cache_config_file ) ) {
$status['cache_disabled'] = true;
}
}
/**
* @param array $status
*/
protected function add_compression_status( & $status ) {
if ( defined( 'WPSC_DISABLE_COMPRESSION' ) ) {
$status['compression_disabled_by_admin'] = true;
} elseif ( false == function_exists( 'gzencode' ) ) {
$status['compression_disabled_no_gzencode'] = true;
}
}
/**
* @param array $status
*/
protected function add_rewrite_status( & $status ) {
global $home_path, $wp_cache_config_file;
include( $wp_cache_config_file );
// Return if the rewrite caching is disabled.
if ( ! $cache_enabled || ! $super_cache_enabled || ! $wp_cache_mod_rewrite ) {
return;
}
$scrules = implode( "\n", extract_from_markers( $home_path . '.htaccess', 'WPSuperCache' ) );
extract( wpsc_get_htaccess_info() );
if ( $scrules != $rules ) {
$status[ 'mod_rewrite_rules' ] = true;
}
$got_rewrite = apache_mod_loaded( 'mod_rewrite', true );
if ( $wp_cache_mod_rewrite && false == apply_filters( 'got_rewrite', $got_rewrite ) ) {
$status[ 'mod_rewrite_missing' ] = true;
}
if ( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
$status[ 'htaccess_ro' ] = true;
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
class WP_Super_Cache_Rest_Preload extends WP_REST_Controller {
/**
* Update the cache settings.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$parameters = $request->get_json_params();
if ( defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
wp_cache_debug( 'WP_Super_Cache_Rest_Preload: preload disabled by admin' );
return rest_ensure_response( array( 'error' => 'preload disabled by admin' ) );
}
if ( isset( $parameters[ 'enable' ] ) ) {
if ( $parameters[ 'enable' ] == true ) {
wp_cache_debug( 'WP_Super_Cache_Rest_Preload: enable' );
wpsc_enable_preload();
return( rest_ensure_response( array( 'enabled' => true ) ) );
} else {
wp_cache_debug( 'WP_Super_Cache_Rest_Preload: cancel' );
wpsc_cancel_preload();
return( rest_ensure_response( array( 'enabled' => false ) ) );
}
}
}
}

View File

@@ -0,0 +1,97 @@
<?php
class WP_Super_Cache_Rest_Test_Cache extends WP_REST_Controller {
/**
* Get a collection of items
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
global $cache_path;
$url = trailingslashit( get_bloginfo( 'url' ) );
$response = array( 'status' => 'UNKNOWN' );
$has_errors = false;
$attempts = array( 'prime', 'first', 'second' );
$c = 0;
foreach ( $attempts as $attempt_name ) {
$attempt = array();
$page[ $c ] = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) );
if ( ! is_wp_error( $page[ $c ] ) ) {
$fp = fopen( $cache_path . $c . ".html", "w" );
fwrite( $fp, $page[ $c ][ 'body' ] );
fclose( $fp );
}
if ( is_wp_error( $page[ $c ] ) ) {
$has_errors = true;
$attempt['status'] = false;
$attempt['errors'] = $this->format_error( $page[ $c ] );
} elseif ( $page[ $c ]['response']['code'] != 200 ) {
$has_errors = true;
$attempt['status'] = false;
$attempt['errors'] = array( $page[ $c ]['response']['message'] );
// Don't run this step on prime cache.
} elseif ( 0 !== $c && 0 === preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[ $c ]['body'], $matches2 ) ) {
$has_errors = true;
$attempt['status'] = false;
$attempt['errors'] = array( __( 'Timestamps not found', 'wp-super-cache' ) );
} else {
$attempt['status'] = true;
}
$response[ 'attempts' ][ $attempt_name ] = $attempt;
++$c;
}
if (
false == $has_errors &&
preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[ 1 ][ 'body' ], $matches1 ) &&
preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[ 2 ][ 'body' ], $matches2 ) &&
$matches1[2] == $matches2[2]
) {
$response[ 'status' ] = true;
} else {
$response[ 'status' ] = false;
$response[ 'error' ] = array( __( 'Timestamps do not match', 'wp-super-cache' ) );
}
$error = '';
if ( $response[ 'status' ] == false ) {
if ( isset( $response[ 'error' ] ) ) {
$error = $response[ 'error' ];
} else {
foreach( $response[ 'attempts' ] as $attempt ) {
$error .= $attempt[ 'errors' ] . "\n";
}
}
return new WP_Error( 'test_error', $error, array( 'status' => 500 ) );
}
return rest_ensure_response( $response );
}
/**
* @param WP_Error $error
* @return array
*/
protected function format_error( WP_Error $error ) {
$messages = array();
foreach ( $error->get_error_codes() as $code ) {
foreach ( $error->get_error_messages( $code ) as $err ) {
$messages[] = $err;
}
}
return $messages;
}
}

View File

@@ -0,0 +1,22 @@
<?php
class WP_Super_Cache_Rest_Update_Plugins extends WP_REST_Controller {
/**
* Toggle plugins on/off through the /plugins/ endpoint
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$parameters = $request->get_json_params();
global $valid_nonce;
$valid_nonce = true;
wpsc_update_plugin_list( $parameters );
$list = wpsc_get_plugin_list();
return rest_ensure_response( $list );
}
}

View File

@@ -0,0 +1,652 @@
<?php
require_once __DIR__ . '/class.wp-super-cache-settings-map.php';
class WP_Super_Cache_Rest_Update_Settings extends WP_REST_Controller {
/**
* Update the cache settings.
*
* @param WP_REST_Request $request Full data about the request.
*
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$parameters = $request->get_json_params();
// Override to force locking.
if ( defined( 'WPSC_DISABLE_LOCKING' ) ) {
$parameters['cache_disable_locking'] = 1;
}
// Set the nonce to valid, so that form sets will work later.
global $valid_nonce;
$valid_nonce = true;
$errors = array();
if ( isset( $parameters['easy'] ) ) {
$errors = $this->toggle_easy_caching( $parameters['easy'] );
} elseif ( isset( $parameters[ 'reset' ] ) ) {
$errors = $this->restore_default_settings( $parameters );
} else {
foreach ( $parameters as $name => $value ) {
$has_error = $this->set_value_by_key( $value, $name );
if ( false == is_numeric( $has_error ) && false == is_bool( $has_error ) ) {
$errors[] = $has_error;
}
}
$this->save_time_settings( $parameters );
$this->save_preload_settings();
$this->set_debug_settings( $parameters );
}
if ( ! empty( $errors ) ) {
return rest_ensure_response( $errors );
} else {
$get_settings = new WP_Super_Cache_Rest_Get_Settings();
return $get_settings->callback( $request );
}
}
/**
* Given a key and a value, set the value for that key, based on
* the configuration in the settings map.
*
* @param mixed $value
* @param string $key
*
* @return string|null
*/
protected function set_value_by_key( $value, $key ) {
$settings_map = WP_Super_Cache_Settings_Map::$map;
// If this parameter isn't in the map, then let's ignore it.
if ( ! isset( $settings_map[ $key ] ) ) {
return null;
}
$map = $settings_map[ $key ];
if ( isset( $map['set'] ) ) {
if ( method_exists( $this, $map['set'] ) ) {
$has_error = call_user_func( array( $this, $map['set'] ), $value, $key );
} elseif ( function_exists( $map['set'] ) ) {
$has_error = call_user_func( $map['set'], $value );
}
} elseif ( isset( $map['global'] ) ) {
$set_method = method_exists( $this, 'set_' . $map['global'] ) ?
'set_' . $map['global'] : 'set_global';
if ( $set_method == 'set_global' ) {
$has_error = call_user_func( array( $this, $set_method ), $key, $value );
} else {
$has_error = call_user_func( array( $this, $set_method ), $value );
}
}
if ( ! empty( $has_error ) ) {
return $has_error;
}
return null;
}
/**
* A generic method for setting globals.
*
* The setting must be added to the whitelist in order to be set this way.
*
* @param string $global_name
* @param mixed $value
*/
protected function set_global( $global_name, $value ) {
$whitelist = array(
'wp_super_cache_late_init',
'wp_cache_disable_utf8',
'wp_cache_no_cache_for_get',
'wp_supercache_304',
'wp_cache_mfunc_enabled',
'wp_cache_mobile_enabled',
'wp_cache_front_page_checks',
'wp_supercache_cache_list',
'wp_cache_hello_world',
'wp_cache_clear_on_post_edit',
'cache_rebuild_files',
'wp_cache_refresh_single_only',
'wp_cache_mutex_disabled',
'wpsc_save_headers',
);
if ( ! in_array( $global_name, $whitelist ) ) {
return false;
}
wp_cache_setting( $global_name, (int)$value );
}
/**
* @param mixed $value
*/
protected function set_wp_cache_location( $value ) {
global $cache_path;
if ( $value != '' && ( ! isset( $cache_path ) || $value != $cache_path ) ) {
$dir = realpath( trailingslashit( dirname( $value ) ) );
if ( $dir == false ) {
$dir = WP_CONTENT_DIR . '/cache/';
} else {
$dir = trailingslashit( $dir ) . trailingslashit( wpsc_deep_replace( array(
'..',
'\\'
), basename( $value ) ) );
}
$new_cache_path = $dir;
} else {
$new_cache_path = WP_CONTENT_DIR . '/cache/';
}
if ( $new_cache_path != $cache_path ) {
if ( file_exists( $new_cache_path ) == false ) {
rename( $cache_path, $new_cache_path );
}
$cache_path = $new_cache_path;
wp_cache_setting( 'cache_path', $cache_path );
}
}
/**
* @param mixed $value
*/
protected function set_cache_enabled( $value ) {
if ( $value != 1 ) {
wp_cache_disable();
return;
}
wp_cache_enable();
}
/**
* @param mixed $value
*/
protected function set_lock_down( $value ) {
$_POST[ 'wp_lock_down' ] = (int)$value;
wp_update_lock_down();
}
/**
* @param mixed $value
*/
protected function set_super_cache_enabled( $value ) {
global $wp_cache_mod_rewrite;
if ( is_numeric( $value ) == false ) {
$types = array( 'wpcache' => 0, 'mod_rewrite' => 1, 'PHP' => 2 );
if ( isset( $types[ $value ] ) ) {
$value = $types[ $value ];
} else {
return false;
}
}
if ( $value === 0 ) { // WPCache
wp_super_cache_disable();
} else {
wp_super_cache_enable();
$wp_cache_mod_rewrite = 0; // PHP recommended
if ( $value == 1 ) { // mod_rewrite
$wp_cache_mod_rewrite = 1;
add_mod_rewrite_rules();
} elseif( $value == 2 ) { // PHP
remove_mod_rewrite_rules();
}
wp_cache_setting( 'wp_cache_mod_rewrite', $wp_cache_mod_rewrite );
}
return true;
}
/**
* @param mixed $value
*/
protected function set_wp_cache_not_logged_in( $value ) {
global $wp_cache_not_logged_in, $cache_path;
if ( 0 != $value ) {
if ( 0 == $wp_cache_not_logged_in && function_exists( 'prune_super_cache' ) ) {
prune_super_cache( $cache_path, true );
}
$wp_cache_not_logged_in = (int) $value;
} else {
$wp_cache_not_logged_in = 0;
}
wp_cache_setting( 'wp_cache_not_logged_in', $wp_cache_not_logged_in );
}
/**
* @param mixed $value
*/
protected function set_wp_cache_make_known_anon( $value ) {
global $wp_cache_make_known_anon, $cache_path;
if ( 1 == $value ) {
if ( $wp_cache_make_known_anon == 0 && function_exists( 'prune_super_cache' ) ) {
prune_super_cache( $cache_path, true );
}
$wp_cache_make_known_anon = 1;
} else {
$wp_cache_make_known_anon = 0;
}
wp_cache_setting( 'wp_cache_make_known_anon', $wp_cache_make_known_anon );
}
/**
* @param mixed $value
*/
protected function set_wp_cache_object_cache( $value ) {
global $_wp_using_ext_object_cache, $wp_cache_object_cache, $cache_path;
if ( ! $_wp_using_ext_object_cache ) {
return;
}
if ( $value == 0 ) {
if ( function_exists( 'prune_super_cache' ) ) {
prune_super_cache( $cache_path, true );
}
$wp_cache_object_cache = 1;
} else {
$wp_cache_object_cache = 0;
}
wp_cache_setting( 'wp_cache_object_cache', $wp_cache_object_cache );
}
/**
* @param mixed $value
*
* @return null|string
*/
protected function set_cache_compression( $value ) {
global $cache_compression, $cache_path;
$new_cache_compression = 0;
if ( defined( 'WPSC_DISABLE_COMPRESSION' ) ) {
$cache_compression = 0;
wp_cache_setting( 'cache_compression', $cache_compression );
} else {
if ( 1 == $value ) {
$new_cache_compression = 1;
}
if ( 1 == ini_get( 'zlib.output_compression' ) || "on" == strtolower( ini_get( 'zlib.output_compression' ) ) ) {
return __( "You attempted to enable compression but `zlib.output_compression` is enabled. See #21 in the Troubleshooting section of the readme file.", 'wp-super-cache' );
}
if ( $new_cache_compression != $cache_compression ) {
$cache_compression = $new_cache_compression;
wp_cache_setting( 'cache_compression', $cache_compression );
if ( function_exists( 'prune_super_cache' ) ) {
prune_super_cache( $cache_path, true );
}
delete_option( 'super_cache_meta' );
}
}
return null;
}
/**
* @param array $cache_pages
*/
protected function set_wp_cache_pages( $cache_pages ) {
if ( ! is_array( $cache_pages ) ) {
return;
}
$_POST['wp_edit_rejected_pages'] = 1;
foreach ( $cache_pages as $page => $value ) {
if ( $value ) {
$_POST['wp_cache_pages'][ $page ] = 1;
}
}
wp_cache_update_rejected_pages();
}
/**
* @param mixed $value
*/
protected function set_cache_rejected_uri( $value ) {
$_REQUEST['wp_rejected_uri'] = implode( "\n", $value );
wp_cache_update_rejected_strings();
}
/**
* @param mixed $value
*/
protected function set_cache_acceptable_files( $value ) {
$_REQUEST['wp_accepted_files'] = implode( "\n", $value );
wp_cache_update_accepted_strings();
}
/**
* @param mixed $value
*/
protected function set_cache_rejected_user_agent( $value ) {
$_POST['wp_rejected_user_agent'] = implode( "\n", $value );
wp_cache_update_rejected_ua();
}
/**
* @param mixed $value
*/
protected function set_ossdl_cname( $value ) {
update_option( 'ossdl_cname', $value );
}
/**
* @param mixed $value
*/
protected function set_ossdl_off_blog_url( $value ) {
update_option( 'ossdl_off_blog_url', untrailingslashit( $value ) );
}
/**
* @param mixed $value
*/
protected function set_ossdl_off_cdn_url( $value ) {
update_option( 'ossdl_off_cdn_url', $value );
}
/**
* @param mixed $value
*/
protected function set_ossdl_off_include_dirs( $value ) {
update_option( 'ossdl_off_include_dirs', $value == '' ? 'wp-content,wp-includes' : $value );
}
/**
* @param mixed $value
*/
protected function set_ossdl_off_exclude( $value ) {
update_option( 'ossdl_off_exclude', $value );
}
/**
* @param mixed $value
*/
protected function set_ossdl_https( $value ) {
update_option( 'ossdl_https', $value ? 1 : 0 );
}
/**
* @param mixed $value
*/
protected function set_ossdlcdn( $value ) {
global $wp_cache_config_file;
$ossdlcdn = $value ? 1 : 0;
wp_cache_replace_line( '^ *\$ossdlcdn', "\$ossdlcdn = $ossdlcdn;", $wp_cache_config_file );
}
/**
* @param mixed $value
* @param string $name
*/
protected function set_time_setting( $value, $name ) {
$_POST[ $name ] = $value;
$_POST['_time_setting'] = true;
}
/**
* @param mixed $value
* @param string $name
*/
protected function set_preload_setting( $value, $name ) {
$_POST[ $name ] = $value;
$_POST['_preload_setting'] = true;
}
/**
* Easy caching is a mode that allows the user to press one button and
* enable a sensible default of settings.
*
* @param bool $enabled
*/
protected function toggle_easy_caching( $enabled = true ) {
global $cache_path, $wp_cache_shutdown_gc, $cache_schedule_type;
if ( $enabled ) {
$settings = array(
'wp_cache_mobile_enabled' => 1,
'is_cache_enabled' => 1,
'cache_rebuild_files' => 1,
'cache_compression' => 0,
'wp_cache_not_logged_in' => 2,
);
wp_cache_enable();
if ( ! defined( 'DISABLE_SUPERCACHE' ) ) {
wp_cache_debug( 'DISABLE_SUPERCACHE is not set, super_cache enabled.' );
wp_super_cache_enable();
}
wpsc_set_default_gc();
} else {
wp_cache_disable();
$settings = array( 'is_cache_enabled' => 0 );
wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
wp_clear_scheduled_hook( 'wp_cache_gc' );
wp_clear_scheduled_hook( 'wp_cache_gc_watcher' );
}
foreach ( $settings as $key => $value ) {
$this->set_value_by_key( $value, $key );
}
if ( $cache_path != WP_CONTENT_DIR . '/cache/' ) {
$this->set_value_by_key( $cache_path, 'wp_cache_location' );
}
$advanced_settings = array(
'wp_super_cache_late_init',
'wp_cache_disable_utf8',
'wp_cache_no_cache_for_get',
'wp_supercache_304',
'wp_cache_mfunc_enabled',
'wp_cache_mobile_enabled',
'wp_cache_front_page_checks',
'wp_supercache_cache_list',
'wp_cache_hello_world',
'wp_cache_clear_on_post_edit',
'wp_cache_make_known_anon',
'wp_cache_object_cache',
'wp_cache_refresh_single_only',
'cache_compression',
'wp_cache_mutex_disabled'
);
foreach ( $advanced_settings as $setting ) {
$value = ( isset( $GLOBALS[ $setting ] ) && $GLOBALS[ $setting ] == 1 ) ? 1 : 0;
$this->set_value_by_key( $value, $setting );
}
}
/**
* Runs at the end and saves the time settings.
*/
protected function save_time_settings( $parameters ) {
if ( ! isset( $_POST['_time_setting'] ) || true !== $_POST['_time_setting'] ) {
return;
}
$_POST['action'] = 'expirytime';
$all_time_settings = array(
'cache_max_time',
'cache_schedule_type',
'cache_scheduled_time',
'cache_schedule_interval',
'cache_time_interval',
'cache_gc_email_me'
);
foreach ( $all_time_settings as $time_setting ) {
if ( false == isset( $_POST[ $time_setting ] ) || $GLOBALS[ $time_setting ] == $_POST[ $time_setting ] ) {
$_POST[ $time_setting ] = $GLOBALS[ $time_setting ]; // fill in the potentially missing fields before updating GC settings.
}
}
if ( isset( $parameters['cache_gc_email_me'] ) && $parameters['cache_gc_email_me'] == 0 ) {
unset( $_POST['cache_gc_email_me'] );
}
$_POST[ 'wp_max_time' ] = $_POST[ 'cache_max_time' ];
wp_cache_time_update();
}
/**
* set the cached direct pages list.
*/
protected function set_cache_direct_pages( $list ) {
if ( is_array( $list ) == false ) {
return false;
}
$_POST[ 'direct_pages' ] = $list;
wpsc_update_direct_pages();
}
/**
* add an entry to the cached direct pages list.
*/
protected function new_direct_page( $value ) {
global $cached_direct_pages;
if ( isset( $_POST[ 'direct_pages' ] ) == false ) {
$_POST[ 'direct_pages' ] = $cached_direct_pages;
}
$_POST[ 'new_direct_page' ] = $value;
wpsc_update_direct_pages();
}
/**
* Runs at the end and saves the preload settings.
*/
protected function save_preload_settings() {
if ( ! isset( $_POST['_preload_setting'] ) || true !== $_POST['_preload_setting'] ) {
return;
}
$_POST['action'] = 'preload';
$all_preload_settings = array(
'preload_interval' => 'wp_cache_preload_interval',
'preload_on' => 'wp_cache_preload_on',
'preload_taxonomies' => 'wp_cache_preload_taxonomies',
'preload_email_volume' => 'wp_cache_preload_email_volume',
'preload_posts' => 'wp_cache_preload_posts',
);
foreach ( $all_preload_settings as $key => $original ) {
if ( ! isset( $_POST[ $key ] ) ) {
$_POST[ $original ] = $GLOBALS[ $original ];
} else {
$_POST[ $original ] = $_POST[ $key ];
if ( $key !== 'preload_interval' && ( $_POST[ $key ] === 0 || $_POST[ $key ] === false ) ) {
unset( $_POST[ $original ] );
}
}
}
wpsc_preload_settings();
}
/*
* Delete the plugin configuration file and restore the sample one.
*/
protected function restore_default_settings( $parameters ) {
global $wp_cache_config_file, $wp_cache_config_file_sample;
if ( file_exists( $wp_cache_config_file_sample ) ) {
copy( $wp_cache_config_file_sample, $wp_cache_config_file );
$cache_page_secret = md5( gmdate( 'H:i:s' ) . wp_rand() );
wp_cache_setting( 'cache_page_secret', $cache_page_secret );
if ( function_exists( "opcache_invalidate" ) ) {
@opcache_invalidate( $wp_cache_config_file );
}
}
wpsc_set_default_gc( true );
}
/**
* Update the debug settings.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function set_debug_settings( $parameters ) {
$settings = array (
'wp_super_cache_debug',
'wp_cache_debug_ip',
'wp_super_cache_comments',
'wp_super_cache_front_page_check',
'wp_super_cache_front_page_clear',
'wp_super_cache_front_page_text',
'wp_super_cache_front_page_notification',
'wpsc_delete_log',
);
foreach( $settings as $setting ) {
if ( isset( $parameters[ $setting ] ) ) {
if ( $parameters[ $setting ] != false ) {
$_POST[ $setting ] = $parameters[ $setting ];
}
$_POST[ 'wp_cache_debug' ] = 1;
} else {
if ( ! isset( $GLOBALS[ $setting ] ) ) {
$GLOBALS[ $setting ] = 0;
}
$_POST[ $setting ] = $GLOBALS[ $setting ];
}
}
global $valid_nonce;
$valid_nonce = true;
$settings = wpsc_update_debug_settings();
}
}

View File

@@ -0,0 +1,263 @@
<?php
class WP_Super_Cache_Settings_Map {
/**
* A map describing how settings transform from their external names
* into internal methods and globals.
*
* Key definitions:
*
* - get: A getter method or function that will be called to return the var
* - set: A setter method or function that will be called to set the var
* - option: An option name that will be used to get or set the var
* - global: A name of a global that can GET
*
* @var array
*/
public static $map = array(
'is_submit_enabled' => array(
'get' => 'get_is_submit_enabled',
'set' => '',
),
'is_preload_enabled' => array(
'get' => 'get_is_preload_enabled',
'set' => '',
),
'cache_lock_down' => array(
'get' => 'get_is_lock_down_enabled',
'set' => 'set_lock_down',
),
'cache_next_gc' => array(
'get' => 'get_next_gc',
'set' => '',
),
'cache_gc_email_me' => array(
'global' => 'cache_gc_email_me',
'set' => 'set_time_setting',
),
'cache_path_url' => array(
'get' => 'get_cache_path_url',
),
'cache_type' => array(
'get' => 'get_cache_type',
'set' => 'set_super_cache_enabled',
),
'is_preloading' => array(
'get' => 'wpsc_is_preloading',
'set' => '',
),
'post_count' => array(
'get' => 'get_post_count',
'set' => '',
),
'is_cache_enabled' => array(
'global' => 'cache_enabled',
'set' => 'set_cache_enabled',
),
'is_super_cache_enabled' => array(
'global' => 'super_cache_enabled',
'set' => 'set_super_cache_enabled',
),
'is_mobile_enabled' => array(
'global' => 'wp_cache_mobile_enabled',
),
'is_mfunc_enabled' => array(
'global' => 'wp_cache_mfunc_enabled',
),
'cache_list' => array(
'global' => 'wp_supercache_cache_list',
),
'clear_cache_on_post_edit' => array(
'global' => 'wp_cache_clear_on_post_edit',
),
'wpsc_save_headers' => array(
'global' => 'wpsc_save_headers',
),
'cache_rebuild' => array(
'global' => 'cache_rebuild_files',
),
'dont_cache_logged_in' => array(
'global' => 'wp_cache_not_logged_in',
),
'make_known_anon' => array(
'global' => 'wp_cache_make_known_anon',
),
'cache_path' => array(
'global' => 'cache_path',
'set' => 'set_wp_cache_location',
),
'default_cache_path' => array(
'get' => 'get_default_cache_path',
),
'use_object_cache' => array(
'global' => 'wp_cache_object_cache',
),
'refresh_current_only_on_comments' => array(
'global' => 'wp_cache_refresh_single_only',
),
'cache_compression' => array(
'global' => 'cache_compression',
'set' => 'set_cache_compression',
),
'cache_mod_rewrite' => array(
'global' => 'wp_cache_mod_rewrite',
),
'use_304_headers' => array(
'global' => 'wp_supercache_304',
),
'cache_late_init' => array(
'global' => 'wp_super_cache_late_init',
),
'front_page_checks' => array(
'global' => 'wp_cache_front_page_checks',
),
'cache_page_secret' => array(
'global' => 'cache_page_secret',
),
'disable_utf8' => array(
'global' => 'wp_cache_disable_utf8',
),
'no_cache_for_get' => array(
'global' => 'wp_cache_no_cache_for_get',
),
'cache_schedule_type' => array(
'global' => 'cache_schedule_type',
'set' => 'set_time_setting',
),
'cache_scheduled_time' => array(
'global' => 'cache_scheduled_time',
'set' => 'set_time_setting',
),
'cache_max_time' => array(
'global' => 'cache_max_time',
'set' => 'set_time_setting',
),
'cache_time_interval' => array(
'global' => 'cache_time_interval',
'set' => 'set_time_setting',
),
'shutdown_garbage_collector' => array(
'global' => 'wp_cache_shutdown_gc',
),
'pages' => array(
'global' => 'wp_cache_pages',
),
'minimum_preload_interval' => array(
'get' => 'get_minimum_preload_interval',
),
'preload_interval' => array(
'global' => 'wp_cache_preload_interval',
'set' => 'set_preload_setting',
),
'preload_posts' => array(
'global' => 'wp_cache_preload_posts',
'set' => 'set_preload_setting',
),
'preload_on' => array(
'global' => 'wp_cache_preload_on',
'set' => 'set_preload_setting',
),
'preload_active' => array(
'get' => 'get_is_preload_active',
),
'preload_taxonomies' => array(
'global' => 'wp_cache_preload_taxonomies',
'set' => 'set_preload_setting',
),
'preload_email_me' => array(
'global' => 'wp_cache_preload_email_me',
'set' => 'set_preload_setting',
),
'preload_email_volume' => array(
'global' => 'wp_cache_preload_email_volume',
'set' => 'set_preload_setting',
),
'cache_mobile_browsers' => array(
'global' => 'wp_cache_mobile_browsers',
),
'cache_mobile_prefixes' => array(
'global' => 'wp_cache_mobile_prefixes',
),
'cache_disable_locking' => array(
'global' => 'wp_cache_mutex_disabled',
),
'cache_hello_world' => array(
'global' => 'wp_cache_hello_world',
),
'cache_schedule_interval' => array(
'global' => 'cache_schedule_interval',
'set' => 'set_time_setting',
),
'cache_acceptable_files' => array(
'global' => 'cache_acceptable_files',
),
'cache_rejected_uri' => array(
'global' => 'cache_rejected_uri',
),
'cache_rejected_user_agent' => array(
'global' => 'cache_rejected_user_agent',
),
'cache_direct_pages' => array(
'global' => 'cached_direct_pages',
'set' => 'set_cache_direct_pages',
),
'new_direct_page' => array(
'set' => 'new_direct_page',
),
'ossdl_cname' => array(
'option' => 'ossdl_cname',
'set' => 'set_ossdl_cname',
),
'ossdl_https' => array(
'option' => 'ossdl_https',
'set' => 'set_ossdl_https',
),
'ossdl_off_cdn_url' => array(
'option' => 'ossdl_off_cdn_url',
'set' => 'set_ossdl_off_cdn_url',
),
'ossdl_off_blog_url' => array(
'option' => 'ossdl_off_blog_url',
'set' => 'set_ossdl_off_blog_url',
),
'ossdl_off_exclude' => array(
'option' => 'ossdl_off_exclude',
'set' => 'set_ossdl_off_exclude',
),
'ossdl_off_include_dirs' => array(
'option' => 'ossdl_off_include_dirs',
'set' => 'set_ossdl_off_include_dirs',
),
'ossdlcdn' => array(
'global' => 'ossdlcdn',
'set' => 'set_ossdlcdn',
),
'wp_super_cache_debug' => array(
'global' => 'wp_super_cache_debug',
),
'wp_cache_debug_username' => array(
'get' => 'wpsc_debug_username',
),
'wp_cache_debug_log' => array(
'global' => 'wp_cache_debug_log',
),
'wp_cache_debug_ip' => array(
'global' => 'wp_cache_debug_ip',
),
'wp_super_cache_comments' => array(
'global' => 'wp_super_cache_comments',
),
'wp_super_cache_front_page_check' => array(
'global' => 'wp_super_cache_front_page_check',
),
'wp_super_cache_front_page_clear' => array(
'global' => 'wp_super_cache_front_page_clear',
),
'wp_super_cache_front_page_text' => array(
'global' => 'wp_super_cache_front_page_text',
),
'wp_super_cache_front_page_notification' => array(
'global' => 'wp_super_cache_front_page_notification',
),
);
}

View File

@@ -0,0 +1,166 @@
<?php
require_once( __DIR__ . '/class.wp-super-cache-rest-get-settings.php' );
require_once( __DIR__ . '/class.wp-super-cache-rest-update-settings.php' );
require_once( __DIR__ . '/class.wp-super-cache-rest-get-stats.php' );
require_once( __DIR__ . '/class.wp-super-cache-rest-get-cache.php' );
require_once( __DIR__ . '/class.wp-super-cache-rest-get-status.php' );
require_once( __DIR__ . '/class.wp-super-cache-rest-test-cache.php' );
require_once( __DIR__ . '/class.wp-super-cache-rest-delete-cache.php' );
require_once( __DIR__ . '/class.wp-super-cache-rest-preload.php' );
require_once( __DIR__ . '/class.wp-super-cache-rest-get-plugins.php' );
require_once( __DIR__. '/class.wp-super-cache-rest-update-plugins.php' );
class WP_Super_Cache_Router {
/**
* Register the routes for the objects of the controller.
*
* GET /wp-super-cache/v1/settings
* POST /wp-super-cache/v1/settings
* GET /wp-super-cache/v1/stats
* GET /wp-super-cache/v1/cache
* POST /wp-super-cache/v1/cache
*/
public static function register_routes() {
$version = '1';
$namespace = 'wp-super-cache/v' . $version;
$get_settings = new WP_Super_Cache_Rest_Get_Settings();
$update_settings = new WP_Super_Cache_Rest_Update_Settings();
$get_stats = new WP_Super_Cache_Rest_Get_Stats();
$get_cache = new WP_Super_Cache_Rest_Get_Cache();
$test_cache = new WP_Super_Cache_Rest_Test_Cache();
$delete_cache = new WP_Super_Cache_Rest_Delete_Cache();
$preload_cache = new WP_Super_Cache_Rest_Preload();
$get_status = new WP_Super_Cache_Rest_Get_Status();
$get_plugins = new WP_Super_Cache_Rest_Get_Plugins();
$update_plugins = new WP_Super_Cache_Rest_Update_Plugins();
register_rest_route( $namespace, '/settings', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $get_settings, 'callback' ),
'permission_callback' => __CLASS__ . '::get_item_permissions_check',
'args' => array(),
),
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $update_settings, 'callback' ),
'permission_callback' => __CLASS__ . '::update_item_permissions_check',
'args' => array(),
),
) );
register_rest_route( $namespace, '/status', array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $get_status, 'callback' ),
'permission_callback' => __CLASS__ . '::get_item_permissions_check',
) );
register_rest_route( $namespace, '/stats', array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $get_stats, 'callback' ),
'permission_callback' => __CLASS__ . '::get_item_permissions_check',
) );
register_rest_route( $namespace, '/cache', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $get_cache, 'callback' ),
'permission_callback' => __CLASS__ . '::get_item_permissions_check',
'args' => array(),
),
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $delete_cache, 'callback' ),
'permission_callback' => __CLASS__ . '::delete_item_permissions_check',
'args' => array(),
),
) );
register_rest_route( $namespace, '/preload', array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $preload_cache, 'callback' ),
'permission_callback' => __CLASS__ . '::update_item_permissions_check',
) );
register_rest_route( $namespace, '/cache/test', array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $test_cache, 'callback' ),
'permission_callback' => __CLASS__ . '::create_item_permissions_check',
) );
register_rest_route( $namespace, '/plugins', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $get_plugins, 'callback' ),
'permission_callback' => __CLASS__ . '::get_item_permissions_check',
'args' => array(),
),
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $update_plugins, 'callback' ),
'permission_callback' => __CLASS__ . '::update_item_permissions_check',
'args' => array(),
),
) );
}
/**
* Check if a given request has access to get items
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
*/
public static function get_items_permissions_check( $request ) {
return wpsupercache_site_admin();
}
/**
* Check if a given request has access to get a specific item
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
*/
public static function get_item_permissions_check( $request ) {
return self::get_items_permissions_check( $request );
}
/**
* Check if a given request has access to create items
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
*/
public static function create_item_permissions_check( $request ) {
return self::get_items_permissions_check( $request );
}
/**
* Check if a given request has access to update a specific item
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
*/
public static function update_item_permissions_check( $request ) {
return self::create_item_permissions_check( $request );
}
/**
* Check if a given request has access to update a specific item
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
*/
public static function delete_item_permissions_check( $request ) {
return self::update_item_permissions_check( $request );
}
}
function wpsc_load_rest_api() {
$wpsupercache_route = new WP_Super_Cache_Router();
$wpsupercache_route->register_routes();
};
add_action( 'rest_api_init', 'wpsc_load_rest_api' );

View File

@@ -0,0 +1,80 @@
<?php
/**
* Device detection for Jetpack.
*
* Since WPSC doesn't use an autoloader or composer, this is a simplified version of the package
* as of November 11, 2025.
*
* @package automattic/jetpack-device-detection
*/
namespace Automattic\WPSC;
require_once __DIR__ . '/functions.php';
require_once __DIR__ . '/class-user-agent-info.php';
use Automattic\WPSC\Device_Detection\User_Agent_Info;
use function Automattic\WPSC\Device_Detection\wp_unslash;
/**
* Class Automattic\WPSC\Device_Detection
*
* Determine if the current User Agent matches the passed $kind.
*
* Note: str_contains() and other PHP8+ functions that have a polyfill in core are not used here,
* as wp-includes/compat.php may not be loaded yet.
*/
class Device_Detection {
/**
* Detects phone devices.
*
* @return bool
*/
public static function is_phone() {
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
$ua_info = new User_Agent_Info( $_SERVER['HTTP_USER_AGENT'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Handled in User_Agent_Info
$agent = strtolower( filter_var( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) );
if ( strpos( $agent, 'ipad' ) ) {
return false;
}
// Remove Samsung Galaxy tablets (SCH-I800) from being mobile devices.
if ( strpos( $agent, 'sch-i800' ) ) {
return false;
}
if ( $ua_info->is_android_tablet() && false === $ua_info->is_kindle_touch() ) {
return false;
}
if ( $ua_info->is_blackberry_tablet() ) {
return false;
}
// checks for iPhoneTier devices & RichCSS devices.
if ( $ua_info->isTierIphone() || $ua_info->isTierRichCSS() ) {
return true;
}
$dumb_agents = $ua_info->dumb_agents;
foreach ( $dumb_agents as $dumb_agent ) {
if ( false !== strpos( $agent, $dumb_agent ) ) {
return true;
}
}
if ( isset( $_SERVER['HTTP_X_WAP_PROFILE'] ) ) {
return true;
} elseif ( isset( $_SERVER['HTTP_ACCEPT'] ) && ( preg_match( '/wap\.|\.wap/i', $_SERVER['HTTP_ACCEPT'] ) || false !== strpos( strtolower( $_SERVER['HTTP_ACCEPT'] ), 'application/vnd.wap.xhtml+xml' ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- This is doing the validating.
return true;
}
return false;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,39 @@
<?php
/**
* Utility functions for device detection.
*
* Since WPSC doesn't use an autoloader or composer, this is a simple copy/paste of the package
* as of November 11, 2025.
*
* @package automattic/jetpack-device-detection
*/
namespace Automattic\WPSC\Device_Detection;
// Check if the function is already defined, in case someone bypassed the autoloader or something
// to get the two classes from different copies of the package.
if ( ! function_exists( __NAMESPACE__ . '\\wp_unslash' ) ) {
/**
* A wrapper for WordPress's `wp_unslash()`.
*
* Even though PHP itself dropped the option to add slashes to superglobals a decade ago,
* WordPress still does it through some misguided extreme backwards compatibility. 🙄
*
* If WordPress's function exists, assume it needs to be called.
* Else if on WordPress.com, do a simplified version because we're running really early.
* Else, assume it's not needed.
*
* @param string $value String of data to unslash.
* @return string Possibly unslashed $value.
*/
function wp_unslash( $value ) {
if ( function_exists( '\\wp_unslash' ) ) {
return \wp_unslash( $value );
} elseif ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
return stripslashes( $value );
} else {
return $value;
}
}
}

View File

@@ -0,0 +1,190 @@
/* TODO: Migrate to SCSS after adding build step to WPSC */
/* TODO: Migrate CSS from wp-cache.php */
#wpwrap {
/* Declare JP CSS variables */
/* TODO: Integrate root-variables.scss from base-styles package */
--jp-black: #000;
--jp-gray: #dcdcde;
--jp-white-off: #f9f9f6;
--jp-white: #fff;
--font-headline-medium: 48px;
--font-headline-small: 36px;
--font-title-medium: 24px;
--font-body: 16px;
--font-body-small: 14px;
/* Declare commonly used variables */
--wpsc-header-font:
Corbel,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen-Sans,
Ubuntu,
Cantarell,
"Helvetica Neue",
sans-serif;
--max-container-width: 1128px;
background-color: var(--jp-white);
}
#wpbody-content {
padding-bottom: 0;
}
#wpsc-dashboard {
/* Remove default wp-admin spacing */
margin-left: -20px;
padding-top: 20px;
}
#wpsc-dashboard,
#wpsc-dashboard p,
#wpsc-dashboard .form-table,
#wpsc-dashboard .form-table td,
#wpsc-dashboard .form-table th,
#wpsc-dashboard .form-table td p {
font-size: var(--font-body);
}
#wpsc-callout ul,
#wpsc-callout ol,
#wpsc-callout > p:last-child {
font-size: var(--font-body-small);
}
#wpsc-dashboard > .header,
#wpsc-dashboard > .footer,
#wpsc-dashboard .wpsc-body-content,
#wpsc-dashboard .wpsc-nav {
max-width: var(--max-container-width);
margin-left: auto;
margin-right: auto;
width: 100%;
}
.header {
--icon-height: 48px;
display: flex;
margin-top: 1em;
}
.header .wpsc-icon {
width: var(--icon-height);
height: var(--icon-height);
border-radius: 7px;
}
.header .wpsc-name {
color: var(--jp-black);
font-family: var(--wpsc-header-font);
font-size: var(--font-headline-small);
letter-spacing: -0.015em;
line-height: var(--icon-height);
margin-left: 0.25em;
}
.wpsc-nav {
display: flex;
width: 100%;
overflow: hidden;
}
.wpsc-nav-tab {
width: auto;
flex: none;
border-bottom: 2px solid transparent;
border-top: none;
text-align: center;
margin: 0 16px;
}
.wpsc-nav-tab:hover,
.wpsc-nav-tab:focus,
.wpsc-nav-tab.wpsc-nav-tab-selected {
box-shadow: inset 0 -1px 0 rgb(0, 0, 0);
}
.wpsc-nav-tab a {
display: flex;
align-items: center;
box-sizing: border-box;
padding: 15px;
width: 100%;
font-size: 1rem;
font-weight: 400;
line-height: 24px;
color: var(--jp-black);
cursor: pointer;
text-decoration: none;
}
.wpsc-nav-container {
background: var(--jp-white);
}
.wpsc-body {
background: var(--jp-white-off);
}
.wpsc-card {
background: var(--jp-white);
border-radius: 4px;
flex-wrap: wrap;
font-size: var(--font-body);
line-height: 1.3;
margin-bottom: 2em;
margin-right: 1em;
max-width: 100%;
padding: 1rem 1.5rem;
position: relative;
}
.footer {
--icon-height: 16px;
display: flex;
margin-top: 1em;
margin-bottom: 1em;
}
.footer .wp-super-cache-version .wpsc-icon {
border-radius: 2px;
height: var(--icon-height);
width: var(--icon-height);
vertical-align: middle;
}
.footer .wp-super-cache-version .wpsc-name {
font-family: var(--wpsc-header-font);
letter-spacing: -0.015em;
margin-left: 0.25em;
line-height: var(--icon-height);
vertical-align: middle;
}
.footer .automattic-airline {
flex: 1;
height: 45px;
text-align: right;
}
.footer .automattic-airline img {
width: 190px;
height: auto;
}
#wpsc-notice-boost-migrate {
margin-top: 10px;
a.button.button-primary {
background-color: var(--jp-black);
color: var(--jp-white);
}
}

View File

@@ -0,0 +1,51 @@
<?php
global $WPSC_HTTP_HOST, $cache_enabled, $cache_path, $blogcacheid, $blog_cache_dir;
// we need to backup HTTP_HOST early in the PHP process, and if running in command line set it to something useful.
if ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
$WPSC_HTTP_HOST = function_exists( 'mb_strtolower' ) ? mb_strtolower( $_SERVER['HTTP_HOST'] ) : strtolower( $_SERVER['HTTP_HOST'] );
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
$WPSC_HTTP_HOST = htmlentities( $WPSC_HTTP_HOST, ENT_COMPAT );
} elseif ( PHP_SAPI === 'cli' && function_exists( 'get_option' ) ) {
$WPSC_HTTP_HOST = (string) parse_url( get_option( 'home' ), PHP_URL_HOST );
} else {
$cache_enabled = false;
$WPSC_HTTP_HOST = '';
}
// We want to be able to identify each blog in a WordPress MU install
$blogcacheid = '';
$blog_cache_dir = $cache_path;
// we might be able to simplify this. I run a multisite and the blogs directory isn't used any more.
// $blogcacheid is set to the domain or prefix path of your site, and all files are put in $cache_path/supercache/$blogcacheid/[REQUEST_URI path]/
if ( is_multisite() ) {
global $current_blog;
if ( is_object( $current_blog ) && function_exists( 'is_subdomain_install' ) ) {
$blogcacheid = is_subdomain_install() ? $current_blog->domain : trim( $current_blog->path, '/' );
} elseif ( ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) || ( defined( 'VHOST' ) && VHOST === 'yes' ) ) {
$blogcacheid = $WPSC_HTTP_HOST;
} else {
$request_uri = str_replace( '..', '', preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI'] ) );
$request_uri = str_replace( '//', '/', $request_uri );
$wpsc_path_segs = array_filter( explode( '/', trim( $request_uri, '/' ) ) );
$wpsc_base_count = defined( 'PATH_CURRENT_SITE' ) ? count( array_filter( explode( '/', trim( PATH_CURRENT_SITE, '/' ) ) ) ) : 0;
if ( ! str_ends_with( $request_uri, '/' ) ) {
$wpsc_path_segs = array_slice( $wpsc_path_segs, 0, -1 );
}
if ( count( $wpsc_path_segs ) > $wpsc_base_count &&
( ! defined( 'PATH_CURRENT_SITE' ) || str_starts_with( $request_uri, PATH_CURRENT_SITE ) )
) {
$blogcacheid = $wpsc_path_segs[ $wpsc_base_count ];
}
}
// If blogcacheid is empty then set it to main blog.
if ( empty( $blogcacheid ) ) {
$blogcacheid = 'blog';
}
$blog_cache_dir = str_replace( '//', '/', $cache_path . 'blogs/' . $blogcacheid . '/' );
}

View File

@@ -0,0 +1,105 @@
<?php
/*
WP-Cache Config Sample File
See wp-cache.php for author details.
*/
if ( ! defined('WPCACHEHOME') )
define( 'WPCACHEHOME', WP_PLUGIN_DIR . '/wp-super-cache/' );
$cache_compression = 0; // Super cache compression
$cache_enabled = false;
$super_cache_enabled = true;
$cache_max_time = 3600; //in seconds
//$use_flock = true; // Set it true or false if you know what to use
$cache_path = WP_CONTENT_DIR . '/cache/';
$file_prefix = 'wp-cache-';
$ossdlcdn = 0;
// Array of files that have 'wp-' but should still be cached
$cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );
$cache_rejected_uri = array('wp-.*\\.php', 'index\\.php');
$cache_rejected_user_agent = array();
$cache_rebuild_files = 1;
// Disable the file locking system.
// If you are experiencing problems with clearing or creating cache files
// uncommenting this may help.
$wp_cache_mutex_disabled = 1;
// Just modify it if you have conflicts with semaphores
$sem_id = 5419;
if ( '/' != substr($cache_path, -1)) {
$cache_path .= '/';
}
$wp_cache_mobile = 0;
$wp_cache_mobile_whitelist = 'Stand Alone/QNws';
$wp_cache_mobile_browsers = 'Android, 2.0 MMP, 240x320, AvantGo, BlackBerry, Blazer, Cellphone, Danger, DoCoMo, Elaine/3.0, EudoraWeb, hiptop, IEMobile, iPhone, iPod, KYOCERA/WX310K, LG/U990, MIDP-2.0, MMEF20, MOT-V, NetFront, Newt, Nintendo Wii, Nitro, Nokia, Opera Mini, Palm, Playstation Portable, portalmmm, Proxinet, ProxiNet, SHARP-TQ-GX10, Small, SonyEricsson, Symbian OS, SymbianOS, TS21i-10, UP.Browser, UP.Link, Windows CE, WinWAP';
// change to relocate the supercache plugins directory
$wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
// set to 1 to do garbage collection during normal process shutdown instead of wp-cron
$wp_cache_shutdown_gc = 0;
$wp_super_cache_late_init = 0;
// uncomment the next line to enable advanced debugging features
$wp_super_cache_advanced_debug = 0;
$wp_super_cache_front_page_text = '';
$wp_super_cache_front_page_clear = 0;
$wp_super_cache_front_page_check = 0;
$wp_super_cache_front_page_notification = '0';
$wp_cache_anon_only = 0;
$wp_supercache_cache_list = 0;
$wp_cache_debug_to_file = 0;
$wp_super_cache_debug = 0;
$wp_cache_debug_level = 5;
$wp_cache_debug_ip = '';
$wp_cache_debug_log = '';
$wp_cache_debug_email = '';
$wp_cache_pages[ "search" ] = 0;
$wp_cache_pages[ "feed" ] = 0;
$wp_cache_pages[ "category" ] = 0;
$wp_cache_pages[ "home" ] = 0;
$wp_cache_pages[ "frontpage" ] = 0;
$wp_cache_pages[ "tag" ] = 0;
$wp_cache_pages[ "archives" ] = 0;
$wp_cache_pages[ "pages" ] = 0;
$wp_cache_pages[ "single" ] = 0;
$wp_cache_pages[ "author" ] = 0;
$wp_cache_hide_donation = 0;
$wp_cache_not_logged_in = 0;
$wp_cache_clear_on_post_edit = 0;
$wp_cache_hello_world = 0;
$wp_cache_mobile_enabled = 0;
$wp_cache_cron_check = 0;
$wp_cache_mfunc_enabled = 0;
$wp_cache_make_known_anon = 0;
$wp_cache_refresh_single_only = 0;
$wp_cache_mod_rewrite = 0;
$wp_supercache_304 = 0;
$wp_cache_front_page_checks = 0;
$wp_cache_disable_utf8 = 0;
$wp_cache_no_cache_for_get = 0;
$cache_scheduled_time = "00:00";
$wp_cache_preload_interval = 600;
$cache_schedule_type = 'interval';
$wp_cache_preload_posts = 0;
$wp_cache_preload_on = 0;
$wp_cache_preload_taxonomies = 0;
$wp_cache_preload_email_me = 0;
$wp_cache_preload_email_volume = 'none';
$wp_cache_mobile_prefixes = '';
$cached_direct_pages = array();
$wpsc_served_header = false;
$cache_gc_email_me = 0;
$wpsc_save_headers = 0;
$cache_schedule_interval = 'daily';
$wp_super_cache_comments = 1;
$wpsc_version = 169;
?>

View File

@@ -0,0 +1,195 @@
<?php
if ( ! function_exists( 'wp_cache_phase2' ) ) {
require_once __DIR__. '/wp-cache-phase2.php';
}
// error_reporting(E_ERROR | E_PARSE); // uncomment to debug this file!
// directory where the configuration file lives.
if ( !defined( 'WPCACHECONFIGPATH' ) ) {
define( 'WPCACHECONFIGPATH', WP_CONTENT_DIR );
}
if ( ! @include WPCACHECONFIGPATH . '/wp-cache-config.php' ) {
return false;
}
// points at the wp-super-cache plugin directory because sometimes file paths are weird. Edge cases,
if ( ! defined( 'WPCACHEHOME' ) ) {
define( 'WPCACHEHOME', __DIR__ . '/' );
}
if ( defined( 'DISABLE_SUPERCACHE' ) ) {
wp_cache_debug( 'DISABLE_SUPERCACHE set, super_cache disabled.' );
$super_cache_enabled = 0;
}
require WPCACHEHOME . 'wp-cache-base.php';
if ( '/' === $cache_path || empty( $cache_path ) ) {
define( 'WPSCSHUTDOWNMESSAGE', 'WARNING! Caching disabled. Configuration corrupted. Reset configuration on Advanced Settings page.' );
add_action( 'wp_footer', 'wpsc_shutdown_message' );
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', 1 );
}
return;
}
// $blog_cache_dir is used all over the code alongside the supercache directory but at least with multisite installs it appears to do nothing.
// I started putting everything in cache/supercache/blogname/path/ a long time ago but never got around to removing the code that used the blogs directory.
if ( $blogcacheid != '' ) {
$blog_cache_dir = str_replace( '//', '/', $cache_path . 'blogs/' . $blogcacheid . '/' );
} else {
$blog_cache_dir = $cache_path;
}
$wp_cache_phase1_loaded = true;
// part of the coarse file locking which should really be removed, but there are edge cases where semaphores didn't work in the past.
$mutex_filename = 'wp_cache_mutex.lock';
$new_cache = false;
// write a plugin to extend wp-super-cache!
if ( ! isset( $wp_cache_plugins_dir ) ) {
$wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
}
// from the secret shown on the Advanced settings page.
if ( isset( $_GET['donotcachepage'] ) && isset( $cache_page_secret ) && $_GET['donotcachepage'] == $cache_page_secret ) {
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', 1 );
}
}
// Load wp-super-cache plugins
$plugins = glob( $wp_cache_plugins_dir . '/*.php' );
if ( is_array( $plugins ) ) {
foreach ( $plugins as $plugin ) {
if ( is_file( $plugin ) ) {
require_once $plugin;
}
}
}
// Load plugins from an array of php scripts. This needs to be documented.
if ( isset( $wpsc_plugins ) && is_array( $wpsc_plugins ) ) {
foreach( $wpsc_plugins as $plugin_file ) {
if ( file_exists( ABSPATH . $plugin_file ) ) {
include_once( ABSPATH . $plugin_file );
}
}
}
// also look for plugins in wp-content/wp-super-cache-plugins/
if (
file_exists( WPCACHEHOME . '../wp-super-cache-plugins/' ) &&
is_dir( WPCACHEHOME . '../wp-super-cache-plugins/' )
) {
$plugins = glob( WPCACHEHOME . '../wp-super-cache-plugins/*.php' );
if ( is_array( $plugins ) ) {
foreach ( $plugins as $plugin ) {
if ( is_file( $plugin ) ) {
require_once $plugin;
}
}
}
}
// for timing purposes for the html comments
$wp_start_time = microtime();
if ( isset( $_SERVER['REQUEST_URI'] ) ) { // Cache this in case any plugin modifies it and filter out tracking parameters.
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- none available before WordPress is loaded. Sanitized in wp_cache_postload().
$wp_cache_request_uri = wpsc_remove_tracking_params_from_uri( $_SERVER['REQUEST_URI'] ); // phpcs:ignore
// $wp_cache_request_uri is expected to be a string. If running from wp-cli it will be null.
if ( $wp_cache_request_uri === null ) {
$wp_cache_request_uri = '';
}
} else {
$wp_cache_request_uri = '';
}
// don't cache in wp-admin
if ( wpsc_is_backend() ) {
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', 1 );
}
return true;
}
// if a cookie is found that we don't like then don't serve/cache the page
if ( wpsc_is_rejected_cookie() ) {
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', 1 );
}
wp_cache_debug( 'Caching disabled because rejected cookie found.' );
return true;
}
if ( wpsc_is_caching_user_disabled() ) {
wp_cache_debug( 'Caching disabled for logged in users on settings page.' );
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', 1 );
}
return true;
}
// make logged in users anonymous so they are shown logged out pages.
if ( isset( $wp_cache_make_known_anon ) && $wp_cache_make_known_anon ) {
wp_supercache_cache_for_admins();
}
// an init action wpsc plugins can hook on to.
do_cacheaction( 'cache_init' );
if ( ! $cache_enabled ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- set by configuration or cache_init action
return true;
}
// don't cache or serve cached files for various URLs, including the Customizer.
if ( isset( $_SERVER['REQUEST_METHOD'] ) && in_array( $_SERVER['REQUEST_METHOD'], array( 'POST', 'PUT', 'DELETE' ), true ) ) {
wp_cache_debug( 'Caching disabled for non GET request.' );
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', 1 );
}
return true;
}
if ( isset( $_GET['customize_changeset_uuid'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
wp_cache_debug( 'Caching disabled for customizer.' );
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', 1 );
}
return true;
}
$file_expired = false;
$cache_filename = '';
$meta_file = '';
$wp_cache_gzip_encoding = '';
$gzipped = 0;
$gzsize = 0;
if ( $cache_compression ) {
$wp_cache_gzip_encoding = gzip_accepted(); // false or 'gzip'
}
// The wp_cache_check_mobile function appends "-mobile" to the cache filename if it detects a mobile visitor.
add_cacheaction( 'supercache_filename_str', 'wp_cache_check_mobile' );
if ( function_exists( 'add_filter' ) ) { // loaded since WordPress 4.6
add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );
}
if ( defined( 'DOING_CRON' ) ) {
// this is required for scheduled CRON jobs.
extract( wp_super_cache_init() ); // $key, $cache_filename, $meta_file, $cache_file, $meta_pathname
return true;
}
// late init delays serving a cache file until after the WordPress init actin has fired and (most of?) WordPress has loaded.
// If it's not enabled then serve a cache file now if possible.
if ( ! isset( $wp_super_cache_late_init ) || 0 === $wp_super_cache_late_init ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- the wp-cache-config.php include attempt may define this var
wp_cache_serve_cache_file();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff