PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.2
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.2
3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 All 195 releases
← All changes | admin/class-convertkit-admin-cache-plugins.php +46 -11 2.2.83.4.2 View file →
@@ -53,18 +53,24 @@
53 53 * @since 2.2.2
54 54 */
55 55 public function maybe_configure_cache_plugins() {
56 56
57 - // Bail if Restrict Content is disabled.
58 - $restrict_content_settings = new ConvertKit_Settings_Restrict_Content();
59 - if ( ! $restrict_content_settings->enabled() ) {
57 + // Only allow Administrators to update third party Plugin settings.
58 + if ( ! current_user_can( 'manage_options' ) ) {
60 59 return;
61 60 }
62 61
62 + // If no Pages, Posts or CPTs are configured to use Restrict Content, don't
63 + // configure any caching plugins.
64 + if ( ! WP_ConvertKit()->get_class( 'admin_restrict_content' )->restrict_content_enabled() ) {
65 + return;
66 + }
67 +
63 68 $this->litespeed_cache();
64 69 $this->w3_total_cache();
65 70 $this->wp_fastest_cache();
66 71 $this->wp_optimize();
72 + $this->wp_rocket();
67 73 $this->wp_super_cache();
68 74
69 75 }
70 76
@@ -117,9 +123,9 @@
117 123 public function litespeed_cache_notice( $notice ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
118 124
119 125 return sprintf(
120 126 '%s %s %s %s',
121 - esc_html__( 'ConvertKit: Member Content: Please add', 'convertkit' ),
127 + esc_html__( 'Kit: Member Content: Please add', 'convertkit' ),
122 128 '<code>ck_subscriber_id</code>',
123 129 sprintf(
124 130 '<a href="%s">%s</a>',
125 131 esc_url(
@@ -188,9 +194,9 @@
188 194 public function w3_total_cache_notice( $notice ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
189 195
190 196 return sprintf(
191 197 '%s %s %s %s',
192 - esc_html__( 'ConvertKit: Member Content: Please add', 'convertkit' ),
198 + esc_html__( 'Kit: Member Content: Please add', 'convertkit' ),
193 199 '<code>ck_subscriber_id</code>',
194 200 sprintf(
195 201 '<a href="%s">%s</a>',
196 202 esc_url(
@@ -271,13 +277,8 @@
271 277 // Fetch settings.
272 278 $config = new WPO_Cache_Config();
273 279 $settings = $config->get();
274 280
275 - // Check that we received an array of settings.
276 - if ( ! is_array( $settings ) ) {
277 - return;
278 - }
279 -
280 281 // Check the exception cookies array key exists in the settings.
281 282 if ( ! array_key_exists( 'cache_exception_cookies', $settings ) ) {
282 283 $settings['cache_exception_cookies'] = array();
283 284 }
@@ -295,8 +296,42 @@
295 296
296 297 }
297 298
298 299 /**
300 + * Add a rule to WP Rocket to prevent caching when
301 + * the ck_subscriber_id cookie is present.
302 + *
303 + * @since 2.7.0
304 + */
305 + public function wp_rocket() {
306 +
307 + // Bail if the WP Rocket plugin is not active.
308 + if ( ! is_plugin_active( 'wp-rocket/wp-rocket.php' ) ) {
309 + return;
310 + }
311 +
312 + // Sanity check that we can access WP-Optimize's configuration class.
313 + if ( ! function_exists( 'update_rocket_option' ) ) {
314 + return;
315 + }
316 +
317 + // Fetch settings.
318 + $settings = get_rocket_option( 'cache_reject_cookies', array() );
319 +
320 + // If the cookie exception exists, no need to modify anything.
321 + if ( in_array( $this->key, $settings, true ) ) {
322 + return;
323 + }
324 +
325 + // Add cookie to exceptions.
326 + $settings[] = $this->key;
327 +
328 + // Update configuration to include excluding caching for the ck_subscriber_id cookie.
329 + update_rocket_option( 'cache_reject_cookies', $settings );
330 +
331 + }
332 +
333 + /**
299 334 * Show a notice in the WordPress Administration interface if
300 335 * WP Super Cache is active, its caching enabled and no rule to disable caching
301 336 * exists when the ck_subscriber_id cookie is present.
302 337 *
@@ -345,9 +380,9 @@
345 380 public function wp_super_cache_notice( $notice ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
346 381
347 382 return sprintf(
348 383 '%s %s %s %s',
349 - esc_html__( 'ConvertKit: Member Content: Please add', 'convertkit' ),
384 + esc_html__( 'Kit: Member Content: Please add', 'convertkit' ),
350 385 '<code>ck_subscriber_id</code>',
351 386 sprintf(
352 387 '<a href="%s">%s</a>',
353 388 esc_url(