| @@ -1,23 +1,23 @@ | ||
| 1 | 1 | <?php |
| 2 | +declare(strict_types=1); | |
| 3 | + | |
| 2 | 4 | namespace Imagify\Webp\RewriteRules; |
| 3 | 5 | |
| 4 | -defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); | |
| 6 | +use Imagify\WriteFile\AbstractApacheDirConfFile; | |
| 5 | 7 | |
| 6 | 8 | /** |
| 7 | 9 | * Add and remove rewrite rules to the .htaccess file to display WebP images on the site. |
| 8 | 10 | * |
| 9 | - * @since 1.9 | |
| 10 | - * @author Grégory Viguier | |
| 11 | + * @since 1.9 | |
| 11 | 12 | */ |
| 12 | -class Apache extends \Imagify\WriteFile\AbstractApacheDirConfFile { | |
| 13 | +class Apache extends AbstractApacheDirConfFile { | |
| 13 | 14 | |
| 14 | 15 | /** |
| 15 | 16 | * Name of the tag used as block delemiter. |
| 16 | 17 | * |
| 17 | - * @var string | |
| 18 | - * @since 1.9 | |
| 19 | - * @author Grégory Viguier | |
| 18 | + * @var string | |
| 19 | + * @since 1.9 | |
| 20 | 20 | */ |
| 21 | 21 | const TAG_NAME = 'Imagify: rewrite rules for webp'; |
| 22 | 22 | |
| 23 | 23 | /** |
| @@ -23,20 +23,20 @@ | ||
| 23 | 23 | /** |
| 24 | 24 | * Get unfiltered new contents to write into the file. |
| 25 | 25 | * |
| 26 | 26 | * @since 1.9 |
| 27 | - * @access protected | |
| 28 | 27 | * @source https://github.com/vincentorback/WebP-images-with-htaccess |
| 29 | - * @author Grégory Viguier | |
| 30 | 28 | * |
| 31 | 29 | * @return string |
| 32 | 30 | */ |
| 33 | 31 | protected function get_raw_new_contents() { |
| 34 | 32 | $extensions = $this->get_extensions_pattern(); |
| 33 | + $extensions = str_replace( '|webp', '', $extensions ); | |
| 35 | 34 | $home_root = wp_parse_url( home_url( '/' ) ); |
| 36 | 35 | $home_root = $home_root['path']; |
| 37 | 36 | |
| 38 | - return trim( ' | |
| 37 | + return trim( | |
| 38 | + ' | |
| 39 | 39 | <IfModule mod_setenvif.c> |
| 40 | 40 | # Vary: Accept for all the requests to jpeg, png, and gif. |
| 41 | 41 | SetEnvIf Request_URI "\.(' . $extensions . ')$" REQUEST_image |
| 42 | 42 | </IfModule> |
| @@ -56,7 +56,8 @@ | ||
| 56 | 56 | </IfModule> |
| 57 | 57 | |
| 58 | 58 | <IfModule mod_headers.c> |
| 59 | 59 | Header append Vary Accept env=REQUEST_image |
| 60 | -</IfModule>' ); | |
| 60 | +</IfModule>' | |
| 61 | + ); | |
| 61 | 62 | } |
| 62 | 63 | } |