I fixed the error for now. Since I’m using a Windows system and you are using string compares to prevent edge cases I run into this issue:
in “rbm-field-helpers-php”:
if ( strpos( __FILE__, WP_PLUGIN_DIR ) !== false) {
define( 'RBM_FIELD_HELPERS_URI', plugins_url( '', __FILE__ ) );
define( 'RBM_FIELD_HELPERS_DIR', plugin_dir_path( __FILE__ ) );
} else {
$theme_dir = get_stylesheet_directory();
// Relative path from the Theme Directory to the directory holding RBM FH
$relative_from_theme_dir = dirname( str_replace( $theme_dir, '', __FILE__ ) );
// Build out our Constants for DIR and URI
// DIR could have been made using just dirname( __FILE__ ), but we needed the difference to create the URI anyway
define( 'RBM_FIELD_HELPERS_URI', get_stylesheet_directory_uri() . $relative_from_theme_dir );
define( 'RBM_FIELD_HELPERS_DIR', $theme_dir . $relative_from_theme_dir );
}
and this is my fix for now.
//this fixes issues when comparing the string in the next step.
//Original result of "WP_PLUGIN_DIR" for me was C:\xampp\htdocs\wp-content/plugins" - and is being tested against a string with only "\" in it.
$alternateString = str_replace( "/", "\\", WP_PLUGIN_DIR);
if ( strpos( __FILE__, WP_PLUGIN_DIR ) !== false || strpos(__FILE__, $alternateString) !== false) {
define( 'RBM_FIELD_HELPERS_URI', plugins_url( '', __FILE__ ) );
define( 'RBM_FIELD_HELPERS_DIR', plugin_dir_path( __FILE__ ) );
} else {
$theme_dir = get_stylesheet_directory();
// Relative path from the Theme Directory to the directory holding RBM FH
$relative_from_theme_dir = dirname( str_replace( $theme_dir, '', __FILE__ ) );
// Build out our Constants for DIR and URI
// DIR could have been made using just dirname( __FILE__ ), but we needed the difference to create the URI anyway
define( 'RBM_FIELD_HELPERS_URI', get_stylesheet_directory_uri() . $relative_from_theme_dir );
define( 'RBM_FIELD_HELPERS_DIR', $theme_dir . $relative_from_theme_dir );
}
@additivefx
Thanks for the report! I believe this could be fixed with wp_normalize_path(). Could you try replacing your fix with the following for me? I do not have a Windows server to test on.
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
if ( strpos( __FILE__, $plugin_dir ) !== false ) {
define( 'RBM_FIELD_HELPERS_URI', plugins_url( '', __FILE__ ) );
define( 'RBM_FIELD_HELPERS_DIR', plugin_dir_path( __FILE__ ) );
}
else {
$theme_dir = get_stylesheet_directory();
// Relative path from the Theme Directory to the directory holding RBM FH
$relative_from_theme_dir = dirname( str_replace( $theme_dir, '', __FILE__ ) );
// Build out our Constants for DIR and URI
// DIR could have been made using just dirname( __FILE__ ), but we needed the difference to create the URI anyway
define( 'RBM_FIELD_HELPERS_URI', get_stylesheet_directory_uri() . $relative_from_theme_dir );
define( 'RBM_FIELD_HELPERS_DIR', $theme_dir . $relative_from_theme_dir );
}
-
This reply was modified 6 years, 12 months ago by
d4mation. Reason: formatting
-
This reply was modified 6 years, 12 months ago by
d4mation.
-
This reply was modified 6 years, 12 months ago by
d4mation. Reason: Long week
I have edited the above a few times. Just in case you grabbed one of the previous versions of it I wanted you to be aware 🙂
Hi,
this does not fix the problem, since it tries to match the these two strings:
C:/xampp/htdocs/wp-content/plugins
C:\xampp\htdocs\wp-content\plugins\client-dash\core\library\rbm-field-helpers\rbm-field-helpers.php
You have to normalize both strings, so this is the fix you’re looking for:
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
$current_file_dir = wp_normalize_path ( __FILE__ );
if ( strpos( $current_file_dir, $plugin_dir ) !== false ) {
...
@additivefx
Sorry for the delay. I must have missed the email replies for this.
I’ll run through some testing for this and let you know when I’ve released an update!
@additivefx
I wanted to let you know that I’ve released a fix for this in Client Dash v2.1.2. This should work properly on Windows-based Servers now!