Skip to content

Commit 0ed47ce

Browse files
authored
Merge pull request #261 from wp-media/branch-2.9
Version 2.9
2 parents ea5b773 + 0431388 commit 0ed47ce

File tree

104 files changed

+20771
-13606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+20771
-13606
lines changed

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
bin export-ignore
44
phpunit.xml export-ignore
55
tests export-ignore
6-
readme.md export-ignore
6+
README.md export-ignore
7+
.gitattributes export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules/

inc/3rd-party/3rd-party.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/aelia-currencyswitcher.php' );
1919
require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/aelia-prices-by-country.php' );
2020
require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/aelia-tax-display-by-country.php' );
21+
require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/woocommerce-multilingual.php' );
2122
require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/woocommerce-currency-converter-widget.php' );
2223
require( WP_ROCKET_3RD_PARTY_PATH . 'ecommerce/edd-software-licencing.php' );
2324
require( WP_ROCKET_3RD_PARTY_PATH . 'age-verify.php' );
@@ -27,13 +28,19 @@
2728
require( WP_ROCKET_3RD_PARTY_PATH . 'wp-postratings.php' );
2829
require( WP_ROCKET_3RD_PARTY_PATH . 'wp-print.php' );
2930
require( WP_ROCKET_3RD_PARTY_PATH . 'buddypress.php' );
31+
require( WP_ROCKET_3RD_PARTY_PATH . 'disqus.php' );
3032
require( WP_ROCKET_3RD_PARTY_PATH . 'give.php' );
3133
require( WP_ROCKET_3RD_PARTY_PATH . 'custom-login.php' );
3234
require( WP_ROCKET_3RD_PARTY_PATH . 'mobile/amp.php' );
35+
require( WP_ROCKET_3RD_PARTY_PATH . 'mobile/wp-appkit.php' );
3336
require( WP_ROCKET_3RD_PARTY_PATH . 'jetpack.php' );
3437
require( WP_ROCKET_3RD_PARTY_PATH . 'yoast-seo.php' );
3538
require( WP_ROCKET_3RD_PARTY_PATH . 'all-in-one-seo-pack.php' );
3639
require( WP_ROCKET_3RD_PARTY_PATH . 'wp-rest-api.php' );
3740
require( WP_ROCKET_3RD_PARTY_PATH . 'page-builder/beaver-builder.php' );
3841
require( WP_ROCKET_3RD_PARTY_PATH . 'page-builder/thrive-visual-editor.php' );
3942
require( WP_ROCKET_3RD_PARTY_PATH . 'page-builder/visual-composer.php' );
43+
require( WP_ROCKET_3RD_PARTY_PATH . 'security/secupress.php' );
44+
require( WP_ROCKET_3RD_PARTY_PATH . 'simple-custom-css.php' );
45+
46+
require( WP_ROCKET_3RD_PARTY_PATH . 'themes/divi.php' );

inc/3rd-party/disqus.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
3+
4+
if ( defined( 'DISQUS_VERSION' ) ) :
5+
/**
6+
* Excludes Disqus scripts from JS minification
7+
*
8+
* @since 2.9
9+
* @author Remy Perona
10+
*
11+
* @param Array $excluded_handle An array of JS handles enqueued in WordPress
12+
* @return Array the updated array of handles
13+
*/
14+
add_filter( 'rocket_exclude_js', 'rocket_exclude_js_disqus' );
15+
function rocket_exclude_js_disqus( $excluded_js ) {
16+
$excluded_js[] = str_replace( home_url(), '', plugins_url( '/disqus-comment-system/media/js/disqus.js' ) );
17+
$excluded_js[] = str_replace( home_url(), '', plugins_url( '/disqus-comment-system/media/js/count.js' ) );
18+
19+
return $excluded_js;
20+
}
21+
22+
endif;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
3+
4+
// Compatibility with the currency switcher in WooCommerce Multilingual plugin
5+
if ( defined( 'WCML_VERSION' ) ) :
6+
add_action( 'wcml_switch_currency', 'rocket_clean_domain' );
7+
endif;

