Delay main class initialisation so plugins can use the provided hooks
-
Currently the plugin initialises outside of any hook, so any plugins (or even more tragically: themes) that load after this plugin can not use most of the plugins hooks, because by the time the code execution reaches these plugins/themes, WPSL hooks have already been fired. Just try to add this code anywhere outside the WPSL plugin and set a breakpoint in it. The breakpoint will never be reached.
add_filter( 'wpsl_store_meta', 'dgz_wpsl_store_meta', 10, 2 );
function dgz_wpsl_store_meta( $store_meta, $pid ) {
return $store_meta;
}
add_filter('wpsl_frontend_meta_fields', 'dgz_wpsl_frontend_meta_fields' );
function dgz_wpsl_frontend_meta_fields($store_fields){
return $store_fields;
}Suggested solution:
Inside wp-store-locator.php initialise the main WPSL class inside a hook like this:
add_action('plugins_loaded', function(){
$GLOBALS['wpsl'] = new WP_Store_locator();
});This way WPSL will retain full functionality, but the delayed initialisation will allow other plugins to use the hooks provided.
Thank you for your consideration.
The topic ‘Delay main class initialisation so plugins can use the provided hooks’ is closed to new replies.