0

I've been asked to create a WordPress plugin that will basically show a button on the "edit" and the "new" pages of the admin panel which (when clicking the button) verify an API key (which you can set in the settings) and then send the post contents to a 3rd party.

When the 3rd party receives the text, they'll do their work on it and send it back through email to the website owner.

Now, the question is:

How do I get that button on the WP-admin on the new and edit pages of WordPress, is it even possible to get the current post's content, and send it to the 3rd party?

I'd love to hear if this is feasible (since I don't know what WordPress is capable of) and if so, if you could send me in the right direction.

1

absolutely it is possible.

function add_property_import_meta_box()
{
    add_meta_box('property-import-images', 'Property Actions', 'function_import_images_metabox', 'property', 'side', 'high');
}

add_action('add_meta_boxes', 'add_property_import_meta_box');

function function_import_images_metabox($post)
{
    // Noncename needed to verify where the data originated
    echo '<input type="hidden" name="property_actions_nonce" id="property_actions_nonce" value="' .
        wp_create_nonce( plugin_basename(__FILE__) ) . '" />';

    ?>
    <p><a href="/wp-admin/admin.php?page=actionhere" class="button button-primary button-large">Second Action</a></p>
    <p><a href="/wp-admin/admin.php?page=actionhere" class="button button-primary button-large">Third Action</a></p>


<?php }

More info https://developer.wordpress.org/reference/functions/add_meta_box/

  • To connect to api's you could use wp_remote_get – AceWebDesign Jan 31 '17 at 12:47
  • Thanks for answering, would you mind explaining what the code does tho? I don't need the html explained but the metabox stuff is new for me :) – FMashiro Jan 31 '17 at 12:48
  • 1
    add_action adds the action for the meta boxes. using the function add_property_import_meta_box (you can call whatever function name you decide though. in the add_meta_box function you can see the callback function it uses is function_import_images_metabox and the post type is 'property'. The html is shown in that function so you can put whatever you want in that metabox. – AceWebDesign Jan 31 '17 at 23:51
  • hope that helps – AceWebDesign Jan 31 '17 at 23:53

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.