0

How to process the textarea field with the standard WordPress function wpautop() when clicking the button?

Here's the form:

<textarea id="my_ta">Lorem ipsum!</textarea>
<button id="button_processing_ta">Обработать</button>

Here's the handler (to function.php):

<?php
  function my_action_javascript() { ?>
    <script>
      document.getElementById( 'button_processing_ta' ).addEventListener( 'click', function() {
        let my_ta = document.getElementById( 'my_ta' );

        // ???
        wpautop( my_ta.value );
      });
    </script>
  <?php }

  add_action( 'admin_print_footer_scripts', 'my_action_javascript', 99 );
?>

Sorry for my English...

0

Take a look at AJAX in Plugins which uses admin-ajax.php. This is a way for you to interact with WordPress via a javascript request to WordPress.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.