Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.14.3 release #6083

Merged
merged 18 commits into from Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/deploy_dynamic_lists_fallback.yml
Expand Up @@ -51,6 +51,26 @@ jobs:
commit_message: update dynamic lists
commit_user_name: WP Media GitHub Actions Bot

- name: get latest incompatible plugins lists
id: getIncompatiblePluginsLists
run: |
echo "::set-output name=lists::$(curl -s https://b.rucss.wp-rocket.me/api/incompatible-plugins/list)"

- name: Save IncompatiblePlugins Lists
id: saveIncompatiblePluginsLists
uses: jsdaniell/create-json@1.1.2
with:
name: "dynamic-lists-incompatible-plugins.json"
json: ${{ steps.getIncompatiblePluginsLists.outputs.lists }}
dir: '/'

- name: Commit IncompatiblePlugins JSON file
if: ${{ steps.saveIncompatiblePluginsLists.outcome == 'success' }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: update incompatible plugins dynamic lists
commit_user_name: WP Media GitHub Actions Bot

- name: get latest DelayJS lists
id: getDynamicDelayJSLists
run: |
Expand Down
2 changes: 1 addition & 1 deletion dynamic-lists-delayjs.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dynamic-lists-incompatible-plugins.json
@@ -0,0 +1 @@
{"":[{"slug":"wp-super-cache","file":"wp-super-cache\/wp-cache.php"},{"slug":"enable-gzip-compression","file":"enable-gzip-compression\/enable-gzip-compression.php"},{"slug":"quick-cache","file":"quick-cache\/quick-cache.php"},{"slug":"leverage-browser-caching-ninjas","file":"leverage-browser-caching-ninjas\/leverage-browser-caching-ninja.php"},{"slug":"wp-performance-score-booster","file":"wp-performance-score-booster\/wp-performance-score-booster.php"},{"slug":"litespeed-cache","file":"litespeed-cache\/litespeed-cache.php"},{"slug":"remove-query-strings-from-static-resources","file":"remove-query-strings-from-static-resources\/remove-query-strings.php"},{"slug":"wp-http-compression","file":"wp-http-compression\/wp-http-compression.php"},{"slug":"query-strings-remover","file":"query-strings-remover\/query-strings-remover.php"},{"slug":"page-optimize","file":"page-optimize\/page-optimize.php"},{"slug":"speed-booster-pack","file":"speed-booster-pack\/speed-booster-pack.php"},{"slug":"swift-performance","file":"swift-performance\/performance.php"},{"slug":"gzip-ninja-speed-compression","file":"gzip-ninja-speed-compression\/gzip-ninja-speed.php"},{"slug":"super-static-cache","file":"super-static-cache\/super-static-cache.php"},{"slug":"lite-cache","file":"lite-cache\/plugin.php"},{"slug":"hyper-cache","file":"hyper-cache\/plugin.php"},{"slug":"wp-ffpc","file":"wp-ffpc\/wp-ffpc.php"},{"slug":"wp-fast-cache","file":"wp-fast-cache\/wp-fast-cache.php"},{"slug":"psn-pagespeed-ninja","file":"psn-pagespeed-ninja\/pagespeedninja.php"},{"slug":"swift-performance-lite","file":"swift-performance-lite\/performance.php"},{"slug":"force-gzip","file":"force-gzip\/force-gzip.php"},{"slug":"add-expires-headers","file":"add-expires-headers\/add-expires-headers.php"},{"slug":"hyper-cache-extended","file":"hyper-cache-extended\/plugin.php"},{"slug":"gator-cache","file":"gator-cache\/gator-cache.php"},{"slug":"flexicache","file":"flexicache\/wp-plugin.php"},{"slug":"wp-fastest-cache","file":"wp-fastest-cache\/wpFastestCache.php"},{"slug":"wordpress-gzip-compression","file":"wordpress-gzip-compression\/ezgz.php"},{"slug":"wp-optimize","file":"wp-optimize\/wp-optimize.php"},{"slug":"check-and-enable-gzip-compression","file":"check-and-enable-gzip-compression\/richards-toolbox.php"},{"slug":"far-future-expiry-header","file":"far-future-expiry-header\/far-future-expiration.php"},{"slug":"leverage-browser-caching","file":"leverage-browser-caching\/leverage-browser-caching.php"},{"slug":"wpcompressor","file":"wpcompressor\/wpcompressor.php"},{"slug":"combine-css","file":"combine-css\/combine-css.php"},{"slug":"w3-total-cache","file":"w3-total-cache\/w3-total-cache.php"},{"slug":"cache-enabler","file":"cache-enabler\/cache-enabler.php"}],"minify_css||minify_js":[{"slug":"merge-minify-refresh","file":"merge-minify-refresh\/merge-minify-refresh.php"},{"slug":"async-js-and-css","file":"async-js-and-css\/asyncJSandCSS.php"},{"slug":"wp-super-minify","file":"wp-super-minify\/wp-super-minify.php"},{"slug":"fast-velocity-minify","file":"fast-velocity-minify\/fvm.php"},{"slug":"dependency-minification","file":"dependency-minification\/dependency-minification.php"},{"slug":"bwp-minify","file":"bwp-minify\/bwp-minify.php"},{"slug":"minqueue","file":"minqueue\/plugin.php"},{"slug":"scripts-gzip","file":"scripts-gzip\/scripts_gzip.php"},{"slug":"wp-minify","file":"wp-minify\/wp-minify.php"}],"lazyload":[{"slug":"lazy-load","file":"lazy-load\/lazy-load.php"},{"slug":"bj-lazy-load","file":"bj-lazy-load\/bj-lazy-load.php"},{"slug":"jquery-image-lazy-loading","file":"jquery-image-lazy-loading\/jq_img_lazy_load.php"},{"slug":"crazy-lazy","file":"crazy-lazy\/crazy-lazy.php"},{"slug":"specify-image-dimensions","file":"specify-image-dimensions\/specify-image-dimensions.php"},{"slug":"advanced-lazy-load","file":"advanced-lazy-load\/advanced_lazyload.php"}],"minify_js":[{"slug":"wp-js","file":"wp-js\/wp-js.php"},{"slug":"scripts-to-footerphp","file":"scripts-to-footerphp\/scripts-to-footer.php"},{"slug":"combine-js","file":"combine-js\/combine-js.php"},{"slug":"footer-javascript","file":"footer-javascript\/footer-javascript.php"}],"control_heartbeat":[{"slug":"heartbeat-control","file":"heartbeat-control\/heartbeat-control.php"}],"lazyload_iframes":[{"slug":"lazy-load-for-videos","file":"lazy-load-for-videos\/codeispoetry.php"}]}
2 changes: 1 addition & 1 deletion dynamic-lists.json

Large diffs are not rendered by default.

13 changes: 4 additions & 9 deletions inc/Engine/Activation/Activation.php
Expand Up @@ -91,14 +91,9 @@ public static function activate_plugin() {
]
);

