title: Add custom buttons with custom actions in Edit Post screen in WordPress?
body: <p>I am creating something for a client and I have a <strong>Class</strong> that I created with a <strong>Custom Post Type called 'PuSH Feeds'</strong> and when the user adds a new post and publishes it they can then click on one of <strong>two buttons</strong> that I have in the <strong>Custom Meta Box</strong>.</p>
  
  <p>One button is for <strong>'Subscribe'</strong> and the other for <strong>'Unsubscribe'</strong>. I am using the <strong>save_post action hook</strong> and testing if the <strong>$_POST</strong> global has that <strong>'pushfeed-subscribe'</strong> or <strong>'pushfeed-unsubscribe'</strong> and then do what I need to do. However for some reason I have found that once I click on the subscribe on my local machine stops the script because it says it did 100 consecutive calls etc and I end up with loads of duplicate posts with no title.</p>
  
  <p>What would be the best way to avoid this and is there a better hook I can use for these special custom actions I want to activate of subscribing to a feed (which goes into another class and performs the subscribe method)?</p>
  
  <p>This is the markup I have for those two buttons I mentioned with is inside the Metabox</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;input type="submit" class="button-secondary" name="pushfeed-subscribe" id="pushfeed-subscribe" value="Subscribe"&gt;
  &lt;input type="submit" class="button-secondary" name="pushfeed-unsubscribe" id="pushfeed-unsubscribe" value="Unsubscribe"&gt;
  </code></pre>
  
  <p>Then I have this for the action hook:</p>
  
  <pre class="lang-php prettyprint-override"><code>add_action( 'save_post', array( $this, 'pushfeed_save_post_meta' ) );
  </code></pre>
  
  <p>The actual hook is like this:</p>
  
  <pre class="lang-php prettyprint-override"><code>public function pushfeed_save_post_meta( $post_id ) {
  
      // Bail if we're doing an auto save
      if ( defined( 'DOING_AUTOSAVE' ) &amp;&amp; DOING_AUTOSAVE ) return;
  
      // if our nonce isn't there, or we can't verify it, bail
      if( !isset( $_POST['pushfeed-nonce-field'] ) || !wp_verify_nonce( $_POST['pushfeed-nonce-field'], basename( __FILE__ ) ) ) return;
  
      // If Subsctiption ID is empty, generate a random long number and save it
      if ( empty( $_POST['pushfeed-subscription-id'] ) ) {
  
          $random_number = substr(number_format(time() * mt_rand(),0,'',''),0,10);
          $pushfeed_subscription_id = $random_number . $post_id;
          update_post_meta( $post_id, 'pushfeed-subscription-id', $pushfeed_subscription_id );
      }
  
      ...
  
      if ( isset( $_POST['pushfeed-subscribe'] ) || isset( $_POST['pushfeed-unsubscribe'] ) ) {
  
          $subscription_domain = get_post_meta($post_id, 'pushfeed-domain', true);
          $subscription_id = get_post_meta($post_id, 'pushfeed-subscription-id', true);
          $subscription_feed_url = get_post_meta($post_id, 'pushfeed-feed-url', true);
          $subscription_callback_url = $subscription_domain . '/pushfeed/' . $subscription_id;
  
  
          $sub = PuSHSubscriber::instance($subscription_domain, $subscription_id, 'PuSHSubscription', new PuSHEnvironment());
  
          if ( isset( $_POST['pushfeed-subscribe'] ) ) {
              $sub-&gt;subscribe($subscription_feed_url, $subscription_callback_url);
          } elseif ( isset( $_POST['pushfeed-unsubscribe'] ) ) {
              $sub-&gt;unsubscribe($subscription_feed_url, $subscription_callback_url);
          }
  
      }
  
  }
  </code></pre>
  
  <p>I am trying to find out why is it that the post is saving multiple duplicates with no title.
  <strong>But above all I would like to know if there is a better action hook I can call for these two custom actions.</strong></p>
  
  <p><strong>Update :</strong></p>
  
  <p>Hi everyone. I ended up using an Ajax request using the wordpress admin-ajax.php when clicking a button and then firing of the subscription method. Once that is done the subscription method will do a get request and if returns a 200 code then the method returns true to the Ajax. </p>