Open sohan5005 opened 9 years ago
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?
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.
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
ok, if I want to use update_option function, then how should I call the option id or option name?
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);
Hi, how is your customizer integration? Regards
I haven't integrated any options to the customizer. I'll try that later. But there should be a solution. :(
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?
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.
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?
This option isn't available in VP but you can grouping your options in nested menu.
I think this option should be included as other frameworks do.
Maybe you have right by this is not user friendly because always when you go to another sub page the page is refreshed.
Look what I found for customizer http://kirki.org/ :)
Looks great for the customizer.
I'm trying to achieve the submenus. If I'm done, I'll pull a request.
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'
);
}
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