wp_editor implement using javascript on dynamic multiple textarea

wp_editor implement using javascript on dynamic multiple textarea

WordPress provide extendability in our functionality. Due to this developer have the flexibility to modify it according to client requirement. Sometimes if you want to provide good user interface using WordPress component like editor, media. A Very common using component is WordPress editor. Whenever developer has task to provide HTML formatted text area. In that situation developer always use existing component like wp_editor. Its good & easily implemented. One advantage also there when the WordPress update same time it will also update.

You can easily apply the editor on the text editor using below example.

<textarea id="about_us"></textarea>

Add code in our plugin or functions.php


<?php wp_editor( "loaded content", "place your editor id without #", "setting array"); ?>
<?php wp_editor( $content, $editor_id, $settings = array() ); ?>

With the help of above code, you can populate the WordPress editor in the text area. But Its better for single and static textarea. But if you have multiple textarea then need to write to code for each textarea. So the code will increases. But the code review perspective code should be minimum for the requirement. It also fails when you have dynamic text area created using the jQuery. In that situation, it’s not loaded. So there is a need such an API that provides the generate the wp_editor using javascript.

Now for removing above issue WordPress release a new version of editor API. With the help of that, you load wp_editor using javascript. Due to this developer can load the editor using javascript. It’s very easy to load wp_editor on the text area with the usage of below steps.

First of all, need to enqueue the editor in the functions.php or plugin file like below


<?php wp_enqueue_editor(); ?>

It load the all js files related to wp_editor. Now you can load the editor in our js file where ever you want. New release provide the below functions.


    wp.editor.initialize();
    wp.editor.remove();
    wp.editor.getContent();

You can review code of new release and modify our js according to it.

Addition of TinyMCE to the Text Widget

Editor API changes in 4.8

(See wp-admin/js/editor.js for more info.)

Now the developer has more flexibility to add wp_editor on dynamically generated textarea. Due to this, you can create page builder like functionality. Due to this feature WordPress also add the editor in the widget section in the latest release.

24 thoughts on “wp_editor implement using javascript on dynamic multiple textarea

  1. Long time reader, first time commenter — so, thought I’d drop a comment..
    — and at the same time ask for a favor.

    Your wordpress site is very simplistic – hope you don’t mind me
    asking what theme you’re using? (and don’t mind if I steal it?

    :P)

    I just launched my small businesses site –also built in wordpress like
    yours– but the theme slows (!) the site down quite a bit.

    In case you have a minute, you can find it by searching for “royal cbd” on Google (would appreciate any feedback)

    Keep up the good work– and take care of yourself during the
    coronavirus scare!

    ~Justin

  2. Hi there would you mind letting me know which webhost you’re using?
    I’ve loaded your blog in 3 different web browsers and I must say this blog loads a lot quicker
    then most. Can you recommend a good internet hosting provider at a reasonable price?
    Thanks a lot, I appreciate it!

  3. Great post. I was checking constantly this blog and I am
    impressed! Very helpful information specially the remaining section 🙂 I take care of
    such info a lot. I used to be looking for this particular information for a long time.
    Thanks and best of luck.

    Feel free to visit my web blog … CBD oil for anxiety

  4. Hi would you mind letting me know which web host you’re utilizing?
    I’ve loaded your blog in 3 different browsers and I must say this blog loads a
    lot quicker then most. Can you recommend a
    good web hosting provider at a fair price?
    Kudos, I appreciate it!

  5. I was wondering if you ever thought of changing the layout of your website?

    Its very well written; I love what youve got to say. But maybe you
    could a little more in the way of content so people could
    connect with it better. Youve got an awful lot of text for only having 1 or two images.
    Maybe you could space it out better?

    Here is my blog post – CBD oil for dogs

  6. Hey There. I found your blog using msn. This is a very well written article.
    I will be sure to bookmark it and come back to read more of your useful info.
    Thanks for the post. I’ll definitely return.

  7. May I just say what a comfort to find someone that really knows
    what they’re talking about over the internet.
    You certainly know how to bring a problem to light and make it important.
    More people ought to read this and understand this
    side of the story. I can’t believe you’re not more popular because you
    certainly possess the gift.

    my web-site delta 8 (http://www.thedailyworld.com)

  8. Thanks for one’s marvelous posting! I seriously enjoyed reading it, you’re
    a great author.I will remember to bookmark your blog and will
    come back very soon. I want to encourage you to ultimately
    continue your great writing, have a nice evening!

  9. Hey I know this is off topic but I was wondering if you
    knew of any widgets I could add to my blog
    that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some time
    and was hoping maybe you would have some experience with something like this.

    Please let me know if you run into anything.
    I truly enjoy reading your blog and I look forward
    to your new updates.

  10. Excellent article. Keep writing such kind of information on your page.

    Im really impressed by your site.
    Hello there, You have performed an excellent job.
    I will definitely digg it and for my part suggest to my friends.
    I am sure they will be benefited from this site.

  11. Hmm is anyone else encountering problems with the images on this
    blog loading? I’m trying to figure out if its a problem on my end or
    if it’s the blog. Any feed-back would be greatly appreciated.

  12. Your way of explaining everything in this post is truly pleasant, all be
    able to without difficulty be aware of it, Thanks a lot.

  13. My brother recommended I might like this blog. He was totally right.

    This post truly made my day. You can not imagine
    simply how much time I had spent for this info! Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons