Plugin Directory

Changeset 2631473


Ignore:
Timestamp:
11/17/2021 02:34:16 PM (4 years ago)
Author:
milanmk
Message:

Release 1.17.10

Location:
schema-app-structured-data-for-schemaorg
Files:
27 added
4 edited

Legend:

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

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

    r2618480 r2631473  
    382382
    383383
    384     protected function get_youtube_video( $id ) {
     384    protected function get_youtube_video( $id = '' ) {
    385385        if ( ! empty( $id ) ) {
    386386            $transient_id = sprintf( 'HunchSchema-Markup-YouTube-%s', $id );
     
    392392
    393393
    394             $response = wp_remote_retrieve_body( wp_remote_get( sprintf( 'https://api.schemaapp.com/schemaorg/video.json?ids=%s', $id ) ) );
     394            $response = wp_remote_retrieve_body( wp_remote_get( sprintf( 'https://api.schemaapp.com/markup/markup?url=https://www.youtube.com/watch?v=%s', $id ) ) );
    395395
    396396            if ( ! empty( $response ) ) {
    397                 // First delete then set; set method only updates expiry time if transient already exists
    398                 delete_transient( $transient_id );
    399                 set_transient( $transient_id, json_decode( $response ), ( 14 * DAY_IN_SECONDS ) );
    400 
    401                 return json_decode( $response );
     397                $response_json = json_decode( $response );
     398                $markup = $response_json->items->{"https://www.youtube.com/watch?v={$id}"} ?? false;
     399
     400                if ( $markup ) {
     401                    // First delete then set; set method only updates expiry time if transient already exists
     402                    delete_transient( $transient_id );
     403                    set_transient( $transient_id, $markup, ( 14 * DAY_IN_SECONDS ) );
     404
     405                    return $markup;
     406                }
    402407            }
    403408        }
     
    411416            // https?://(?:[0-9A-Z-]+\.)?(?:youtu\.be/|youtube(?:-nocookie)?\.com\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:[\'"][^<>]*>|</a>))[?=&+%\w.-]*
    412417            // https?://(?:[0-9A-Z-]+\.)?(?:youtu\.be/|youtube(?:-nocookie)?\.com\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)[?=&+%\w.-]*
    413             preg_match_all( '~https?://(?:www\.)?(?:youtu\.be/|youtube(?:-nocookie)?\.com\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)[?=&+%\w.-]*~im', $string, $matches );
     418            preg_match_all( '~(?:https?:)?//(?:www\.)?(?:youtu\.be/|youtube(?:-nocookie)?\.com\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)[?=&+%\w.-]*~im', $string, $matches );
    414419
    415420            if ( isset( $matches[1] ) && count( $matches[1] ) ) {
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php

    r2618480 r2631473  
    102102
    103103        /**
    104          * Get a resource's schema data through API.
     104         * Get a resource's schema data through API. Markup returned by all data sources are merged together.
    105105         *
    106106         * @uses SchemaServer->getResource()
     
    116116            }
    117117
    118             $schema_data = '';
    119             $remote_error = false;
     118            $schema_data = array();
    120119
    121120            foreach ( $this->data_sources as $data_source ) {
    122                 $remote_response = wp_remote_get( $data_source );
     121                $request = wp_remote_get( $data_source );
    123122
    124                 if ( ! is_wp_error( $remote_response ) && wp_remote_retrieve_response_code( $remote_response ) == 200 ) {
    125                     $schema_data = wp_remote_retrieve_body( $remote_response );
     123                if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) != 200 ) {
     124                    return '';
     125                }
    126126
    127                     // Check if editor schema data is not empty or literal 'null' or empty json array
    128                     if ( ! empty( $schema_data ) && $schema_data !== 'null' && $schema_data !== '[]' ) {
    129                         // First delete then set; set method only updates expiry time if transient already exists
    130                         delete_transient( $this->transient_id );
    131                         set_transient( $this->transient_id, $schema_data, 86400 ); // Expiry 1 day
     127                $response = wp_remote_retrieve_body( $request );
    132128
    133                         break;
     129                // Check if editor schema data is not empty or literal 'null' or empty json array
     130                if ( ! empty( $response ) && $response !== 'null' && $response !== '[]' ) {
     131                    $response_json = json_decode( $response );
     132
     133                    if ( is_array( $response_json ) ) {
     134                        $schema_data = array_merge( $schema_data, $response_json );
     135                    } else {
     136                        $schema_data[] = $response_json;
    134137                    }
    135                 } else {
    136                     $remote_error = true;
    137138                }
    138139            }
    139140
    140             // Store empty schema data from API
    141             if ( empty( $schema_data ) && ! $remote_error ) {
    142                 delete_transient( $this->transient_id );
    143                 set_transient( $this->transient_id, $schema_data, 604800 ); // Expiry 7 days
    144             }
     141            // Expiry is 7 days for empty schema data or else 1 day
     142            $transient_expiry = empty( $schema_data ) ? 604800 : 86400;
     143            $schema_data = ( count( $schema_data ) == 1 ) ? reset( $schema_data ) : $schema_data;
    145144
    146             return $schema_data;
     145            // First delete then set; set method only updates expiry time if transient already exists
     146            delete_transient( $this->transient_id );
     147            set_transient( $this->transient_id, wp_json_encode( $schema_data ), $transient_expiry );
     148
     149            return empty( $schema_data ) ? '' : wp_json_encode( $schema_data );
    147150        }
    148151
  • schema-app-structured-data-for-schemaorg/trunk/readme.txt

    r2618480 r2631473  
    99Requires PHP: 5.4
    1010Tested up to: 5.8
    11 Stable tag: 1.17.9
     11Stable tag: 1.17.10
    1212License: GPL2
    1313License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8080== Changelog ==
    8181
     82= 1.17.10 =
     83Release Date - 16 November 2021
     84
     85- Improve, Updated YouTube URL matching for URLs without protocol
     86- Improve, Merging of Editor and Highlighter markup
     87- Fix, Late escaping of data for display
     88
    8289= 1.17.9 =
    8390Release Date - 8 October 2021
     
    527534== Upgrade Notice ==
    528535
    529 = 1.17.9 =
    530 - Updated sanitization when saving data and escaping of HTML data for displaying
     536= 1.17.10 =
     537- Updated YouTube URL matching, Merging of Editor and Highlighter markup
Note: See TracChangeset for help on using the changeset viewer.