• Resolved gsc89

    (@gsc89)


    2 issues.

    Upon activating your plugin:

    View post on imgur.com

    “The plugin generated 186 characters of unexpected output during activation. If you notice “ headers already sent ” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.”

    “Unable to load pluggable.php in: /wp-includes/pluggable.php Safety Exit is disabled until this error is fixed.”

    Following up on this, I have looked into your plugin file.

    This is not good code:

    
    try {
    	if( !file_exists(realpath(dirname(__FILE__) . '/../../../')."/wp-includes/pluggable.php") ) {
    		throw new Exception ('Unable to load pluggable.php in: ' . realpath(dirname(__FILE__) . '/../../../')."/wp-includes/pluggable.php" . ' Safety Exit is disabled until this error is fixed.');
    	}else{
    		require_once(realpath(dirname(__FILE__) . '/../../../')."/wp-includes/pluggable.php");
    	}
    }catch(Exception $e){
    	if ( is_admin() ){
    	?>
    	<div class="error notice">
    		<p><?= $e->getMessage(); ?></p>
    	</div>
    	<?php
    	}
    	$errors = true;
    }
    

    You are assuming all wordpress installs will have the pluggable.php file in the same location by relative path, this is poor.

    Many wordpress installs are now based on composer meaning your relative path code here will not be accurate across all wordpress installs.

    You should be working out where wordpress is actually installed not relying on this being correct by relative path.

    This topic touches on the number of ways you can get this path without using relative paths like you have.

    https://stackoverflow.com/questions/6195451/how-to-get-wp-include-directory

    • This topic was modified 4 years, 7 months ago by gsc89.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter gsc89

    (@gsc89)

    This code would allow this plugin to work with bedrock installs. https://roots.io/bedrock/

    
    
    $path = realpath(dirname(__FILE__) . '/../../../')."/wp-includes/pluggable.php";
    
    // This adds support for bedrock, ABSPATH is set by bedrock as part of the config.
    if(defined('ABSPATH')){
        $path = ABSPATH . '/wp-includes/pluggable.php';
    }
    
    $errors = false;
    // Check to see if required file exists. If not do not initialize plugin
    try {
        if( !file_exists( $path ) ) {
            throw new Exception ('Unable to load pluggable.php in: ' . $path . ' Safety Exit is disabled until this error is fixed.');
        }else{
            require_once($path);
        }
    }catch(Exception $e){
        if ( is_admin() ){
            ?>
            <div class="error notice">
                <p><?= $e->getMessage(); ?></p>
            </div>
            <?php
        }
        $errors = true;
    }
    

    You would probably need a better method to handle composer based installs not using bedrock.

    Plugin Author tcordero

    (@tcordero)

    Hey @gsc89,

    Sorry for the late response! Works been crazy busy. Thats for the input! If you want you can make a pull request on the plugins github and I can review / merge it! However I will add it to my TODO list for the plugin!

    Thanks,
    Tomas

    Thread Starter gsc89

    (@gsc89)

    Missed this sorry, I have done as you instructed and made a PR over on github.

    Thread Starter gsc89

    (@gsc89)

    @tcordero can you please merge that pull request? Its been a few months now and would still like to use a non core modified version of your plugin.

    https://github.com/tomascordero/safety-exit/pulls

    Thanks,
    Sam.

    Plugin Author tcordero

    (@tcordero)

    Hey @gsc89

    Sorry about the delay! Started a new job a few months back and it has been go go go! I actually have been scheduling some time in the coming weeks to do a massive overhaul of the button designer. Before I start on that I will merge your addition into master. Keep an eye out for the update this weekend!

    Thanks again for doing the pull request!

    -Tomas

    Plugin Author tcordero

    (@tcordero)

    This update has been pushed!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Plugin not working.’ is closed to new replies.