Skip to content

Commit e79d732

Browse files
committed
Improve file naming and organization
1 parent bd5e73b commit e79d732

File tree

6 files changed

+112
-107
lines changed

6 files changed

+112
-107
lines changed

packages/playground/wordpress/src/boot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from '.';
2424
import { basename, dirname, joinPaths } from '@php-wasm/util';
2525
import { logger } from '@php-wasm/logger';
26-
import { ensureWpConfig } from './rewrite-wp-config';
26+
import { ensureWpConfig } from './wp-config';
2727

2828
export type PhpIniOptions = Record<string, string>;
2929
export type Hook = (php: PHP) => void | Promise<void>;

packages/playground/wordpress/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export {
1010
getFileNotFoundActionForWordPress,
1111
} from './boot';
1212
export type { PhpIniOptions, PHPInstanceCreatedHook } from './boot';
13-
export { defineWpConfigConstants, ensureWpConfig } from './rewrite-wp-config';
13+
export { defineWpConfigConstants, ensureWpConfig } from './wp-config';
1414
export { getLoadedWordPressVersion } from './version-detect';
1515

1616
export * from './version-detect';
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
/**
3+
* The base configuration for WordPress
4+
*
5+
* The wp-config.php creation script uses this file during the installation.
6+
* You don't have to use the website, you can copy this file to "wp-config.php"
7+
* and fill in the values.
8+
*
9+
* This file contains the following configurations:
10+
*
11+
* * Database settings
12+
* * Secret keys
13+
* * Database table prefix
14+
* * ABSPATH
15+
*
16+
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
17+
*
18+
* @package WordPress
19+
*/
20+
21+
// ** Database settings - You can get this info from your web host ** //
22+
/** The name of the database for WordPress */
23+
define( 'DB_NAME', 'database_name_here' );
24+
25+
/** Database username */
26+
define( 'DB_USER', 'username_here' );
27+
28+
/** Database password */
29+
define( 'DB_PASSWORD', 'password_here' );
30+
31+
/** Database hostname */
32+
define( 'DB_HOST', 'localhost' );
33+
34+
/** Database charset to use in creating database tables. */
35+
define( 'DB_CHARSET', 'utf8mb4' );
36+
37+
/** The database collate type. Don't change this if in doubt. */
38+
define( 'DB_COLLATE', '' );
39+
40+
/**#@+
41+
* Authentication unique keys and salts.
42+
*
43+
* Change these to different unique phrases! You can generate these using
44+
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
45+
*
46+
* You can change these at any point in time to invalidate all existing cookies.
47+
* This will force all users to have to log in again.
48+
*
49+
* @since 2.6.0
50+
*/
51+
define( 'AUTH_KEY', 'put your unique phrase here' );
52+
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
53+
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
54+
define( 'NONCE_KEY', 'put your unique phrase here' );
55+
define( 'AUTH_SALT', 'put your unique phrase here' );
56+
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
57+
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
58+
define( 'NONCE_SALT', 'put your unique phrase here' );
59+
60+
/**#@-*/
61+
62+
/**
63+
* WordPress database table prefix.
64+
*
65+
* You can have multiple installations in one database if you give each
66+
* a unique prefix. Only numbers, letters, and underscores please!
67+
*
68+
* At the installation time, database tables are created with the specified prefix.
69+
* Changing this value after WordPress is installed will make your site think
70+
* it has not been installed.
71+
*
72+
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix
73+
*/
74+
$table_prefix = 'wp_';
75+
76+
/**
77+
* For developers: WordPress debugging mode.
78+
*
79+
* Change this to true to enable the display of notices during development.
80+
* It is strongly recommended that plugin and theme developers use WP_DEBUG
81+
* in their development environments.
82+
*
83+
* For information on other constants that can be used for debugging,
84+
* visit the documentation.
85+
*
86+
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
87+
*/
88+
define( 'WP_DEBUG', false );
89+
90+
/* Add any custom values between this line and the "stop editing" line. */
91+
92+
93+
94+
/* That's all, stop editing! Happy publishing. */
95+
96+
/** Absolute path to the WordPress directory. */
97+
if ( ! defined( 'ABSPATH' ) ) {
98+
define( 'ABSPATH', __DIR__ . '/' );
99+
}
100+
101+
/** Sets up WordPress vars and included files. */
102+
require_once ABSPATH . 'wp-settings.php';

packages/playground/wordpress/src/test/wp-config-transformer.spec.ts

