2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-08-12 12:20:02 +00:00
WordPress makes it possible to define options using `define` statements inside a configuration file named `wp-config.php`. However, if `define` statements are located at the end of this file, they are ignored by WordPress. This rule raises an issue when a `define` statement appears after `wp-settings.php` is loaded.
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-08-12 12:20:02 +00:00
2022-02-04 17:28:24 +01:00
[source,php]
2021-08-12 12:20:02 +00:00
----
// in wp-config.php
define( 'WP_DEBUG', false );
/* Add any custom values between this line and the "stop editing" line. */
/* That's all, stop editing! Happy publishing. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
require_once ABSPATH . 'wp-settings.php';
define( 'WP_POST_REVISIONS', 3 ); // Noncompliant
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2021-08-12 12:20:02 +00:00
2022-02-04 17:28:24 +01:00
[source,php]
2021-08-12 12:20:02 +00:00
----
// in wp-config.php
define( 'WP_DEBUG', false );
/* Add any custom values between this line and the "stop editing" line. */
define( 'WP_POST_REVISIONS', 3 ); // Noncompliant
/* That's all, stop editing! Happy publishing. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
require_once ABSPATH . 'wp-settings.php';
----