The warning is clear:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘cookie_GA’ not found or invalid function name in C:\wamp64\www\wordpress\wp-includes\class-wp-hook.php on line 286
So cookie_GA()
is not found. When can this be the case? Well, of course when is_allowed_cookie('_ga')
is false. So either wrap the add_action()
call inside that if
as well or create a dummy function.
if (is_allowed_cookie('_ga')) {
add_action( 'init', 'cookie_GA' );
function cookie_GA() { /* your code */ }
}