reduxframework / customizer-integration

0 stars 0 forks source link

Customizer update sections and field in new url #6

Open PayteR opened 8 years ago

PayteR commented 8 years ago

Hi, i'm currious, if there is some way how can i update customizer sections "from inside of iframe".

For example, when i'm in customizer, and have some field, for example "Homepage sidebar visible" checkbox, i want to have this field just on homepage in customizer and when i click to some post in iframe, i want this field disapear, and vice versa... can i somehow achieve this? thx

dovy commented 8 years ago

Hmm. So hide fields from within the iframe?

kmob2 commented 8 years ago

Not sure if this is what you are looking for.

Contextual controls, section and panels were added to the Theme Customizer API, but not yet built into redux framework. But it should be easy to extend your https://developer.wordpress.org/themes/advanced-topics/customizer-api/#contextual-controls-sections-and-panels

But you can easily add the following to your theme-customizer.php

// Hide core sections/controls when they aren't used on the current page.
$wp_customize->get_section( 'header_image' )->active_callback = 'is_front_page';
$wp_customize->get_control( "site_icon" )->active_callback = 'is_front_page';

The only thing I am currently not sure of, is what the redux ID is for PHP. I would have assumed it's the same as the HTML output used for javascript: opt_name[field_id], but that doesn't seem to work. I guess though that's a different question.

Additionally to your question, you can make the customizer panel focus on a section and controller when clicking into a specified area inside of the iframe. https://core.trac.wordpress.org/ticket/31320