Skip to content

Boost + wpcomsh: ensure API endpoints are registered #43262

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

Merged
merged 4 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions projects/plugins/wpcomsh/changelog/fix-hog-87
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Ensure wpcomsh users are able to purchase the Boost paid offering
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ protected function __construct() {
add_filter(
'jetpack_my_jetpack_should_initialize',
function () {
return get_option( 'wpcom_admin_interface' ) === 'wp-admin';
$should_init = get_option( 'wpcom_admin_interface' ) === 'wp-admin';
if ( ! $should_init && class_exists( '\Automattic\Jetpack\My_Jetpack\Initializer' ) ) {
// My Jetpack REST API endpoints are used for more than just My Jetpack UI.
add_action( 'rest_api_init', array( '\Automattic\Jetpack\My_Jetpack\Initializer', 'register_rest_endpoints' ) ); // @phan-suppress-current-line PhanUndeclaredClassInCallable
}
return $should_init;
}
);
}
Expand Down
28 changes: 28 additions & 0 deletions projects/plugins/wpcomsh/tests/JetpackCompatibilityTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Jetpack Compatibility Test file.
*
* @package wpcomsh
*/

/**
* Test Jetpack_Compatibility functionality.
*/
class JetpackCompatibilityTest extends WP_UnitTestCase {
use \Automattic\Jetpack\PHPUnit\WP_UnitTestCase_Fix;

/**
* Test_wpcomsh_get_plugin_updated_submenus.
*/
public function test_wpcomsh_my_jetpack_rest_apis_available() {
// Check if the REST API routes are registered if Boost is included.
$plugins = getenv( 'JP_MONO_INTEGRATION_PLUGINS' );
if ( ! $plugins || strpos( $plugins, 'boost' ) === false ) {
$this->markTestSkipped( 'Jetpack Boost plugin is not included in JP_MONO_INTEGRATION_PLUGINS.' );
}

$routes = rest_get_server()->get_routes();

$this->assertArrayHasKey( '/my-jetpack/v1/site/products', $routes, 'Products endpoint is not registered' );
}
}