Skip to content

Commit

Permalink
Jetpack: optimize the Sharing module hook (#40128)
Browse files Browse the repository at this point in the history
Make the Sharing module run the `template_redirect` action callback only when necessary.
  • Loading branch information
sergeymitr authored Nov 11, 2024
1 parent f609d2d commit 11ca6bd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Optimize the Sharing module hook callback.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ function sharing_process_requests() {
}
}
}
add_action( 'template_redirect', __NAMESPACE__ . '\sharing_process_requests', 9 );

// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only checking for the data being present.
if ( isset( $_GET['share'] ) ) {
add_action( 'template_redirect', __NAMESPACE__ . '\sharing_process_requests', 9 );
}

/**
* Automatically add the Sharing Buttons block to the end of the Single Posts template.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,11 @@ function sharing_process_requests() {
}
}
}
add_action( 'template_redirect', 'sharing_process_requests', 9 );

// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only checking for the data being present.
if ( isset( $_GET['share'] ) ) {
add_action( 'template_redirect', 'sharing_process_requests', 9 );
}

/**
* Gets the url to customise the sharing buttons in Calypso.
Expand Down

0 comments on commit 11ca6bd

Please sign in to comment.