Skip to content

Commit e91a6e5

Browse files
Copilotswissspidy
andcommitted
Use get_blog_id_from_url() for cached URL lookups
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent fe4046b commit e91a6e5

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/Site_Command.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -483,19 +483,14 @@ public function get( $args, $assoc_args ) {
483483
$path .= '/';
484484
}
485485

486-
// Query the database for the site
487-
global $wpdb;
488-
$site = $wpdb->get_row(
489-
$wpdb->prepare(
490-
"SELECT * FROM {$wpdb->blogs} WHERE domain = %s AND path = %s",
491-
$domain,
492-
$path
493-
)
494-
);
486+
// Use WordPress's cached function to get the blog ID
487+
$blog_id = get_blog_id_from_url( $domain, $path );
495488

496-
if ( ! $site ) {
489+
if ( ! $blog_id ) {
497490
WP_CLI::error( "Could not find site with URL: {$site_arg}" );
498491
}
492+
493+
$site = $this->fetcher->get_check( $blog_id );
499494
} else {
500495
// Treat as site ID
501496
$site = $this->fetcher->get_check( $site_arg );

0 commit comments

Comments
 (0)