Lines changed: 7 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
13
import { PHP } from '@php-wasm/universal';
24
import { RecommendedPHPVersion } from '@wp-playground/common';
35
// eslint-disable-next-line @nx/enforce-module-boundaries -- ignore test-related interdependencies so we can test.
@@ -6,110 +8,11 @@ import { phpVars } from '@php-wasm/util';
68

79
import wpConfigTransformer from '../wp-config-transformer.php?raw';
810

9-
const wpConfigSample = `
10-
<?php
11-
/**
12-
* The base configuration for WordPress
13-
*
14-
* The wp-config.php creation script uses this file during the installation.
15-
* You don't have to use the website, you can copy this file to "wp-config.php"
16-
* and fill in the values.
17-
*
18-
* This file contains the following configurations:
19-
*
20-
* * Database settings
21-
* * Secret keys
22-
* * Database table prefix
23-
* * ABSPATH
24-
*
25-
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
26-
*
27-
* @package WordPress
28-
*/
29-
30-
// ** Database settings - You can get this info from your web host ** //
31-
/** The name of the database for WordPress */
32-
define( 'DB_NAME', 'database_name_here' );
33-
34-
/** Database username */
35-
define( 'DB_USER', 'username_here' );
36-
37-
/** Database password */
38-
define( 'DB_PASSWORD', 'password_here' );
39-
40-
/** Database hostname */
41-
define( 'DB_HOST', 'localhost' );
42-
43-
/** Database charset to use in creating database tables. */
44-
define( 'DB_CHARSET', 'utf8' );
45-
46-
/** The database collate type. Don't change this if in doubt. */
47-
define( 'DB_COLLATE', '' );
48-
49-
/**#@+
50-
* Authentication unique keys and salts.
51-
*
52-
* Change these to different unique phrases! You can generate these using
53-
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
54-
*
55-
* You can change these at any point in time to invalidate all existing cookies.
56-
* This will force all users to have to log in again.
57-
*
58-
* @since 2.6.0
59-
*/
60-
define( 'AUTH_KEY', 'put your unique phrase here' );
61-
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
62-
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
63-
define( 'NONCE_KEY', 'put your unique phrase here' );
64-
define( 'AUTH_SALT', 'put your unique phrase here' );
65-
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
66-
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
67-
define( 'NONCE_SALT', 'put your unique phrase here' );
68-
69-
/**#@-*/
70-
71-
/**
72-
* WordPress database table prefix.
73-
*
74-
* You can have multiple installations in one database if you give each
75-
* a unique prefix. Only numbers, letters, and underscores please!
76-
*
77-
* At the installation time, database tables are created with the specified prefix.
78-
* Changing this value after WordPress is installed will make your site think
79-
* it has not been installed.
80-
*
81-
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix
82-
*/
83-
$table_prefix = 'wp_';
84-
85-
/**
86-
* For developers: WordPress debugging mode.
87-
*
88-
* Change this to true to enable the display of notices during development.
89-
* It is strongly recommended that plugin and theme developers use WP_DEBUG
90-
* in their development environments.
91-
*
92-
* For information on other constants that can be used for debugging,
93-
* visit the documentation.
94-
*
95-
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
96-
*/
97-
define( 'WP_DEBUG', false );
98-
99-
/* Add any custom values between this line and the "stop editing" line. */
100-
101-
102-
103-
/* That's all, stop editing! Happy publishing. */
104-
105-
/** Absolute path to the WordPress directory. */
106-
if ( ! defined( 'ABSPATH' ) ) {
107-
define( 'ABSPATH', __DIR__ . '/' );
108-
}
109-
110-
/** Sets up WordPress vars and included files. */
111-
require_once ABSPATH . 'wp-settings.php';
112-
`;
11+
// load wp-config-sample.php
12+
const wpConfigSample = fs.readFileSync(
13+
path.join(import.meta.dirname, 'wp-config-sample.php'),
14+
'utf8'
15+
);
11316

11417
const codeSample = `
11518
/*

packages/playground/wordpress/src/rewrite-wp-config.spec.ts renamed to packages/playground/wordpress/src/test/wp-config.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs';
22
import path from 'node:path';
33
import { PHP } from '@php-wasm/universal';
4-
import { defineWpConfigConstants, ensureWpConfig } from './rewrite-wp-config';
4+
import { defineWpConfigConstants, ensureWpConfig } from '../wp-config';
55
import { RecommendedPHPVersion } from '@wp-playground/common';
66
// eslint-disable-next-line @nx/enforce-module-boundaries -- ignore test-related interdependencies so we can test.
77
import { loadNodeRuntime } from '@php-wasm/node';

0 commit comments

Comments
 (0)