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

Promote with Blaze: Purge cache on Atomic sites when site visibility changes #40650

Merged
merged 8 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Purge the cache when the site visibility changes on Atomic sites
54 changes: 54 additions & 0 deletions projects/plugins/wpcomsh/feature-plugins/blaze.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @package wpcomsh
*/

use Automattic\Jetpack\Connection\Manager as Jetpack_Connection;

/**
* Activate the Blaze module
* If you use a version of Jetpack that supports it,
Expand Down Expand Up @@ -61,5 +63,57 @@ function wpcomsh_activate_blaze_module_on_launching( $old_value, $new_value ) {
if ( $blog_public === 1 ) {
wpcomsh_activate_blaze_module();
}

return $new_value;
}
add_filter( 'update_option_blog_public', 'wpcomsh_activate_blaze_module_on_launching', 10, 2 );

/**
* Delete the transient for the given site id.
*
* @return void
*/
function wpcomsh_blaze_purge_transient_cache() {
$site_id = Jetpack_Connection::get_site_id();

if ( is_wp_error( $site_id ) ) {
return;
}

$transient = 'jetpack_blaze_site_supports_blaze_' . $site_id;
delete_transient( $transient );
}

/**
* Delete the caching transient when coming soon is changed.
*/
add_action(
'pre_update_option_wpcom_public_coming_soon',
function ( $option ) {
wpcomsh_blaze_purge_transient_cache();
return $option;
}
);

/**
* Delete the caching transient when the blog visibility option changes.
*/
add_action(
'pre_update_option_blog_public',
function ( $option ) {
wpcomsh_blaze_purge_transient_cache();
return $option;
}
);

/**
* On Atomic sites the Promote with Blaze option is enabled.
*
* @phan-suppress PhanUndeclaredFunctionInCallable -- jetpack_blaze_post_row_actions_disable is part of jetpack.
mmtr marked this conversation as resolved.
Show resolved Hide resolved
*/
add_action(
'jetpack_modules_loaded',
function () {
remove_filter( 'jetpack_blaze_post_row_actions_enable', 'jetpack_blaze_post_row_actions_disable' );
}
);
Loading