wp-papi / papi

:rocket: WordPress Page Type API with custom fields
https://wp-papi.github.io
MIT License
263 stars 32 forks source link

Link field not working in WP 4.7 #207

Closed pjbtwo closed 7 years ago

pjbtwo commented 7 years ago

What I expected

Expected to add a link to a page

What happened instead

In link pop-up window you must specify open in new window for link to work. If I leave checkbox unchecked, no link is added. Console reports javascript error:

VM949:24 Uncaught ReferenceError: target is not defined(…) (anonymous function) @ VM949:24 c @ load-scripts.php?c=0&load[]=hoverIntent,common,admin-bar,heartbeat,autosave,wp-ajax-response,jquery…:112 value @ link.js:146 dispatch @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,plupload&ver=4.7:3 r.handle @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,plupload&ver=4.7:3

Steps to reproduce

Try to add a link to any page or post with WP v 4.7

What versions of softwares are you using?

frozzare commented 7 years ago

Sounds like a issue with 4.7, will look at this when I get some time to do it.

On 12 dec. 2016 11:59 +0100, pjbtwo notifications@github.com, wrote:

What I expected

Expected to add a link to a page

What happened instead

In link pop-up window you must specify open in new window for link to work. If I leave checkbox unchecked, no link is added. Console reports javascript error:

VM949:24 Uncaught ReferenceError: target is not defined(…) (anonymous function) @ VM949:24 c @ load-scripts.php?c=0&load[]=hoverIntent,common,admin-bar,heartbeat,autosave,wp-ajax-response,jquery…:112 value @ link.js:146 dispatch @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,plupload&ver=4.7:3 r.handle @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,plupload&ver=4.7:3

Steps to reproduce

Try to add a link to any page or post with WP v 4.7

What versions of softwares are you using? Browser: Chrome 54.0.2840.98 Papi: 3.1.17 WordPress: 4.7

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub (https://github.com/wp-papi/papi/issues/207), or mute the thread (https://github.com/notifications/unsubscribe-auth/AAA5EuuhvwYgQdXpXY2yN24ryF5M55_hks5rHSj-gaJpZM4LKa0q).

pjbtwo commented 7 years ago

I think I found something. It seems wpLink.getAttrs() doesn't return target if the checkbox is left unchecked. I put a little check in render() method of Link in link.js to see if target is present or not. If not present I set it to '_self' else I leave it. Seems to have fixed the problem but I leave it up to you to do it correct in source files.

frozzare commented 7 years ago

@pjbtwo fixed in 3.x branch by @rasmusbe, new patch release will be released soon.

frozzare commented 7 years ago

https://github.com/wp-papi/papi/releases/tag/v3.1.18