Home › Forums › Bug Reports › (another) ReferenceError: wp is not defined
Greetings — I read the posts here and here related to the error
ReferenceError: wp is not defined
and am not sure if our error is related. We’re running WP 3.6.1 and ACF 4.2.2, but have no ACF-related plugins. The problem is affecting a media library button we have on a slideshow custom post form supplied by the theme developer (Striking): the button fails to bring up the media interface for users in author role (vs. admin, which works fine, but our many users are author role). Running debugger brings up the above error (when in author role) relative to this code in /js/input.min.js, I believe:
typeof wp=="object"&&(e="backbone");
This then triggers an error in the Striking theme code when we click the media button:
file_frame = wp.media.frames.file_frame = wp.media({
The theme developer cannot reproduce the error, so we are pretty sure it’s an ACF conflict but don’t know how to resolve. I’m happy to provide a user account if you’d like to diagnose.
Many thanks,
Jim P.
Can you confirm what version of ACF you are using?
I just searched for typeof wp=="object"&&(e="backbone");
in the input.js file, and can’t find it…
Perhaps you are using an older or modified version of ACF? Can you update?
Are you looking at input.js or input.min.js? The latter is the one indicated in debugger, though I realize it’s simply the minified version of the file you indicate. You’re right, though, so not sure what’s up. I’ll append a bit more of the minified code below. Btw, my ACF interface definitely says “Advanced Custom Fields 4.2.2”!
Cheers,
Jim P.
this.frame.dispose();this.frame=null},type:function(){var e="thickbox";typeof wp=="object"&&(e="backbone");return e},init:function(){var t=wp.media.view.AttachmentCompat.prototype;t.orig_render=t.render;t.orig_dispose=t.dispose;t.className="compat-item acf_postbox no_box";t.render=function(){var t=this;if(t.ignore_render)return this;this.orig_render();
Btw, the error triggered in the Striking code also says “wp is not defined,” and is relative to this media frame js code in the Striking plugin theme:
file_frame = wp.media.frames.file_frame = wp.media({
Is this JS error only appearing for a specific post_type edit screen? Do you get the error on a page or post edit screen?
It is possible that your theme’s post_type has some specific code which removes the wp media javascript from the edit screen.
You may need to track down this code in the theme and customize it to allow for the wp media JS to be included.
Hope that helps.
Thanks
E
The error occurs for a specific post type used by the theme: slideshow. It also occurs only for a specific role: author (or at least for sub-admin). The theme developer has tested it on their end and cannot duplicate this problem. I have tracked down the code in the theme that also generates the “wp is not defined” error, as noted above, and it’s in their media frame code, so that seems to be why the media frame doesn’t appear when users of author role (my students) click the media buttons on this custom post type. They suggested it was a conflict with another plugin, and since I see the same error in ACF and for author role only I figured this would be the reason. (But perhaps it’s not a big deal on the ACF side?) I can take your recommendation to the theme developer, but any further insights based on this info welcome! Btw, ACF is a great plugin, and is central to how we deploy WP in a learning environment.
Thanks for the props. I don’t have much advice, but hopefuly the theme dev can help you out.
Cheers
E
The topic ‘(another) ReferenceError: wp is not defined’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.