Title: Add a button on WP post-edit page, which when clicked will call a python script.
Last modified: March 23, 2021

---

# Add a button on WP post-edit page, which when clicked will call a python script.

 *  [uchavarkar](https://wordpress.org/support/users/uchavarkar/)
 * (@uchavarkar)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/add-a-button-on-wp-post-edit-page-which-will-call-a-python-script/)
 * Hello
    I’m developing an admin-side plugin for WordPress admin and authors to
   be involved in the post edit screen when an article is being drafted. I am trying
   to add a button on the WP post-edit page, which when clicked will send the post’s
   content to a python script that implements NLP, and uploads the processed data
   to a MySQL database and finally notify the plugin code running once the data 
   is uploaded. My PHP code will then pull the data from the MySQL DB and display
   it on a pop-up screen for the author to see.
 * I want to add the button in the position shown (check out this link [Screenshot of post-edit screen ( button location ) ](https://i2.paste.pics/BYIPF.png)).
   The flow is similar to any text analysis plugin (but I want to call the analysis
   functionality only when clicked). I need help with locating the exact documentation
   that shows how my plugin, when activated can add the button and register the 
   functions to call. Would appreciate a pointer or two on this! Currently I’m looking
   at the source code of Easy Content Analysis and WProofReader.
    (And I can call
   a PHP function in my plugin that can inturn call my python script too.)
    -  This topic was modified 5 years, 2 months ago by [uchavarkar](https://wordpress.org/support/users/uchavarkar/).
    -  This topic was modified 5 years, 2 months ago by [uchavarkar](https://wordpress.org/support/users/uchavarkar/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Zack Krida](https://wordpress.org/support/users/zackkrida/)
 * (@zackkrida)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/add-a-button-on-wp-post-edit-page-which-will-call-a-python-script/#post-14225179)
 * Hello [@uchavarkar](https://wordpress.org/support/users/uchavarkar/),
 * First, here’s a WordPress hook you could use to add content to the post edit 
   page, near the ‘publish’ button:
 * [https://developer.wordpress.org/reference/hooks/post_submitbox_misc_actions/#user-contributed-notes](https://developer.wordpress.org/reference/hooks/post_submitbox_misc_actions/#user-contributed-notes)
 * Then, your button would need to make a network request with ajax (likely a POST
   request) to a url that accepts data and would fire your php script (Which would
   itself pass the data to your python function).
 * You could use the WordPress REST API to create this endpoint for your ajax request.
   You can research and see examples of adding api endpoints here: [https://developer.wordpress.org/reference/functions/register_rest_route/](https://developer.wordpress.org/reference/functions/register_rest_route/)
 * Good luck!
 *  Thread Starter [uchavarkar](https://wordpress.org/support/users/uchavarkar/)
 * (@uchavarkar)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/add-a-button-on-wp-post-edit-page-which-will-call-a-python-script/#post-14241046)
 * Thanks [@zackkrida](https://wordpress.org/support/users/zackkrida/) I am trying
   the links and guide you have provided. I am not able to embed the HTML code in
   the right file. Do you have any suggestions for that ?
    Thank you for the help!!
 *  [Zack Krida](https://wordpress.org/support/users/zackkrida/)
 * (@zackkrida)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/add-a-button-on-wp-post-edit-page-which-will-call-a-python-script/#post-14249440)
 * Hi [@uchavarkar](https://wordpress.org/support/users/uchavarkar/) could you explain
   a little more the steps you’ve done so far? This is a fairly technical task with
   a few steps, and I’m not exactly sure what you’ve already done or not.
 *  Thread Starter [uchavarkar](https://wordpress.org/support/users/uchavarkar/)
 * (@uchavarkar)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/add-a-button-on-wp-post-edit-page-which-will-call-a-python-script/#post-14261246)
 * I am not following the PHP OOP as of yet. I have one main _plugin.php_ file, 
   which contains the main class of my plugin. This is where, I enqueue javascript
   file _(plugin folder/assets/plugin.js)_ , which contains the ajax request which
   will trigger once the button is pressed to run the PHP file _(plugin folder/run-
   script.php)_ which will call the python script _(plugin folder/assets/python.
   py)_ . All custom API endpoints are mentioned in _(plugin folder/includes/wp-
   admin-api.php)_
 * I want to know where should I embed the code for adding the button (the one near
   the publish button), and how should I run the HTML code within it?
 * I followed some of the links below, but they did not work.
    [https://code.tutsplus.com/tutorials/how-to-use-php-in-html-code–cms-34378](https://code.tutsplus.com/tutorials/how-to-use-php-in-html-code–cms-34378)
   [https://stackoverflow.com/questions/18140270/how-to-write-html-code-inside-php-i-want-write-html-code-within-the-php-sc](https://stackoverflow.com/questions/18140270/how-to-write-html-code-inside-php-i-want-write-html-code-within-the-php-sc)
    -  This reply was modified 5 years, 2 months ago by [uchavarkar](https://wordpress.org/support/users/uchavarkar/).
    -  This reply was modified 5 years, 2 months ago by [uchavarkar](https://wordpress.org/support/users/uchavarkar/).
    -  This reply was modified 5 years, 2 months ago by [uchavarkar](https://wordpress.org/support/users/uchavarkar/).
    -  This reply was modified 5 years, 2 months ago by [uchavarkar](https://wordpress.org/support/users/uchavarkar/).
    -  This reply was modified 5 years, 2 months ago by [uchavarkar](https://wordpress.org/support/users/uchavarkar/).
 *  Thread Starter [uchavarkar](https://wordpress.org/support/users/uchavarkar/)
 * (@uchavarkar)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/add-a-button-on-wp-post-edit-page-which-will-call-a-python-script/#post-14271334)
 * Hi [@zackkrida](https://wordpress.org/support/users/zackkrida/), would love to
   hear your expertise on this topic. Awaiting your reply.
    Thank you

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Add a button on WP post-edit page, which when clicked will call a python
script.’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 5 replies
 * 2 participants
 * Last reply from: [uchavarkar](https://wordpress.org/support/users/uchavarkar/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/add-a-button-on-wp-post-edit-page-which-will-call-a-python-script/#post-14271334)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
