Opened 11 years ago
Last modified 5 years ago
#25471 new enhancement
Allow wp_link_dialogue to open in contexts outside of the editor
Reported by: | we_tell | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 3.6.1 |
Component: | Editor | Keywords: | needs-patch |
Focuses: | javascript | Cc: |
Description
I use wp_link_dialogue within metaboxes to provide a nicer way for users to enter URL's. Its handy for say slideshows, or profiles that point to external sites.
wp_link_dialogue works perfectly on pages where an editor instance exists, but on pages that don't have editor instances it fails due to wplink.js looking for the global wpActiveEditor var, which of course doesn't exist as there is no editor. Aside from the js error, invoking the dialogue on pages with no editor involves calling _WP_Editors::wp_link_dialog(); directly to output the required html which isn't ideal, or calling wp_editor and using css to hide it, which just seems lame.
Ideally wp_link_dialogue should function independently of the editor.
Approaches
- Amend wplink.js to allow wpActiveEditor to be undefined and pass in a seperate value for textfield to the open method. Con is that wp_link_dialog() still has to be invoked with a call to _WP_Editors::wp_link_dialog()
- Move wp_link_dialog into a seperate class, amend _WP_Editors to call this class and allow for a user defined textfield within wplink.js
Abstracting WP_Link and moving it out of WP_Editor seems like the better solution. The JS will still need a context to be passed in, whether it is a text field, textarea or an editor id.