Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author brasofilo

    (@brasofilo)

    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…

    Thread Starter Hassan

    (@hassanhamm)

    Understandable. I’ll try to reach out to AME’s dev ??

    Thread Starter Hassan

    (@hassanhamm)

    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 ??

    Plugin Author brasofilo

    (@brasofilo)

    !!!!
    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

    Thread Starter Hassan

    (@hassanhamm)

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Issue with notification bubbles and Admin Menu Editor’ is closed to new replies.