• Giulio

    (@ferocious)


    Hello!

    Wordpress 4.9 introduces CodeMirror library for use within core and an API to use with plugin development. I was able to successfully manage how to integrate the editor into the administration page of my plugin following Ruter’s advice in his post but when I come to face with Widget API I can not handle this new feature because I don’t know the Widget ID to pass as parameter to wp.codeEditor.initialize().
    Before the 4.9 release I used a copy of custom-html-widgets.js adapted for use by my plugin but now it does not work anymore. What is the correct way to use CodeMirror with the Widget API?

Viewing 1 replies (of 1 total)
  • Thread Starter Giulio

    (@ferocious)

    I don’t like answering my own question, but I feel this is the one of the possible solutions so far, but not the best:
    I used the file custom-html-widgets.js as a model for my own plugin, renaming the main method to avoid conflicts to runtime. Each plugin needs this file in order to use Codemirror into the Widgets panel and connecting it directly by using wp_enqueue_script does not seem to work. Then I worked on InitializeEditor and Init in order to find the selector for the textarea of my widget. At last I did register this new script with wp_register_script in the Widget extended class.

Viewing 1 replies (of 1 total)
  • The topic ‘Problem with Widget and Code Editor API’ is closed to new replies.