Hide devices selection from customizer?

Yes. There is a customize_previewable_devices filter which is used to manage which devices are displayed here. For example, to conditionally remove the Tablet device, do: add_filter( ‘customize_previewable_devices’, function( $devices ) { if ( ! current_user_can( ‘do_something’ ) ) { unset( $devices[‘tablet’] ); } return $devices; } );

Is there an event or an other method that tells me the preview is loaded?

Yes, this is the way to detect when the preview has loaded: wp.customize.bind( ‘ready’, function() { wp.customize.previewer.bind( ‘ready’, function( message ) { console.info( ‘Preview is loaded’ ); } ); } ); This JS code should be enqueued at the customize_controls_enqueue_scripts action with customize-controls script as its dependency.

How to add new args data in $wp_customize->add_setting?

This might be what you are looking for $args = array( ‘default’ => ‘#e9ecef’, ‘capability’ => ‘edit_theme_options’, ); if ( something() ) { $args[‘output’] = array( array( ‘element’ => ‘body’, ‘property’ => ‘background-color’, ), ); } $wp_customize->add_setting( ‘modular_header_main_border_bottom_color’, $args ); We are first creating an array for arguments. Later we are pushing a key value … Read more

Count top level menu items

I am not really sure whether there is some native function for this or not, but you could do it like this: $menu_object = wp_get_nav_menu_object(“Main menu”); $menu_items = wp_get_nav_menu_items($menu_object->term_id); $menu_items_count = 0; foreach ( (array) $menu_items as $key => $menu_item ) { if ($menu_item->menu_item_parent == 0 ) $menu_items_count++; }

How do I get current page ID in WordPress customizer file?

Thanks for your question. active_callback is exactly what you’re looking for. You can use it with controls: $wp_customizer->add_control( ‘setting_name’, array( ‘type’ => ‘text’, ‘section’ => ‘section_name’, ‘label’ => ‘Option with context’, ‘active_callback’ => ‘is_front_page’ ) ); and with sections: $wp_customize->add_section( ‘section-name’, array( ‘title’ => ‘Section with context’, ‘active_callback’ => ‘is_front_page’ ) ); In examples above, … Read more

Customizer Not Applying Any Change, No Error Thrown

So I finally have it. The problem came from the php.ini configuration option filter.default. The option was set to: filter.default = full_special_chars filter.default_flags = 0 As explained in the PHP documentation, this had the effect of sanitizing and stripping characters from all $_POST, $_GET, $_COOKIE, $_REQUEST and $_SERVER data, effectively beating me in the back … Read more

Get a setting value conditionally in the Customizer api

I’m not sure if this is what you wanted, but you can use wp.customize.get() to get all the currently set Customizer settings: var settings = wp.customize.get(); // get all settings var border_style = settings[‘myplugin[border_style]’]; var border_color = settings[‘myplugin[border_color]’]; // Or, this works, too. var border_style = wp.customize.get()[‘myplugin[border_style]’]; var border_color = wp.customize.get()[‘myplugin[border_color]’]; Reference

How to add a default value to get_option if it’s used as a variable?

So I originally suggested normalizing the options array; i.e. merging saved values with the default values. And this does solve the “undefined index” notice: $my_options = wp_parse_args( get_option( ‘my_options’ ), [ ‘my_background_color_option’ => ‘#000’, // … other args. ] ); But to make sure that an option is not empty (e.g. not ”, false, null, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)