File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed
Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -616,22 +616,16 @@ public function create( $args, $assoc_args ) {
616616 // Sanitize and lowercase the derived base
617617 $ base = strtolower ( $ base );
618618 } else {
619- // For subdirectory installs, use the path as the base
620- $ base = trim ( $ custom_path , '/ ' );
621- // Use the last part of the path if there are multiple segments
622- if ( ! empty ( $ base ) ) {
623- $ path_parts = explode ( '/ ' , $ base );
624- $ last_part = array_pop ( $ path_parts );
625- if ( null !== $ last_part && '' !== $ last_part ) {
626- $ base = $ last_part ;
627- }
628- }
629- // If base is empty (root path), require explicit slug
619+ // For subdirectory installs, derive slug from the last part of the path.
620+ $ path_parts = array_filter ( explode ( '/ ' , trim ( $ custom_path , '/ ' ) ) );
621+ $ base = (string ) array_pop ( $ path_parts );
622+
623+ // If base is empty (root path), require explicit slug.
630624 if ( empty ( $ base ) ) {
631625 WP_CLI ::error ( 'Could not derive a valid slug from the URL path. Please provide --slug explicitly. ' );
632626 }
633627
634- // Sanitize and lowercase the derived base
628+ // Sanitize and lowercase the derived base.
635629 $ base = strtolower ( $ base );
636630 }
637631 } else {
You can’t perform that action at this time.
0 commit comments