• Resolved digitaltech

    (@digitaltech)


    Greetings,

    Your plugin looks nice. However, I got a fatal error right off the bat due to the content directory name being hard coded at line 11 of…

    /plugins/minimal-coming-soon-maintenance-mode/framework/admin/preview.php

    Instead, one of the built-in WP functions should be used. See…

    https://codex.www.ads-software.com/Determining_Plugin_and_Content_Directories

    I have renamed my content directory using the following in my wp-config.php…

    define( ‘WP_CONTENT_DIR’, ‘my-content-dir-name’ );

    This is sanctioned practice, so updating your code to use a built-in WP function to get the name should resolve the issue.

    -Steve

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author WebFactory

    (@webfactory)

    Hi Steve,
    Don’t know how that got under the radar ?? Really sorry! We’ll get it fixed ASAP to use the appropriate WP function and fetch the dir.

    Thank you for letting us know!

    Plugin Author WebFactory

    (@webfactory)

    @digitaltech this is proving to be a bit more difficult than we thought. Since preview.php is called directly there are no WP ENV vars to rely on. So at the moment, the code stays as is because there is no proper quick fix. We have to rewrite how the whole preview works in order to fix it. Sorry ??

    Thread Starter digitaltech

    (@digitaltech)

    Sorry for the late reply, but thanks for the notice. Just FYI, the following should enable the preview to work for default WP installations as well as in situations where the wp-content directory is simply renamed (such as in my case)…

    
    $wp_loader = realpath( __DIR__ . '/../../../../../wp-load.php' );
    if ( file_exists( $wp_loader ) ) {
    	require_once( $wp_loader );
    } else {
    	die( 'Unable to load WP core. Please preview Maintenance Mode by opening the site home page.' );
    }
    

    It won’t work, however, in cases where the wp-content directory is actually moved to another location relative to the site root.

    Plugin Author WebFactory

    (@webfactory)

    Hi,
    By rename you mean “kept on the same folder level as default, just literarily renamed”? That leaves us with people that moved it somewhere else in the folder structure ??

    Idea: we try to load default location first and cover 99% of users. If it fails we search for wp-load.php file. That should cover 0.9% leaving us with 0.1% that can’t be helped anyway ??

    Thread Starter digitaltech

    (@digitaltech)

    Yes, exactly. What I offered is an improvement over the existing approach, but it doesn’t cover the case where wp-content has been moved to another level.

    Plugin Author WebFactory

    (@webfactory)

    I’ll give my idea a go. I think it will cover 99.99% of cases. Will let you know!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Fatal Error Due to Hard Coded Directory Name’ is closed to new replies.