Opened 10 years ago
Last modified 4 years ago
#32143 new enhancement
wpLink function getAttrs() missing link-text
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.2 |
Component: | Editor | Keywords: | reporter-feedback |
Focuses: | javascript | Cc: |
Description
After last update to 4.2 wpLink() was renewed and the title-input was replaced.
Instead of title, you can now insert/change the link text.
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/js/wplink.js?rev=32017
But in function getAttrs() the val of link-text was forgotten.
Therfor I proporse to add this line in getAttrs():
linktext: $.trim( inputs.text.val() ),
Also it would be nice to populate the link-text field with the document title of a chosed intern element, like it was made with the old title-field before.
Change History (6)
#1
in reply to:
↑ description
@
10 years ago
- Component changed from General to Editor
#2
@
10 years ago
In some plugins wpLink is also used to add contextual links beneath the editor (mostly in a seperate metabox). Therfor htmlUpdate() or mceUpdate() wont help, cause they are only for use within the textarea of the editor.
The content of the wp-link-text is not a HTML attribute and so getAttrs() might be the wrong position to return it, but to add a single line of code there wouldnt hurt anyone :)
#3
@
9 years ago
The title here is also used for the ACF Link Picker field type. Currently I can't add "Related links" to my site because the title doesn't fill in because it is no longer present in the getAttrs() function. I don't mind it not being there and am happy to adjust my code to get it from somewhere else... is there somewhere else I can get it? I can't figure out a way to access the 'inputs' variable that is used throughout wplink to access the Title value.
I realize you can never count on reusing a piece of the core in a plugin, but it seems confusing and unnecesssary to rewrite wplink just to use it in practically the same way a little further down the page.
Just my use-case and upvote.
#4
@
9 years ago
Hi!
I agree with xwolf and thesarahkemp. Removing the title from the getAttrs()
basically makes it impossible to get the title outside the editor (metaboxes for instance).
If you could add a function that will just return the title that would be great :)
Hi @xwolf, welcome to Trac!
That line already exists in
htmlUpdate()
andmceUpdate()
functions. Link text is not really an attribute likehref
ortarget
, why should it be ingetAttrs()
?