diff --git a/projects/plugins/jetpack/changelog/update-sharing-services-assets-only-on-old-themes b/projects/plugins/jetpack/changelog/update-sharing-services-assets-only-on-old-themes new file mode 100644 index 0000000000000..3b4740084a2ac --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-sharing-services-assets-only-on-old-themes @@ -0,0 +1,4 @@ +Significance: major +Type: compat + +Improved compatibiliy with modern block themes by not checking whether we should use legacy sharing buttons mechanism diff --git a/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php b/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php index 2487064126881..4df18b88bb36f 100644 --- a/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php +++ b/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php @@ -898,6 +898,10 @@ class_exists( 'Jetpack_AMP_Support' ) * @return void */ function sharing_add_header() { + if ( ! sharing_should_load_legacy_sharing_buttons() ) { + return; + } + $sharer = new Sharing_Service(); $enabled = $sharer->get_blog_services(); @@ -912,6 +916,20 @@ function sharing_add_header() { } add_action( 'wp_head', 'sharing_add_header', 1 ); +/** + * Determine if legacy sharing buttons should be loaded. + * Do this by checking if the current theme is a block theme + * If it is, we shouldn't enqueue the sharing assets + * as the recommended way of adding sharing buttons is via the editor. + * + * @since $$next-version$$ + * + * @return bool True if legacy sharing buttons should be loaded, false otherwise. + */ +function sharing_should_load_legacy_sharing_buttons() { + return ! wp_is_block_theme(); +} + /** * Launch sharing requests on page load when a specific query string is used. *