• Resolved ozobo

    (@ozobo)


    Hello everyone,

    i’m developping my custom plugin and i want to add bubble notification.

    When my field called “Option 1” is empty i want to add a bubble on my menu.

    When it’s not empty i want hide the bubble.

    I thinked about use an add_action(admin_menu) hook and then create a function where :

    
    add_menu_page("My plugin" , printf(__('Plugin %s'), "<span class='update-plugins count-$count' title='Myplugin><span class='update-count'>" . number_format_i18n($count) . "</span></span>"),'manage_options')

    With ?ount receiving if my parameter is empty or not

    But it doesn’t working when the field is not empty.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You should conditionally set the menu title to one string with the notification or another without. I’m not sure how you would determine your plugin field value, but making up a function as an example, something like

    $option = get_my_plugin_field('option-1');
    if ( $option ) {
      $title = 'Just the Title';
    } else {
      $title = 'Title with notification';
    }
    add_menu_page('My Plugin", $title, 'manage_options', 'my-plugin-menu');

    You can boil that down into a one liner with ternary operators, but it’s much more difficult to read and I’d advise against it. (ternary operators are used in the construct if_true()?'do this':'else this';)

Viewing 1 replies (of 1 total)
  • The topic ‘Add nd remove admin bubble notification’ is closed to new replies.