Thursday, December 22, 2022
HomeWordPress Developmentplugin improvement - Name API on submit save/replace and present the lead...

plugin improvement – Name API on submit save/replace and present the lead to admin space


After updating/saving a submit, I need to name an API and present the response message within the submit editor. I attempted many issues, searched numerous web sites, and located nothing that works.

This can be a easy model of my code, inside a customized plugin (nothing particular; only a single PHP file):

operate revalidate_post($post_id) {
    file_get_contents("https://another-site.com/revalidate/?id=" . $post_id);

    // present a message in submit editor, and say if operation was profitable or not:
    // show_message()
}

add_action("save_post", "revalidate_post", 20, 1);

Can any person please clarify how can I do that, step-by-step? The JSON response and issues aren’t my query; I am caught within the show_message() factor.

Some comparable questions say that WordPress redirects to a different web page when the submit is revealed/up to date, and thus their resolution is to avoid wasting worth in cookies or URL params, and use that to point out a message after the redirection is full. Nonetheless, in WordPress 6 and the Block Editor, I do not see that redirection. Solely a easy snackbar (toast notification) seems on the underside left that claims “Publish up to date/revealed”.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments