themeum / kirki

Extending the customizer
https://kirki.org
MIT License
1.26k stars 327 forks source link

Allow using `required` in panels & sections #240

Open aristath opened 9 years ago

aristath commented 9 years ago

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

aristath commented 9 years ago

WIP: https://github.com/reduxframework/kirki/commit/234ef819f768af48f90e09b1d35bc4b44eeb1e51

ghost commented 9 years ago

Hi aristath, Please make a sample code to implement this feature. Thank you

aristath commented 9 years ago

There is no sample code because this does not currently work. As soon as I manage to get this one to work I'll add a code sample & documentation in the wiki.

rahulv3a commented 8 years ago

@aristath Expanded sections (#703), when combined with 'required' in sections, could result in a very user-friendly customizer in my opinion.

I was wondering if you could include this in v2.2 final release. Only, of course, if it can be done easy without spending too much time and effort :)

I remember you mentioned that adding dependencies to all settings inside a section hides it. But it adds to much complexity to the code, especially if options already have some dependencies. It makes the code difficult to maintain :-|

Here's how I'm planning to implementing it:

Header (Panel)
|- Header Type (Expanded Section)
   |- Select box (Type 1 | Type 2 | Type 3)
|- Logo (Section)
   |- Various logo options
|- Topbar (Section)
   |- Various topbar options
|- Main navigation (Section)
   |- Various main navigation options
|- Call to Action (Section)
   |- Various call to action options
|- Adverts (Section)
   |- Various Google Adsense options

Section visible depending upon Header type selected:

Vishal-Deshpande commented 8 years ago

Any possibility of this feature being included in upcoming version?

rahulv3a commented 8 years ago

@PlayerThemes For the time being you could use active_callback in add_section() to accomplish the same.

Kirki::add_section( 'example_section', array(
  'panel'           => 'example_panel',
  'title'           => esc_html__( 'Example', 'example' ),
  'active_callback' => 'example_callback_function',
) );
function example_callback_function() {
  return get_theme_mod( 'example_field_id', 'default_value' );
}