Skip to content

Commit 99c3b7c

Browse files
committed
add filter for jetpack_mcp_get_ordered_blogs_of_user
1 parent 7c15a02 commit 99c3b7c

File tree

5 files changed

+9
-15
lines changed

5 files changed

+9
-15
lines changed

projects/packages/mcp/src/AbilitiesRegistry/Abilities/class-exampleusersitesresourceability.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ public function execute() {
6666
}
6767

6868
// Get all sites for the user.
69-
// @phan-suppress-next-line PhanUndeclaredFunction
70-
$all_sites = get_ordered_blogs_of_user( $current_user_id, true, true, true );
69+
$all_sites = apply_filters( 'jetpack_mcp_get_ordered_blogs_of_user', array(), $current_user_id, true, true, true );
7170

72-
if ( ! $all_sites || is_wp_error( $all_sites ) ) {
71+
if ( empty( $all_sites ) || is_wp_error( $all_sites ) ) {
7372
return new WP_Error(
7473
'no_sites',
7574
'Unable to retrieve user sites',

projects/packages/mcp/src/AbilitiesRegistry/Executors/User/UserNotificationsExecutor.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ private function list_notification_settings( array $input ) { // phpcs:ignore Va
8282

8383
$current_user_id = $this->get_current_user_id();
8484
// Get user sites for blog-specific settings.
85-
// @phan-suppress-next-line PhanUndeclaredFunction
86-
$user_sites = get_ordered_blogs_of_user( $current_user_id );
85+
$user_sites = apply_filters( 'jetpack_mcp_get_ordered_blogs_of_user', array(), $current_user_id, true, true, true );
8786
if ( ! $user_sites ) {
8887
$user_sites = array();
8988
}

projects/packages/mcp/src/AbilitiesRegistry/Executors/User/UserProfileExecutor.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ private function get_user_preferences( WP_User $user ): array { // phpcs:ignore
132132
* @return array User statistics.
133133
*/
134134
private function get_user_stats( WP_User $user ): array { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- $user will be used in future implementation
135-
// @phan-suppress-next-line PhanUndeclaredFunction
136-
$user_sites = get_ordered_blogs_of_user( $user->ID );
135+
$user_sites = apply_filters( 'jetpack_mcp_get_ordered_blogs_of_user', array(), $user->ID, true, true, true );
137136
$total_sites = $user_sites ? count( $user_sites ) : 0;
138137

139138
// Get content statistics across all user's sites.
@@ -190,8 +189,7 @@ private function get_social_data( WP_User $user ): array { // phpcs:ignore Varia
190189
* @return array Activity data.
191190
*/
192191
private function get_activity_data( WP_User $user ): array { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- $user will be used in future implementation
193-
// @phan-suppress-next-line PhanUndeclaredFunction
194-
$user_sites = get_ordered_blogs_of_user( $user->ID );
192+
$user_sites = apply_filters( 'jetpack_mcp_get_ordered_blogs_of_user', array(), $user->ID, true, true, true );
195193

196194
return array(
197195
'most_active_site' => $this->get_most_active_site( $user, $user_sites ),

projects/packages/mcp/src/AbilitiesRegistry/Executors/User/UserSitesExecutor.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,10 @@ private function get_user_sites() {
8787

8888
$current_user_id = $this->get_current_user_id();
8989

90-
// Get all sites for the user using WordPress.com API.
91-
// @phan-suppress-next-line PhanUndeclaredFunction
92-
$all_sites = get_ordered_blogs_of_user( $current_user_id, true, true, true );
90+
// Get all sites for the user
91+
$all_sites = apply_filters( 'jetpack_mcp_get_ordered_blogs_of_user', array(), $current_user_id, true, true, true );
9392

94-
if ( ! $all_sites || is_wp_error( $all_sites ) ) {
93+
if ( empty( $all_sites ) || is_wp_error( $all_sites ) ) {
9594
return $this->create_error( 'no_sites', 'Unable to retrieve user sites', 404 );
9695
}
9796

projects/packages/mcp/src/AbilitiesRegistry/Executors/User/UserSubscriptionsExecutor.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,7 @@ private function get_usage_data() {
222222
$current_user_id = $this->get_current_user_id();
223223

224224
// Get user sites for usage calculation.
225-
// @phan-suppress-next-line PhanUndeclaredFunction
226-
$user_sites = get_ordered_blogs_of_user( $current_user_id );
225+
$user_sites = apply_filters( 'jetpack_mcp_get_ordered_blogs_of_user', array(), $current_user_id, true, true, true );
227226
$sites_count = is_array( $user_sites ) ? count( $user_sites ) : 0;
228227

229228
// Calculate storage usage (simplified).

0 commit comments

Comments
 (0)