Make WordPress Core

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's profile 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

  1. 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()
  2. 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

Change History (2)

#1 @azaozz
10 years ago

  • Milestone changed from Awaiting Review to Future Release

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.

#2 @chriscct7
9 years ago

  • Focuses javascript added
  • Keywords 2nd-opinion removed
Note: See TracTickets for help on using tickets.