Skip to content

Commit a1da21c

Browse files
authored
Comments: Load on public-api after switching to the target blog (#53958)
1 parent 726ef74 commit a1da21c

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Comments: Keep headings in P2 comments edited through the REST API.

‎projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,14 @@ private static function should_disable_comment_experience( $blog_id ) {
839839
* Load Verbum Comments.
840840
*/
841841
public static function load_verbum_comments() {
842+
// public-api boots on its own blog, so decide once the request has switched to its target.
843+
if ( 'public-api.wordpress.com' === wp_parse_url( home_url(), PHP_URL_HOST ) ) {
844+
// Now, for reads across sites that never switch: avatars only touch comments with our stored photo.
845+
\Automattic\Jetpack\Comments\Avatars::init();
846+
add_action( 'rest_api_switched_to_blog', array( __CLASS__, 'load_verbum_comments' ) );
847+
return;
848+
}
849+
842850
if ( class_exists( 'Verbum_Comments' ) ) {
843851
return;
844852
} else {
@@ -865,8 +873,8 @@ public static function load_verbum_comments() {
865873

866874
/**
867875
* Register Jetpack Comments' browser-facing routes ahead of the comment
868-
* experience gates. admin-ajax is is_admin(), and a public-api request runs
869-
* plugins_loaded on the wrong blog, so load_verbum_comments() skips both.
876+
* experience gates. admin-ajax is is_admin(), so load_verbum_comments() skips it,
877+
* and on public-api it waits for the blog switch, which comes after rest_api_init.
870878
* Runs on every request, blog 1 and P2s included, on purpose: the routes
871879
* gate themselves on Comments::is_enabled(), as Posts_To_Podcast_Endpoint does.
872880
*/

0 commit comments

Comments
 (0)