File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,8 +79,18 @@ public function get_loggers() {
7979 * Run the profiler against WordPress
8080 */
8181 public function run () {
82- $ url = WP_CLI ::get_runner ()->config ['url ' ];
83- $ this ->is_admin_request = ! empty ( $ url ) && (bool ) preg_match ( '#/wp-admin(/|$)#i ' , $ url );
82+ $ url = WP_CLI ::get_runner ()->config ['url ' ];
83+ $ path = '' ;
84+ if ( ! empty ( $ url ) ) {
85+ $ parsed_url = @parse_url ( $ url );
86+ if ( false !== $ parsed_url && isset ( $ parsed_url ['path ' ] ) ) {
87+ $ path = $ parsed_url ['path ' ];
88+ } else {
89+ // Fallback for cases where $url is just a path.
90+ $ path = $ url ;
91+ }
92+ }
93+ $ this ->is_admin_request = ! empty ( $ path ) && (bool ) preg_match ( '#/wp-admin(/|$|\?)#i ' , $ path );
8494
8595 if ( $ this ->is_admin_request && 'admin ' !== WP_CLI ::get_runner ()->config ['context ' ] ) {
8696 WP_CLI ::error ( 'Profiling an admin URL requires --context=admin. ' );
You can’t perform that action at this time.
0 commit comments