Plugin Directory

Changeset 2129926


Ignore:
Timestamp:
07/29/2019 04:13:13 AM (7 years ago)
Author:
milanmk
Message:

Release 1.14.0

Location:
schema-app-structured-data-for-schemaorg
Files:
26 added
5 edited

Legend:

Unmodified
Added
Removed
  • schema-app-structured-data-for-schemaorg/trunk/hunch-schema.php

    r2097983 r2129926  
    55 * Plugin URI: http://www.schemaapp.com
    66 * Description: This plugin adds http://schema.org structured data to your website
    7  * Version: 1.13.0
     7 * Version: 1.14.0
    88 * Author: Hunch Manifest
    99 * Author URI: https://www.hunchmanifest.com
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaFront.php

    r2070040 r2129926  
    1818        add_action( 'plugins_loaded', array( $this, 'hook_plugins_loaded' ) );
    1919        add_action( 'init', array( $this, 'HandleCache' ) );
     20        add_action( 'rest_api_init', array( $this, 'hook_rest_api_init' ) );
    2021
    2122        if ( ! empty( $this->Settings['SchemaLinkedOpenData'] ) ) {
     
    8485
    8586            exit;
     87        }
     88    }
     89
     90
     91    public function hook_rest_api_init() {
     92        register_rest_route( 'hunch_schema', '/cache/', array(
     93            array( 'methods' => 'GET', 'callback' => array( $this, 'rest_api_cache' ) ),
     94            array( 'methods' => 'POST', 'callback' => array( $this, 'rest_api_cache_modify' ) ),
     95        ) );
     96    }
     97
     98
     99    public function rest_api_cache( $request ) {
     100        return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Please use POST method to send data' ), 405 );
     101    }
     102
     103
     104    public function rest_api_cache_modify( $request ) {
     105        $request_data = json_decode( $request->get_body() );
     106
     107        if ( empty( $request->get_body() ) || empty( $request_data ) ) {
     108            return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid JSON data' ), 400 );
     109        } elseif ( empty( $request_data->{"@type"} ) || empty( $request_data->{"@id"} ) || empty( $request_data->{"@graph"} ) ) {
     110            return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid @type, @id or @graph property' ), 400 );
     111        } else {
     112            if ( stripos( $request_data->{"@id"}, site_url() ) === false ) {
     113                return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid @id property, url does not match' ), 400 );
     114            }
     115
     116            $transient_id = 'HunchSchema-Markup-' . md5( $request_data->{"@id"} );
     117
     118            switch ( $request_data->{"@type"} ) {
     119                case 'EntityCreated':
     120                case 'EntityUpdated':
     121                    set_transient( $transient_id, json_encode( reset( $request_data->{"@graph"} ) ), 86400 );
     122                    return new WP_REST_Response( array( 'status' => 'ok', 'message' => 'Cache updated' ), 200 );
     123                    break;
     124                case 'EntityDeleted':
     125                    delete_transient( $transient_id );
     126                    return new WP_REST_Response( array( 'status' => 'ok', 'message' => 'Cache deleted' ), 200 );
     127                    break;
     128                default:
     129                    return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid @type property' ), 400 );
     130            }
    86131        }
    87132    }
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php

    r2097983 r2129926  
    128128         * @param type $params
    129129         */
    130         public function activateLicense($params) {
     130        public function activateLicense( $params ) {
     131            $response = wp_remote_post( 'https://app.schemaapp.com/schemaApi/license/addSite', array(
     132                'sslverify' => false,
     133                'headers' => array( 'Content-Type' => 'application/json' ),
     134                'body' => json_encode( $params ),
     135            ));
    131136
    132                 $api = self::API_SERVER . self::ACTIVATE;
     137            $response_code = wp_remote_retrieve_response_code( $response );
     138            $response_data = json_decode( wp_remote_retrieve_body( $response ) );
    133139
    134                 // Call the custom API.
    135                 $response = wp_remote_post($api, array(
    136                         'timeout' => 15,
    137                         'sslverify' => false,
    138                         'body' => $params
    139                 ));
    140                 $response_code = wp_remote_retrieve_response_code($response);
    141 
    142                 // decode the license data
    143                 $license_data = json_decode(wp_remote_retrieve_body($response));
    144 
    145                 if (in_array($response_code, array(200, 201))) {
    146                         return array(true, $license_data);
    147                 } else {
    148                         return array(false, $license_data);
    149                 }
     140            if ( in_array( $response_code, array( 200, 201 ) ) ) {
     141                return array( true, $response_data->status );
     142            } else {
     143                return array( false, $response_data->error );
     144            }
    150145        }
    151146
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaSettings.php

    r2097983 r2129926  
    546546            $SchemaServer = new SchemaServer();
    547547
    548             $Response = $SchemaServer->activateLicense( array( 'license' => $new_input['schema_license_wc'], 'item_name' => urlencode( SchemaSettings::SCHEMA_ITEM_NAME ), 'url' => home_url() ) );
     548            $Response = $SchemaServer->activateLicense( array( 'license' => $new_input['schema_license_wc'], 'siteToAdd' => site_url() ) );
    549549
    550550            if ( $Response[0] == true )
  • schema-app-structured-data-for-schemaorg/trunk/readme.txt

    r2097983 r2129926  
    99Requires PHP: 5.4
    1010Tested up to: 5.2
    11 Stable tag: 1.13.0
     11Stable tag: 1.14.0
    1212License: GPL2
    1313License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8787== Changelog ==
    8888
     89= 1.14.0 =
     90- Feature, Added webhook support for schema data events which will update markup cache in realtime
     91- Improve, WC migrate license web service
     92
    8993= 1.13.0 =
    9094- Feature, Added HunchSchema_Thing markup filters `hunch_schema_thing_markup_` permalink, excerpt, image, videos, tags, comments, author, publisher
     
    376380== Upgrade Notice ==
    377381
    378 = 1.13.0 =
    379 - Added HunchSchema_Thing markup filters, switched API calls to api.schemaapp.com
     382= 1.14.0 =
     383- Added webhook support for schema data events, WC migrate license web service
Note: See TracChangeset for help on using the changeset viewer.