Custom callback not working

Support MB Conditional Logic Custom callback not working

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24939
    JulienJulien
    Participant

    Hello,

    I tried today to make working my custom callback condition but it's not working...
    I followed documentation without success

    Example code

    <?php
    add_action( 'admin_head', function(){
      ?>
          <script type="text/javascript">
              function dummy_function(){
                console.log('dummy');
                return false;
              }
          </script>
    <?php
    }, 100);
    
    add_filter( 'rwmb_meta_boxes', function($meta_boxes){
    
      $meta_boxes[] = array(
        'title'  => 'Conditional meta',
        'post_types' => array( 'post', 'page' ),
        'fields' => array(
          array(
            'visible' => ['dummy_function()', true],
            'name'       => 'Color',
            'id'    => "color",
            'type'       => 'text',
          ),
        ),
      );
    
      return $meta_boxes;
    
    });
    ?>

    If I comment lines 249 on conditional-logic.js my function is evaluated.
    File is located on /plugins/meta-box-aio/meta-box-conditional-logic/conditional-logic.js

    All is updated
    Wordpress 5.7
    Meta Box 5.3.9
    Meta Box AIO 1.13.4

    #24940
    JulienJulien
    Participant
    <?php
    if ( ! isGutenbergElement( logic[0] ) && ! dependentFieldSelector && !compare(logic[0], ')', 'contains') ) {
        return;
    }

    instead of

    <?php
    if ( ! isGutenbergElement( logic[0] ) && ! dependentFieldSelector ) {
        return;
    }

    It could be a real fix ?

    #24946
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thank you for your effort.

    Your suggestion code works as well on my end. I will inform the development team to check on this case.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.