' . implode( '
', $errors ) . '
';
+ echo wp_kses_post( $notice );
+
+ // Remove transient after displaying notice.
+ delete_transient( $this->error_transient );
+ }
+
+ /**
+ * Store an error message in a transient then redirect.
+ *
+ * @param object $error A WP_Error object.
+ * @return void
+ */
+ private function set_error( $error ) {
+ set_transient( $this->error_transient, $error, 30 );
+
+ wp_safe_redirect( wp_get_referer() );
+ exit;
+ }
+}
diff --git a/inc/Dependencies/WPMedia/PluginFamily/Controller/PluginFamilyInterface.php b/inc/Dependencies/WPMedia/PluginFamily/Controller/PluginFamilyInterface.php
new file mode 100644
index 0000000000..621a9bbe96
--- /dev/null
+++ b/inc/Dependencies/WPMedia/PluginFamily/Controller/PluginFamilyInterface.php
@@ -0,0 +1,19 @@
+ 'imagify',
+ 'seo-by-rank-math' => '',
+ 'backwpup' => '',
+ 'uk-cookie-consent' => '',
+ ];
+
+ /**
+ * Get filtered plugins.
+ *
+ * @param string $main_plugin Main plugin installed.
+ *
+ * @return array
+ */
+ public function get_filtered_plugins( string $main_plugin ): array {
+ $plugins = require_once 'wp_media_plugins.php';
+
+ return $this->filter_plugins_by_activation( $plugins, $main_plugin );
+ }
+
+ /**
+ * Filter plugins family data by activation status and returns both categorized and uncategorized format.
+ *
+ * @param array $plugins Array of family plugins.
+ * @param string $main_plugin Main plugin installed.
+ *
+ * @return array
+ */
+ public function filter_plugins_by_activation( array $plugins, string $main_plugin ): array {
+ if ( empty( $plugins ) ) {
+ return [];
+ }
+
+ list( $active_plugins, $inactive_plugins ) = [ [], [] ];
+
+ foreach ( $plugins as $cat => $cat_data ) {
+ foreach ( $cat_data['plugins'] as $plugin => $data ) {
+
+ $plugin_path = $plugin . '.php';
+ $plugin_slug = dirname( $plugin );
+ $main_plugin_slug = dirname( $main_plugin );
+ $wpr_referrer = 'wp-rocket' !== $main_plugin_slug ? $this->wp_rocket_referrer[ $main_plugin_slug ] : '';
+
+ /**
+ * Check for activated plugins and pop them out of the array
+ * to re-add them back using array_merge to be displayed after
+ * plugins that are not installed or not activated.
+ */
+ if ( is_plugin_active( $plugin_path ) && $main_plugin . '.php' !== $plugin_path ) {
+ // set cta data of active plugins.
+ $plugins[ $cat ]['plugins'][ $plugin ]['cta'] = [
+ 'text' => 'Activated',
+ 'url' => '#',
+ ];
+
+ // Send active plugin to new array.
+ $active_plugins[ $plugin ] = $plugins[ $cat ]['plugins'][ $plugin ];
+
+ // Remove active plugin from current category.
+ $active_plugin = $plugins[ $cat ]['plugins'][ $plugin ];
+ unset( $plugins[ $cat ]['plugins'][ $plugin ] );
+
+ // Send active plugin to the end of array in current category.
+ $plugins[ $cat ]['plugins'][ $plugin ] = $active_plugin;
+
+ // Remove category with active plugin from current array.
+ $active_cat = $plugins[ $cat ];
+ unset( $plugins[ $cat ] );
+
+ // Send category with active plugins to the end of array.
+ $plugins[ $cat ] = $active_cat;
+ continue;
+ }
+
+ $install_activate_url = admin_url( 'admin-post.php' );
+
+ $args = [
+ 'action' => 'plugin_family_install_' . $plugin_slug,
+ '_wpnonce' => wp_create_nonce( 'plugin_family_install_' . $plugin_slug ),
+ 'plugin_to_install' => rawurlencode( $plugin ),
+ ];
+
+ if ( 'imagify' === $plugin_slug ) {
+ $args = [
+ 'action' => 'install_imagify_from_partner_' . $main_plugin_slug,
+ '_wpnonce' => wp_create_nonce( 'install_imagify_from_partner' ),
+ '_wp_http_referer' => rawurlencode( $this->get_current_url() ),
+ ];
+ }
+
+ $install_activate_url = add_query_arg( $args, $install_activate_url );
+
+ // Set Installation link.
+ $plugins[ $cat ]['plugins'][ $plugin ]['cta'] = [
+ 'text' => 'Install',
+ 'url' => $install_activate_url,
+ ];
+
+ // Create unique CTA data for WP Rocket.
+ if ( 'wp-rocket/wp-rocket' === $plugin ) {
+ $url = 'https://wp-rocket.me/?utm_source=' . $wpr_referrer . '-coupon&utm_medium=plugin&utm_campaign=' . $wpr_referrer;
+
+ $plugins[ $cat ]['plugins'][ $plugin ]['cta'] = [
+ 'text' => 'Get it Now',
+ 'url' => $url,
+ ];
+
+ $plugins[ $cat ]['plugins'][ $plugin ]['link'] = $url;
+ }
+
+ // Set activation text.
+ if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_path ) ) {
+ $plugins[ $cat ]['plugins'][ $plugin ]['cta']['text'] = 'Activate';
+
+ if ( 'wp-rocket/wp-rocket' === $plugin ) {
+ $plugins[ $cat ]['plugins'][ $plugin ]['cta']['url'] = $install_activate_url;
+ }
+ }
+
+ // Send inactive plugins to new array.
+ $inactive_plugins[ $plugin ] = $plugins[ $cat ]['plugins'][ $plugin ];
+ }
+
+ // Remove main plugin from categorized array.
+ if ( isset( $plugins[ $cat ]['plugins'][ $main_plugin ] ) ) {
+ unset( $plugins[ $cat ]['plugins'][ $main_plugin ] );
+ }
+ }
+
+ $uncategorized = array_merge( $inactive_plugins, $active_plugins );
+ // Remove main plugin from uncategorized array.
+ unset( $uncategorized[ $main_plugin ] );
+
+ return [
+ 'categorized' => $plugins,
+ 'uncategorized' => $uncategorized,
+ ];
+ }
+
+ /**
+ * Get the current URL.
+ * Gotten from Imagify_Partner Package.
+ *
+ * @return string
+ */
+ protected function get_current_url(): string {
+ if ( ! isset( $_SERVER['SERVER_PORT'], $_SERVER['HTTP_HOST'] ) ) {
+ return '';
+ }
+
+ $port = (int) wp_unslash( $_SERVER['SERVER_PORT'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
+ $port = 80 !== $port && 443 !== $port ? ( ':' . $port ) : '';
+ $url = ! empty( $GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI'] ) ? $GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI'] : ( ! empty( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
+
+ return 'http' . ( is_ssl() ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST'] . $port . $url; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
+ }
+}
diff --git a/inc/Dependencies/WPMedia/PluginFamily/Model/wp_media_plugins.php b/inc/Dependencies/WPMedia/PluginFamily/Model/wp_media_plugins.php
new file mode 100644
index 0000000000..e1a1e296db
--- /dev/null
+++ b/inc/Dependencies/WPMedia/PluginFamily/Model/wp_media_plugins.php
@@ -0,0 +1,67 @@
+ [
+ 'title' => 'Optimize Performance',
+ 'plugins' => [
+ 'wp-rocket/wp-rocket' => [
+ 'logo' => [
+ 'file' => 'logo-wp-rocket.svg',
+ 'width' => '50%',
+ ],
+ 'title' => 'Speed Up Your Website, Instantly',
+ 'desc' => 'WP Rocket is the easiest way to make your WordPress website faster and boost your Google PageSpeed score. Get more traffic, better engagement, and higher conversions effortlessly.',
+ 'link' => '',
+ ],
+ 'imagify/imagify' => [
+ 'logo' => [
+ 'file' => 'logo-imagify.svg',
+ 'width' => '50%',
+ ],
+ 'title' => 'Speed Up Your Website With Lighter Images',
+ 'desc' => 'Imagify is the easiest WordPress image optimizer. It automatically compresses images, converts them to WebP and AVIF formats, and lets you resize and optimize with just one click!',
+ 'link' => 'https://imagify.io/',
+ ],
+ ],
+ ],
+ 'boost_traffic' => [
+ 'title' => 'Boost Traffic',
+ 'plugins' => [
+ 'seo-by-rank-math/rank-math' => [
+ 'logo' => [
+ 'file' => 'logo-rank-math.svg',
+ 'width' => '60%',
+ ],
+ 'title' => 'The Swiss Army Knife of SEO Tools',
+ 'desc' => 'Rank Math SEO is the Best WordPress SEO plugin with the features of many SEO and AI SEO tools in a single package to help multiply your SEO traffic.',
+ 'link' => 'https://rankmath.com/wordpress/plugin/seo-suite/',
+ ],
+ ],
+ ],
+ 'protect_secure' => [
+ 'title' => 'Protect & Secure',
+ 'plugins' => [
+ 'backwpup/backwpup' => [
+ 'logo' => [
+ 'file' => 'logo-backwpup.svg',
+ 'width' => '60%',
+ ],
+ 'title' => 'The Easiest Way to Protect Your Website',
+ 'desc' => 'BackWPup is the most comprehensive and user-friendly backup & restore plugin for WordPress. Easily schedule automatic backups, securely store and restore with just a few clicks!',
+ 'link' => 'https://backwpup.com/',
+ ],
+ 'uk-cookie-consent/uk-cookie-consent' => [
+ 'logo' => [
+ 'file' => 'logo-termly.svg',
+ 'width' => '50%',
+ ],
+ 'title' => 'GDPR/CCPA Cookie Consent Banner',
+ 'desc' => 'One of the easiest, most comprehensive, and popular cookie consent plugins available. Google Gold Certified Partner to quickly comply with data privacy laws from around the world.',
+ 'link' => 'https://termly.io/resources/articles/wordpress-cookies-guide/',
+ ],
+ ],
+ ],
+];
diff --git a/inc/Engine/Admin/Database/OptimizationProcess.php b/inc/Engine/Admin/Database/OptimizationProcess.php
index a901588a41..bfd0f7c2c6 100644
--- a/inc/Engine/Admin/Database/OptimizationProcess.php
+++ b/inc/Engine/Admin/Database/OptimizationProcess.php
@@ -124,7 +124,7 @@ protected function task( $item ) {
}
break;
case 'database_optimize_tables':
- $query = $wpdb->get_results( "SELECT table_name, data_free FROM information_schema.tables WHERE table_schema = '" . DB_NAME . "' and Engine <> 'InnoDB' and data_free > 0" );
+ $query = $wpdb->get_results( "SELECT table_name AS table_name, data_free AS data_free FROM information_schema.tables WHERE table_schema = '" . DB_NAME . "' and Engine <> 'InnoDB' and data_free > 0" );
if ( $query ) {
$number = 0;
foreach ( $query as $table ) {
diff --git a/inc/Engine/Admin/Settings/Render.php b/inc/Engine/Admin/Settings/Render.php
index 7650b99ac0..24aef63bb5 100644
--- a/inc/Engine/Admin/Settings/Render.php
+++ b/inc/Engine/Admin/Settings/Render.php
@@ -3,6 +3,7 @@
use stdClass;
use WP_Rocket\Abstract_Render;
+use WP_Rocket\Dependencies\WPMedia\PluginFamily\Model\PluginFamily;
defined( 'ABSPATH' ) || exit;
@@ -31,6 +32,26 @@ class Render extends Abstract_render {
*/
private $hidden_settings;
+ /**
+ * Plugin family
+ *
+ * @var PluginFamily
+ *
+ * @since 3.17.2
+ */
+ protected $plugin_family;
+
+ /**
+ * Creates an instance of the object.
+ *
+ * @param string $template_path Template path.
+ * @param PluginFamily $plugin_family Plugin Family Instance.
+ */
+ public function __construct( string $template_path, PluginFamily $plugin_family ) {
+ parent::__construct( $template_path );
+ $this->plugin_family = $plugin_family;
+ }
+
/**
* Sets the settings value.
*
@@ -194,6 +215,19 @@ public function render_tools_section() {
echo $this->generate( 'page-sections/tools' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Dynamic content is properly escaped in the view.
}
+ /**
+ * Render the plugins page section.
+ *
+ * @since 3.17.2
+ */
+ public function render_plugin_section() {
+ $plugin_family = $this->plugin_family->get_filtered_plugins( 'wp-rocket/wp-rocket' );
+
+ $data = $plugin_family['categorized'];
+
+ echo $this->generate( 'page-sections/plugins', $data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Dynamic content is properly escaped in the view.
+ }
+
/**
* Renders the settings sections for a page section.
*
diff --git a/inc/Engine/Admin/Settings/ServiceProvider.php b/inc/Engine/Admin/Settings/ServiceProvider.php
index 7e2aeb9de2..20a287010c 100644
--- a/inc/Engine/Admin/Settings/ServiceProvider.php
+++ b/inc/Engine/Admin/Settings/ServiceProvider.php
@@ -2,6 +2,8 @@
namespace WP_Rocket\Engine\Admin\Settings;
use WP_Rocket\Dependencies\League\Container\ServiceProvider\AbstractServiceProvider;
+use WP_Rocket\Dependencies\WPMedia\PluginFamily\Model\PluginFamily as PluginFamilyModel;
+use WP_Rocket\Dependencies\WPMedia\PluginFamily\Controller\PluginFamily as PluginFamilyController;
/**
* Service provider for the WP Rocket settings.
@@ -36,10 +38,18 @@ public function provides( string $id ): bool {
* @return void
*/
public function register(): void {
+ $this->getContainer()->add( 'plugin_family_model', PluginFamilyModel::class );
+ $this->getContainer()->add( 'plugin_family_controller', PluginFamilyController::class );
+
$this->getContainer()->add( 'settings', Settings::class )
->addArgument( $this->getContainer()->get( 'options' ) );
$this->getContainer()->add( 'settings_render', Render::class )
- ->addArgument( $this->getContainer()->get( 'template_path' ) . '/settings' );
+ ->addArguments(
+ [
+ $this->getContainer()->get( 'template_path' ) . '/settings',
+ 'plugin_family_model',
+ ]
+ );
$this->getContainer()->add( 'settings_page', Page::class )
->addArgument( $this->getContainer()->get( 'settings_page_config' ) )
->addArgument( $this->getContainer()->get( 'settings' ) )
@@ -51,6 +61,11 @@ public function register(): void {
->addArgument( $this->getContainer()->get( 'template_path' ) )
->addArgument( $this->getContainer()->get( 'options' ) );
$this->getContainer()->addShared( 'settings_page_subscriber', Subscriber::class )
- ->addArgument( $this->getContainer()->get( 'settings_page' ) );
+ ->addArguments(
+ [
+ $this->getContainer()->get( 'settings_page' ),
+ 'plugin_family_controller',
+ ]
+ );
}
}
diff --git a/inc/Engine/Admin/Settings/Subscriber.php b/inc/Engine/Admin/Settings/Subscriber.php
index 0b649596e5..b66fc12dd1 100644
--- a/inc/Engine/Admin/Settings/Subscriber.php
+++ b/inc/Engine/Admin/Settings/Subscriber.php
@@ -3,6 +3,7 @@
use Imagify_Partner;
use WP_Rocket\Event_Management\Subscriber_Interface;
+use WP_Rocket\Dependencies\WPMedia\PluginFamily\Controller\{ PluginFamily, PluginFamilyInterface };
/**
* WP Rocket settings page subscriber.
@@ -10,7 +11,7 @@
* @since 3.5.5 Moves into the new architecture.
* @since 3.3
*/
-class Subscriber implements Subscriber_Interface {
+class Subscriber implements Subscriber_Interface, PluginFamilyInterface {
/**
* Page instance
*
@@ -18,13 +19,24 @@ class Subscriber implements Subscriber_Interface {
*/
private $page;
+ /**
+ * PluginFamily instance
+ *
+ * @var PluginFamily
+ *
+ * @since 3.17.2
+ */
+ protected $plugin_family;
+
/**
* Creates an instance of the object.
*
- * @param Page $page Page instance.
+ * @param Page $page Page instance.
+ * @param PluginFamily $plugin_family Plugin Family Instance.
*/
- public function __construct( Page $page ) {
- $this->page = $page;
+ public function __construct( Page $page, PluginFamily $plugin_family ) {
+ $this->page = $page;
+ $this->plugin_family = $plugin_family;
}
/**
@@ -35,7 +47,7 @@ public function __construct( Page $page ) {
* @return array
*/
public static function get_subscribed_events() {
- return [
+ $events = [
'admin_menu' => 'add_admin_page',
'admin_init' => 'configure',
'wp_ajax_rocket_refresh_customer_data' => 'refresh_customer_data',
@@ -44,6 +56,7 @@ public static function get_subscribed_events() {
[ 'add_menu_tools_page' ],
[ 'add_imagify_page', 9 ],
[ 'add_tutorials_page', 11 ],
+ [ 'add_plugins_page', 12 ],
],
'admin_enqueue_scripts' => [
[ 'enqueue_rocket_scripts' ],
@@ -56,6 +69,8 @@ public static function get_subscribed_events() {
'wp_rocket_upgrade' => [ 'enable_separate_cache_files_mobile', 9, 2 ],
'admin_notices' => 'display_update_notice',
];
+
+ return array_merge( $events, PluginFamily::get_subscribed_events() );
}
/**
@@ -278,4 +293,40 @@ public function enable_separate_cache_files_mobile( $new_version, $old_version )
public function display_update_notice() {
$this->page->display_update_notice();
}
+
+ /**
+ * Add Plugins section to navigation.
+ *
+ * @since 3.17.2
+ *
+ * @param array $navigation Array of menu items.
+ * @return array
+ */
+ public function add_plugins_page( $navigation ) {
+ $navigation['plugins'] = [
+ 'id' => 'plugins',
+ 'title' => __( 'Our Plugins', 'rocket' ),
+ 'menu_description' => __( 'Build Better, Faster, Safer', 'rocket' ),
+ ];
+
+ return $navigation;
+ }
+
+ /**
+ * Install and activate plugin method for plugin family
+ *
+ * @return void
+ */
+ public function install_activate(): void {
+ $this->plugin_family->install_activate();
+ }
+
+ /**
+ * Display error related to plugin family
+ *
+ * @return void
+ */
+ public function display_error_notice(): void {
+ $this->plugin_family->display_error_notice();
+ }
}
diff --git a/inc/Engine/CDN/CDN.php b/inc/Engine/CDN/CDN.php
index 985e037328..ba864553d1 100644
--- a/inc/Engine/CDN/CDN.php
+++ b/inc/Engine/CDN/CDN.php
@@ -4,6 +4,7 @@
namespace WP_Rocket\Engine\CDN;
use WP_Rocket\Admin\Options_Data;
+use WP_Rocket\Engine\Support\CommentTrait;
/**
* CDN class
@@ -11,6 +12,8 @@
* @since 3.4
*/
class CDN {
+ use CommentTrait;
+
/**
* WP Rocket Options instance
*
@@ -80,7 +83,7 @@ public function rewrite( $html ) {
$html = str_replace( $match[0], $cdn_url, $html );
}
- return $html;
+ return $this->add_meta_comment( 'cdn', $html );
}
/**
diff --git a/inc/Engine/CDN/Subscriber.php b/inc/Engine/CDN/Subscriber.php
index e8a45b5320..c4eac541d4 100644
--- a/inc/Engine/CDN/Subscriber.php
+++ b/inc/Engine/CDN/Subscriber.php
@@ -45,8 +45,8 @@ public function __construct( Options_Data $options, CDN $cdn ) {
public static function get_subscribed_events() {
return [
'rocket_buffer' => [
- [ 'rewrite', 20 ],
- [ 'rewrite_srcset', 21 ],
+ [ 'rewrite', 2 ],
+ [ 'rewrite_srcset', 3 ],
],
'rocket_css_content' => 'rewrite_css_properties',
'rocket_usedcss_content' => 'rewrite_css_properties',
diff --git a/inc/Engine/Cache/ServiceProvider.php b/inc/Engine/Cache/ServiceProvider.php
index 6a9a8f3cd0..eb34187aaf 100644
--- a/inc/Engine/Cache/ServiceProvider.php
+++ b/inc/Engine/Cache/ServiceProvider.php
@@ -27,6 +27,7 @@ class ServiceProvider extends AbstractServiceProvider {
'expired_cache_purge_subscriber',
'preload_caches_query',
'cache_config',
+ 'taxonomy_subscriber',
];
/**
@@ -75,5 +76,6 @@ public function register(): void {
$this->getContainer()->add( 'cache_config', ConfigSubscriber::class )
->addArgument( $this->getContainer()->get( 'options' ) )
->addArgument( $this->getContainer()->get( 'options_api' ) );
+ $this->getContainer()->addShared( 'taxonomy_subscriber', TaxonomySubscriber::class );
}
}
diff --git a/inc/Engine/Cache/TaxonomySubscriber.php b/inc/Engine/Cache/TaxonomySubscriber.php
new file mode 100644
index 0000000000..0289029947
--- /dev/null
+++ b/inc/Engine/Cache/TaxonomySubscriber.php
@@ -0,0 +1,71 @@
+ 'disable_cache_on_not_valid_taxonomy_pages',
+ 'rocket_buffer' => [ 'stop_optimizations_for_not_valid_taxonomy_pages', 1 ],
+ ];
+ }
+
+ /**
+ * Disable caching invalid taxonomy frontend pages.
+ *
+ * @param bool $can_cache Filter callback passed value.
+ * @return bool
+ */
+ public function disable_cache_on_not_valid_taxonomy_pages( $can_cache ) {
+ if ( $this->is_not_valid_taxonomy_page() ) {
+ return false;
+ }
+
+ return $can_cache;
+ }
+
+ /**
+ * Stop optimizing those invalid taxonomy pages by returning empty html string,
+ * So it fall back to the normal page's HTML.
+ *
+ * @param string $html Page's buffer HTML.
+ * @return string
+ */
+ public function stop_optimizations_for_not_valid_taxonomy_pages( $html ) {
+ return $this->is_not_valid_taxonomy_page() ? '' : $html;
+ }
+
+ /**
+ * Check if we are on the taxonomy frontend page, but it's not valid url query.
+ *
+ * @return bool (True when not valid taxonomy page, False if it's a valid one)
+ */
+ private function is_not_valid_taxonomy_page() {
+ if ( ! is_category() && ! is_tag() && ! is_tax() ) {
+ return false;
+ }
+
+ $term_id = get_queried_object_id();
+ if ( empty( $term_id ) ) {
+ return false;
+ }
+
+ global $wp;
+
+ $term_link = get_term_link( $term_id );
+ if ( is_wp_error( $term_link ) ) {
+ return false;
+ }
+
+ $current_link = home_url( add_query_arg( [], $wp->request ?? '' ) );
+
+ return untrailingslashit( $term_link ) !== untrailingslashit( $current_link );
+ }
+}
diff --git a/inc/Engine/Common/Database/Queries/AbstractQuery.php b/inc/Engine/Common/Database/Queries/AbstractQuery.php
index 992e667eba..e04f0e555d 100644
--- a/inc/Engine/Common/Database/Queries/AbstractQuery.php
+++ b/inc/Engine/Common/Database/Queries/AbstractQuery.php
@@ -520,8 +520,8 @@ protected function table_exists(): bool {
}
// Query statement.
- $query = 'SELECT table_name FROM information_schema.tables WHERE table_name = %s LIMIT 1';
- $prepared = $db->prepare( $query, $db->{$this->table_name} );
+ $query = 'SELECT table_name FROM information_schema.tables WHERE table_schema = %s AND table_name = %s LIMIT 1';
+ $prepared = $db->prepare( $query, $db->__get( 'dbname' ), $db->{$this->table_name} );
$result = $db->get_var( $prepared );
// Does the table exist?
diff --git a/inc/Engine/Common/PerformanceHints/Database/Queries/AbstractQueries.php b/inc/Engine/Common/PerformanceHints/Database/Queries/AbstractQueries.php
index 6f7d7db96b..b74e6b2fae 100644
--- a/inc/Engine/Common/PerformanceHints/Database/Queries/AbstractQueries.php
+++ b/inc/Engine/Common/PerformanceHints/Database/Queries/AbstractQueries.php
@@ -60,6 +60,10 @@ public function delete_by_url( string $url ) {
$deleted = true;
foreach ( $items as $item ) {
+ if ( ! is_object( $item ) || ! isset( $item->id ) ) {
+ continue;
+ }
+
$deleted = $deleted && $this->delete_item( $item->id );
}
@@ -121,8 +125,8 @@ protected function table_exists(): bool {
}
// Query statement.
- $query = 'SELECT table_name FROM information_schema.tables WHERE table_name = %s LIMIT 1';
- $prepared = $db->prepare( $query, $db->{$this->table_name} );
+ $query = 'SELECT table_name FROM information_schema.tables WHERE table_schema = %s AND table_name = %s LIMIT 1';
+ $prepared = $db->prepare( $query, $db->__get( 'dbname' ), $db->{$this->table_name} );
$result = $db->get_var( $prepared );
// Does the table exist?
diff --git a/inc/Engine/Common/PerformanceHints/Frontend/Processor.php b/inc/Engine/Common/PerformanceHints/Frontend/Processor.php
index d690fcf518..4540404392 100644
--- a/inc/Engine/Common/PerformanceHints/Frontend/Processor.php
+++ b/inc/Engine/Common/PerformanceHints/Frontend/Processor.php
@@ -95,6 +95,10 @@ public function maybe_apply_optimizations( string $html ): string {
* @return string The modified HTML content with the beacon script injected just before the closing body tag.
*/
private function inject_beacon( $html, $url, $is_mobile ): string {
+ if ( rocket_get_constant( 'DONOTROCKETOPTIMIZE' ) && empty( $_GET['wpr_imagedimensions'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+ return $html;
+ }
+
$min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
if ( ! $this->filesystem->exists( rocket_get_constant( 'WP_ROCKET_ASSETS_JS_PATH' ) . 'wpr-beacon' . $min . '.js' ) ) {
diff --git a/inc/Engine/CriticalPath/CriticalCSSSubscriber.php b/inc/Engine/CriticalPath/CriticalCSSSubscriber.php
index ffba529501..8d663f8e99 100644
--- a/inc/Engine/CriticalPath/CriticalCSSSubscriber.php
+++ b/inc/Engine/CriticalPath/CriticalCSSSubscriber.php
@@ -8,6 +8,7 @@
use WP_Rocket\Engine\Optimization\RegexTrait;
use WP_Rocket\Event_Management\Subscriber_Interface;
use WP_Filesystem_Direct;
+use WP_Rocket\Engine\Support\CommentTrait;
/**
* Critical CSS Subscriber.
@@ -16,6 +17,7 @@
*/
class CriticalCSSSubscriber implements Subscriber_Interface {
use RegexTrait;
+ use CommentTrait;
/**
* Instance of Critical CSS.
@@ -602,7 +604,9 @@ public function insert_critical_css_buffer( $buffer ) {
1
);
- return preg_replace( '#