Plugin Directory

Changeset 1812232


Ignore:
Timestamp:
01/30/2018 09:01:12 PM (8 years ago)
Author:
vberkel
Message:

Release v1.9.6 fix WooCommerce Activation, other improves

Location:
schema-app-structured-data-for-schemaorg/trunk
Files:
7 edited

Legend:

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

    r1806458 r1812232  
    55 * Plugin URI: http://www.schemaapp.com
    66 * Description: This plugin adds http://schema.org structured data to your website
    7  * Version: 1.9.5
     7 * Version: 1.9.6
    88 * Author: Hunch Manifest
    99 * Author URI: https://www.hunchmanifest.com
  • schema-app-structured-data-for-schemaorg/trunk/lib/HunchSchema/Category.php

    r1504799 r1812232  
    1919            $hasPart[] = array
    2020                (
    21                 '@type' => 'BlogPosting',
     21                '@type' => ! empty( $this->Settings['SchemaDefaultTypePost'] ) ? $this->Settings['SchemaDefaultTypePost'] : 'BlogPosting',
    2222                'headline' => get_the_title(),
    2323                'url' => get_the_permalink(),
  • schema-app-structured-data-for-schemaorg/trunk/lib/HunchSchema/Page.php

    r1776282 r1812232  
    9494                    'item' => array
    9595                    (
    96                         '@id' => get_permalink( $PostId ),
     96                        '@id' => get_permalink( $PostId ) . "#breadcrumbitem",
    9797                        'name' => get_the_title( $PostId ),
    9898                    ),
  • schema-app-structured-data-for-schemaorg/trunk/lib/HunchSchema/Tag.php

    r1623890 r1812232  
    2020            $hasPart[] = array
    2121            (
    22                 '@type' => 'BlogPosting',
     22                '@type' => ! empty( $this->Settings['SchemaDefaultTypePost'] ) ? $this->Settings['SchemaDefaultTypePost'] : 'BlogPosting',
    2323                'headline' => get_the_title(),
    2424                'url' => get_the_permalink(),
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaFront.php

    r1806006 r1812232  
    1818        add_action( 'init', array( $this, 'HandleCache' ) );
    1919        add_action( 'wp', array( $this, 'LinkedOpenData' ), 10, 1 );
    20         add_action( 'wp_footer', array( $this, 'hunch_schema_add' ) );
     20        add_action( 'wp_footer', array( $this, 'hunch_schema_add' ), 50 );
    2121
    2222        if ( ! empty( $this->Settings['SchemaRemoveMicrodata'] ) )
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php

    r1806458 r1812232  
    1 <?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
     1<?php
     2
     3defined('ABSPATH') OR die('This script cannot be accessed directly.');
     4
    25/**
    36 * Handle interactions with the http://app.schemaapp,com server
     
    69 */
    710class SchemaServer {
    8      
    9     private $options;
    10     private $resource;
    11     private $server;
    1211
    13     const EDITOR = "https://app.schemaapp.com/editor";
    14     const ACTIVATE = "/service/activate.json";
     12        private $options;
     13        private $resource;
    1514
    16     public function __construct($uri = "") {
    17         $this->options = get_option('schema_option_name');   
     15        const API_SERVER = "https://api.hunchmanifest.com/";
     16        const DATA_SERVER = "https://data.schemaapp.com/";
     17        const EDITOR = "https://app.schemaapp.com/editor";
     18        const ACTIVATE = "service/activate.json";
    1819
    19         if ( !empty($uri ) ) {
    20             $this->resource = $uri;           
    21         } elseif (is_front_page() && is_home() || is_front_page()) {
    22             $this->resource = get_site_url() . '/';
    23         } elseif (is_tax() || is_post_type_archive()) {
    24             $this->resource = 'http' .
    25                 (null !== filter_input(INPUT_SERVER, 'HTTPS') ? 's' : '') .
    26                 '://' .
    27                 filter_input(INPUT_SERVER, 'HTTP_HOST') .
    28                 filter_input(INPUT_SERVER, 'REQUEST_URI');
    29         } else {
    30             $this->resource = get_permalink();           
     20        public function __construct($uri = "") {
     21                $this->options = get_option('schema_option_name');
     22
     23                if (!empty($uri)) {
     24                        $this->resource = $uri;
     25                } elseif (is_front_page() && is_home() || is_front_page()) {
     26                        $this->resource = get_site_url() . '/';
     27                } elseif (is_tax() || is_post_type_archive()) {
     28                        $this->resource = 'http' .
     29                                (null !== filter_input(INPUT_SERVER, 'HTTPS') ? 's' : '') .
     30                                '://' .
     31                                filter_input(INPUT_SERVER, 'HTTP_HOST') .
     32                                filter_input(INPUT_SERVER, 'REQUEST_URI');
     33                } else {
     34                        $this->resource = get_permalink();
     35                }
    3136        }
    3237
    33         $this->server = 'https://data.schemaapp.com/';
     38        /**
     39         * Get Resource JSON_LD content
     40         *
     41         * @param type $uri
     42         * @return string
     43         */
     44        public function getResource($uri = '', $pretty = false) {
    3445
    35     }
    36    
    37     /**
    38     * Get Resource JSON_LD content
    39     *
    40     * @param type $uri
    41     * @return string
    42     */
    43     public function getResource( $uri = '', $pretty = false ) {
    44 
    45         if ( empty( $this->options['graph_uri'] ) ) {
    46             return '';
    47         }
     46                if (empty($this->options['graph_uri'])) {
     47                        return '';
     48                }
    4849
    4950
    50         $resource = '';
     51                $resource = '';
    5152
    52         if ( ! empty( $uri ) ) {
    53             $resource = $uri;
    54         } elseif ( ! empty( $this->resource ) ) {
    55             $resource = $this->resource;
    56         } else {
    57             return '';
    58         }
     53                if (!empty($uri)) {
     54                        $resource = $uri;
     55                } elseif (!empty($this->resource)) {
     56                        $resource = $this->resource;
     57                } else {
     58                        return '';
     59                }
    5960
    6061
    61         $transient_id = 'HunchSchema-Markup-' . md5( $resource );
    62         $transient = get_transient( $transient_id );
     62                $transient_id = 'HunchSchema-Markup-' . md5($resource);
     63                $transient = get_transient($transient_id);
    6364
    64         if ( $transient !== false ) {
    65             return $transient;
    66         }
     65                if ($transient !== false) {
     66                        return $transient;
     67                }
    6768
    6869
    69         $remote_response = wp_remote_get( $this->readLink( $resource ) );
     70                $remote_response = wp_remote_get($this->readLink($resource));
    7071
    71         if ( is_wp_error( $remote_response )
    72                         || wp_remote_retrieve_body( $remote_response ) === "" 
    73                         || wp_remote_retrieve_body( $remote_response ) === 'null'
    74                         || wp_remote_retrieve_response_code( $remote_response ) != 200 ) {
    75             $schemadata = '';
    76         } else {
    77             $schemadata = wp_remote_retrieve_body( $remote_response );
     72                if (is_wp_error($remote_response) || wp_remote_retrieve_body($remote_response) === "" || wp_remote_retrieve_body($remote_response) === 'null' || wp_remote_retrieve_response_code($remote_response) != 200) {
     73                        $schemadata = '';
     74                } else {
     75                        $schemadata = wp_remote_retrieve_body($remote_response);
    7876
    79             if ( $pretty && version_compare( phpversion(), '5.4.0', '>=' ) ) {
    80                 $schemadata = json_encode( json_decode( $schemadata ), JSON_PRETTY_PRINT );
    81             }
     77                        if ($pretty && version_compare(phpversion(), '5.4.0', '>=')) {
     78                                $schemadata = json_encode(json_decode($schemadata), JSON_PRETTY_PRINT);
     79                        }
     80                }
    8281
    83         }
    84                
    85                 set_transient( $transient_id, $schemadata, 86400 );
     82                set_transient($transient_id, $schemadata, 86400);
    8683
    87         return $schemadata;
    88     }
    89 
    90 
    91     /**
    92     * Get the Link to Update a Resource that exists
    93     *
    94     * @param type $uri
    95     * @return string
    96     */
    97     protected function readLink( $uri = '' ) {
    98         $uri = ! empty( $uri ) ? $uri : $this->resource;
    99         $graph = str_replace("http://schemaapp.com/db/", "", $this->options['graph_uri']); 
    100         return $this->server . $graph . '/' . trim( base64_encode( $uri ), '=' );
    101     }
    102 
    103 
    104     /**
    105      * Get the Link to Update a Resource that exists
    106      *
    107      * @param type $uri
    108      * @return string
    109      */
    110     public function updateLink() {               
    111         $link = self::EDITOR . "?resource=" . $this->resource;
    112         return $link;
    113     }
    114    
    115     /**
    116      * Get the link to create a new resource
    117      *
    118      * @param type $uri
    119      * @return string
    120      */
    121     public function createLink() {
    122         $link = self::EDITOR . "?create=" . $this->resource;       
    123         return $link;
    124     }
    125        
    126     /**
    127      * Activate Licenses, sends license key to Hunch Servers to confirm purchase
    128      *
    129      * @param type $params
    130      */
    131     public function activateLicense($params) {
    132 
    133         $api = $this->server . self::ACTIVATE;
    134        
    135         // Call the custom API.
    136         $response = wp_remote_post( $api, array(
    137             'timeout'   => 15,
    138             'sslverify' => false,
    139             'body'      => $params
    140         ));
    141         $response_code =  wp_remote_retrieve_response_code( $response );
    142 
    143         // decode the license data
    144         $license_data = json_decode( wp_remote_retrieve_body( $response ) );
    145        
    146         if ( in_array($response_code, array(200, 201) ) ) {
    147             return array(true, $license_data);
    148         } else {
    149             return array(false, $license_data);
     84                return $schemadata;
    15085        }
    15186
    152     }
     87        /**
     88         * Get the Link to Update a Resource that exists
     89         *
     90         * @param type $uri
     91         * @return string
     92         */
     93        protected function readLink($uri = '') {
     94                $uri = !empty($uri) ? $uri : $this->resource;
     95                $graph = str_replace("http://schemaapp.com/db/", "", $this->options['graph_uri']);
     96                return $this::DATA_SERVER . $graph . '/' . trim(base64_encode($uri), '=');
     97        }
     98
     99        /**
     100         * Get the Link to Update a Resource that exists
     101         *
     102         * @param type $uri
     103         * @return string
     104         */
     105        public function updateLink() {
     106                $link = self::EDITOR . "?resource=" . $this->resource;
     107                return $link;
     108        }
     109
     110        /**
     111         * Get the link to create a new resource
     112         *
     113         * @param type $uri
     114         * @return string
     115         */
     116        public function createLink() {
     117                $link = self::EDITOR . "?create=" . $this->resource;
     118                return $link;
     119        }
     120
     121        /**
     122         * Activate Licenses, sends license key to Hunch Servers to confirm purchase
     123         *
     124         * @param type $params
     125         */
     126        public function activateLicense($params) {
     127
     128                $api = self::API_SERVER . self::ACTIVATE;
     129
     130                // Call the custom API.
     131                $response = wp_remote_post($api, array(
     132                        'timeout' => 15,
     133                        'sslverify' => false,
     134                        'body' => $params
     135                ));
     136                $response_code = wp_remote_retrieve_response_code($response);
     137
     138                // decode the license data
     139                $license_data = json_decode(wp_remote_retrieve_body($response));
     140
     141                if (in_array($response_code, array(200, 201))) {
     142                        return array(true, $license_data);
     143                } else {
     144                        return array(false, $license_data);
     145                }
     146        }
    153147
    154148}
  • schema-app-structured-data-for-schemaorg/trunk/readme.txt

    r1806458 r1812232  
    77Requires at least: 3.5
    88Tested up to: 4.8
    9 Stable tag: 1.9.5
     9Stable tag: 1.9.6
    1010License: GPL2
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8484
    8585== Changelog ==
     86= 1.9.6 =
     87- Fix, WooCommerce Activation error
     88- Fix, Breadcrumb List Item, unique @id
     89- Fix, CollectionPage items check for and use configured default
     90- Improve, add low priority to hunch_schema_add function, behind other JS
     91
    8692= 1.9.5 =
    8793- Fix, API error in PHP versions < 5.4
Note: See TracChangeset for help on using the changeset viewer.