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

Clean up Limit Global Styles logic #70121

Merged
merged 7 commits into from
Dec 6, 2022
Merged
Changes from 1 commit
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
Expand Up @@ -119,18 +119,14 @@ function wpcom_block_global_styles_frontend( $theme_json ) {

if ( class_exists( 'WP_Theme_JSON_Data' ) ) {
return new WP_Theme_JSON_Data( array(), 'custom' );
} elseif ( class_exists( 'WP_Theme_JSON_Data_Gutenberg' ) ) {
return new WP_Theme_JSON_Data_Gutenberg( array(), 'custom' );
}

/*
* If both `WP_Theme_JSON_Data` and `WP_Theme_JSON_Data_Gutenberg` are missing,
* then the site is running an old version of WordPress and Gutenberg where we
* cannot block the user styles properly.
* If `WP_Theme_JSON_Data` is missing, then the site is running an old
* version of WordPress we cannot block the user styles properly.
*/
return $theme_json;
}
add_filter( 'theme_json_user', 'wpcom_block_global_styles_frontend' );
add_filter( 'wp_theme_json_data_user', 'wpcom_block_global_styles_frontend' );

/**
Expand Down Expand Up @@ -184,7 +180,12 @@ function wpcom_track_global_styles( $blog_id, $post, $updated ) {
* @return bool Returns true if custom styles are in use.
*/
function wpcom_global_styles_in_use() {
$user_cpt = WP_Theme_JSON_Resolver_Gutenberg::get_user_data_from_wp_global_styles( wp_get_theme() );
if ( class_exists( 'WP_Theme_JSON_Resolver' ) ) {
mmtr marked this conversation as resolved.
Show resolved Hide resolved
$user_cpt = WP_Theme_JSON_Resolver::get_user_data_from_wp_global_styles();
dsas marked this conversation as resolved.
Show resolved Hide resolved
} else {
do_action( 'global_styles_log', 'global_styles_not_in_use' );
mmtr marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

if ( ! isset( $user_cpt['post_content'] ) ) {
do_action( 'global_styles_log', 'global_styles_not_in_use' );
Expand Down