Remove nav_menus from customizer using a theme

This is panel not section so remove_section() will not work in this case. However you can use function remove_panel() but it will trigger a notice saying Notice: WP_Customize_Manager::remove_panel was called incorrectly Removing nav_menus manually will cause PHP warnings. Use the customize_loaded_components filter instead. Please see Debugging in WordPress for more information. (This message was added … Read more

Set Default Page On Customizer Live Preview

The default URL being previewed is home_url( “https://wordpress.stackexchange.com/” ). When no url query parameter is present when opening customize.php, this is the preview URL that is used. You can override the previewed URL when there is no url query parameter to supply a different default using something like this: add_action( ‘customize_controls_init’, function() { global $wp_customize; … Read more

WP customizer + gulp + browsersync = refused to display in iframe?

Found a work around by adding ‘ localhost:3000’ to the ‘Content-Security-Policy’ header: function edit_customizer_headers () { function edit_csp_header ($headers) { $headers[‘Content-Security-Policy’] .= ‘ localhost:3000’; return $headers; } add_filter(‘wp_headers’, ‘edit_csp_header’); } add_action(‘customize_preview_init’, ‘edit_customizer_headers’);

Checking if there is an Image inserted – if not don’t display anything

Try the following code: <div class=”item active <?php // If image URL is empty, echo “hidden” echo (get_theme_mod(‘slider_one’, ”) == ” ? ‘hidden’ : ”); ?>”> <img class=”img-responsive” src=”https://wordpress.stackexchange.com/questions/217340/<?php echo esc_url( get_theme_mod(“slider_one’, ” ) ); ?>” alt=”Slider 1″> </div> Then use the following CSS: .hidden { display: none } What this will do is: If … Read more

What is the difference between sanitize_text_field() and wp_filter_nohtml_kses()?

What Do They Do? wp_filter_nohtml_kses strips all HTML from a string, that’s it. It does it via the wp_kses function and it expects slashed data, here’s its implementation: function wp_filter_nohtml_kses( $data ) { return addslashes( wp_kses( stripslashes( $data ), ‘strip’ ) ); } sanitize_text_field on the other hand does more than that, the doc says: … Read more