jcchavezs / cmb2-conditionals

Plugin to relate fields in a CMB2 metabox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cmb2-conditionals should only work on cmb2 fields/metaboxes not all of them

sbouafif opened this issue · comments

Hello,

For a client, I'm using another plugin (Post Public Preview - https://wordpress.org/plugins/public-post-preview/) to create a preview link for non logged in users when the post is in draft mode.

The plugin work like this:

  • Adds a checkbox and an input field containing the url in the "submit box"
  • the input field is not displayed when the checkbox is not checked
  • when the checkbox is clicked, it hides or shows the input field while making an ajax request

When using it with cmb2-conditionnals, cmb2-conditionnals set the Post Public Preview's input field to visible instead of the normal behavior (hidden).

A quick fix for this is to enable cmb2-conditionals only for cmb2 metaboxes and not the entire post page by replacing "CMB2ConditionalsInit( '#post', '#post .cmb2-wrap' );" with "CMB2ConditionalsInit( '.cmb2-postbox', '#post .cmb2-wrap' );"

AFAIR if you did that, you would not be able to have a condition which depends on for instance the publish status and you wouldn't be able to have a condition depending on the status of a field another plugin adds.

Oh I didn't see that cmb2-conditionals works with conditions with fields not created by cmb2. I was only using it with fields I created with cmb2.

The issue can be closed then ;)