Code Block is executed ignoring the visibility conditions of the parent block

I have a code block that enqueues scripts.

add_action('wp_enqueue_scripts', function() {
  ...
  wp_enqueue_script('stripe', 'https://js.stripe.com/v3/');
  wp_enqueue_script('checkout', $js, array(), $ver, array('strategy'  => 'defer'));
  ...
});

The code block is placed inside a Div block with visibility conditions.

image

My expectation is that the code inside the code block will execute only when the visibility condition of its parent/ancestor is met. However, this is not the case. The code block is always executed. Resulting the scripts to be enqueued although they shouldn’t.

The code block should be executed (evaluated) only when visibility conditions of the parent/ancestor is met.

  • WordPress version: 6.4.1
  • Cwicly Plugin version: 1.3.4.1

Hi @nadim,

What visibility conditions are you using for the div block?

Hi, @StrangeTech ,

In this specific case I am using a return function. See below:

image

The function returns “true” and the condition evaluates to “false”. So, no HTML from div and its children is actually rendered on the frontend, as expected. However, seems that the code inside the code block is executed anyway on the backend and this causes the scripts to be enqueued.