jquery - Remove button from page if viewed through Customizer

admin2025-06-06  2

Is it possible to remove a specific button from the page only if it is viewed from the Customizer? I did try a check for wp-customizer in body, but this only checks the body of the iframe and not the main window.

So, any idea how to do this with jQuery?

Is it possible to remove a specific button from the page only if it is viewed from the Customizer? I did try a check for wp-customizer in body, but this only checks the body of the iframe and not the main window.

So, any idea how to do this with jQuery?

Share Improve this question edited Nov 29, 2018 at 12:31 joq3 asked Nov 29, 2018 at 10:35 joq3joq3 3813 silver badges21 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

You did not wrote if you want to check it using PHP or JavaScript but if using PHP you can add to your theme a below function it will return true if the page is previewed using Customizer

function is_customizer_preview() {
  if( isset( $_GET['customize_theme'] ) ) {
    return true;
  } else {
    return false;
  }
}

Then somewhere in the theme template files you can use it like that if you want to have an additional class in the body

<body class="some-classes <?php if(is_customizer_preview()): ?>my-customizer-class<?php endif; ?>">
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749141969a316722.html

最新回复(0)