Skip to content

Commit 8ba8c8a

Browse files
authored
REST API: Site Quality: Only load it on the main site (#700)
The Site Quality API is loaded on all sites, even though it's only intended on being used in one specific place. This removes the API from being loaded unless it's on literally WordPress.org. This does not account for local sites or any tests which may exist.
1 parent 813e0b0 commit 8ba8c8a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mu-plugins/rest-api/index.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,22 @@
1616
*/
1717
function initialize_rest_endpoints() {
1818
require_once __DIR__ . '/endpoints/class-wporg-rest-users-controller.php';
19-
require_once __DIR__ . '/endpoints/class-wporg-site-quality-controller.php';
2019

2120
$users_controller = new Users_Controller();
2221
$users_controller->register_routes();
2322

23+
// The Site Quality controller is only needed on the main site. Note: domain check is due to this plugin running on multiple networks.
24+
if ( 1 === get_current_blog_id() && 'wordpress.org' === get_blog_details()->domain ) {
25+
require_once __DIR__ . '/endpoints/class-wporg-site-quality-controller.php';
26+
}
27+
2428
if ( defined( 'WPORG_THEME_DIRECTORY_BLOGID' ) && WPORG_THEME_DIRECTORY_BLOGID === get_current_blog_id() ) {
2529
require_once __DIR__ . '/endpoints/class-wporg-base-locale-banner-controller.php';
2630
require_once __DIR__ . '/endpoints/class-wporg-themes-locale-banner-controller.php';
2731
$locale_banner_controller = new Themes_Locale_Banner_Controller();
2832
$locale_banner_controller->register_routes();
2933
}
34+
3035
if ( class_exists( 'WordPressdotorg\Plugin_Directory\Plugin_Directory' ) ) {
3136
require_once __DIR__ . '/endpoints/class-wporg-base-locale-banner-controller.php';
3237
require_once __DIR__ . '/endpoints/class-wporg-plugins-locale-banner-controller.php';

0 commit comments

Comments
 (0)