Skip to content

Commit

Permalink
new plugin: remove etags
Browse files Browse the repository at this point in the history
  • Loading branch information
glueckpress committed Feb 19, 2018
1 parent 588a514 commit 8e3650b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
13 changes: 13 additions & 0 deletions htaccess/wp-rocket-htaccess-remove-etag/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# WP Rocket | Remove ETag

Prevents ETag code to be added to htaccess.

Documentation:
* [Divi Theme](https://docs.wp-rocket.me/article/657-divi-theme)

To be used with:
* any setup where ETags should be removed, for example with the Divi theme if font icons are missing in IE 11

Last tested with:
* WP Rocket 2.11.x
* WordPress 4.9.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* Plugin Name: WP Rocket | Remove ETag
* Description: Prevents ETag code to be added to htaccess.
* Plugin URI: https://github.com/wp-media/wp-rocket-helpers/tree/master/htaccess/wp-rocket-htaccess-remove-etag/
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright SAS WP MEDIA 2018
*/

// Namespaces must be declared before any other declaration.
namespace WP_Rocket\Helpers\htaccess\remove_etag;

// Standard plugin security, keep this line in place.
defined( 'ABSPATH' ) or die();

/**
* Prevents ETag code to be added to htaccess.
*/
add_filter ( 'rocket_htaccess_etag', '__return_false');

/**
* Updates .htaccess, regenerates WP Rocket config file.
*
* @author Caspar Hübinger
*/
function flush_wp_rocket() {

if ( ! function_exists( 'flush_rocket_htaccess' )
|| ! function_exists( 'rocket_generate_config_file' ) ) {
return false;
}

// Update WP Rocket .htaccess rules.
flush_rocket_htaccess();

// Regenerate WP Rocket config file.
rocket_generate_config_file();
}
register_activation_hook( __FILE__, __NAMESPACE__ . '\flush_wp_rocket' );

/**
* Removes customizations, updates .htaccess, regenerates config file.
*
* @author Caspar Hübinger
*/
function deactivate() {

// Remove all functionality added above.
remove_filter ( 'rocket_htaccess_etag', '__return_false');

// Flush .htaccess rules, and regenerate WP Rocket config file.
flush_wp_rocket();
}
register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate' );
Binary file not shown.

0 comments on commit 8e3650b

Please sign in to comment.