File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616 },
1717 "require-dev" : {
1818 "wp-cli/entity-command" : " ^2" ,
19+ "wp-cli/rewrite-command" : " ^2" ,
1920 "wp-cli/wp-cli-tests" : " ^5"
2021 },
2122 "config" : {
Original file line number Diff line number Diff line change @@ -15,3 +15,25 @@ Feature: Serve WordPress locally
1515 When I run `curl -sS localhost:8181/license.txt > /tmp/license.txt`
1616 And I run `cmp /tmp/license.txt license.txt`
1717 Then STDOUT should be empty
18+
19+ Scenario : Access wp-login.php
20+ Given a WP install
21+ And I launch in the background `wp server --host=localhost --port=8182`
22+
23+ When I run `curl -sS http://localhost:8182/wp-login.php`
24+ Then STDOUT should contain:
25+ """
26+ wp-login.php
27+ """
28+
29+ Scenario : Pretty permalinks
30+ Given a WP install
31+ And I launch in the background `wp server --host=localhost --port=8183`
32+ And I run `wp option update permalink_structure '/%postname%/' `
33+ And I run `wp rewrite flush`
34+
35+ When I run `curl -sSL http://localhost:8183/hello-world/`
36+ Then STDOUT should contain:
37+ """
38+ Hello world!
39+ """
Original file line number Diff line number Diff line change @@ -107,6 +107,8 @@ function ( $url ) {
107107 $ url = str_replace ( $ site_url_host , $ _SERVER ['HTTP_HOST ' ], $ url );
108108 }
109109
110+ $ url = str_replace ( 'https:// ' , 'http:// ' , $ url );
111+
110112 return $ url ;
111113 },
112114 20
@@ -125,13 +127,24 @@ function ( $url ) {
125127 exit ;
126128 }
127129
128- if ( strpos ( $ wpcli_server_path , '.php ' ) !== false ) {
130+ // Check if this is a PHP file by examining the extension
131+ if ( pathinfo ( $ wpcli_server_path , PATHINFO_EXTENSION ) === 'php ' ) {
132+ // Set $_SERVER variables to mimic direct access to the PHP file
133+ $ _SERVER ['SCRIPT_NAME ' ] = $ wpcli_server_path ;
134+ $ _SERVER ['PHP_SELF ' ] = $ wpcli_server_path ;
135+ $ _SERVER ['SCRIPT_FILENAME ' ] = $ wpcli_server_root . $ wpcli_server_path ;
136+
129137 chdir ( dirname ( $ wpcli_server_root . $ wpcli_server_path ) );
130138 require_once $ wpcli_server_root . $ wpcli_server_path ;
131139 } else {
132140 return false ;
133141 }
134142} else {
143+ // File doesn't exist - route to index.php for pretty permalinks
144+ $ _SERVER ['SCRIPT_NAME ' ] = '/index.php ' ;
145+ $ _SERVER ['PHP_SELF ' ] = '/index.php ' ;
146+ $ _SERVER ['SCRIPT_FILENAME ' ] = $ wpcli_server_root . '/index.php ' ;
147+
135148 chdir ( $ wpcli_server_root );
136149 require_once 'index.php ' ;
137150}
You can’t perform that action at this time.
0 commit comments