How plugins_loaded works?
I am developing a plugin for woocommerce payment gateway.
When I put the code of class definition inside the callback function who is fired by 'plugins_loaded',it works.
?php
add_action('plugins_loaded','WC_test_gateway_plugin');
function WC_test_gateway_plugin{
class my_gateway extends WC_Payment_Gateways{
//code
}
}
?
But when I put it into global scope, it will show that the WC_Payment_Gateways is undefined.
?php
class my_gateway extends WC_Payment_Gateways{
//code
}
?
What's the difference between these 2 practices?
Is it a bad practice to put class definition inside callback function? Any better way for it?
Topic woocommerce-offtopic plugin-development Wordpress
Category Web