Warning: call_user_func_array() expects parameter 1 to be a valid callback

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 … Read more

How to import the css in the plugin admin area?

Just hook your callback into admin_print_styles, i.e.: add_action( ‘admin_print_styles’, ‘mytheme_add_init’ ); Alternately, you could add an is_admin() conditional wrapper inside your callback, and hook into wp_enqueue_scripts: function mytheme_add_init() { if ( is_admin() ) { $file_dir=get_bloginfo(‘template_directory’); wp_enqueue_style(“functions”, $file_dir.”/scripts/custom.css”, false, “1.0”, “all”); wp_enqueue_script(“rm_script”, $file_dir.”/scripts/custom.js”, false, “1.0”); } } add_action( ‘wp_enqueue_scripts’, ‘mytheme_add_init’ ); But the absolute best approach … Read more

WordPress plugin enqueue scripts working for js, but not css files

The function wp_enqueue_style last argument is the $media and you set it to true so its mean you are doing <link rel=”stylesheet” … media=”1″ /> $media (string) (Optional) The media for which this stylesheet has been defined. Accepts media types like ‘all’, ‘print’ and ‘screen’, or media queries like ‘(orientation: portrait)’ and ‘(max-width: 640px)’. Default … Read more

How to include jQuery into my plugin so I can use it on plugin page?

JQuery is a part of WordPress core, so it is automatically there for you to use (i.e. you do not need to register it). However, you still need to enqueue it. This can be done as follows: function my_script() { wp_enqueue_script(‘jquery’); } add_action(‘wp_enqueue_scripts’, ‘my_script’); This loads jQuery from WordPress core, the jQuery files can be … Read more

Remove an action by extending class and replacing it

Problem lies in this line: remove_action(‘woocommerce_before_my_account’, array( $this, ‘my_packages’)); This won’t remove action registered by parent class, because $this is a different object in this case, so you won’t remove any action at all. So how to remove such action? Since you can’t access the same $this value in your class, you’ll have to iterate … Read more

Ajax is not working in a loop

Your code has var getid = $(‘#my-categorychecklist input:checked’).last().val(); see the .last(), that’s why you’re only getting the last item Also, why do you have the same thing in getid and matchid? You need to store the selected categories in an array and loop through them, try something like: var selected_cats = $(‘#my-categorychecklist input:checked’).map(function() { return … Read more

Plugin does not add action

Activation hook is run only after the plugin get activated. So only once and only during that one request. It’s meant to allow author of a plugin to perform some actions after the plugin is activated. Actions, that need to be done only once. For example if your plugin uses custom database table – you … Read more