Skip to content

Commit

Permalink
Sharing Service: Make sure we only check for legacy sharing buttons i…
Browse files Browse the repository at this point in the history
…mplementation on non-block themes (#39349)

* make sure we only check for legacy sharing buttons implementation on non-block themes

* changelog

* Omit the function exists check
  • Loading branch information
oskosk authored Sep 11, 2024
1 parent 1d28331 commit 23f7e3c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions projects/plugins/jetpack/modules/sharedaddy/sharing-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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.
*
Expand Down

0 comments on commit 23f7e3c

Please sign in to comment.