Skip to content

Commit 4ecf862

Browse files
Copilotswissspidy
andcommitted
Improve code clarity based on code review feedback
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 253b5ad commit 4ecf862

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,11 @@ public function install( $args, $assoc_args ) {
215215

216216
// Check if this is a WordPress.org plugin/theme directory URL.
217217
// If so, extract the slug and treat it as a repository installation.
218-
if ( preg_match( '#^https?://wordpress\.org/(plugins|themes)/([^/]+)/?#', $slug, $matches ) ) {
219-
$slug = $matches[2];
218+
// Pattern matches: https://wordpress.org/plugins/plugin-slug/ or https://wordpress.org/themes/theme-slug/
219+
// Capture group 1: type (plugins|themes)
220+
// Capture group 2: slug (the plugin or theme slug name)
221+
if ( preg_match( '~^https?://wordpress\.org/(plugins|themes)/([^/]+)/?~', $slug, $matches ) ) {
222+
$slug = $matches[2]; // Extract the slug.
220223
$is_remote = false;
221224
WP_CLI::log( sprintf( 'Detected WordPress.org %s directory URL, using slug: %s', $matches[1], $slug ) );
222225
}

0 commit comments

Comments
 (0)