Get Image Width From WP_Customize_Image_Control() File Set in WP Theme Customizer

Modern answer to this question: We have WP_Customize_Media_Control control in WP since 4.2 that gives you the attachment id. This answer was posted on I similar question. You can see the documentation for WP_Customize_Media_Control here. Exemple of use: $wp_customize->add_setting( ‘my_menu_image’ ); $wp_customize->add_control( new \WP_Customize_Media_Control( $wp_customize, ‘storms_menu_image_ctrl’, array( ‘priority’ => 10, ‘mime_type’ => ‘image’, ‘settings’ => … Read more

get_theme_mod filter ignores sanitize_callback

Sanitization via the sanitize_callback function takes place when you save the the theme mod. Retrieving a theme mod via get_theme_mod() (which runs the theme_mod_{$name} filter) does not use the sanitize_callback function. So, whatever you’ve set $_GET[‘header_layout’] to will be used regardless of whether it is valid or not. From wp-includes\theme.php: /** * Retrieve theme modification … Read more

How to make a Customizer partial force full refresh instantly?

If you always want a page refresh, then all you have to do is simply remove this line: $wp_customize->get_setting( ‘blogname’ )->transport=”postMessage”; Or explicitly set it to refresh: $wp_customize->get_setting( ‘blogname’ )->transport=”refresh”; By doing this, selective refresh will never get invoked to refresh the partial, and it will skip straight to the full refresh. Note it is … Read more

get_theme_mod only returns false

The debugger tells me that get_theme_mod() is returning ‘false’, when I expect it to return the value of the selected item. get_theme_mod() isn’t working because when you registered the setting, you set the type to option: $wp_customize->add_setting(‘title_font’, array( ‘default’ => ‘Roboto Slab’, ‘capability’ => ‘edit_theme_options’, ‘type’ => ‘option’, ‘transport’ => ‘postMessage’ )); The possible values … Read more

get_theme_mod Not Functioning Properly

I think the problem is simply this line: ‘type’ => ‘option’, You should remove it, because the default is: ‘type’ => ‘theme_mod’, since you want to use get_theme_mod(). You should also consider: prefixing these color settings slugs, to make them more unique. using for example: ‘sanitize_callback’ => ‘sanitize_hex_color’, in your settings setup for sanitazion. ps: … Read more

Add post type titles in customizer dropdown list

Ok I found it, here is the answer for next ones who are looking for the same thing: $cf7forms_list = array(); $args = array(‘post_type’ => ‘wpcf7_contact_form’); $cf7forms = get_posts( $args ); foreach($cf7forms as $cf7form) { $cf7forms_list[$cf7form->post_title] = $cf7form->post_title; } $wp_customize->add_setting( ‘contact_list_section’, array( ‘transport’ => ‘postMessage’ )); $wp_customize->add_control( ‘contact_list_section’, array( ‘label’ => esc_html__( ‘Contact form’, ‘mytheme’ … Read more

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