Closed mnajafzadeh closed 5 years ago
Hi,
Thank you
Please, check this example https://regex101.com/r/QVdhlX/1 You can see if I use [\/\]wp-content$ it will not work for: /host/src/wp-content/
Regards
The default definition of WP_CONTENT_DIR
does not contain a trailing slash (https://github.com/WordPress/WordPress/blob/5.2.1/wp-includes/default-constants.php#L72, https://github.com/WordPress/WordPress/blob/5.2.1/wp-load.php#L68) So you are talking about a case that WP_CONTENT_DIR
has a user-defined custom definition with a trailing slash.
Then I'd suggest preg_replace( '/[\/\\\\]wp-content$/', '', rtrim( WP_CONTENT_DIR, '/\\' ) )
.
Great! I use your suggestion.
Regarding the regular expression pattern,
/[\/\\\\]+wp-content(.*)/m
,+
beforewp-content
? It should be removed if there is no good reason.m
? In what case,WP_CONTENT_DIR
holds a multi-line value? It should be removed if there is no good reason..(.*)
? This will be a problem for rare cases that a user installs WordPress under awp-content
directory. It should be replaced with$
if there is no good reason.