jcchavezs / cmb2-conditionals

Plugin to relate fields in a CMB2 metabox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Any reason not to support option pages?

asadkn opened this issue · comments

There seems to be no support for option pages by default. Is there any reason why not?

It can be added by modifying the cmb2-conditionals.js file with:

CMB2ConditionalsInit('.cmb2-options-page', '.cmb2-options-page .cmb-field-list');

And by adding the cmb2-conditional.js enqueu manually in the plugins. Now adding the enqueue is easy, but the JS code should exist in cmb2-conditionals.js by default so it doesn't have to be modified.

@asadkn Change this line to:

CMB2ConditionalsInit( '.cmb-form' );

Also, you will have to change this line to something like:

if ( 'admin.php' !== $GLOBALS['pagenow'] || 'arp_options' !== $GLOBALS['plugin_page'] ) {
  return;
}

Or just remove it.

Sorry for the GH issue noise, but thanks for the two pointers above for getting this working on options pages. Just what I was needing.