I have a quick question about the
I understand that I can put here my custom hooked functions, this works, but only sometimes.
It seem that some filter/action hook aren’t working if they’re used from
extras.php. They only work from the theme
The throwed error is like below :
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'woo_add_to_cart_check_custom' not found or invalid function name in ...\project\wp-includes\plugin.php on line 235
Is there something i didnt understood about this file ? Or is it used but for some special hooks ?
/lib/extras.php is namespaced. You must include namespace when passing a function within it as a callback.
See “Namespaces” section: https://roots.io/upping-php-requirements-in-your-wordpress-themes-and-plugins/
Thanks master. It was the perfect answer.
Last question, they said on the page you sent me that if for example i need to use
wp_query() i need to precise root namespace (or throught “
But it seem i dont need it to use the wordpress
How do we know wich function (WP core, i think that plugin function always need namespacing) need to have the root namespace specified ?
Thanks again, a lot really.
You only need to worry about classes, functions automatically are assumed to be in the global namespace, unless you prefix a function with a namespace
Thanks @kalenjohnson, all is good now