TGMPA / TGM-Plugin-Activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
http://tgmpluginactivation.com/
GNU General Public License v2.0
1.75k stars 431 forks source link

JS error - wp is not defined #708

Open benitolopez opened 6 years ago

benitolopez commented 6 years ago

Hi,

Every time I update a plugin through TGMPA I receive a JS error at the end of the process:

Uncaught TypeError: Cannot read property 'decrementCount' of undefined

The code fails in this script:

<script type="text/javascript">
    (function( wp ) {
        if ( wp && wp.updates.decrementCount ) {
            wp.updates.decrementCount( "plugin" );
        }
    })( window.wp );
</script>

Any idea?

jrfnl commented 6 years ago

Thanks for reporting this. TGMPA does not have its own javascript, but uses some of the scripts from WordPress Core. Seems they have been making some changes over the last few versions causing notices without impeding functionality. This needs to be investigated, especially how to get this working notice free across all supported WP versions.

benitolopez commented 6 years ago

Yes, the "problem" it's inside the decrement_update_count() method which is called in the after() method of the Plugin_Upgrader_Skin class.

jrfnl commented 6 years ago

Side-note: this may be loosely related to #660 which also reports a notice coming from the WP core JS files.