I have re-worded this to make more sense.
Ok, I have a plugin that uses a remote service that check for updates, much like default WordPress plugins, in this case it just checks an XML file.
I want to show a menu bubble like this when an update is available.
It can show just a "1" or text like "alert", it doesn't matter.
Since my plugin uses an options page (using add_options_page
) the plugin settings show up under the default "Settings" submenu.
I think I need to add the following CSS to get the bubble to show up,
<span class='update-plugins count-1' title='title'><span class='update-count'>1</span></span>
and tie into the global $submenu
. The problem is I cannot use a hard-coded array value for the menu since each site will have different values.
So I cannot use $submenu[80][10] .= <span class='update-plugins count-1' title='title'><span class='update-count'>1</span></span>
How can I find my plugins submenu value, do I have to loop through the array and match the string values?
Also even when I hard-coded the values I could not get the bubble to show up.
//adding plugin to menu
add_action('admin_menu', 'sec_plugin_checker');
function sec_plugin_checker() {
add_options_page(' Plugin Checker', 'Plugin Check', 'activate_plugins',
'sec_plugin_check', 'sec_checker');
// the conditional where I want the bubble to appear
if (!empty($matches)){
echo "Match found !<br />";
global $submenu;
foreach( $submenu as $item ) {
$item[41][20] = sprintf( __( 'Updates %s', 'sec_plugin_checker' ),
"<span class='update-plugins count-1' title='title'>
<span class='update-count'>1</span></span>");
}
}
and here is what a var_dump($submenu);
looks like,
["options-general.php"]=>
array(9){
...
[41]=>
array(4) {
[0]=>
string(20) "Plugin Check"
[1]=>
string(16) "activate_plugins"
[2]=>
string(21) "sec_plugin_check"
[3]=>
string(23) " Plugin Checker"
...
}