wp_remote_get(
home_url(),
[
'timeout' => 0.01,
'blocking' => false,
'user-agent' => 'WP Rocket/Homepage Preload',
'sslverify' => apply_filters( 'https_local_ssl_verify', false ), // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
]
);
/**
* Fires after WP Rocket is activated
*/
do_action( 'rocket_after_activation' );
}
}
11 changes: 11 additions & 0 deletions inc/Engine/Optimization/DynamicLists/DynamicLists.php
Expand Up @@ -264,4 +264,15 @@ public function get_js_exclude_files(): array {

return isset( $lists->exclude_js_files ) ? $lists->exclude_js_files : [];
}

/**
* Get the incompatible plugins list
*
* @return array
*/
public function get_incompatible_plugins() {
$lists = $this->providers['incompatible_plugins']->data_manager->get_plugins_list();

return isset( $lists ) ? $lists : [];
}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);

namespace WP_Rocket\Engine\Optimization\DynamicLists\IncompatiblePluginsLists;

use WP_Rocket\Engine\Optimization\DynamicLists\AbstractAPIClient;

class APIClient extends AbstractAPIClient {

/**
* Specify API endpoint path.
*
* @return string
*/
protected function get_api_path() {
return 'incompatible-plugins/list';
}

}
@@ -0,0 +1,85 @@
<?php
declare(strict_types=1);

