Suppress Error Message before Meta-Box-Groups is Activated

Support MB Group Suppress Error Message before Meta-Box-Groups is Activated

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2635
    pluginovenpluginoven
    Participant

    I am including the meta-box-group plugin as part of our T(-) Countdown Event plugin, and we are using TGMPA to let users know that meta-box-group is a required plugin. However, between the time when our plugin and the meta-box-group plugin is activated, the system is throwing the following warnings:

    Warning: call_user_func() expects parameter 1 to be a valid callback, class 'RWMB_Group_Field' not found in .../wp-content/plugins/meta-box/inc/meta-box.php on line 351
    and
    Warning: call_user_func() expects parameter 1 to be a valid callback, class 'RWMB__Field' not found in .../wp-content/plugins/meta-box/inc/meta-box.php on line 65

    I understand why these warnings are being thrown.
    I understand these will not be displayed if wp-debug is turned off.
    I would just like to inquire about the best practices to avoid having these warnings thrown at all.

    The first thing that comes to mind is to do a conditional check before registering the meta-box group files to ensure that the meta-box-group plugin is activated.

    Another idea would be to only include the entire meta-box registration file if the meta-box-group plugin is activated.

    Or maybe there is a flag that can be set when registering the meta_box grouped fields to suppress this message?

    What are your thoughts on this?

    #2636
    pluginovenpluginoven
    Participant

    This is what I ended up doing:
    I include the meta-box file only if the plugin is activated like so:

    if ( is_plugin_active( 'tmeta-box-group/meta-box-group.php' ) ){
    	include ('inc/config-meta-boxes.php');
    }
    

    NOTE: the folder is now tmeta-box-group (not sure when this changed) and NOT meta-box-group.

    #2639
    Anh TranAnh Tran
    Keymaster

    Hi,

    I think you're doing correctly. However, I will think more about a better way to suppress the error. For now, all fields' classes are loaded by autoload and it makes us impossible to use class_exists.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Suppress Error Message before Meta-Box-Groups is Activated’ is closed to new replies.