350555a8 by Jeff Balicki

cache

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent d83d5b28
Showing 105 changed files with 3463 additions and 0 deletions
# Not loaded by default eslint, but we use tools/js-tools/load-eslint-ignore.js in .eslintrc to pull it in.
# @todo: Files below ignored as part of Automattic/jetpack/pull/25449
# They can be removed here as lint errors are addressed.
/inc/delete-cache-button.js
/inc/preload-notification.js
module.exports = {
extends: [ require.resolve( 'jetpack-js-tools/eslintrc/base' ) ],
rules: {
// Enforce use of the correct textdomain.
'@wordpress/i18n-text-domain': [
'error',
{
allowedTextDomain: 'wp-super-cache',
},
],
},
};
# super-cache
A very fast caching engine for WordPress that produces static html files.
## How to install super-cache
### Installation From Git Repo
## Contribute
## Get Help
Support is handled via the .org support forums.
## Security
Need to report a security vulnerability? Go to [https://automattic.com/security/](https://automattic.com/security/) or directly to our security bug bounty site [https://hackerone.com/automattic](https://hackerone.com/automattic).
## License
super-cache is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt)
# 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 has continued support. If a critical vulnerability is found in the current version of Jetpack, we may opt to backport any patches to previous versions.
## Reporting a Vulnerability
[Jetpack](https://jetpack.com/) is an open-source plugin for WordPress. Our HackerOne program covers the plugin software, as well as a variety of related projects and infrastructure.
**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.
<?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' );
}
<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>
\ No newline at end of file
<svg class="jitm-jp-logo" viewBox="0 0 176 32" xmlns="http://www.w3.org/2000/svg">
<path d="M16 32C24.8365 32 32 24.8362 32 15.9994C32 7.16259 24.8365 0 16 0C7.16351 0 0 7.16377 0 16.0006C0 24.8374 7.16351 32 16 32Z" fill="#069E08"/>
<path d="m16.794 13.313v15.511l8-15.511h-8z" fill="#fff"/>
<path d="m15.176 18.657v-15.482l-7.9692 15.482h7.9692z" fill="#fff"/>
<path d="m41.711 27.015c-0.4629-0.7159-0.8936-1.4307-1.3254-2.1152 2.2813-1.4004 3.0517-2.5196 3.0517-4.636v-12.227h-2.6821v-2.3325h5.7039v13.938c0 3.547-1.0169 5.5378-4.7481 7.3729z"/>
<path d="m65.603 18.677c0 1.1819 0.8326 1.3063 1.3876 1.3063 0.5551 0 1.3566-0.1871 1.9727-0.3731v2.178c-0.8637 0.2801-1.7573 0.4974-2.9907 0.4974-1.4798 0-3.206-0.5602-3.206-3.174v-6.4095h-1.5719v-2.2093h1.5719v-3.2657h2.8364v3.2669h3.5756v2.2093h-3.5756v5.9737z"/>
<path d="m71.523 28.104v-17.641h2.7132v1.0576c1.079-0.8402 2.2813-1.369 3.7611-1.369 2.5588 0 4.5937 1.8049 4.5937 5.6935 0 3.8585-2.2191 6.4095-5.8881 6.4095-0.8936 0-1.603-0.1243-2.3435-0.2801v6.098h-2.8364v0.0314zm5.7338-15.587c-0.8326 0-1.8805 0.4045-2.8675 1.2761v6.0051c0.6161 0.1243 1.2645 0.2173 2.127 0.2173 2.0038 0 3.145-1.2761 3.145-3.9515 0-2.458-0.8326-3.547-2.4045-3.547z"/>
<path d="m93.748 22.007h-2.651v-1.2761h-0.0622c-0.9247 0.716-2.066 1.4935-3.7611 1.4935-1.4798 0-3.0828-1.089-3.0828-3.2983 0-2.9555 2.4966-3.5157 4.254-3.7644l2.4966-0.3416v-0.3417c0-1.5562-0.6161-2.0536-2.066-2.0536-0.7094 0-2.3734 0.2173-3.73 0.7775l-0.2464-2.3023c1.2334-0.4358 2.9285-0.7461 4.3473-0.7461 2.7741 0 4.5626 1.1204 4.5626 4.4489v7.4042h-0.061zm-2.8364-5.382-2.3435 0.373c-0.7094 0.093-1.4487 0.5288-1.4487 1.5864 0 0.9332 0.524 1.462 1.2944 1.462 0.8326 0 1.7262-0.4974 2.4966-1.0576v-2.3638h0.0012z"/>
<path d="m105.46 21.633c-1.171 0.4044-2.219 0.6531-3.546 0.6531-4.2537 0-5.95-2.458-5.95-6.0352 0-3.7643 2.3435-6.098 6.135-6.098 1.417 0 2.281 0.2487 3.237 0.5602v2.4266c-0.833-0.3115-2.035-0.6531-3.206-0.6531-1.727 0-3.2064 0.9332-3.2064 3.6085 0 2.9555 1.4794 3.8585 3.3604 3.8585 0.894 0 1.88-0.1871 3.206-0.7159v2.3953h-0.03z"/>
<path d="m110.83 15.442c0.246-0.2801 0.432-0.5602 4.008-4.9474h3.698l-4.624 5.4762 5.055 6.0666h-3.699l-4.408-5.4762v5.4762h-2.835v-16.333h2.836v9.7379h-0.031z"/>
<path d="m59.066 21.632c-1.4798 0.4672-2.7443 0.6531-4.2241 0.6531-3.6378 0-5.888-1.8351-5.888-6.1294 0-3.1425 1.9116-6.005 5.5794-6.005 3.6379 0 4.9023 2.551 4.9023 4.9776 0 0.8089-0.0622 1.2447-0.0921 1.7107h-7.3367c0.0622 2.5197 1.4798 3.1112 3.6067 3.1112 1.1712 0 2.2191-0.2801 3.4226-0.7159v2.3953h0.0299v0.0024zm-2.5888-6.6896c0-1.4005-0.4629-2.6138-1.9726-2.6138-1.4176 0-2.2813 1.0262-2.4667 2.6138h4.4393z"/>
<path d="m131.97 10.894c0 0.6585-0.146 1.2617-0.439 1.8106-0.293 0.549-0.777 1.0038-1.452 1.3679v0.0454c0.375 0.1284 0.718 0.2933 1.03 0.4936 0.311 0.2003 0.577 0.4383 0.799 0.7149 0.22 0.2767 0.394 0.5888 0.518 0.9363 0.124 0.3486 0.185 0.7382 0.185 1.1687 0 0.3708-0.058 0.7681-0.174 1.192-0.117 0.4238-0.321 0.8344-0.614 1.2317s-0.683 0.7626-1.17 1.0946c-0.487 0.3331-1.103 0.5976-1.846 0.7946-0.188 0.0454-0.392 0.0874-0.614 0.1251-0.221 0.0376-0.467 0.0697-0.737 0.0962-0.27 0.0266-0.571 0.0454-0.9 0.0565-0.331 0.0111-0.702 0.0166-1.114 0.0166h-4.378v-15.184h5.234c1.117 0 2.018 0.114 2.701 0.34087 0.51 0.16601 0.953 0.38403 1.328 0.65297 0.375 0.26893 0.685 0.56774 0.929 0.89644 0.243 0.3287 0.423 0.67731 0.54 1.0436 0.116 0.36628 0.174 0.73598 0.174 1.1056zm-5.661 2.2135c0.749 0 1.309-0.0753 1.677-0.2269 0.413-0.1738 0.707-0.4139 0.883-0.7205 0.176-0.3065 0.265-0.6529 0.265-1.0381 0-0.4006-0.101-0.7581-0.304-1.0724-0.203-0.31431-0.548-0.54672-1.035-0.69834-0.203-0.06087-0.439-0.10403-0.709-0.13059s-0.604-0.03984-1.002-0.03984h-2.262v3.9267h2.487zm-2.487 2.3263v4.2786h1.801c0.479 0 0.892-0.0133 1.238-0.0399 0.344-0.0265 0.641-0.0697 0.889-0.1306 0.383-0.083 0.701-0.1948 0.957-0.3353 0.255-0.1395 0.461-0.2988 0.619-0.477 0.158-0.1771 0.27-0.3741 0.338-0.5899s0.101-0.4438 0.101-0.6861c0-0.4239-0.116-0.7947-0.349-1.1123s-0.596-0.5556-1.092-0.7149c-0.217-0.0687-0.473-0.1174-0.765-0.1472-0.293-0.0299-0.667-0.0454-1.125-0.0454h-2.612z" fill="#646970"/>
<path d="m145.21 16.368c0 0.8697-0.13 1.6634-0.391 2.3813-0.261 0.7178-0.635 1.3318-1.121 1.8432-0.487 0.5113-1.075 0.9065-1.765 1.1845-0.689 0.2791-1.459 0.4175-2.31 0.4175-0.873 0-1.657-0.1396-2.351-0.4175-0.694-0.278-1.281-0.6732-1.764-1.1845-0.484-0.5114-0.854-1.1254-1.109-1.8432-0.257-0.7168-0.386-1.5116-0.386-2.3813s0.13-1.6634 0.391-2.3813c0.261-0.7167 0.635-1.3319 1.121-1.8432 0.487-0.5113 1.076-0.9065 1.765-1.1845 0.689-0.2791 1.46-0.4175 2.31-0.4175 0.874 0 1.657 0.1396 2.351 0.4175 0.694 0.2791 1.282 0.6732 1.765 1.1845s0.852 1.1254 1.108 1.8432c0.257 0.7179 0.386 1.5116 0.386 2.3813zm-2.816 0c0-0.5872-0.07-1.1064-0.207-1.5574-0.138-0.4499-0.33-0.8284-0.575-1.1331-0.246-0.3048-0.541-0.5337-0.886-0.6866-0.345-0.153-0.721-0.2289-1.127-0.2289-0.399 0-0.768 0.0759-1.108 0.2289-0.341 0.1529-0.635 0.3818-0.879 0.6866-0.246 0.3059-0.438 0.6832-0.575 1.1331-0.138 0.4499-0.208 0.9691-0.208 1.5574 0 0.5872 0.07 1.1063 0.208 1.5574 0.137 0.4499 0.331 0.8261 0.58 1.1275 0.249 0.3015 0.544 0.5303 0.885 0.6866s0.714 0.2345 1.121 0.2345c0.406 0 0.778-0.0782 1.115-0.2345 0.338-0.1563 0.628-0.3851 0.874-0.6866 0.245-0.3014 0.437-0.6776 0.575-1.1275 0.137-0.4511 0.207-0.9702 0.207-1.5574z" fill="#646970"/>
<path d="m157.45 16.368c0 0.8697-0.126 1.6634-0.379 2.3813-0.253 0.7178-0.615 1.3318-1.086 1.8432-0.471 0.5113-1.042 0.9065-1.71 1.1845-0.667 0.2791-1.413 0.4175-2.238 0.4175-0.846 0-1.605-0.1396-2.277-0.4175-0.672-0.278-1.241-0.6732-1.709-1.1845-0.468-0.5114-0.827-1.1254-1.074-1.8432-0.249-0.7168-0.374-1.5116-0.374-2.3813s0.126-1.6634 0.379-2.3813c0.252-0.7167 0.615-1.3319 1.086-1.8432s1.041-0.9065 1.709-1.1845c0.668-0.2791 1.414-0.4175 2.239-0.4175 0.846 0 1.605 0.1396 2.277 0.4175 0.672 0.2791 1.241 0.6732 1.709 1.1845s0.826 1.1254 1.074 1.8432c0.249 0.7179 0.374 1.5116 0.374 2.3813zm-2.729 0c0-0.5872-0.068-1.1064-0.201-1.5574-0.134-0.4499-0.319-0.8284-0.557-1.1331-0.238-0.3048-0.524-0.5337-0.858-0.6866-0.335-0.153-0.699-0.2289-1.092-0.2289-0.386 0-0.744 0.0759-1.074 0.2289-0.33 0.1529-0.614 0.3818-0.851 0.6866-0.238 0.3059-0.424 0.6832-0.557 1.1331-0.134 0.4499-0.201 0.9691-0.201 1.5574 0 0.5872 0.067 1.1063 0.201 1.5574 0.133 0.4499 0.321 0.8261 0.562 1.1275 0.241 0.3015 0.527 0.5303 0.857 0.6866s0.692 0.2345 1.086 0.2345c0.393 0 0.754-0.0782 1.081-0.2345s0.608-0.3851 0.846-0.6866c0.238-0.3014 0.423-0.6776 0.557-1.1275 0.135-0.4511 0.201-0.9702 0.201-1.5574z" fill="#646970"/>
<path d="m164.24 18.692c0-0.2367-0.067-0.4309-0.199-0.5839-0.133-0.1529-0.309-0.2802-0.529-0.384-0.219-0.1027-0.471-0.192-0.756-0.269-0.283-0.0759-0.581-0.1529-0.892-0.2288-0.394-0.1072-0.772-0.2311-1.136-0.3718-0.364-0.1406-0.684-0.3259-0.96-0.5548-0.277-0.2288-0.497-0.5168-0.66-0.864-0.163-0.3471-0.245-0.7724-0.245-1.2759 0-0.6184 0.11-1.1542 0.33-1.6086 0.219-0.4543 0.517-0.8294 0.892-1.1274 0.375-0.2981 0.81-0.5191 1.307-0.6642s1.021-0.2177 1.574-0.2177c0.674 0 1.307 0.0558 1.898 0.1663s1.125 0.2534 1.603 0.4287v2.2102c-0.251-0.0837-0.514-0.1618-0.791-0.2344-0.277-0.0725-0.557-0.135-0.841-0.1886s-0.567-0.0971-0.847-0.1318c-0.28-0.0346-0.545-0.0513-0.796-0.0513-0.318 0-0.587 0.0301-0.807 0.0915-0.219 0.0614-0.398 0.1429-0.534 0.2456-0.137 0.1027-0.235 0.221-0.296 0.355s-0.091 0.2724-0.091 0.4175c0 0.2523 0.066 0.4577 0.198 0.6184 0.133 0.1608 0.316 0.2903 0.551 0.3896 0.235 0.0994 0.481 0.1808 0.74 0.2467 0.257 0.0648 0.507 0.1284 0.75 0.1887 0.379 0.0915 0.757 0.202 1.136 0.3315s0.72 0.3114 1.023 0.5436c0.303 0.2333 0.551 0.5347 0.745 0.9042 0.193 0.3706 0.29 0.8417 0.29 1.4133 0 0.6262-0.118 1.1709-0.353 1.6364s-0.563 0.8529-0.983 1.1621-0.925 0.5381-1.512 0.6865c-0.588 0.1485-1.233 0.2233-1.938 0.2233-0.697 0-1.324-0.0558-1.881-0.1663-0.556-0.1106-1.017-0.2501-1.381-0.4175v-2.1857c0.591 0.221 1.136 0.3717 1.637 0.4521 0.5 0.0803 0.967 0.1205 1.398 0.1205 0.334 0 0.644-0.0245 0.932-0.0748 0.289-0.0491 0.536-0.1272 0.745-0.2344s0.374-0.2422 0.495-0.4063c0.124-0.1641 0.184-0.3617 0.184-0.5905z" fill="#646970"/>
<path d="m176 21.896c-0.302 0.0916-0.661 0.1641-1.079 0.2177-0.417 0.0536-0.808 0.0804-1.169 0.0804-0.92 0-1.671-0.1507-2.256-0.4521-0.584-0.3014-0.996-0.7344-1.237-1.2992-0.173-0.4041-0.26-0.9532-0.26-1.6486v-5.745h-2.046v-2.2323h2.046v-3.1008h2.678v3.1019h3.165v2.2323h-3.165v5.3912c0 0.4275 0.064 0.7445 0.192 0.9498 0.226 0.3516 0.674 0.5269 1.345 0.5269 0.308 0 0.616-0.0246 0.921-0.0748 0.305-0.0491 0.593-0.1128 0.864-0.1887v2.2413h1e-3z" fill="#646970"/>
</svg>
{
"name": "automattic/wp-super-cache",
"description": "A very fast caching engine for WordPress that produces static html files.",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"require": {
"automattic/jetpack-device-detection": "^1.4.24"
},
"require-dev": {
"yoast/phpunit-polyfills": "1.0.4",
"automattic/jetpack-changelogger": "^3.3.2"
},
"autoload": {
"classmap": [
"src/"
]
},
"scripts": {
"phpunit": [
"./vendor/phpunit/phpunit/phpunit --colors=always"
],
"test-php": [
"@composer phpunit"
],
"test-e2e": [
"cd tests/e2e && pnpm i && pnpm env:up && pnpm test:run"
],
"build-production": "echo 'Add your build step to composer.json, please!'",
"build-development": "echo 'Add your build step to composer.json, please!'"
},
"repositories": [],
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"autorelease": true,
"autotagger": true,
"changelogger": {
"link-template": "https://github.com/Automattic/wp-super-cache/compare/v${old}...v${new}"
},
"mirror-repo": "Automattic/wp-super-cache",
"release-branch-prefix": "super-cache",
"wp-plugin-slug": "wp-super-cache",
"wp-svn-autopublish": true
},
"config": {
"autoloader-suffix": "6fe342bc02f0b440f7b3c8d8ade42286_super_cacheⓥ1_9_4"
}
}
( 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 ( msg ) {
wpsc_ajax.admin == 1 && console.log( 'Deleted entire cache' );
wpsc_ajax.admin == 0 && console.log( 'Deleted cache for this page and reloading' );
window.location.reload();
},
complete: function ( msg ) {
$( '#wp-admin-bar-delete-cache' ).fadeIn( 'slow' );
},
} );
return false;
} );
} );
} )( jQuery );
<?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 json_decode( 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;
} 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 = $valid_nonce ? realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $req_path ) ) ) ) : false;
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 ) || 0 !== strpos( $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'] ) );
}
}
jQuery( document ).ready( function () {
load_preload_status();
setInterval( function () {
load_preload_status();
}, 1000 );
} );
/**
*
*/
function load_preload_status() {
jQuery.get( {
url: wpsc_preload_ajax.preload_permalink_url + '?' + Math.random(),
success: function ( response ) {
jQuery( '#preload_status' ).text( response );
},
} );
}
<?php
function wpsc_preload_notification_scripts() {
global $cache_path;
if (
isset( $_GET['page'] ) && $_GET['page'] === 'wpsupercache' &&
isset( $_GET['tab'] ) && $_GET['tab'] === 'preload' &&
@file_exists( $cache_path . 'preload_permalink.txt' )
) {
wp_enqueue_script( 'preload-notification', plugins_url( '/preload-notification.js', __FILE__ ), array('jquery'), '1.0', 1 );
wp_localize_script( 'preload-notification', 'wpsc_preload_ajax', array( 'preload_permalink_url' => home_url( str_replace( $_SERVER['DOCUMENT_ROOT'], '', $cache_path ) . '/preload_permalink.txt' ) ) );
}
}
add_action( 'admin_enqueue_scripts', 'wpsc_preload_notification_scripts' );
jQuery( document ).ready( () => {
// 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 link = jQuery( '.wpsc-install-action-button' );
const label = link.find( 'label' );
const spinner = link.find( '.spinner' );
// Dismiss Boost banner.
jQuery( '.wpsc-boost-dismiss' ).on( 'click', function () {
jQuery( '.wpsc-boost-banner' ).fadeOut( 'slow' );
jQuery.post( ajaxurl, {
action: 'wpsc-hide-boost-banner',
nonce: wpscAdmin.boostDismissNonce,
} );
} );
// One-click install for Boost.
jQuery( '#wpsc-install-boost-button' ).on( 'click', event => {
event.preventDefault();
showBoostBannerBusy( __( 'Installing…', 'wp-super-cache' ) );
jQuery
.post( ajaxurl, {
action: 'wpsc_install_plugin',
_ajax_nonce: wpscAdmin.boostInstallNonce,
slug: 'jetpack-boost',
} )
.done( response => {
if ( response.success ) {
activateBoost();
} else {
showBoostBannerError( response.data );
}
} )
.fail( response => {
showBoostBannerError(
sprintf(
/* translators: %d is an HTTP error code */
__( 'Failed to install Jetpack Boost: HTTP %d error received', 'wp-super-cache' ),
response.status
)
);
} );
} );
// Handle activate button click.
jQuery( '#wpsc-activate-boost-button' ).on( 'click', event => {
event.preventDefault();
activateBoost();
} );
// Helper function to show Boost Banner work in progress.
const showBoostBannerBusy = action => {
link.attr( 'disabled', true );
label.text( action );
spinner.addClass( 'is-active' ).show();
};
// Helper function to reset Boost Banner button.
const resetBoostBannerButton = () => {
link.attr( 'disabled', false );
jQuery( '#wpsc-activate-boost-button' )
.find( 'label' )
.text( __( 'Activate Jetpack Boost', 'wp-super-cache' ) );
jQuery( '#wpsc-install-boost-button' )
.find( 'label' )
.text( __( 'Install Jetpack Boost', 'wp-super-cache' ) );
spinner.removeClass( 'is-active' ).hide();
};
// Helper function to show an error.
const showBoostBannerError = err => {
resetBoostBannerButton();
jQuery( '#wpsc-boost-banner-error' )
.text(
err || __( 'An error occurred while trying to activate Jetpack Boost', 'wp-super-cache' )
)
.show();
};
// Activate Jetpack Boost.
const activateBoost = () => {
showBoostBannerBusy( __( 'Activating…', 'wp-super-cache' ) );
jQuery
.post( ajaxurl, {
action: 'wpsc_activate_boost',
_ajax_nonce: wpscAdmin.boostActivateNonce,
} )
.done( response => {
if ( response.success ) {
label.text( 'Success! Sending you to Jetpack Boost...' );
spinner.hide();
window.location.href = 'admin.php?page=jetpack-boost';
} else {
showBoostBannerError( response.data );
}
} )
.fail( response => {
showBoostBannerError(
sprintf(
/* translators: %d is an HTTP error code */
__( 'Failed to activate Jetpack Boost: HTTP %d error received', 'wp-super-cache' ),
response.status
)
);
} );
};
} );
This diff could not be displayed because it is too large.
{
"private": true,
"name": "@automattic/jetpack-super-cache",
"version": "1.9.4",
"description": "A very fast caching engine for WordPress that produces static html files.",
"homepage": "https://jetpack.com",
"bugs": {
"url": "https://github.com/Automattic/jetpack/labels/[Plugin] Super Cache"
},
"repository": {
"type": "git",
"url": "https://github.com/Automattic/jetpack.git",
"directory": "projects/plugins/super-cache"
},
"license": "GPL-2.0-or-later",
"author": "Automattic",
"scripts": {
"build": "echo 'Not implemented.'",
"build-js": "echo 'Not implemented.'",
"build-production": "echo 'Not implemented.'",
"build-production-js": "echo 'Not implemented.'",
"clean": "true"
},
"devDependencies": {}
}
<?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 '<p>' . __( 'Fix problems with the plugin by debugging it here. It will log to a file in your cache directory.', 'wp-super-cache' ) . '</p>';
if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username
}
$log_file_link = "<a href='" . home_url( str_replace( $_SERVER['DOCUMENT_ROOT'], '', "{$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 '<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 '</fieldset>';
<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
<?php
echo '<a name="preload"></a>';
if ( ! $cache_enabled || ! $super_cache_enabled || true === defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
echo '<div class="notice notice-warning"><p>' . __( 'Preloading of cache disabled. Please make sure simple or expert mode is enabled or talk to your host administrator.', 'wp-super-cache' ) . '</p></div>';
return;
}
$count = wpsc_post_count();
if ( $count > 1000 ) {
$min_refresh_interval = 720;
} else {
$min_refresh_interval = 30;
}
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 '<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>";
for( $c = $step; $c < $count; $c += $step ) {
$checked = ' ';
if ( $best == $c )
$checked = 'selected=1 ';
$select .= "<option value='$c'{$checked}>$c</option>";
}
$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 ) . '>'. __( 'No Emails', 'wp-super-cache' ) . '</option>';
echo '<option value="many" '. selected( 'many', $wp_cache_preload_email_volume ) . '>'. __( 'Many emails, 2 emails per 100 posts.', 'wp-super-cache' ) . '</option>';
echo '<option value="medium" '. selected( 'medium', $wp_cache_preload_email_volume ) . '>'. __( 'Medium, 1 email per 100 posts.', 'wp-super-cache' ) . '</option>';
echo '<option value="less" '. selected( 'less', $wp_cache_preload_email_volume ) . '>'. __( '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' ) ) {
$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>';
<?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";
<?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>';
<?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";
<?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' );
<?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;
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' );
}
if ( $cache_badbehaviour === (int) $_POST['cache_badbehaviour'] ) {
$changed = false;
} else {
$changed = true;
}
$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 ( isset( $changed ) && $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' );
<?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 = ' . intval( $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' );
<?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' );
}
<?php
if ( ! class_exists( 'Automattic\Jetpack\Device_Detection' ) ) {
// Manually load Device_Detection before autoload is initialized.
if ( defined( 'WPCACHEHOME' ) ) {
if ( file_exists( WPCACHEHOME . '/vendor/automattic/jetpack-device-detection/src/class-device-detection.php' ) ) {
require_once WPCACHEHOME . '/vendor/automattic/jetpack-device-detection/src/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\Jetpack\Device_Detection' ) ) {
return 'normal';
}
if ( \Automattic\Jetpack\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' );
<?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;
define( 'DONOTCACHEPAGE', 1 );
define( 'SUBMITDISABLED', 'disabled style="color: #aaa" ' );
if ( is_admin() ) {
add_action( 'admin_notices', 'wp_super_cache_multisite_notice' );
}
}
}
<?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' );
<?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 ) );
}
}
<?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 );
}
}
<?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 );
}
}
<?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 ( false === strpos( $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/';
}
}
<?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() );
}
}
<?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;
}
}
}
<?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 ) ) );
}
}
}
}
<?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;
}
}
<?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 );
}
}
<?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',
),
);
}
<?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' );
<?php
/**
* Put your classes in this `src` folder!
*
* @package automattic/PACKAGE-NAME
*/
// Start your code here!
<?php
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_9_4::getLoader();
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.4.24] - 2023-02-20
### Changed
- Minor internal updates.
## [1.4.23] - 2023-01-11
### Changed
- Updated package dependencies.
## [1.4.22] - 2022-12-02
### Changed
- Updated package dependencies. [#27688]
## [1.4.21] - 2022-11-22
### Added
- Add a guard in `functions.php` against being loaded twice from different copies of the package. [#27475]
### Changed
- Updated package dependencies. [#27043]
## [1.4.20] - 2022-11-07
### Fixed
- Ensure that User_Agent is loaded in environments without autoload enabled. (e.g.: WordPress.com and Super Cache) [#27223]
## [1.4.19] - 2022-10-25
### Changed
- Update `wp_unslash` wrapper to possibly run on wpcom before WordPress is loaded. [#26971]
## [1.4.18] - 2022-07-26
### Changed
- Updated package dependencies. [#25158]
## [1.4.17] - 2022-06-21
### Changed
- Renaming master to trunk.
## [1.4.16] - 2022-04-26
### Changed
- Updated package dependencies.
## [1.4.15] - 2022-04-19
### Changed
- PHPCS: Fix `WordPress.Security.ValidatedSanitizedInput`
## [1.4.14] - 2022-03-29
### Changed
- Microperformance: Use === null instead of is_null
## [1.4.13] - 2022-02-09
### Fixed
- Fixed some new PHPCS warnings.
## [1.4.12] - 2022-01-25
### Changed
- Updated package dependencies.
## [1.4.11] - 2022-01-04
### Changed
- Switch to pcov for code coverage.
- Updated package dependencies
## [1.4.10] - 2021-12-14
### Changed
- Updated package dependencies.
## [1.4.9] - 2021-11-16
### Fixed
- Verify $_SERVER['HTTP_USER_AGENT'] exists before use.
## [1.4.8] - 2021-11-02
### Changed
- Set `convertDeprecationsToExceptions` true in PHPUnit config.
- Update PHPUnit configs to include just what needs coverage rather than include everything then try to exclude stuff that doesn't.
## [1.4.7] - 2021-10-19
### Deprecated
- General: remove numerous long-deprecated functions.
## [1.4.6] - 2021-10-13
### Changed
- Updated package dependencies.
## [1.4.5] - 2021-10-12
### Changed
- Updated package dependencies
## [1.4.4] - 2021-09-28
### Changed
- Updated package dependencies.
## [1.4.3] - 2021-08-31
### Changed
- Run composer update on test-php command instead of phpunit.
- Tests: update PHPUnit polyfills dependency (yoast/phpunit-polyfills).
- Updated versions in annotations.
## [1.4.2] - 2021-05-25
### Changed
- Updated package dependencies.
## [1.4.1] - 2021-04-27
### Changed
- Updated package dependencies.
## [1.4.0] - 2021-03-30
### Added
- Added Opera Desktop detection
- Composer alias for dev-master, to improve dependencies
### Changed
- Update package dependencies.
### Fixed
- Use `composer update` rather than `install` in scripts, as composer.lock isn't checked in.
## [1.3.2] - 2021-02-05
- CI: Make tests more generic
## [1.3.1] - 2021-01-19
- Add mirror-repo information to all current composer packages
- Monorepo: Reorganize all projects
## [1.3.0] - 2020-12-09
- Codesniffer: Update mediawiki/mediawiki-codesniffer dependency
- Pin dependencies
- Packages: Update for PHP 8 testing
## [1.2.1] - 2020-11-10
- Improve PHP 8 compatibility
- Updated PHPCS: Packages and Debugger
## [1.2.0] - 2020-10-19
- Replaced intval() with (int) as part of issue #17432.
## [1.1.0] - 2020-08-13
- CI: Try collect js coverage
## 1.0.0 - 2020-06-25
- Moving jetpack_is_mobile into a package
[1.4.24]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.23...v1.4.24
[1.4.23]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.22...v1.4.23
[1.4.22]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.21...v1.4.22
[1.4.21]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.20...v1.4.21
[1.4.20]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.19...v1.4.20
[1.4.19]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.18...v1.4.19
[1.4.18]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.17...v1.4.18
[1.4.17]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.16...v1.4.17
[1.4.16]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.15...v1.4.16
[1.4.15]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.14...v1.4.15
[1.4.14]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.13...v1.4.14
[1.4.13]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.12...v1.4.13
[1.4.12]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.11...v1.4.12
[1.4.11]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.10...v1.4.11
[1.4.10]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.9...v1.4.10
[1.4.9]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.8...v1.4.9
[1.4.8]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.7...v1.4.8
[1.4.7]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.6...v1.4.7
[1.4.6]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.5...v1.4.6
[1.4.5]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.4...v1.4.5
[1.4.4]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.3...v1.4.4
[1.4.3]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.2...v1.4.3
[1.4.2]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.1...v1.4.2
[1.4.1]: https://github.com/Automattic/jetpack-device-detection/compare/v1.4.0...v1.4.1
[1.4.0]: https://github.com/Automattic/jetpack-device-detection/compare/v1.3.2...v1.4.0
[1.3.2]: https://github.com/Automattic/jetpack-device-detection/compare/v1.3.1...v1.3.2
[1.3.1]: https://github.com/Automattic/jetpack-device-detection/compare/v1.3.0...v1.3.1
[1.3.0]: https://github.com/Automattic/jetpack-device-detection/compare/v1.2.1...v1.3.0
[1.2.1]: https://github.com/Automattic/jetpack-device-detection/compare/v1.2.0...v1.2.1
[1.2.0]: https://github.com/Automattic/jetpack-device-detection/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/Automattic/jetpack-device-detection/compare/v1.0.0...v1.1.0
# Jetpack Device Detection
A method to detect device types, originates from `jetpack_is_mobile`.
### Usage
Retrieve device information.
```php
use Automattic\Jetpack\Device_Detection;
$device_info = Device_Detection::get_info();
/**
* array(
* 'is_phone' => (bool) Whether the current device is a mobile phone.
* 'is_smartphone' => (bool) Whether the current device is a smartphone.
* 'is_tablet' => (bool) Whether the current device is a tablet device.
* 'is_handheld' => (bool) Whether the current device is a handheld device.
* 'is_desktop' => (bool) Whether the current device is a laptop / desktop device.
* 'platform' => (string) Detected platform.
* 'is_phone_matched_ua' => (string) Matched UA.
* );
*/
```
Detect any mobile phone.
```php
use Automattic\Jetpack\Device_Detection;
$is_phone = Device_Detection::is_phone();
```
Detect a smartphone.
```php
use Automattic\Jetpack\Device_Detection;
$is_smartphone = Device_Detection::is_smartphone();
```
Detect a dumbphone.
```php
use Automattic\Jetpack\Device_Detection;
$is_dumbphone = Device_Detection::is_phone() && ! Device_Detection::is_smartphone();
```
Detect a tablet.
```php
use Automattic\Jetpack\Device_Detection;
$is_tablet = Device_Detection::is_tablet();
```
Detect a desktop device.
```php
use Automattic\Jetpack\Device_Detection;
$is_desktop = Device_Detection::is_desktop();
```
Detect any handheld device.
```php
use Automattic\Jetpack\Device_Detection;
$is_handheld = Device_Detection::is_handheld();
```
# 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 has continued support. If a critical vulnerability is found in the current version of Jetpack, we may opt to backport any patches to previous versions.
## Reporting a Vulnerability
[Jetpack](https://jetpack.com/) is an open-source plugin for WordPress. Our HackerOne program covers the plugin software, as well as a variety of related projects and infrastructure.
**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.
{
"name": "automattic/jetpack-device-detection",
"description": "A way to detect device types based on User-Agent header.",
"type": "jetpack-library",
"license": "GPL-2.0-or-later",
"require": {},
"require-dev": {
"yoast/phpunit-polyfills": "1.0.4",
"automattic/jetpack-changelogger": "^3.3.2"
},
"autoload": {
"classmap": [
"src/"
]
},
"scripts": {
"phpunit": [
"./vendor/phpunit/phpunit/phpunit --colors=always"
],
"test-php": [
"@composer phpunit"
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"autotagger": true,
"mirror-repo": "Automattic/jetpack-device-detection",
"changelogger": {
"link-template": "https://github.com/Automattic/jetpack-device-detection/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "1.4.x-dev"
}
}
}
<?php
/**
* Device detection for Jetpack.
*
* @package automattic/jetpack-device-detection
*/
namespace Automattic\Jetpack;
require_once __DIR__ . '/functions.php';
require_once __DIR__ . '/class-user-agent-info.php';
use Automattic\Jetpack\Device_Detection\User_Agent_Info;
use function Automattic\Jetpack\Device_Detection\wp_unslash;
/**
* Class Device_Detection
*
* Determine if the current User Agent matches the passed $kind.
*/
class Device_Detection {
/**
* Returns information about the current device accessing the page.
*
* @param string $ua (Optional) User-Agent string.
*
* @return array Device information.
*
* array(
* 'is_phone' => (bool) Whether the current device is a mobile phone.
* 'is_smartphone' => (bool) Whether the current device is a smartphone.
* 'is_tablet' => (bool) Whether the current device is a tablet device.
* 'is_handheld' => (bool) Whether the current device is a handheld device.
* 'is_desktop' => (bool) Whether the current device is a laptop / desktop device.
* 'platform' => (string) Detected platform.
* 'is_phone_matched_ua' => (string) Matched UA.
* );
*/
public static function get_info( $ua = '' ) {
$ua_info = new User_Agent_Info( $ua );
$info = array(
'is_phone' => self::is_mobile( 'any', false, $ua_info ),
'is_phone_matched_ua' => self::is_mobile( 'any', true, $ua_info ),
'is_smartphone' => self::is_mobile( 'smart', false, $ua_info ),
'is_tablet' => $ua_info->is_tablet(),
'platform' => $ua_info->get_platform(),
);
$info['is_handheld'] = $info['is_phone'] || $info['is_tablet'];
$info['is_desktop'] = ! $info['is_handheld'];
if ( function_exists( 'apply_filters' ) ) {
/**
* Filter the value of Device_Detection::get_info.
*
* @since 1.0.0
*
* @param array $info Array of device information.
* @param string $ua User agent string passed to Device_Detection::get_info.
* @param User_Agent_Info $ua_info Instance of Automattic\Jetpack\Device_Detection\User_Agent_Info.
*/
$info = apply_filters( 'jetpack_device_detection_get_info', $info, $ua, $ua_info );
}
return $info;
}
/**
* Detects phone devices.
*
* @param string $ua User-Agent string.
*
* @return bool
*/
public static function is_phone( $ua = '' ) {
$device_info = self::get_info( $ua );
return true === $device_info['is_phone'];
}
/**
* Detects smartphone devices.
*
* @param string $ua User-Agent string.
*
* @return bool
*/
public static function is_smartphone( $ua = '' ) {
$device_info = self::get_info( $ua );
return true === $device_info['is_smartphone'];
}
/**
* Detects tablet devices.
*
* @param string $ua User-Agent string.
*
* @return bool
*/
public static function is_tablet( $ua = '' ) {
$device_info = self::get_info( $ua );
return true === $device_info['is_tablet'];
}
/**
* Detects desktop devices.
*
* @param string $ua User-Agent string.
*
* @return bool
*/
public static function is_desktop( $ua = '' ) {
$device_info = self::get_info( $ua );
return true === $device_info['is_desktop'];
}
/**
* Detects handheld (i.e. phone + tablet) devices.
*
* @param string $ua User-Agent string.
*
* @return bool
*/
public static function is_handheld( $ua = '' ) {
$device_info = self::get_info( $ua );
return true === $device_info['is_handheld'];
}
/**
* Determine if the current User Agent matches the passed $kind.
*
* @param string $kind Category of mobile device to check for. Either: any, dumb, smart.
* @param bool $return_matched_agent Boolean indicating if the UA should be returned.
* @param User_Agent_Info $ua_info Boolean indicating if the UA should be returned.
*
* @return bool|string Boolean indicating if current UA matches $kind. If `$return_matched_agent` is true, returns the UA string.
*/
private static function is_mobile( $kind, $return_matched_agent, $ua_info ) {
$kinds = array(
'smart' => false,
'dumb' => false,
'any' => false,
);
$first_run = true;
$matched_agent = '';
// If an invalid kind is passed in, reset it to default.
if ( ! isset( $kinds[ $kind ] ) ) {
$kind = 'any';
}
if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
return false;
}
$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;
}
if ( $first_run ) {
$first_run = false;
// checks for iPhoneTier devices & RichCSS devices.
if ( $ua_info->isTierIphone() || $ua_info->isTierRichCSS() ) {
$kinds['smart'] = true;
$matched_agent = $ua_info->matched_agent;
}
if ( ! $kinds['smart'] ) {
// if smart, we are not dumb so no need to check.
$dumb_agents = $ua_info->dumb_agents;
foreach ( $dumb_agents as $dumb_agent ) {
if ( false !== strpos( $agent, $dumb_agent ) ) {
$kinds['dumb'] = true;
$matched_agent = $dumb_agent;
break;
}
}
if ( ! $kinds['dumb'] ) {
if ( isset( $_SERVER['HTTP_X_WAP_PROFILE'] ) ) {
$kinds['dumb'] = true;
$matched_agent = 'http_x_wap_profile';
} 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.
$kinds['dumb'] = true;
$matched_agent = 'vnd.wap.xhtml+xml';
}
}
}
if ( $kinds['dumb'] || $kinds['smart'] ) {
$kinds['any'] = true;
}
}
$value = $kinds[ $kind ];
if ( $return_matched_agent ) {
$value = $matched_agent;
}
return $value;
}
}
<?php
/**
* Utility functions for device detection.
*
* @package automattic/jetpack-device-detection
*/
namespace Automattic\Jetpack\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;
}
}
}
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Automattic\\Jetpack\\Device_Detection' => $vendorDir . '/automattic/jetpack-device-detection/src/class-device-detection.php',
'Automattic\\Jetpack\\Device_Detection\\User_Agent_Info' => $vendorDir . '/automattic/jetpack-device-detection/src/class-user-agent-info.php',
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
);
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_9_4
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cacheⓥ1_9_4', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cacheⓥ1_9_4', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_9_4::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
return $loader;
}
}
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_9_4
{
public static $classMap = array (
'Automattic\\Jetpack\\Device_Detection' => __DIR__ . '/..' . '/automattic/jetpack-device-detection/src/class-device-detection.php',
'Automattic\\Jetpack\\Device_Detection\\User_Agent_Info' => __DIR__ . '/..' . '/automattic/jetpack-device-detection/src/class-user-agent-info.php',
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->classMap = ComposerStaticInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_9_4::$classMap;
}, null, ClassLoader::class);
}
}
{
"packages": [
{
"name": "automattic/jetpack-device-detection",
"version": "v1.4.24",
"version_normalized": "1.4.24.0",
"source": {
"type": "git",
"url": "https://github.com/Automattic/jetpack-device-detection.git",
"reference": "9931222d1865eaf7efd26c9e88518e632593f7e2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Automattic/jetpack-device-detection/zipball/9931222d1865eaf7efd26c9e88518e632593f7e2",
"reference": "9931222d1865eaf7efd26c9e88518e632593f7e2",
"shasum": ""
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.2",
"yoast/phpunit-polyfills": "1.0.4"
},
"time": "2023-02-20T19:47:12+00:00",
"type": "jetpack-library",
"extra": {
"autotagger": true,
"mirror-repo": "Automattic/jetpack-device-detection",
"changelogger": {
"link-template": "https://github.com/Automattic/jetpack-device-detection/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "1.4.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0-or-later"
],
"description": "A way to detect device types based on User-Agent header.",
"support": {
"source": "https://github.com/Automattic/jetpack-device-detection/tree/v1.4.24"
},
"install-path": "../automattic/jetpack-device-detection"
}
],
"dev": false,
"dev-package-names": []
}
<?php return array(
'root' => array(
'name' => 'automattic/wp-super-cache',
'pretty_version' => 'dev-trunk',
'version' => 'dev-trunk',
'reference' => NULL,
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev' => false,
),
'versions' => array(
'automattic/jetpack-device-detection' => array(
'pretty_version' => 'v1.4.24',
'version' => '1.4.24.0',
'reference' => '9931222d1865eaf7efd26c9e88518e632593f7e2',
'type' => 'jetpack-library',
'install_path' => __DIR__ . '/../automattic/jetpack-device-detection',
'aliases' => array(),
'dev_requirement' => false,
),
'automattic/wp-super-cache' => array(
'pretty_version' => 'dev-trunk',
'version' => 'dev-trunk',
'reference' => NULL,
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
),
);
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.