In the previous post in this series, I showed how to add content to the post editor using a custom TinyMCE button. The problem with the approach, as we’ve covered thus far, is that the content that we’re adding to the editor is hard-coded.
We’re rarely going to want to be doing this, right? I mean, wouldn’t we rather grab input from the user and then add that to the editor?
For some, this may be creating a shortcode based on some input, for others it may be grabbing input, making an Ajax call, and then putting the result of the request into the editor, or it may be something as simple as taking whatever input the user has provided in a prompt and then adding it to the editor.
Though the latter case is not likely something that is a realistic use case (after all, if they just wanted to put something into the editor, why not just, you know, enter it into the editor?), it’s something that will make rounding out this series a bit more complete because it will show how to connect displaying a prompt to the user, grabbing the input, then using the TinyMCE API to drop the input into the editor.
So that’s what we’ll do.