namespace WP_Rocket\Engine\Optimization\DynamicLists\IncompatiblePluginsLists;

use WP_Rocket\Admin\Options_Data;
use WP_Rocket\Engine\Optimization\DynamicLists\AbstractDataManager;

class DataManager extends AbstractDataManager {

/**
* Plugin options instance.
*
* @var Options_Data
*/
private $options;

/**
* Instantiate the class.
*
* @param Options_Data $options Options instance.
*/
public function __construct( Options_Data $options ) {
parent::__construct();
$this->options = $options;
}
/**
* Get cache transient name.
*
* @return string
*/
protected function get_cache_transient_name() {
return 'wpr_dynamic_lists_incompatible_plugins';
}

/**
* Get lists json filename.
*
* @return string
*/
protected function get_json_filename() {
return 'dynamic-lists-incompatible-plugins';
}

/**
* Gets the plugins list content
*
* @return array
*/
public function get_plugins_list() {
$lists = [];
$list_from_json = $this->get_lists();
foreach ( $list_from_json as $conditions => $list ) {
if ( $this->meet_conditions( $conditions ) ) {
$list = array_column( $list, 'file', 'slug' );
$lists = array_merge( $lists, $list );
}
}
return $lists;
}

/**
* Check if the condition is meet based on plugin option and condition string.
* If $conditions contain "||" split and treat it like or
*
* @param string $conditions condition.
*
* @return bool
*/
private function meet_conditions( $conditions = '' ) {
if ( empty( $conditions ) ) {
return true;
}

$conditions = explode( '||', $conditions );

foreach ( $conditions as $condition ) {
if ( $this->options->get( trim( $condition ), false ) ) {
return true;
}
}
return false;
}

}
18 changes: 16 additions & 2 deletions inc/Engine/Optimization/DynamicLists/ServiceProvider.php
Expand Up @@ -7,6 +7,8 @@
use WP_Rocket\Engine\Optimization\DynamicLists\DefaultLists\DataManager as DefaultListsDataManager;
use WP_Rocket\Engine\Optimization\DynamicLists\DelayJSLists\APIClient as DelayJSListsAPIClient;
use WP_Rocket\Engine\Optimization\DynamicLists\DelayJSLists\DataManager as DelayJSListsDataManager;
use WP_Rocket\Engine\Optimization\DynamicLists\IncompatiblePluginsLists\DataManager as IncompatiblePluginsListsDataManager;
use WP_Rocket\Engine\Optimization\DynamicLists\IncompatiblePluginsLists\APIClient as IncompatiblePluginsListsAPIClient;

