Tax-Meta-Class
Tax-Meta-Class copied to clipboard
JavaScript Error: wpColorPicker is not a function
I'm getting this error when running the plugin and I think it is adversely affecting the WYSIWYG editor (e.g,. can't insert links; can't toggle to the 'text' tab etc).
WordPress Version: 4.4.1 Plugin Version: 2.1.0
Triggered by:
$('.at-color').wpColorPicker();
Happy to try to pitch in and help -- would be great if you could point me in the right direction though.
I confirmed that commenting out lines 63 and 157 of tax-meta-clss.js removes the errors (obviously) and that doing so also restores the other broken functionality that I had mentioned. Is there a known substitute for wpColorPicker? Is the only role it plays is to allow selecting a color in the WYSIWYG?
@technotarek I got the same error and wrote a fix for the issue here: https://github.com/bainternet/Tax-Meta-Class/pull/122.
Do you mind testing it to see if it works for you?
@Akamaozu I ended up using an alternative approach and am no longer using this plugin.
First, excellent library. Thanks for the hard work!
I had this issue too. In my case I was using the color picker which worked when I was creating terms, but not when editing a term (ie: /wp-admin/edit-tags.php
vs /wp-admin/term.php
). Turns out the is_edit_page()
check was only returning true for edit-tags.php
and therefore the enqueues for the styles and scripts weren't getting fired. So in Tax-meta-class.php
line 1133
I changed the function check from:
public function is_edit_page() { global $pagenow; return ( $pagenow == 'edit-tags.php' ); }
to:
public function is_edit_page() { global $pagenow; return ( $pagenow == 'edit-tags.php' || $pagenow == 'term.php' ); }
and all seems to be well.
I'll get this forked and do a pull request later, but thought this may help someone in the meantime.
Another and in my opinion quickest fix would be to add wp-color-picker as a dependency for tax-meta-clss script at line 162
.
@mathiu but that means loading wp-color-picker
even when it's not going to be used.
If every other plugin behaved that way, you'd quickly end up with a bloated WordPress installation.
I wrote a solution (https://github.com/bainternet/Tax-Meta-Class/pull/122) that takes the other approach: doesn't blindly execute the color picker function if it doesn't need to.
It solved other people's problem: https://github.com/bainternet/Tax-Meta-Class/issues/117
Would appreciate it if you can check that it solves yours.
@Mathiu thanks, solved it for me. I'm not using a colour picker. I suspect if I used one, this wouldn't help though. Won't be needing it, so that will remain conjecture.
If every other plugin behaved that way, you'd quickly end up with a bloated WordPress installation.
Wordpress? Bloat? Surely not!! LOL