Plugin Directory

Changeset 2070256


Ignore:
Timestamp:
04/17/2019 09:32:56 PM (7 years ago)
Author:
tagbee
Message:

add rest api support

Location:
tagbee-automatic-post-tagging
Files:
9 added
1 edited

Legend:

Unmodified
Added
Removed
  • tagbee-automatic-post-tagging/trunk/tagbee-post-tagger.php

    r2068299 r2070256  
    44Plugin URI:   https://developer.wordpress.org/plugins/the-basics/
    55Description:  Add Tags to posts
    6 Version:      1.0.6
     6Version:      1.0.7
    77Author:       TagΒee Team
    88Author URI:   https://tagbee.co
     
    2828*/
    2929defined('ABSPATH') or die('Wordpress Plugin');
    30 define('TAGBEE_VERSION', "1.0.6");
     30define('TAGBEE_VERSION', "1.0.7");
    3131define("TAGBEE_NAMESPACE", "tagbee");
    3232define("TAGBEE_INNER_PROPOSAL_ENDPOINT", "proposals");
     
    5656
    5757/** Submit Final Post Info and Save Post Meta */
    58 function tagbee_post_info( $id, $post ) {
     58function tagbee_post_info_callback( $id, $post ) {
    5959
    6060    $id = (int) $id;
     
    9797}
    9898
     99/** Decide if the this is a rest api request */
     100function is_api_used() {
     101    return defined('REST_REQUEST') && REST_REQUEST;
     102}
     103
     104function tagbee_post_info_rest( $post ) {
     105    tagbee_post_info_callback($post->ID, $post);
     106}
     107
     108function tagbee_post_info( $id, $post ) {
     109
     110    if (is_api_used()) {
     111        add_action('rest_after_insert_post', 'tagbee_post_info_rest', 10, 2);
     112        return;
     113    }
     114
     115    tagbee_post_info_callback($id, $post);
     116}
     117
    99118/** Plugin Settings Page */
    100119function tagbee_settings_page() { ?>
Note: See TracChangeset for help on using the changeset viewer.