Plugin Directory

Changeset 2366035


Ignore:
Timestamp:
08/20/2020 07:10:25 PM (5 years ago)
Author:
milanmk
Message:

Release 1.16.1

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

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

    r2295483 r2366035  
    200200                    <tr>
    201201                        <td style="width: 30%;">
    202                             API URL
    203                         </td>
    204                         <td>
    205                             <a href="<?php print $schema_server->api_url; ?>" target="_blank"><?php print $schema_server->api_url; ?></a>
     202                            Data Sources
     203                        </td>
     204                        <td>
     205                            <ul>
     206                            <?php foreach ( $schema_server->data_sources as $data_source ) : ?>
     207                                <li><a href="<?php print $data_source; ?>" target="_blank"><?php print $data_source; ?></a></li>
     208                            <?php endforeach; ?>
     209                            </ul>
    206210                        </td>
    207211                    </tr>
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaFront.php

    r2344163 r2366035  
    5555
    5656    public function hook_plugins_loaded() {
    57         if ( defined( 'WPSEO_VERSION' ) ) {
    58             if ( version_compare( WPSEO_VERSION, '11.0', '<' ) ) {
    59                 // Default enabled
    60                 if ( ! isset( $this->Settings['SchemaRemoveWPSEOMarkup'] ) || $this->Settings['SchemaRemoveWPSEOMarkup'] == 1 ) {
    61                     add_filter( 'wpseo_json_ld_output', array( $this, 'RemoveWPSEOJsonLD' ), 10, 2 );
    62                 }
    63 
    64                 // Disable WPSEO Breadcrumb markup if ours is enabled
    65                 if ( ! empty( $this->Settings['SchemaBreadcrumb'] ) ) {
    66                     add_filter( 'wpseo_json_ld_output', array( $this, 'RemoveWPSEOJsonLDBreadcrumb' ), 10, 2 );
    67                 }
    68             } else {
    69                 // Default enabled
    70                 if ( ! isset( $this->Settings['SchemaRemoveWPSEOMarkup'] ) || $this->Settings['SchemaRemoveWPSEOMarkup'] == 1 ) {
    71                     add_filter( 'wpseo_schema_graph_pieces', array( $this, 'wpseo_remove_schema' ), 10, 2 );
    72                 }
    73             }
     57        // Default enabled
     58        if ( defined( 'WPSEO_VERSION' ) && ( ! isset( $this->Settings['SchemaRemoveWPSEOMarkup'] ) || $this->Settings['SchemaRemoveWPSEOMarkup'] == 1 ) ) {
     59            //https://developer.yoast.com/features/schema/api/
     60            add_filter( 'wpseo_json_ld_output', '__return_false', 100 );
    7461        }
    7562    }
     
    260247            else
    261248            {
     249                if ( ! empty( $this->Settings['Debug'] ) && is_user_logged_in() ) {
     250                    printf( "\n<!--\nURL: %s\nTransient: %s\nTransient Id: %s\nData Sources:\n", $SchemaServer->page_url, ( $SchemaServer->transient ? 'Yes' : 'No' ), $SchemaServer->transient_id );
     251
     252                    foreach ( $SchemaServer->data_sources as $data_source ) {
     253                        printf( "%s\n", $data_source );
     254                    }
     255
     256                    print "-->\n";
     257                }
     258
    262259                printf( '<script type="application/ld+json" data-schema="%s-%s-%s">%s</script>' . "\n", $post->ID, $PostType, $SchemaMarkupType, $SchemaMarkup );
    263260            }
     
    350347
    351348        return $Buffer;
    352     }
    353 
    354 
    355     public function RemoveWPSEOJsonLD( $data, $context )
    356     {
    357         if ( in_array( $context, array( 'website', 'company', 'person', 'breadcrumb' ) ) )
    358         {
    359             return array();
    360         }
    361 
    362         return $data;
    363     }
    364 
    365 
    366     public function RemoveWPSEOJsonLDBreadcrumb( $data, $context )
    367     {
    368         if ( $context == 'breadcrumb' )
    369         {
    370             return array();
    371         }
    372 
    373         return $data;
    374     }
    375 
    376 
    377     public function wpseo_remove_schema( $pieces, $context ) {
    378         $pieces = array();
    379 
    380         return $pieces;
    381349    }
    382350
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php

    r2266757 r2366035  
    1212        private $options;
    1313        private $resource;
    14         public $transient_id;
    15         public $transient = false;
    16         public $page_url;
    17         public $api_url;
     14        public $transient_id    = '';
     15        public $transient       = false;
     16        public $page_url        = '';
     17        public $data_sources    = array();
    1818
    19         const API_SERVER = "https://api.schemaapp.com/";
    20         const DATA_SERVER = "https://data.schemaapp.com/";
    2119        const EDITOR = "https://app.schemaapp.com/editor";
    22         const ACTIVATE = "service/activate.json";
    2320
    2421        public function __construct($uri = "") {
     
    4744         */
    4845        public function getResource($uri = '', $pretty = false) {
    49 
    50                 if (empty($this->options['graph_uri'])) {
    51                         return '';
    52                 }
     46            if ( empty( $this->options['graph_uri'] ) ) {
     47                return '';
     48            }
    5349
    5450
    55                 $resource = '';
     51            $resource = '';
    5652
    57                 if (!empty($uri)) {
    58                         $resource = $uri;
    59                 } elseif (!empty($this->resource)) {
    60                         $resource = $this->resource;
    61                 } else {
    62                         return '';
    63                 }
     53            if ( ! empty( $uri ) ) {
     54                $resource = $uri;
     55            } elseif ( ! empty( $this->resource ) ) {
     56                $resource = $this->resource;
     57            } else {
     58                return '';
     59            }
    6460
    65                 // Decode accent characters
    66                 $this->page_url = $resource = urldecode( $resource );
    6761
    68                 $this->readLink($resource);
     62            $account_id         = str_replace( array( 'http://schemaapp.com/db/', 'https://schemaapp.com/db/' ), '', $this->options['graph_uri'] );
     63            $resource           = $this->page_url = urldecode( $resource ); // Decode accent characters
     64            $resource_hash      = trim( base64_encode( $resource ), '=' );
     65            $this->data_sources = array( "https://data.schemaapp.com/{$account_id}/{$resource_hash}" );
     66            $this->transient_id = 'HunchSchema-Markup-' . md5( $resource );
     67            $transient          = get_transient( $this->transient_id );
    6968
    70                 $this->transient_id = $transient_id = 'HunchSchema-Markup-' . md5($resource);
    71                 $transient = get_transient($transient_id);
    7269
    73                 // Check for missing, empty or 'null' transient
    74                 if ($transient !== false && $transient !== 'null') {
    75                     $this->transient = true;
    76                     return $transient;
    77                 }
     70            $data_sources_additional = ( array ) apply_filters( 'hunch_schema_markup_api_data_source', $account_id, $resource );
    7871
    79                 $remote_response = wp_remote_get($this->readLink($resource));
     72            if ( ! empty( $data_sources_additional ) ) {
     73                foreach ( $data_sources_additional as $data_source ) {
     74                    if ( filter_var( $data_source, FILTER_VALIDATE_URL ) ) {
     75                        $this->data_sources[] = $data_source;
     76                    }
     77                }
     78            }
    8079
    81                 // Check for anything unexpected
    82                 if (is_wp_error($remote_response) || wp_remote_retrieve_body($remote_response) === "" || wp_remote_retrieve_body($remote_response) === false || wp_remote_retrieve_body($remote_response) === 'null' || wp_remote_retrieve_response_code($remote_response) != 200) {
    83                         $schemadata = '';
    84                 } else {
    85                         $schemadata = wp_remote_retrieve_body($remote_response);
    8680
    87                         // First delete then set; set method only updates expiry time if transient already exists
    88                         delete_transient( $transient_id );
    89                         set_transient($transient_id, $schemadata, 86400);
     81            // Check for missing, empty or 'null' transient
     82            if ( ! empty( $transient ) && $transient !== 'null' ) {
     83                $this->transient = true;
    9084
    91                         if ($pretty && version_compare(phpversion(), '5.4.0', '>=')) {
    92                                 $schemadata = json_encode(json_decode($schemadata), JSON_PRETTY_PRINT);
    93                         }
    94                 }
     85                return $transient;
     86            }
    9587
    96                 return $schemadata;
     88
     89            $schemadata = '';
     90
     91            foreach ( $this->data_sources as $data_source ) {
     92                $remote_response = wp_remote_get( $data_source );
     93
     94                if ( ! is_wp_error( $remote_response ) && wp_remote_retrieve_response_code( $remote_response ) == 200 && ! empty( wp_remote_retrieve_body( $remote_response ) ) && wp_remote_retrieve_body( $remote_response ) !== 'null' ) {
     95                    $schemadata = wp_remote_retrieve_body( $remote_response );
     96
     97                    // First delete then set; set method only updates expiry time if transient already exists
     98                    delete_transient( $this->transient_id );
     99                    set_transient( $this->transient_id, $schemadata, 86400 );
     100
     101                    if ( $pretty && version_compare( phpversion(), '5.4.0', '>=' ) ) {
     102                        $schemadata = json_encode( json_decode( $schemadata ), JSON_PRETTY_PRINT );
     103                    }
     104
     105                    break;
     106                }
     107            }
     108
     109            return $schemadata;
    97110        }
    98111
    99         /**
    100          * Get the Link to Update a Resource that exists
    101          *
    102          * @param type $uri
    103          * @return string
    104          */
    105         protected function readLink($uri = '') {
    106                 $uri = !empty($uri) ? $uri : $this->resource;
    107                 $graph = str_replace( array( 'http://schemaapp.com/db/', 'https://schemaapp.com/db/' ), '', $this->options['graph_uri'] );
    108 
    109                 $this->api_url = $this::DATA_SERVER . $graph . '/' . trim(base64_encode($uri), '=');
    110 
    111                 return $this->api_url;
    112         }
    113112
    114113        /**
  • schema-app-structured-data-for-schemaorg/trunk/readme.txt

    r2344163 r2366035  
    88Requires at least: 3.7
    99Requires PHP: 5.4
    10 Tested up to: 5.4
     10Tested up to: 5.5
    1111Stable tag: 1.16.0
    1212License: GPL2
     
    8787== Changelog ==
    8888
     89= 1.16.1 =
     90- Improve, updated Yoast SEO filter to remove schema markup
     91- Improve, added filter for adding data sources to API
     92- Improve, debug info for logged in users
     93
     94
    8995= 1.16.0 =
    9096- Feature, Added global option to enable or disable video schema markup
Note: See TracChangeset for help on using the changeset viewer.