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()?
- Modify search function in WordPress (TwentyTwelve)
- How to customize search result page title?
- which is the function that removes accented vowels?
- How to save Uploaded image in custom option panel?
- Check javascript file Proper way in functions.php
- Is there an error in get_the_tag_list()?
- Custom function for user register in wp?
- How to add background image control to page admin controls?
- woocommerce target button with class after ajax update
- WordPress doesn’t Load JQuery Now? Do I need to enqueue JQuery also?
- Toggle Sidebar Display
- Override the filter from plugin in child theme
- How to use thumbnails in gallery?
- Customizer field value into functions.php variable
- How to add a second stylesheet to the editor
- Customizer: Output default value in Customizer CSS
- Loading CDN that requires jQuery in WordPress
- Converting HTML Template to WordPress Theme
- Override a theme function in a child theme?
- changing behaviour of get_search_form
- Pulling Twitter RSS feed not working as expected (fatal error)
- Include default functions and methods
- Use register_setting() in a loop
- How can I modify all existing tags while keeping the urls themselves?
- Scripts not appending to element in AJAX call – why?
- Add dynamic links in WordPress custom theme
- WordPress website Rs changed to currency symbol
- WordPress menu link doesn’t work properly
- Unable to login using username
- How to change the order of Jquery in the footer of my theme?
- Functions in custom theme
- Attempt to change jQuery version caused White Screen of Death
- Functions.php Problem
- Condition OR for current user ID
- Way to store featured image width and height in two separate variables?
- echo custom fields with AJAX
- Where do I store custom functions that call custom page template files?
- Excerpt for pages not showing
- JQuery undefined and Stylesheet loads in bottom along with js files
- Wp-query Order By problem
- PHP 7.1 | Warning: A non-numeric value encountered in
- login_headertitle is deprecated since version 5.2.0
- I can’t add CSS with functions.php
- Where is this JQuery coming from?
- Different favicon on different pages
- Problem with images URL after filter applying
- Is this an acceptable practice for WordPress theme development?
- Create theme for mobile phones and tablets only?
- Rewrite Question Mark in Post Template with URL Parameter for clean URLs
- loginout function customization
- How to make sure relative URL works when site is not on root domain?
- How to add php within jquery
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- Bootstrap slider not working
- CF7 select value get to function and reciept value from function
- Is hand coding required at all?
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- Woocommerce custom calculation function
- Replace image attributes for lazyload plugin on image elements with specific class
- How to disable site title and description when custom header is uploaded on the customizer?
- WordPress Jquery+scripts enqueue issue
- us states dropdown function and echo in theme template files
- Adding a jQuery rotator function
- Random text changing to weird icons in both admin & front end
- functions.php / replacing div’s with new ones?
- Post variables not displaying correctly in custom function
- why jquery is not loading in wordpress page?
- Turning WordPress Into full-featured website?
- Owl Carousel and WordPress Integration Via WP_Enqueue
- How to create a post without link in wordpress?