DevinVinson / WordPress-Plugin-Boilerplate

[WordPress] A foundation for WordPress Plugin Development that aims to provide a clear and consistent guide for building your plugins.
http://wppb.io
7.66k stars 2.25k forks source link

Help Including Callback Function in Plugin Boilerplate #571

Open GermanPearls opened 3 years ago

GermanPearls commented 3 years ago

Trying the boilerplate for the first time and am running into problems with including functions used in hooks.

Here's what I did:

  1. created call back function, 'call-back-function'
  2. 'call-back-function' saved in a callback-functions.php file
  3. in includes/class-plugin-name.php file, I have:

require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/callback-functions.php';

  1. in includes/class-plugin-name.php file, in define_public_hooks function I included:

$this->loader->add_action( 'frm_after_create_entry', $plugin_public, 'call-back-funciton', 30, 2);

But, the hook can't find the call-back-function. I get an error:

call_user_func_array() expects parameter 1 to be a valid callback....

What am I missing / doing wrong?

christiespeich commented 2 years ago

call-back-function should be a function in the class {plugin_name}_Public