| @@ -6,10 +6,8 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace PoweredCache; |
| 9 | 9 | |
| 10 | -use const PoweredCache\Constants\POST_META_DISABLE_CSS_OPTIMIZATION; | |
| 11 | -use const PoweredCache\Constants\POST_META_DISABLE_JS_OPTIMIZATION; | |
| 12 | 10 | use PoweredCache\Optimizer\CSS; |
| 13 | 11 | use PoweredCache\Optimizer\Helper; |
| 14 | 12 | use PoweredCache\Optimizer\JS; |
| 15 | 13 | use function PoweredCache\Utils\get_cache_dir; |
| @@ -56,14 +54,8 @@ | ||
| 56 | 54 | * Setup routine |
| 57 | 55 | */ |
| 58 | 56 | public function setup() { |
| 59 | 57 | $this->settings = \PoweredCache\Utils\get_settings(); |
| 60 | - | |
| 61 | - // Check request method | |
| 62 | - if ( ! isset( $_SERVER['REQUEST_METHOD'] ) || ! in_array( $_SERVER['REQUEST_METHOD'], [ 'GET', 'HEAD' ], true ) ) { | |
| 63 | - return true; | |
| 64 | - } | |
| 65 | - | |
| 66 | 58 | /** |
| 67 | 59 | * Filters whether apply or not apply file optimizations on wp-admin. |
| 68 | 60 | * |
| 69 | 61 | * @hook powered_cache_fo_dashboard |
| @@ -85,24 +77,8 @@ | ||
| 85 | 77 | if ( is_admin() && ! $this->optimize_dashboard ) { |
| 86 | 78 | return; |
| 87 | 79 | } |
| 88 | 80 | |
| 89 | - /** | |
| 90 | - * Filters FileOptimizer integration | |
| 91 | - * | |
| 92 | - * @hook powered_cache_fo_disable | |
| 93 | - * | |
| 94 | - * @param {boolean} False by default. | |
| 95 | - * | |
| 96 | - * @return {boolean} New value. | |
| 97 | - * @since 2.2 | |
| 98 | - */ | |
| 99 | - $disable_file_optimizer = apply_filters( 'powered_cache_fo_disable', false ); | |
| 100 | - | |
| 101 | - if ( $disable_file_optimizer ) { | |
| 102 | - return; | |
| 103 | - } | |
| 104 | - | |
| 105 | 81 | add_action( 'init', [ $this, 'setup_css_combine' ] ); |
| 106 | 82 | add_action( 'init', [ $this, 'setup_js_combine' ] ); |
| 107 | 83 | add_filter( 'script_loader_tag', [ $this, 'js_minify' ], 10, 3 ); |
| 108 | 84 | add_filter( 'style_loader_tag', [ $this, 'css_minify' ], 10, 4 ); |
| @@ -125,36 +101,13 @@ | ||
| 125 | 101 | |
| 126 | 102 | if ( $this->settings['combine_google_fonts'] ) { |
| 127 | 103 | add_action( 'wp_enqueue_scripts', [ $this, 'combine_google_fonts' ], 99 ); |
| 128 | 104 | } |
| 105 | + add_action( 'wp_enqueue_scripts', [ $this, 'combine_google_fonts' ], 99 ); | |
| 129 | 106 | |
| 130 | - add_action( 'template_redirect', [ $this, 'maybe_suppress_optimizations' ] ); | |
| 131 | 107 | } |
| 132 | 108 | |
| 133 | - | |
| 134 | 109 | /** |
| 135 | - * Maybe suppress optimizations based on the post meta options | |
| 136 | - * | |
| 137 | - * @since 2.1 | |
| 138 | - */ | |
| 139 | - public function maybe_suppress_optimizations() { | |
| 140 | - if ( is_singular() ) { | |
| 141 | - $disable_css_optimization = (bool) get_post_meta( get_the_ID(), POST_META_DISABLE_CSS_OPTIMIZATION, true ); | |
| 142 | - $disable_js_optimization = (bool) get_post_meta( get_the_ID(), POST_META_DISABLE_JS_OPTIMIZATION, true ); | |
| 143 | - | |
| 144 | - if ( $disable_css_optimization ) { | |
| 145 | - add_filter( 'powered_cache_fo_css_do_concat', '__return_false' ); | |
| 146 | - add_filter( 'powered_cache_fo_disable_css_minify', '__return_true' ); | |
| 147 | - } | |
| 148 | - | |
| 149 | - if ( $disable_js_optimization ) { | |
| 150 | - add_filter( 'powered_cache_fo_js_do_concat', '__return_false' ); | |
| 151 | - add_filter( 'powered_cache_fo_disable_js_minify', '__return_true' ); | |
| 152 | - } | |
| 153 | - } | |
| 154 | - } | |
| 155 | - | |
| 156 | - /** | |
| 157 | 110 | * Purge FO cache |
| 158 | 111 | * |
| 159 | 112 | * @since 2.0 |
| 160 | 113 | */ |
| @@ -513,17 +466,8 @@ | ||
| 513 | 466 | $font_args['family'] = implode( '|', $families ); |
| 514 | 467 | |
| 515 | 468 | if ( ! empty( $subsets ) ) { |
| 516 | 469 | $font_args['subset'] = implode( ',', $subsets ); |
| 517 | - } | |
| 518 | - | |
| 519 | - /** | |
| 520 | - * Force font display: swap | |
| 521 | - * | |
| 522 | - * @since 2.2 | |
| 523 | - */ | |
| 524 | - if ( $this->settings['swap_google_fonts_display'] ) { | |
| 525 | - $font_display = 'swap'; | |
| 526 | 470 | } |
| 527 | 471 | |
| 528 | 472 | /** |
| 529 | 473 | * Filters font display attribute of the google fonts. |