inc/3rd-party/ecommerce/woocommerce.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,24 @@
55

66
add_filter( 'rocket_cache_query_strings', '__rocket_cache_v_query_string' );
77
add_filter( 'update_option_woocommerce_default_customer_address', '__rocket_after_update_single_options', 10, 2 );
8+
add_action( 'woocommerce_save_product_variation', 'rocket_clean_cache_after_woocommerce_save_product_variation', 10 );
89

910
endif;
1011

12+
/**
13+
* Clean product cache on variation update
14+
*
15+
* @since 2.9
16+
* @author Remy Perona
17+
*
18+
* @param int $variation_id ID of the variation
19+
*/
20+
function rocket_clean_cache_after_woocommerce_save_product_variation( $variation_id ) {
21+
if ( $product_id = wp_get_post_parent_id( $variation_id ) ) {
22+
rocket_clean_post( $product_id );
23+
}
24+
}
25+
1126
/**
1227
* Automatically cache v query string when WooCommerce geolocation with cache compatibility option is active
1328
*

inc/3rd-party/mobile/wp-appkit.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
3+
4+
if ( class_exists( 'WpAppKit' ) ) :
5+
6+
add_filter( 'rocket_cache_reject_uri', 'rocket_add_appkit_exclude_pages' );
7+
8+
endif;
9+
10+
function rocket_add_appkit_exclude_pages( $urls ) {
11+
$urls[] = '/wp-appkit-api/(.*)';
12+
13+
return $urls;
14+
}
15+
16+
add_action( 'activate_wp-appkit/wp-appkit.php', 'rocket_activate_wp_appkit', 11 );
17+
function rocket_activate_wp_appkit() {
18+
add_filter( 'rocket_cache_reject_uri', 'rocket_add_appkit_exclude_pages' );
19+
20+
// Update the WP Rocket rules on the .htaccess
21+
flush_rocket_htaccess();
22+
23+
// Regenerate the config file
24+
rocket_generate_config_file();
25+
}
26+
27+
add_action( 'deactivate_wp-appkit/wp-appkit.php', 'rocket_deactivate_wp_appkit', 11 );
28+
function rocket_deactivate_wp_appkit() {
29+
remove_filter( 'rocket_cache_reject_uri', 'rocket_add_appkit_exclude_pages' );
30+
31+
// Update the WP Rocket rules on the .htaccess
32+
flush_rocket_htaccess();
33+
34+
// Regenerate the config file
35+
rocket_generate_config_file();
36+
}

inc/3rd-party/page-builder/beaver-builder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
function __rocket_beaver_builder_clean_domain() {
1313
rocket_clean_minify();
1414
rocket_clean_domain();
15+
rocket_clean_cache_busting();
1516
}
1617

1718
endif;
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
3+
4+
add_action( 'update_option_secupress_users-login_settings', '__rocket_after_update_single_options', 10, 2 );
5+
6+
7+
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_secupress_move_login' );
8+
9+
function rocket_exclude_secupress_move_login( $urls ) {
10+
if ( ! function_exists( 'secupress_move_login_get_slugs' ) ) {
11+
return $urls;
12+
}
13+
14+
$bases = secupress_get_rewrite_bases();
15+
$slugs = secupress_move_login_get_slugs();
16+
17+
foreach ( $slugs as $slug ) {
18+
$urls[] = $bases['base'] . ltrim( $bases['site_from'], '/' ) . $slug . '/?';
19+
}
20+
21+
return $urls;
22+
}
23+
24+
25+
add_action( 'secupress.plugins.activation', 'rocket_maybe_activate_secupress', 10001 );
26+
27+
function rocket_maybe_activate_secupress() {
28+
if ( function_exists( 'secupress_move_login_get_slugs' ) ) {
29+
rocket_activate_secupress();
30+
}
31+
}
32+
33+
34+
add_action( 'secupress.plugin.move_login.activate', 'rocket_activate_secupress' );
35+
36+
function rocket_activate_secupress() {
37+
add_filter( 'rocket_cache_reject_uri', 'rocket_exclude_secupress_move_login' );
38+
39+
// Update the WP Rocket rules on the .htaccess.
40+
flush_rocket_htaccess();
41+
42+
// Regenerate the config file.
43+
rocket_generate_config_file();
44+
}
45+
46+
47+
add_action( 'secupress.deactivation', 'rocket_maybe_deactivate_secupress', 10001 );
48+
49+
function rocket_maybe_deactivate_secupress() {
50+
if ( function_exists( 'secupress_move_login_get_slugs' ) ) {
51+
rocket_deactivate_secupress();
52+
}
53+
}
54+
55+
56+
add_action( 'secupress.plugin.move_login.deactivate', 'rocket_deactivate_secupress' );
57+
58+
function rocket_deactivate_secupress() {
59+
remove_filter( 'rocket_cache_reject_uri', 'rocket_exclude_secupress_move_login' );
60+
61+
// Update the WP Rocket rules on the .htaccess.
62+
flush_rocket_htaccess();
63+
64+
// Regenerate the config file.
65+
rocket_generate_config_file();
66+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
3+
4+
if ( defined( 'SCCSS_FILE' ) ) :
5+
add_action( 'wp_enqueue_scripts', 'rocket_cache_sccss', 1 );
6+
add_action( 'update_option_sccss_settings', 'rocket_delete_sccss_cache_file' );
7+
add_filter( 'rocket_cache_busting_filename', 'rocket_sccss_cache_busting_filename' );
8+
endif;
9+
10+
/**
11+
* Caches SCCSS code & remove the default enqueued URL
12+
*
13+
* @since 2.9
14+
* @author Remy Perona
15+
*/
16+
function rocket_cache_sccss() {
17+
$sccss = rocket_get_cache_busting_paths( 'sccss.css', 'css' );
18+
19+
if ( ! file_exists( $sccss['filepath'] ) ) {
20+
rocket_sccss_create_cache_file( $sccss['bustingpath'], $sccss['filepath'] );
21+
}
22+
23+
wp_enqueue_style( 'scss', $sccss['url'] );
24+
remove_action( 'wp_enqueue_scripts', 'sccss_register_style', 99 );
25+
}
26+
27+
/**
28+
* Deletes & recreates cache for SCCSS code
29+
*
30+
* @since 2.9
31+
* @author Remy Perona
32+
*/
33+
function rocket_delete_sccss_cache_file() {
34+
$sccss = rocket_get_cache_busting_paths( 'sccss.css', 'css' );
35+
36+
@unlink( $sccss['filepath'] );
37+
rocket_sccss_create_cache_file( $sccss['bustingpath'], $sccss['filepath'] );
38+
}
39+
40+
/**
41+
* Returns the filename for SCSSS cache file
42+
*
43+
* @since 2.9
44+
* @author Remy Perona
45+
*
46+
* @param string $filename filename.
47+
* @return string filename
48+
*/
49+
function rocket_sccss_cache_busting_filename( $filename ) {
50+
if ( false !== strpos( $filename, 'sccss' ) ) {
51+
return 'sccss.css';
52+
}
53+
54+
return $filename;
55+
}
56+
57+
/**
58+
* Creates the cache file for SCCSS code
59+
*
60+
* @since 2.9
61+
* @author Remy Perona
62+
*
63+
* @param string $cache_busting_path Path to the cache busting directory.
64+
* @param string $cache_sccss_filepath Path to the sccss cache file.
65+
*/
66+
function rocket_sccss_create_cache_file( $cache_busting_path, $cache_sccss_filepath ) {
67+
$options = get_option( 'sccss_settings' );
68+
$raw_content = isset( $options['sccss-content'] ) ? $options['sccss-content'] : '';
69+
$content = wp_kses( $raw_content, array( '\'', '\"' ) );
70+
$content = str_replace( '&gt;', '>', $content );
71+
72+
if ( ! is_dir( $cache_busting_path ) ) {
73+
rocket_mkdir_p( $cache_busting_path );
74+
}
75+
76+
rocket_put_content( $cache_sccss_filepath, $content );
77+
}

0 commit comments

Comments
 (0)