Skip Navigation

[Resolved] Add Toolset Hook to my custom plugin

This thread is resolved. Here is a description of the problem and solution.

Problem:
Add Toolset Hook to my custom plugin

Solution:
The setting for admin bar option is saved within the wp_options table with the key "toolset_options" where we save the settings as serialized array.

You just need to get the value of key "toolset_options" from wp_options table and then unserialize it and look for the array key "show_admin_bar_shortcut" which holds the value either "on" or "off".

If you want to display the "Design with Toolset" menu, you should update the "show_admin_bar_shortcut" to "on" and if you want to disable it then set it value to "off" and accordingly save the "toolset_options" key value.

Relevant Documentation:

This support ticket is created 2 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Paul Marconi 2 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2090915

Hello,

I know how to detect if the Toolset view plugin is installed and active.
I want to remove the 'Design with Toolset' tab on the admin bar menu (located at the top).
I placed the code for that in my theme's functions.php file and it works, but I would like to place the code into my simple custom plugin that I've built. However, it doesn't work when I placed the same code into my custom plugin php file.

Below is the code that I've used:
<?php
/**
* Plugin Name: My Custom plugin
* Plugin URI: hidden link
* Description: My Custom plugin
* Version: 1.0.0
* Author: XX
* Text Domain: xx
* License: GPL2
*/
/**
* Register all shortcodes
*
* @return null
*/

function register_shortcodes() {
add_shortcode('menu', 'display_menu_shortcode');

if ( is_plugin_active( 'wp-views/wp-views.php' ) ) {
add_action( 'admin_bar_menu', 'remove_tooleset_item', 999 );
}

}
add_action( 'init', 'register_shortcodes' );

function remove_tooleset_item( $wp_admin_bar ) {
$wp_admin_bar->remove_node( 'toolset_admin_bar_menu' );
}

function display_menu_shortcode($atts, $content = null) {
extract(shortcode_atts(array( 'name' => null, ), $atts));
return "<nav role='navigation'>".wp_nav_menu( array( 'menu' => $name, 'menu_id' => $name, 'menu_class' => 'menu cf', 'container' => '','echo' => false ) )."</nav>";
}
?>

It's not working, am I missing anything?

Thank you!

#2091213

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I think I've more easy solution for you.

The setting for admin bar option is saved within the wp_options table with the key "toolset_options" where we save the settings as serialized array.

You just need to get the value of key "toolset_options" from wp_options table and then unserialize it and look for the array key "show_admin_bar_shortcut" which holds the value either "on" or "off".

If you want to display the "Design with Toolset" menu, you should update the "show_admin_bar_shortcut" to "on" and if you want to disable it then set it value to "off" and accordingly save the "toolset_options" key value.

I hope this helps.

#2092609

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.