PHP Error on activation
-
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__ ) );
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘PHP Error on activation’ is closed to new replies.