WordPress.org

Ready to get started?Download WordPress

Forums

Hook Sniffer
[resolved] PHP Error on activation (8 posts)

  1. NateWr
    Member
    Posted 4 months ago #

    When I try to activate this plugin, it makes a require_once() call to load wp-hook-sniff-core.php. This fails because the plugin's folder name is (mis)defined.

    The error occurs on line 71 of wp-hook-sniffer.php. Here's the relevant code:

    /* Define the component's parent folder name */
    	define( 'WP_HOOK_PLUGIN_NAME', 'wordpress-hook-sniffer' );
    
    	/* Define the component's loader file -- this file */
    	define( 'WP_HOOK_PLUGIN_LOADER', 'wp-hook-sniffer.php' );
    
    	/* Define component's directory and URL Paths */
    	define( 'WP_HOOK_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . WP_HOOK_PLUGIN_NAME );
    	define( 'WP_HOOK_PLUGIN_URL', WP_PLUGIN_URL . '/' . WP_HOOK_PLUGIN_NAME );
    
    	/* WordPress is installed and activated, finish initialization and go! */
    	require_once( WP_HOOK_PLUGIN_DIR . '/wp-hook-sniff-core.php' );

    Notice that the WP_HOOK_PLUGIN_NAME is 'wordpress-hook-sniffer' but the plugin installs to 'hook-sniffer' when installed through the WP admin dashboard. Since people can rename the plugin directory, I find the following a more reliable way to define the plugin path info:

    define( 'PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
    define( 'PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
    define( 'PLUGIN_FNAME', plugin_basename( __FILE__ ) );

    https://wordpress.org/plugins/hook-sniffer/

  2. NateWr
    Member
    Posted 4 months ago #

    FYI, in case anyone else runs into the same issue. This also means that I can't deactivate the plugin through the interface, so it has not restored the default /wp-includes/plugin.php file. I needed to manually restore this file to prevent a PHP notice from displaying on the permalinks page.

  3. Mirco Babini
    Member
    Plugin Author

    Posted 2 months ago #

    NateWr,
    Thank you so much for your feedback.

    I'll fix that asap today.

    Thanks again.

  4. matifibrahim
    Member
    Posted 1 month ago #

    @Mirco

    Please check the plugin on wp3.9 it is throwing error on activation.

  5. Mirco Babini
    Member
    Plugin Author

    Posted 1 month ago #

    Done,
    Check the latest 0.17 release.

    @NateWr thank you so much for your feedback.
    @matifibrahim hope it works for you now.

    If you find the plugin useful, feel free to review it with some stars :)

    Thanks again,

  6. matifibrahim
    Member
    Posted 1 month ago #

    @Micro

    Throwing fatal error when go to Settings->WP Hook Sniffer

    Fatal error: Call to undefined function wp_register_plugin_realpath() in C:\wamp\www\wp3.9\wp-settings.php on line 213

    same error when you try to deactivate the plugin. A through testing is needed on wp3.9 if you want to resurrect this plugin. Thanks for your efforts.

  7. Mirco Babini
    Member
    Plugin Author

    Posted 1 month ago #

    It's coz your WordPress is corrupted.
    As @NateWr said you must replace the /wp-includes/plugin.php file.

    I'm sorry, it's here.

    Cheers,

  8. cwgservices
    Member
    Posted 1 month ago #

    Hey Mirco, I have a modified plugin.php file that has the missing functions restored. I can provide by email, please contact me by replying to the [accidentally sent prematurely] email to you via contact form on your site.

    I put my new file in place of your 'modified' version, and I was able to activate the plugin on 3.9.1 without getting a fatal error. Unfortunately I didn't get any output either, even after checking all possible types of output in the settings page. So there's something else wrong but at least this avoids manual replacement of plugin.php to restore normal site operation.

    Thanks for your work on this. I hope you will contact me for the file, and that it will help. There are two sections where functions had to be added, and I commented the beginning and end of each section with my initials so you can easily zero in on the changes.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.