| @@ -75,13 +75,13 @@ | ||
| 75 | 75 | |
| 76 | 76 | if ( !defined( 'ABSPATH' ) ) { |
| 77 | 77 | echo '<p>It\'s possible you have an unusual directory structure, and we can\'t find the path to the root of your WordPress install.'.'</p>'; |
| 78 | 78 | echo '<p>You can tell Plugin Detective about your install by creating a config file here:</p>'; |
| 79 | - echo '<pre>'. $path_to_pd_config .'</pre>'; | |
| 79 | + echo '<pre>'. esc_html( $path_to_pd_config ) .'</pre>'; | |
| 80 | 80 | echo '<p>where you define the path to your WP install</p>'; |
| 81 | 81 | echo '<code>'. "define( 'ABSPATH', '/path/to/wordpress/install/' );" .'</code>'; |
| 82 | 82 | echo '<p>You may want to define other customized values like <code>WP_CONTENT_DIR</code>, <code>WP_CONTENT_URL</code> or other values from your wp-config.php file that are unique to your install</p>'; |
| 83 | - echo '<p>Error details: <code>Couldn\'t find ABSPATH from plugin path: ' . $this->plugin->dir() . '</code></p>'; | |
| 83 | + echo '<p>Error details: <code>Couldn\'t find ABSPATH from plugin path: ' . esc_html( $this->plugin->dir() ) . '</code></p>'; | |
| 84 | 84 | echo '<style>code { color: #333; background-color: #ccc; padding: 5px; }</style>'; |
| 85 | 85 | exit(); |
| 86 | 86 | } |
| 87 | 87 | } |
| @@ -94,9 +94,9 @@ | ||
| 94 | 94 | if ( ! @file_exists( $wp_config_dir_path ) ) { |
| 95 | 95 | $wp_config_dir_path = ABSPATH . 'wp' . '/' . 'wp-config.php'; |
| 96 | 96 | |
| 97 | 97 | if ( ! @file_exists( $wp_config_dir_path ) ) { |
| 98 | - die( "Unable to locate wp-config.php file: \n" . ABSPATH. 'wp-config.php' . "\n OR \n" . dirname( ABSPATH ) . '/' . 'wp-config.php' ); | |
| 98 | + die( esc_html( "Unable to locate wp-config.php file: \n" . ABSPATH . 'wp-config.php' . "\n OR \n" . dirname( ABSPATH ) . '/' . 'wp-config.php' ) ); | |
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| @@ -101,8 +101,9 @@ | ||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
| 104 | 104 | if ( isset($_ENV['PANTHEON_ENVIRONMENT']) ) { |
| 105 | + // phpcs:disable WordPress.Security.ValidatedSanitizedInput -- Reading platform-provided database credentials from the Pantheon environment, not user input. | |
| 105 | 106 | define('DB_NAME', $_ENV['DB_NAME']); |
| 106 | 107 | |
| 107 | 108 | /** MySQL database username */ |
| 108 | 109 | define('DB_USER', $_ENV['DB_USER']); |
| @@ -111,13 +112,15 @@ | ||
| 111 | 112 | define('DB_PASSWORD', $_ENV['DB_PASSWORD']); |
| 112 | 113 | |
| 113 | 114 | /** MySQL hostname; on Pantheon this includes a specific port number. */ |
| 114 | 115 | define('DB_HOST', $_ENV['DB_HOST'] . ':' . $_ENV['DB_PORT']); |
| 116 | + // phpcs:enable WordPress.Security.ValidatedSanitizedInput | |
| 115 | 117 | } |
| 116 | 118 | |
| 117 | 119 | $config_files = array( |
| 118 | 120 | dirname( $wp_config_dir_path ) . '/wp-config-local.php', |
| 119 | 121 | dirname( $wp_config_dir_path ) . '/wp-config-hosting.php', |
| 122 | + dirname( $wp_config_dir_path ) . '/wp-config-ddev.php', | |
| 120 | 123 | $wp_config_dir_path, |
| 121 | 124 | ); |
| 122 | 125 | $attempts = array( |
| 123 | 126 | 'standard', |
| @@ -231,11 +234,26 @@ | ||
| 231 | 234 | if ( !empty( $WP_CONTENT_URL ) ) { |
| 232 | 235 | define( 'WP_CONTENT_URL', $WP_CONTENT_URL ); |
| 233 | 236 | } |
| 234 | 237 | |
| 235 | - $config_file->set_type( 'php-variable' ); | |
| 238 | + // Search every config file for $table_prefix, not just whichever one | |
| 239 | + // was last assigned by the DB_* loop above. Split-config layouts | |
| 240 | + // (DDEV, LocalWP, etc.) place credentials and $table_prefix in | |
| 241 | + // different files. | |
| 236 | 242 | global $table_prefix; |
| 237 | - $table_prefix = $config_file->get_key( 'table_prefix' ); | |
| 243 | + $table_prefix = ''; | |
| 244 | + foreach ( $config_files as $config_file_path ) { | |
| 245 | + if ( ! file_exists( $config_file_path ) ) { | |
| 246 | + continue; | |
| 247 | + } | |
| 248 | + $config_file = new PDT_Config( $config_file_path ); | |
| 249 | + $config_file->set_type( 'php-variable' ); | |
| 250 | + $value = $config_file->get_key( 'table_prefix' ); | |
| 251 | + if ( ! empty( $value ) ) { | |
| 252 | + $table_prefix = $value; | |
| 253 | + break; | |
| 254 | + } | |
| 255 | + } | |
| 238 | 256 | $GLOBALS['table_prefix'] = $table_prefix; |
| 239 | 257 | |
| 240 | 258 | if ( !defined('WP_CONTENT_DIR') ) |
| 241 | 259 | define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down |
| @@ -284,9 +302,9 @@ | ||
| 284 | 302 | * @since 2.1.0 |
| 285 | 303 | * @deprecated |
| 286 | 304 | */ |
| 287 | 305 | if ( !defined('PLUGINDIR') ) |
| 288 | - define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat. | |
| 306 | + define( 'PLUGINDIR', 'wp-content/plugins' ); // phpcs:ignore WordPress.WP.DiscouragedConstants.PLUGINDIRDeclarationFound -- Standalone bootstrap mirrors wp-settings.php and re-creates this back-compat core constant. | |
| 289 | 307 | |
| 290 | 308 | /** |
| 291 | 309 | * Allows for the mu-plugins directory to be moved from the default location. |
| 292 | 310 | * |
| @@ -301,9 +319,9 @@ | ||
| 301 | 319 | * @since 2.8.0 |
| 302 | 320 | * @deprecated |
| 303 | 321 | */ |
| 304 | 322 | if ( !defined( 'MUPLUGINDIR' ) ) |
| 305 | - define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH. For back compat. | |
| 323 | + define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // phpcs:ignore WordPress.WP.DiscouragedConstants.MUPLUGINDIRDeclarationFound -- Standalone bootstrap mirrors wp-settings.php and re-creates this back-compat core constant. | |
| 306 | 324 | |
| 307 | 325 | |
| 308 | 326 | } |
| 309 | 327 | |