Dobby not catching notices

#2 · closed · 6 comments

View on GitHub ↗

tyrann0us

#### Version Information * PHP: 7.0.6 * WordPress: 4.8 * Non-multisite installation #### Steps to Reproduce 1. Force notices to show up (for example activate "[Google Analytics for WordPress by MonsterInsights](https://wordpress.org/plugins/google-analytics-for-wordpress/)") #### What I Expected The notices to be hidden on page load. #### What Happened Instead The notices are all shown because Dobby creates and toggles an empty div: `<div class="dobby-notices hide-if-js" style="display: none;"></div>`. ![screenshot-wordpress-blank l 2017-07-17 08-17-16](https://user-images.githubusercontent.com/8144115/28257113-809ba306-6ac8-11e7-845b-2dc06808b9a2.png)

Comments

tfrommen

Hm, if Dobby outputs an admin notice himself, [he **did** capture something](https://github.com/tfrommen/Dobby/blob/215470d8a73dc33a50aa7e598198d08ee7ccd43b/dobby.php#L44-L47). Why the notices are not anymore where Dobby put them, I don't know. Can you see if the notices (all but Dobby's) have a class of `inline`?

tyrann0us

No, they don't have the `inline` class. This is the rendered (shortened) markup on the Dashboard: ``` […] <div id="wpbody-content" […]> <div id="screen-meta" class="metabox-prefs">[…]</div> <div id="screen-meta-links">[…]</div> <div class="dobby-notices hide-if-js"></div> <div class="wrap"> <h1>Dashboard</h1> <div id="dobby" class="notice notice-info"> <p>Dobby took care of your admin notices. <button class="button dobby-button">Toggle notices</button></p> </div> <div class="updated">[…]</div> <div class="error">[…]</div> […] </div> […] </div> […] ``` Notice the empty (and misplaced?) `<div class="dobby-notices hide-if-js"></div>`? I also disabled all plugins (except Dobby and Google Analytics for WordPress by MonsterInsights) and activated Twenty Seventeen but the problem persists.

tfrommen

Oh, I see, they don't even have the `notice` class, that's the reason the `preg_replace()` fails. Hm...

tfrommen

@tyrann0us could you please see if [this branch](https://github.com/tfrommen/Dobby/tree/issue/2_missed_notices) is working for you? Thanks.

tyrann0us

This fixes it for me. 👍

tfrommen

This has been fixed in 27798460a5c8b1b3fa03c6f2ce9f070e824a9a79 (differently than in the referenced branch, but still). Thanks for catching this (so soon).