Custom script in header causing error in pro page editing or customization

Hi - When adding a script (apex chat in this case) to the header within functions.php (pro-child) it then breaks pro editing or customization, but the script works fine on the front end. Guessing I am doing something wrong or missing something. Thank you for your time.

Receiving the following error when editing a page or customizing with Pro:
WARNING: You are viewing this page in an unauthorized frame window!

function add_head_script() { ?>

<?php } add_action( 'wp_head', 'add_head_script', 99 ); ?>

Hi there @z1z1z1,

Can you paste the entire function you are trying to add please. You shouldn’t receive an error like that. It could be through the misplacement of tags or if you are trying to load an iFrame from another site within the header.

If you could even perhaps attach or include a dropbox link to your entire functions.php in a secure note that would be great.

Thanks!

Hi - Upon save the script is removed, tried multiple times. Added secure note as requested and the script was removed as well.

Hi There,

Try uploading the file functions.php file using a dropbox and then share us the link instead. Before that, try adding a filter on the code so it will only be added when you’re not on the builder. Something like this:

  function add_head_script(){
      if (!isset($_GET['cornerstone'])) {
     ?>
      <!-- Insert SCRIPT Here -->
     <?php 
     }
   }
   add_action( 'wp_head', 'add_head_script' );

Hope this helps.

Hi - Thank you for the update. Unfortunately this resulted in the same issue. Chat initiates fine but pro editor no longer works. I’ve added a secure note with details to functions.php output and screenshots of the errors and issues. Please let me know if you need any further information.

Hi there,

Hmm, maybe it’ needs to be excluded in the preview, please try this one instead

  function add_head_script(){
      if ( isset( $_GET['cornerstone_preview'] ) ) return false;

     ?>
      <!-- Insert SCRIPT Here -->
     <?php 

   }
   add_action( 'wp_head', 'add_head_script' );

Hope this helps.

Hi - Thank you for the response. That worked in loading the chat script and also fixed the issue with page editing using Pro. When customizing ‘Appearance -> Customize’ same issues occur with the redirect and unable to customize options. Updated the shared drive with a new screenshot ‘customize-redirect’.

Hi There,

Can you try this:

  function add_head_script(){
  if ( isset( $_GET['cornerstone_preview'] )  ||  isset( $_GET['customize_theme'] ) ) return false;

 ?>
  <!-- Insert SCRIPT Here -->
 <?php 

 }
 add_action( 'wp_head', 'add_head_script' );

Let us know how this goes.

Hi - Thank you again. This fixed the customizer, but last time I forgot to check pro-header and footer editor. That is the last piece that is still not working. Updated drive with new screen shot of the header editor ‘pro-header-warning’.

Hello There,

Thanks for updating in! Do you have any other custom code added on the page? A raw html or an iframe code may have been added on the page. To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

Please let us know how it goes.

Hi - Entire issue is about resolved other than the customizer breaking, pro header and footer works, page pro editor works, only thing that does not is the Appearance -> Customize. No other custom code, raw html, nor iframe. Site is under development and not publicly accessible.

Hello There,

Thanks for updating in! There could be a JS error on the page which is why the customizer is not saving it. Instead of using the customizer, please go to Pro > Launch > Theme Options. All the options here are mostly the same thing you see in the customizer. Please check that out and made your changes of settings from there.

Please let us know how it goes.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.