This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WP Rocket clean post cache after WC order | |
* Description: Clean the cache for each product ordered after a completed WooCommerce order | |
* Author: WP Rocket team | |
* License: GNU General Public License v3 or later | |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html | |
*/ | |
// Basic security, prevents file from being loaded directly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user_agent = $_SERVER['HTTP_USER_AGENT']; | |
if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'WP-Rocket' ) === false ) { | |
if ( strpos( $_SERVER['HTTP_X_ROCKET'], 'WP-Rocket' ) === false ) { | |
die( 'BAD_UA_XR: ' . ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? htmlspecialchars( $_SERVER['HTTP_USER_AGENT'] ) : 'not set' ) . ' & ' . ( isset( $_SERVER['HTTP_X_ROCKET'] ) ? htmlspecialchars( $_SERVER['HTTP_X_ROCKET'] ) : 'not set' ) ); | |
} | |
$user_agent = $_SERVER['HTTP_X_ROCKET']; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( function( $ ) { | |
wp.customizerCtrlEditor = { | |
init: function() { | |
$(window).load(function(){ | |
$('textarea.wp-editor-area').each(function(){ | |
var tArea = $(this), | |
id = tArea.attr('id'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function register_theme_customizer() { | |
$wp_customize->add_section( 'editor', array( | |
'title' => 'Editeur', | |
'description' => 'Editeur TinyMCE', | |
'priority' => 300 | |
) ); | |
$wp_customize->add_setting( 'theme[editor_content]', array( | |
'default' => '', | |
'transport' => 'postMessage', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Text_Editor_Custom_Control extends WP_Customize_Control | |
{ | |
public $type = 'textarea'; | |
/** | |
** Render the content on the theme customizer page | |
*/ | |
public function render_content() { ?> | |
<label> | |
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> | |
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exclude page from cache but keep optimizations. | |
add_action( 'wp_rocket_loaded', function() { | |
// Exclude post type with ID = 1. | |
if ( is_single(1) ) { | |
add_filter( 'do_rocket_generate_caching_files', '__return_false' ); | |
} | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wp_rocket_loaded', function() { | |
add_action( 'clean_post_cache', function( $post_id ) { | |
rocket_clean_domain(); | |
} ); | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'rocket_htaccess_files_match', function( $rules ) { | |
$rules = '<IfModule mod_alias.c>' . PHP_EOL; | |
$rules .= '<FilesMatch "\.(html|htm|rtf|rtx|txt|xsd|xsl|xml)$">' . PHP_EOL; | |
$rules .= '<IfModule mod_headers.c>' . PHP_EOL; | |
$rules .= 'Header unset Pragma' . PHP_EOL; | |
$rules .= 'Header append Cache-Control "public"' . PHP_EOL; | |
$rules .= 'Header unset Last-Modified' . PHP_EOL; | |
$rules .= '</IfModule>' . PHP_EOL; | |
$rules .= '</FilesMatch>' . PHP_EOL . PHP_EOL; | |
$rules .= '<FilesMatch "\.(css|htc|js|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$">' . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'rocket_cache_mobile_files_tablet', function( $version ) { | |
return 'mobile'; | |
} ); |
NewerOlder