michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
339 stars 71 forks source link

Replacing ABSPATH to work on Wordpress.com servers. #282

Closed mnajafzadeh closed 5 years ago

michaeluno commented 5 years ago

Regarding the regular expression pattern, /[\/\\\\]+wp-content(.*)/m ,

mnajafzadeh commented 5 years ago

Hi,

Thank you

mnajafzadeh commented 5 years ago

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

michaeluno commented 5 years ago

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, '/\\' ) ).

mnajafzadeh commented 5 years ago

Great! I use your suggestion.