Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

Options in Customizer

Open danyj opened this issue 11 years ago • 124 comments

Have you planed to include theme options in customizer?

danyj avatar Mar 30 '15 20:03 danyj

Nothing on this?

danyj avatar Apr 03 '15 10:04 danyj

We didn't planed that. But we need to investigate, maybe we will do.

ghost avatar Apr 03 '15 10:04 ghost

I did something similar once. I'll try to recover it and adapt it to your framework if I have time.

As a brief guideline, you should hook into the "customize_register" action, loop through the options registered in Unyson, and then register the necessary settings and controls for each field with $wp_customize->add_control() and $wp_customize->add_setting().

An $option['cusomizer'] attribute could be checked on each option to decide if it should appear in the customizer.

Note that each field type may require different setting and controls, with different sets of attributes each, so switch on each field type and act differently when necessary. Usually one regular setting and one control per field, but more advanced field types need extra controls. These should be extended from the base WP_Customize_Control class, and ideally reutilize as much code as possible from the fields displayed on regular options pages. How this can be achieved is beyond my knowledge of the framework.

On a last note, think about how options in the customizer are organized in sections, so maybe add "section" as an extra option container type, (added to box, tab and group) or else add all the orphaned options in a "general" section, or simply interpret all container types as sections and go with that.

I hope it helps.

albertso avatar Apr 13 '15 23:04 albertso

I think that we should get this one going, slowly but surely themes with customizer are taking over and people are kinda getting tired of the actual theme options without previews. @albertso if you could show us what you did it would be great. yes I was just looking at it and a loop seems like it would work, thing is that we have some really special options in Unyson that need a port to customizer but looking at customizer instructions I hope that this one would work

$wp_customize->add_control(
    new FW_Option_Type_Multi_Picker(
        $wp_customize,
        'some-setting',
        array(
            'label' => 'Some Setting',
            'section' => 'example_section_one',
            'settings' => 'some-setting',
        )
    )
);

derived from here http://themefoundation.com/wordpress-theme-customizer/

these guys have a pretty nice set to https://github.com/aristath/kirki and getting ready to make it Redux compatible and Redux options already work in customizer.

danyj avatar Apr 19 '15 09:04 danyj

If you care to look I am testing the waters now http://wordpress.stackexchange.com/questions/184671/how-to-tell-theme-customizer-to-save-setting-in-my-option-table

danyj avatar Apr 19 '15 11:04 danyj

Can you believe this http://wptavern.com/wordpress-org-now-requires-theme-authors-to-use-the-customizer-to-build-theme-options

danyj avatar Apr 23 '15 18:04 danyj

In my opinion, it is good for user experience, all users will know how to custom theme using customizer. Moreover, it's core of wordpress, so it's safe and very security, today you can see a lot of framework option like redux, option tree have problem with XSS Vulnerability, read more here: http://wptavern.com/xss-vulnerability-affects-more-than-a-dozen-popular-wordpress-plugins The customizer is better in each version of wordpress but for me now, I prefer theme option, especial Unyson theme option. Because it's very flexible and strong enough.

dylan-ngo11 avatar Apr 23 '15 18:04 dylan-ngo11

not saying is bad , but mandatory is bit over top and unyson not having options inside customizer yet ( I know you working on it ) is kinda show stopper. hopefully TF will not enforce this.

danyj avatar Apr 23 '15 19:04 danyj

@danyj : TF will not, all top of theme on TF are using their own option framework ;)

dylan-ngo11 avatar Apr 23 '15 19:04 dylan-ngo11

Who ever is on this task , you want to look at this http://kirki.org/, they made sub sub menus for customizer section which if converted right can transform our theme option tabs and sub tabs to it . This is what I mean http://screencast.com/t/J0DkLbU5aMW

danyj avatar Apr 23 '15 22:04 danyj

I used to, this is very useful customizer and easy to use.

dylan-ngo11 avatar Apr 24 '15 02:04 dylan-ngo11

When you get a chance , if you have started on this, please advise if you are planing to port our options to customizer as they are now in theme options , or is there going to be a different array structure and if all options will be able to be ported. I am most concerned about the addable popups, image pickers, multi pickers and other specialty options. Reason why I am asking is to get prepared and structure the options different way. Or to look for another solution for customizer. Thank you!

danyj avatar Apr 25 '15 21:04 danyj

@moldcraft please guys , just a hint so that I know what to do, wait or go with custom solution.

danyj avatar Apr 29 '15 06:04 danyj

I will take a look at this next week. Because of the TF requirement, we will try everything to make options work in customizer. I think we will make framework-customizations/theme/options/customizer.php

ghost avatar Apr 29 '15 06:04 ghost

thnx for reply , I will wait few more days than. If you cant do this than please do let us know.

danyj avatar Apr 29 '15 06:04 danyj

I wasn't at office the last 8 weeks, that's why some issues were fixed with big delay. In a feew days I will come back to full-time.

ghost avatar Apr 29 '15 07:04 ghost

I don't like the theme option in customizer, it should be separated. You should consider use one of theme in your theme before developing. Firstly, if you support option in both theme option and customizer, user will not know where to go to setup. It's very confuse. Secondly, I think it will limit functions of Theme Option. Lastly, WP core now can support all most options like Theme option do. I prefer if Unyson support some default fields so that user can intergrate easily like Theme Option.

dylan-ngo11 avatar Apr 29 '15 07:04 dylan-ngo11

@duongancol how is it confusion to work with visual editor? that is what everyone is after now. only reason x bypassed everyone in weekly sales in last 2 weeks by a looong mile is the customizer.

and if unyson adds options they should not be base only , first thing everyone will try to switch is typography, font size , backgrounds , and if you have set those up in your admin inside a popup , addable popup than what? if you used multi-picker same thing. so I think they should try their best to port all if possible. this way any dev can decide , use both theme option or customizer or use them individually.

what I did 2 months ago is topmenu visual editor in theme options that works perfect , than when I was done with options I thought that it would be nice to have a complete site visual layout in backend so that while admin works he/she can see the change , you can guess that this took me on the road to a slow admin , but if I had a customizer , I would not have to do any of it and would just need to setup the options. and I doubt that I am the only one who wants to see the theme changes before they are saved.

danyj avatar Apr 29 '15 07:04 danyj

oh and I am talking about options functionality , not port my complete theme options backend to customizer. I am talking about options to be functional in customizer as they are in all areas of unyson, how we add them to a customizer should be our concern from there, they just need to work

danyj avatar Apr 29 '15 07:04 danyj

got ti @danyj and I agree with that.

dylan-ngo11 avatar Apr 29 '15 07:04 dylan-ngo11