Forum Replies Created

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

    (@additivefx)

    Also: How can I get any messages from your plugin so I can at least try to debug this?

    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 ) {
    ...
    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 );
    		
    }
Viewing 3 replies - 1 through 3 (of 3 total)