/**
* Service provider for the WP Rocket DynamicLists
Expand All @@ -27,6 +29,8 @@ class ServiceProvider extends AbstractServiceProvider {
'dynamic_lists_defaultlists_api_client',
'dynamic_lists_delayjslists_data_manager',
'dynamic_lists_delayjslists_api_client',
'dynamic_lists_incompatible_plugins_lists_data_manager',
'dynamic_lists_incompatible_plugins_lists_api_client',
'dynamic_lists',
'dynamic_lists_subscriber',
];
Expand All @@ -43,20 +47,30 @@ public function register() {
$this->getContainer()->add( 'dynamic_lists_delayjslists_data_manager', DelayJSListsDataManager::class );
$this->getContainer()->add( 'dynamic_lists_delayjslists_api_client', DelayJSListsAPIClient::class )
->addArgument( $this->getContainer()->get( 'options' ) );
$this->getContainer()->add( 'dynamic_lists_incompatible_plugins_lists_data_manager', IncompatiblePluginsListsDataManager::class )
->addArgument( $this->getContainer()->get( 'options' ) );
$this->getContainer()->add( 'dynamic_lists_incompatible_plugins_lists_api_client', IncompatiblePluginsListsAPIClient::class )
->addArgument( $this->getContainer()->get( 'options' ) );

$providers = [
'defaultlists' =>
'defaultlists' =>
(object) [
'api_client' => $this->getContainer()->get( 'dynamic_lists_defaultlists_api_client' ),
'data_manager' => $this->getContainer()->get( 'dynamic_lists_defaultlists_data_manager' ),
'title' => __( 'Default Lists', 'rocket' ),
],
'delayjslists' =>
'delayjslists' =>
(object) [
'api_client' => $this->getContainer()->get( 'dynamic_lists_delayjslists_api_client' ),
'data_manager' => $this->getContainer()->get( 'dynamic_lists_delayjslists_data_manager' ),
'title' => __( 'Delay JavaScript Execution Exclusion Lists', 'rocket' ),
],
'incompatible_plugins' =>
(object) [
'api_client' => $this->getContainer()->get( 'dynamic_lists_incompatible_plugins_lists_api_client' ),
'data_manager' => $this->getContainer()->get( 'dynamic_lists_incompatible_plugins_lists_data_manager' ),
'title' => __( 'Incompatible plugins Lists', 'rocket' ),
],
];

$this->getContainer()->add( 'dynamic_lists', DynamicLists::class )
Expand Down
12 changes: 12 additions & 0 deletions inc/Engine/Optimization/DynamicLists/Subscriber.php
Expand Up @@ -41,6 +41,7 @@ public static function get_subscribed_events() {
'rocket_excluded_inline_js_content' => 'add_combine_js_excluded_inline',
'rocket_preload_exclude_urls' => 'add_preload_exclusions',
'rocket_exclude_js' => 'add_js_exclude_files',
'rocket_plugins_to_deactivate' => 'add_incompatible_plugins_to_deactivate',
];
}

Expand Down Expand Up @@ -189,4 +190,15 @@ public function add_js_exclude_files( $js_files = [] ): array {

return array_merge( $js_files, $this->dynamic_lists->get_js_exclude_files() );
}

/**
* Add incompatible plugins to the array
*
* @param array $plugins Array of $plugins.
*
* @return array
*/
public function add_incompatible_plugins_to_deactivate( $plugins = [] ): array {
return array_merge( (array) $plugins, $this->dynamic_lists->get_incompatible_plugins() );
}
}
33 changes: 2 additions & 31 deletions inc/Engine/Optimization/RUCSS/Admin/Subscriber.php
Expand Up @@ -211,16 +211,6 @@ public function truncate_used_css() {

$this->delete_used_css_rows();
$this->set_notice_transient();

wp_safe_remote_get(
home_url(),
[
'timeout' => 0.01,
'blocking' => false,
'user-agent' => 'WP Rocket/Homepage Preload',
'sslverify' => apply_filters( 'https_local_ssl_verify', false ), // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
]
);
}

/**
Expand Down Expand Up @@ -331,9 +321,10 @@ public function truncate_used_css_handler() {
rocket_get_constant( 'WP_ROCKET_IS_TESTING', false ) ? wp_die() : exit;
}

rocket_clean_domain();

$this->delete_used_css_rows();

rocket_clean_domain();
rocket_dismiss_box( 'rocket_warning_plugin_modification' );

set_transient(
Expand All @@ -350,16 +341,6 @@ public function truncate_used_css_handler() {

$this->set_notice_transient();

wp_remote_get(
home_url(),
[
'timeout' => 0.01,
'blocking' => false,
'user-agent' => 'WP Rocket/Homepage Preload',
'sslverify' => apply_filters( 'https_local_ssl_verify', false ), // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
]
);

wp_safe_redirect( esc_url_raw( wp_get_referer() ) );
rocket_get_constant( 'WP_ROCKET_IS_TESTING', false ) ? wp_die() : exit;
}
Expand Down Expand Up @@ -579,16 +560,6 @@ public function set_option_on_update( $new_version, $old_version ) {
$this->database->truncate_used_css_table();
rocket_clean_domain();
$this->set_notice_transient();

wp_safe_remote_get(
home_url(),
[
'timeout' => 0.01,
'blocking' => false,
'user-agent' => 'WP Rocket/Homepage Preload',
'sslverify' => apply_filters( 'https_local_ssl_verify', false ), // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
]
);
}

/**
Expand Down