WordPress.org

Forums

Admin Tweaks
Issue with notification bubbles and Admin Menu Editor (6 posts)

  1. Hassan
    Member
    Posted 1 year ago #

    I use the Admin Menu Editor to customize my admin menu. There appears to be a conflict with this plugin when it comes to displaying those bubbles in custom post types menu items.

    The issue is that the bubbles do not show on the menu items. I'm not sure which plugin is the culprit here, but I think you can reproduce this and see for yourself.

    http://wordpress.org/plugins/many-tips-together/

  2. brasofilo
    Member
    Plugin Author

    Posted 1 year ago #

    Oh, I've seen Admin Menu Editor conflicting with other features of my plugin and with other plugins too. I ended up giving up on it.

    I think it does a complete rewrite of the Menu, overriding other plugin's modifications. I'm afraid I won't touch this issue as I'm more inclined to think it's AME who should play nice with other plugins. Or maybe it's impossible...

  3. Hassan
    Member
    Posted 1 year ago #

    Understandable. I'll try to reach out to AME's dev :)

  4. Hassan
    Member
    Posted 1 year ago #

    Question: How do you actually display these bubbles?

    I tried populating them with this code in my functions.php file, without this plugin, and they seem to work fine with AME:

    add_action( 'admin_menu', 'pending_posts_bubble_wpse_89028', 999 );
    function pending_posts_bubble_wpse_89028()
    {
        global $menu;
        $args = array( 'public' => true );
        $post_types = get_post_types( $args );
        unset( $post_types['attachment'] );
    
        foreach( $post_types as $pt )
        {
            // count posts
            $cpt_count = wp_count_posts( $pt );
            if ( $cpt_count->pending )
            {
                $suffix = ( 'post' == $pt ) ? '' : "?post_type=$pt";
                $key = recursive_array_search_php_91365( "edit.php$suffix", $menu );
                if( !$key )
                    return;
                $menu[$key][0] .= sprintf(
                    '<span class="update-plugins count-%1$s"><span class="plugin-count">%1$s</span></span>',
                    $cpt_count->pending
                );
            }
        }
    }
    function recursive_array_search_php_91365( $needle, $haystack )
    {
        foreach( $haystack as $key => $value )
        {
            $current_key = $key;
            if(
                $needle === $value
                OR (
                    is_array( $value )
                    && recursive_array_search_php_91365( $needle, $value ) !== false
                )
            )
            {
                return $current_key;
            }
        }
        return false;
    }

    The issue appears to be that Admin Tweaks is adding a bunch of new lines to the menu title which confuses AME plugin because it doesn't "understand" multilines in menu titles, and that's why it keeps resetting the title.

    P.S. I just noticed that I was the one who asked that question on WP Answers and you were the same one who answered :D

  5. brasofilo
    Member
    Plugin Author

    Posted 1 year ago #

    !!!!
    That's amazing, Hassan :)
    I incorporated the feature after that Q&A, jejeje, talk about circularity..!

    I'm really not remembering which other issue I had with AME that lead me to believe it's his fault... Well, alas, great that you dig the issue out.

    I created a Pastebin with your code. I don't understand really why, but rules here are no more than 10 lines of code (!) and mods usually delete code from threads. I'll check this the next time I open the plugin code.

    saludos!
    Rodolfo

  6. Hassan
    Member
    Posted 1 year ago #

    Okay, I think I now understand what's happening here. This is actually simpler than I thought.

    In a nutshell, the code you have in /many-tips-together/inc/hooks/adminmenus.php at about line 107 is:

    '<span
        class="update-plugins count-%1$s"
        style="background-color:white;color:black">
        <span
            class="plugin-count"
            style="text-shadow:none">%1$s</span>
    </span>'

    You simply need to write all of that in a single line (without line breaks) to avoid any conflicts. You should also remove those nasty inline styles btw. So, now I modified it to look like this:
    ' <span class="update-plugins count-%1$s"><span class="plugin-count">%1$s</span></span>'

    ...and everything is good again!

    P.S. Make sure to add a space before the first opening span for the bubble to appear nicely next to the menu item name, just like the case with the default bubbles on plugins and comments menus.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Admin Tweaks
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic