There are a few ways to speak back and forth with the customizer API. I don't think my scenario is that much f an offshoot so I will give it to you.

  1. I have a button in the Customizer to trigger a PHP script. It is a settingless control button. The part about it being an action and not a setting is very important. This button only controls an action for the preview pane.
  2. The PHP script that the button triggers via AJAX compiles CSS and returns it via the natural post javascript functionality.
  3. I have no way of pushing the data to a style tag in the preview pane so that it changes the look of the site.

I have tried using partials but they seem to be hooked to controls with settings. I have tried using postMessage but again it seems to be linked to settings. I don't need a setting, I only need a trigger that sends data over.

The point here is that I need an action to take place in PHP with the simple click of a button. I can do it all day in AJAX normally, but transferring data from the Customizer Settings to the Customizer Preview pane with any PHP in the interim is a PAIN. Pun intended.

  • So the point is that you need to send PHP retrieved from the customizer panel to preview? – koMah Dec 14 '16 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.