PluginProbe
Autoptimize / 3.1.4
Autoptimize v3.1.4
2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 All 107 releases
← All changes | classes/autoptimizeCache.php +25 -5 2.7.83.1.4 View file →
@@ -90,9 +90,9 @@
90 90 *
91 91 * @param string $data Data to cache.
92 92 * @param string $mime Mimetype.
93 93 *
94 - * @return void
94 + * @return void|bool
95 95 */
96 96 public function cache( $data, $mime )
97 97 {
98 98 // readonly FS explicitly OK'ed by developer, so just pretend all is OK.
@@ -381,9 +381,19 @@
381 381 * @return bool
382 382 */
383 383 public static function clearall( $propagate = true )
384 384 {
385 - if ( ! self::cacheavail() ) {
385 + if ( defined( 'ET_CORE_VERSION' ) && 'Divi' === get_template() ) {
386 + // see https://blog.futtta.be/2018/11/17/warning-divi-purging-autoptimizes-cache/ .
387 + $dbt = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 2 );
388 + $caller = isset( $dbt[1]['function'] ) ? $dbt[1]['function'] : null;
389 + if ( 'et_core_clear_wp_cache' === $caller ) {
390 + _doing_it_wrong( 'autoptimizeCache::clearall', 'Divi devs: please don\'t clear Autoptimize\'s cache, it is unneeded and can break sites. You can contact me at futtta@gmail.com to discuss.', 'Autoptimize 2.9.6' );
391 + return false;
392 + }
393 + }
394 +
395 + if ( ! self::cacheavail() || true === apply_filters( 'autoptimize_filter_cache_clearall_disabled', false ) ) {
386 396 return false;
387 397 }
388 398
389 399 // TODO/FIXME: If cache is big, switch to advanced/new cache clearing automatically?
@@ -631,12 +641,16 @@
631 641 $_fallback_filename = 'autoptimize_404_handler.php';
632 642 $_fallback_php = trailingslashit( WP_CONTENT_DIR ) . $_fallback_filename;
633 643 $_fallback_status = true;
634 644
635 - if ( ! file_exists( $_fallback_php ) ) {
645 + if ( ! file_exists( $_fallback_php ) && is_writable( WP_CONTENT_DIR ) ) {
636 646 $_fallback_php_contents = file_get_contents( AUTOPTIMIZE_PLUGIN_DIR . 'config/' . $_fallback_filename );
637 647 $_fallback_php_contents = str_replace( '<?php exit;', '<?php', $_fallback_php_contents );
638 648 $_fallback_php_contents = str_replace( '<!--ao-cache-dir-->', AUTOPTIMIZE_CACHE_DIR, $_fallback_php_contents );
649 + $_fallback_php_contents = str_replace( '<!--ao-cachefile-prefix-->', AUTOPTIMIZE_CACHEFILE_PREFIX, $_fallback_php_contents );
650 + if ( is_multisite() ) {
651 + $_fallback_php_contents = str_replace( '$multisite = false;', '$multisite = true;', $_fallback_php_contents );
652 + }
639 653 if ( apply_filters( 'autoptimize_filter_cache_fallback_log_errors', false ) ) {
640 654 $_fallback_php_contents = str_replace( '// error_log', 'error_log', $_fallback_php_contents );
641 655 }
642 656 $_fallback_status = file_put_contents( $_fallback_php, $_fallback_php_contents );
@@ -680,9 +694,9 @@
680 694 $fallback_path = AUTOPTIMIZE_CACHE_DIR . $js_or_css . '/autoptimize_fallback.' . $js_or_css;
681 695
682 696 // prepare for Shakeeb's Unused CSS files to be 404-handled as well.
683 697 if ( strpos( $original_request, 'uucss/uucss-' ) !== false ) {
684 - $original_request = preg_replace( '/uucss\/uucss-[a-z0-9]{32}-/', 'css/', $original_request );
698 + $original_request = preg_replace( '/uucss\/uucss-[a-z0-9]{32}-/', 'css/', $original_request );
685 699 }
686 700
687 701 // set fallback URL.
688 702 $fallback_target = preg_replace( '/(.*)_(?:[a-z0-9]{32})\.(js|css)$/', '${1}_fallback.${2}', $original_request );
@@ -808,13 +822,16 @@
808 822 } elseif ( array_key_exists( 'KINSTA_CACHE_ZONE', $_SERVER ) ) {
809 823 $_kinsta_clear_cache_url = 'https://localhost/kinsta-clear-cache-all';
810 824 $_kinsta_response = wp_remote_get(
811 825 $_kinsta_clear_cache_url,
812 - array(
826 + array(
813 827 'sslverify' => false,
814 828 'timeout' => 5,
815 829 )
816 830 );
831 + } elseif ( class_exists( 'RaidboxesNginxCacheFunctions' ) ) {
832 + $rb_cache_helper = new RaidboxesNginxCacheFunctions();
833 + $rb_cache_helper->purge_cache();
817 834 } elseif ( defined('NGINX_HELPER_BASENAME') ) {
818 835 do_action( 'rt_nginx_helper_purge_all' );
819 836 } elseif ( file_exists( WP_CONTENT_DIR . '/wp-cache-config.php' ) && function_exists( 'prune_super_cache' ) ) {
820 837 // fallback for WP-Super-Cache
@@ -826,8 +843,11 @@
826 843 } else {
827 844 prune_super_cache( $cache_path . 'supercache/', true );
828 845 prune_super_cache( $cache_path, true );
829 846 }
847 + } elseif ( class_exists( 'NginxCache' ) ) {
848 + $nginx_cache = new NginxCache();
849 + $nginx_cache->purge_zone_once();
830 850 }
831 851 }
832 852 // @codingStandardsIgnoreEnd
833 853 }