• Hi,

    I’m currently facing a very strange issue that must come from Client Dash – When I deactivate the plugin it goes away.

    Only in the backend I get Warnings in the JavaScript console (and similar errors in my apache error log) saying this:

    Failed to load <script> with source "http://myurl/wp-content/themes/JointsWP-CSS-masterC:xampphtdocswp-contentpluginsclient-dashcorelibraryrbm-field-helpers/assets/dist/js/rbm-field-helpers-admin.min.js?ver=1.4.3".

    I get LOTS of them every time the admin page is loaded and I don’t know where to start to find the problem. Every one of those errors contains the string

    C:xampphtdocswp-contentpluginsclient-dashcorelibraryrbm-field-helpers

    which seems to be inserted into these paths that are otherwise correct. Since that’s your plugin I thought I’d ask you first!

    Thanks! btw. it’s VERY urgent, this it probably the source of freezes of our webserver that happen every few days…

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Jonathan Laukenmann

    (@additivefx)

    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 );
    		
    }
    Plugin Author d4mation

    (@d4mation)

    @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
    Plugin Author d4mation

    (@d4mation)

    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 🙂

    Thread Starter Jonathan Laukenmann

    (@additivefx)

    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 ) {
    ...
    Plugin Author d4mation

    (@d4mation)

    @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!

    Plugin Author d4mation

    (@d4mation)

    @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!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Loading Script failed Errors – Path without Backslashes’ is closed to new replies.