Skip to content

Commit 1e56241

Browse files
committed
Bugfix: make extension_url contain correct url in all cases
The old code populated _extension_url with contents like https://example.org/var/www/sites/htdocs/wp-content/plugins/redux-framework/ -> ReduxCore/inc/extensions/customizer/ New implementation is does not mind if Redux is embedded in a theme or plugin, supports having WordPress installed in any directory and to avoid future bugs: the new code is clean and easy to read.
1 parent bbb2d7d commit 1e56241

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

extensions/customizer/extension_customizer.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public function __construct( $parent ) {
8080
add_action( 'customize_save_after', array( &$this, 'customizer_save_after' ) ); // After save
8181
if ( empty( $this->extension_dir ) ) {
8282
$this->extension_dir = trailingslashit( str_replace( '\\', '/', dirname( __FILE__ ) ) );
83-
$this->extension_url = site_url( str_replace( trailingslashit( str_replace( '\\', '/', ABSPATH ) ), '', $this->extension_dir ) );
83+
preg_match("/wp-content\/(.*)/", $this->extension_dir, $match);
84+
$this->extension_url = site_url('/wp-content/'.$match[1]);
8485
}
8586

8687
}

extensions/edd/extension_edd.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ public function __construct( $parent ) {
5252

5353
if ( empty( $this->extension_dir ) ) {
5454
$this->extension_dir = trailingslashit( str_replace( '\\', '/', dirname( __FILE__ ) ) );
55-
$this->extension_url = site_url( str_replace( trailingslashit( str_replace( '\\', '/', ABSPATH ) ), '', $this->extension_dir ) );
55+
preg_match("/wp-content\/(.*)/", $this->extension_dir, $match);
56+
$this->extension_url = site_url('/wp-content/'.$match[1]);
5657
}
57-
58+
5859

5960
if ( isset( $parent->args['edd'] ) && !empty( $parent->args['edd'] ) ) {
6061
// Create defaults array

0 commit comments

Comments
 (0)