Tax-Meta-Class icon indicating copy to clipboard operation
Tax-Meta-Class copied to clipboard

JavaScript Error: wpColorPicker is not a function

Open technotarek opened this issue 9 years ago • 7 comments

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.

technotarek avatar Feb 02 '16 01:02 technotarek

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 avatar Feb 02 '16 02:02 technotarek

@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 avatar May 03 '16 14:05 Akamaozu

@Akamaozu I ended up using an alternative approach and am no longer using this plugin.

technotarek avatar May 03 '16 14:05 technotarek

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.

baysideufl avatar Jun 05 '16 20:06 baysideufl

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 avatar Jun 20 '16 06:06 Mathiu

@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.

Akamaozu avatar Jun 20 '16 10:06 Akamaozu

@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

hughbris avatar Jun 08 '18 00:06 hughbris