Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any chance to make vafpress work with customizer? #106

Open
sohan5005 opened this issue Feb 10, 2015 · 16 comments
Open

Is there any chance to make vafpress work with customizer? #106

sohan5005 opened this issue Feb 10, 2015 · 16 comments

Comments

@sohan5005
Copy link

Hi, I wanted to know if it's already implemented or can be done anyhow. I can't find anything about customnizer in vafpress documentation.

Is there any function available to update vp_option fields from somewhere else? Then I think, we can make this work with the live customizer.

Thanks

@padalec
Copy link

padalec commented Feb 10, 2015

Hi,
no, I don't think to VP has this options, but this can be very useful! That is why I think to build it. Maybe someone also would like to build this function and help me on this?

@sohan5005
Copy link
Author

the project, currently i'm working on, needs this functionality. So I have a basic Idea to do this, but need help.

The idea is, there must be a function which used to update the fields in vp_option when we hit save. But I can't find it in the core files. If we execute the function in the customizer, then it probably going to work. Because, the options data must be saved in database.

@padalec
Copy link

padalec commented Feb 10, 2015

vp_option is used only to get options from db. In my theme I don't use vp_option function. If You only need to update options You should use: http://codex.wordpress.org/Function_Reference/update_option
Regards

@sohan5005
Copy link
Author

ok, if I want to use update_option function, then how should I call the option id or option name?

@padalec
Copy link

padalec commented Feb 10, 2015

Your option key is ('option_key') the key Your passed to VP_Option() class
http://vafpress.com/documentation/vafpress-framework/options/builder.html
if You want to see all options just use this code below:
$options = get_option('option_key');
print_r($options);

@padalec
Copy link

padalec commented Feb 12, 2015

Hi,
how is your customizer integration?
Regards

@sohan5005
Copy link
Author

I haven't integrated any options to the customizer. I'll try that later. But there should be a solution. :(

@sohan5005
Copy link
Author

By the way, one more problem here. I'm registering the options panel in top level menu in dashboard. The position is '61' which is under appearance and above plugins. But I didn't get the submenus of my options panel as other frameworks do. Is there any option that I need to enable or I need to register the submenus manually?

@padalec
Copy link

padalec commented Feb 13, 2015

Do Your looking for submenu in your options groups? If yes you should use "nested menu"
http://vafpress.com/documentation/vafpress-framework/options/group.html
in your option template array.

@sohan5005
Copy link
Author

No, I don't mean that. As we usually add the options in Appearance > Theme options. I've added my options panel directly in top level menus in admin panel. When you hover over to the appearance, you see submenu with themes, customize, widget, menus etc. When you hover on plugins, you see installed plugin, add new, editor. Like that, I have added my options panel in top level menu and I want to show submenu like Basic styles, fonts, blog options, sidebar options etc.
I'm already using nested menu. Does VF has any option to have submenus when we register the options panel in top level? Or we have to register the submenu manually?
submenu

@padalec
Copy link

padalec commented Feb 13, 2015

This option isn't available in VP but you can grouping your options in nested menu.

@sohan5005
Copy link
Author

I think this option should be included as other frameworks do.

@padalec
Copy link

padalec commented Feb 13, 2015

Maybe you have right by this is not user friendly because always when you go to another sub page the page is refreshed.

@padalec
Copy link

padalec commented Feb 13, 2015

Look what I found for customizer http://kirki.org/ :)

@sohan5005
Copy link
Author

Looks great for the customizer.

I'm trying to achieve the submenus. If I'm done, I'll pull a request.

@sohan5005
Copy link
Author

I have used this code to register the submenus on my theme. This actually makes a little work but doesn't do a great job. When you first click on any submenu, it will link you to the actual menu but you can't change group with it. So this code needs to be furnished a little bit.

I think this can be integrated into the framework with some modifications.

// add the action on admin_menu init
add_action('admin_menu', 'register_vp_submenus');

// declare the function
function register_vp_submenus() {

    // the file which contains the array of options
    $settings = include get_template_directory() . '/admin/option.php';

    // slug of the options panel
    $option_slug = 'my_slug';

    // minimum role
    $min_role = 'edit_theme_options';

    // select the 'menu' items from array
    $do_submenus = $settings['menus'];

    // loop to check and add submenu items
    foreach ($do_submenus as $do_submenu) {

        // if nested menu, add the actual groups which contain options
        if( is_array($do_submenu['menus']) ) {
            foreach ( $do_submenu['menus'] as $group_sub ) {
                add_submenu_page( 
                        $option_slug,
                        $group_sub['title'],
                        $group_sub['title'],
                        $min_role,
                        '/admin.php?page=' . $option_slug . '#_' . $group_sub['name']
                    );
            }
        } else {
        add_submenu_page( 
                $option_slug,
                $do_submenu['title'],
                $do_submenu['title'],
                $min_role,
                '/admin.php?page=' . $option_slug . '#_' . $do_submenu['name']
            );
        }
    }

    // Add the utility menu which is not in the user created array
    add_submenu_page( 
             $option_slug,
            __( 'Utility' , 'textdomain' ),
            __( 'Utility' , 'textdomain' ),
            $min_role,
            '/admin.php?page=' . $option_slug . '#_menu_util'
        );

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants