Hide Theme options and Customize Admin menu

Under the appearance admin menu, I have customizer added by the theme, and theme options added by a plugin. I’m using this code to hide both menus ( submenu’s of Appearance )for ALL admins apart from a certain USERNAME. function hide_menu() { global $current_user; $current_user = wp_get_current_user(); $user_name = $current_user->user_login; //check condition for the user … Read more

How to check if I am inside the WP Theme Customizer preview?

I have some elements showing on the home page that I do not want to display in the Theme Customizer preview window. Is there a simple check in PHP that I can use for that ? For example: <img class=”background” src=”https://wordpress.stackexchange.com/questions/101713/<?php echo $background ?>” <?php if(is_wpThemeCustomizer()) echo ‘style=”display:none”‘ ?>/> I could do it in javascript … Read more

Adding Controls to Theme Customizer If Certain Page Template is Active

How to Conditionally add controls on Theme Customizer panel. Conditional like is_page() or is_page_template() obviously does/will not work because the page is being shown is customize.php. Code Example add_action( ‘customize_register’, ‘my_theme_customize_register’, 11 ); function my_theme_customize_register($wp_customize){ if( is_page_template(‘my-template.php’){ // add special control } } Another observation is, customization setting control panel does not refresh when we … Read more

Using jQuery to retrieve customizer value

I am trying to use jQuery to retrieve a theme options (customizer) value: $wp_customize->add_setting( ‘header_fixed’, array( ‘default’ => true, ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, ‘header_fixed’, array( ‘label’ => __( ‘Enable fixed navigation?’, ‘theme’ ), ‘section’ => ‘header_section’, ‘settings’ => ‘header_fixed’, ‘type’ => ‘checkbox’, ‘priority’ => 40, ) ) ); If the above value is … Read more

Hide Text when check box option is ticked in customizer?

How I hide the Head Text which is “Magna Aliquam” when “Hide Head Text” checkbox is checked and show when the checkbox is unchecked. Below is my code, but I’m lost. Any help would be appreciated wp.customize( ‘hide_head_text’, function( value ) { value.bind( function( to ) { if($(“hide_head_text”).is(‘:checked’)) $(“.welcome-text h2”).hide(); // checked else $(“.welcome-text h2”).show(); … Read more

Change setting name in Customizer and keep the data

I created a theme while back when I was new to Customizer API and for some weird reasons I named theme settings as: $wp_customize->add_setting(‘thefunk_theme_options[header_color] Instead of just header_color and saved every setting in an array like thefunk_theme_options[header_color] So I recently found out that it’s generating some issues, so I want to save every setting, let’s … Read more

How Can I Create a List of Values to Be Iterated Through via WordPress Customization API?

I currently have a theme with OptionTree installed. It is used to create a list of locations which are then visible in a dropdown in the header of the page. The display code with OptionTree looks like this: <form action=”” id=”formsel” method=”post”> <div class=”locations”> <?php $location = ot_get_option(‘location’);?> <label for=”country_id” class=”no-display”>Select Country</label> <select name=”country_id” id=”country_id” … Read more