you can just check for the customize object, but if you absolutely need a conditional statement to determine whatever it is you need, you can do something like this:
jQuery( function( $ ) {
// set var
var in_customizer = false;
// check for wp.customize return boolean
if ( typeof wp !== 'undefined' ) {
in_customizer = typeof wp.customize !== 'undefined' ? true : false;
}
// if you're in the customizer do this
if ( in_customizer ) {
console.log('in customizer');
// if you're not in the customizer do this
} else {
console.log('not in customizer');
}
});
Related Posts:
- Display random categories on the front page (Finding and Editing Theme Functions)
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- How to Link External jQuery/Javascript files with WordPress
- Using classes instead of global functions in functions.php
- Issue with get_theme_mod returning a blank value instead of the saved value
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Add external js file to footer with id
- Theme-Config tab in admin Pannel?
- How to correctly add JQuery in a WP theme?
- How to call custom function from functions.php in site-wide template files?
- PHP files included in functions.php don’t seem to work
- WP 3.1 upgrade breaks AutoFocus+ theme
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Right way to update widget on dynamic new input field
- How to load jQuery in the footer – nothing works for me
- Best practices regarding the creation of custom widgets?
- Jquery implementation not working on page reload
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Some questions about how proper add 2 CSS file in a WordPress theme?
- Getting the teaser text without overriding global variables
- “options.php” not found
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Can’t change theme name
- Header menu aligned right on all pages except for single-post page [closed]
- CSS style and app.js not loading
- WordPress Ajaxifying not working properly
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- Add custom css to theme
- How to get postId from the argument $block when register_block_type()?
- How to use webpack in WordPress theme? I want some scripts to load in the footer, some in the header and some with script parameters
- Passing Jquery value to WordPress function
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- Problem with images URL after filter applying
- WordPress can’t get jquery/unslider to work
- Is this an acceptable practice for WordPress theme development?
- Add loggedout class on body using a function or JS
- Is there a hack for using is_page() within the function.php file?
- Are innerHTML elements visible to jQuery functions?
- What is the correct way to include my new functions and scripts in WordPress?
- two search forms on the same page
- How to override this theme function in child theme
- New to WordPress – Read the Codex, Other Docs; Still Confused
- Include Jquery libraries in wordpress theme?
- Function to replace comment’s accented characters before posting
- wp_nav_menu work in functions.php but not in the theme
- get_template_directory() – references parent theme directory
- Create theme for mobile phones and tablets only?
- How to add custom page elements to the WYSIWYG editor?
- Rewrite Question Mark in Post Template with URL Parameter for clean URLs
- Insert a field with PREG_REPLACE – strange behaviour
- How to echo Widget Title in Custom Frontend-Template Box
- contact form in template with jquery,validate and ajax
- New checkbox in custom widget isn’t saving data
- Linking Javascript in functions.php file
- how to display a page before the home page
- loginout function customization
- How do I preserve changes to a theme’s functions.php across updates?
- get content from page through AJAX
- How can I assign separate stylesheets to different pages?
- Creating multiple category drop down
- How to make sure relative URL works when site is not on root domain?
- display unique post per category
- How to add icon over specific thumb
- How to setup a popup registeration page in wordpress with function.php
- colorbox not loading in
- Call javascript functions from each page
- How to add php within jquery
- Function to check if custom page is used by page?
- Help with IF has focus then… statment
- implementing a centralized content “show-do-not-show” toggle?
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- What function actually renders the wp_admin_bar ? How can I call it?
- Removing the custom_image_header from wp_head
- Problem with custom function from jQuery slider tutorial
- How to display this meta data (an array) in form of a function (created with a custom write panel)?
- WordPress – using sessions?
- Get URLs for AJAX Filter Checkboxes WordPress
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Astra theme – cannot set short product description under the product title (product name)
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- How to remove font awesome from loading in wp theme
- How to fix Function create_function() is deprecated in / themes
- Exclude specific post from query
- wp_set_object_term via js btn frontend
- Advanced method to control cache of enqueued style/script
- WordPress wp_dequeue_script remove all other scripts
- How to replace ACTION url from original wordpress login form?
- Populate Product Regular Price with a calculated ACF Field Value
- Override category archive page title (not the head title)
- Hide ‘add to cart’ when certain value in dropdown is selected
- Ajax Form Issues using Lightsail (AWS)
- Can I use ‘Featured Image’ as a hero image and a thumbnail?
- Save_post – Warning: Cannot modify header information
- What is the earliest Hook a Script can use?
- How to use WP conditional tag in a functions.php with OCEANWP Theme?
- Bootstrap slider not working
- WordPress does not load jQuery
- Class parameter in get_avatar args doesn’t get added to output