AMP plugin for WordPress issues

Has anyone been able to get AMP plugin working with CP? They list compatibility with v4.9, but it’s not working. There are JavaScript errors on the page. See screenshot.

Thanks.

Strange that you would be getting ReferenceError: wp is not defined, that JavaScript variable should be defined on all WP and CP installations going back much further than WP 4.9.

Maybe try on a fresh site, and if that doesn’t work post a topic on the plugin’s support forum?

Trying the plugin on WP 4.9 is probably the best bet if you want to get good support for it. You should see the same error there.

Thanks, James. I’ll do some troubleshooting and see if I can figure this out. Will report back.

1 Like

It’s looking for the i18n which I thought was added for Gubenberg, so I don’t know if that 4.9 label is accurate.

1 Like

We had to do a similar polyfill for i18n/wp code is like

		if ( ! wp_script_is( 'wp-i18n', 'registered' ) ) {
			wp_enqueue_script( 'fl-wp-i18n', "{$js_vendors}i18n-polyfill.js" );
		}

and the js file is simply

window.wp = window.wp || {};
window.wp.i18n = {};
1 Like

Thanks, I really appreciate this. That did the trick and fixed both errors.

@james should we consider adding this to CP core? Or at least a doc article to point people to.

For reference, here’s the thread in the plugin’s forum.

1 Like

In general we try not to add patches for specific plugins into CP core. Plugins that declare compatibility with WP 4.9 should actually work with WP 4.9. We do everything we can to make sure WP-4.9-compatible plugins actually work with CP, but doing more than that would end up starting a big game of cat and mouse that never ends.

5 Likes

This makes a nice patch plugin for those with the issue.

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

The AMP plugin authors are fixing this issue, and the fix is slated for the upcoming v2.1 release of the plugin: WP 4.9 Pollyfill JS Compatablity. · Issue #6100 · ampproject/amp-wp · GitHub

2 Likes