Changeset 2631473
- Timestamp:
- 11/17/2021 02:34:16 PM (4 years ago)
- Location:
- schema-app-structured-data-for-schemaorg
- Files:
-
- 27 added
- 4 edited
-
tags/1.17.10 (added)
-
tags/1.17.10/css (added)
-
tags/1.17.10/css/schemaStyle.css (added)
-
tags/1.17.10/data (added)
-
tags/1.17.10/data/tree.jsonld (added)
-
tags/1.17.10/hunch-schema.php (added)
-
tags/1.17.10/js (added)
-
tags/1.17.10/js/schema.js (added)
-
tags/1.17.10/js/schemaAdmin.js (added)
-
tags/1.17.10/js/schemaEditor.js (added)
-
tags/1.17.10/lib (added)
-
tags/1.17.10/lib/HunchSchema (added)
-
tags/1.17.10/lib/HunchSchema/Author.php (added)
-
tags/1.17.10/lib/HunchSchema/Blog.php (added)
-
tags/1.17.10/lib/HunchSchema/Category.php (added)
-
tags/1.17.10/lib/HunchSchema/Page.php (added)
-
tags/1.17.10/lib/HunchSchema/Post.php (added)
-
tags/1.17.10/lib/HunchSchema/Search.php (added)
-
tags/1.17.10/lib/HunchSchema/Tag.php (added)
-
tags/1.17.10/lib/HunchSchema/Thing.php (added)
-
tags/1.17.10/lib/SchemaCron.php (added)
-
tags/1.17.10/lib/SchemaEditor.php (added)
-
tags/1.17.10/lib/SchemaFront.php (added)
-
tags/1.17.10/lib/SchemaServer.php (added)
-
tags/1.17.10/lib/SchemaSettings.php (added)
-
tags/1.17.10/lib/classmap.php (added)
-
tags/1.17.10/readme.txt (added)
-
trunk/hunch-schema.php (modified) (1 diff)
-
trunk/lib/HunchSchema/Thing.php (modified) (3 diffs)
-
trunk/lib/SchemaServer.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
schema-app-structured-data-for-schemaorg/trunk/hunch-schema.php
r2611646 r2631473 5 5 * Plugin URI: http://www.schemaapp.com 6 6 * Description: This plugin adds http://schema.org structured data to your website 7 * Version: 1.17. 97 * Version: 1.17.10 8 8 * Author: Hunch Manifest 9 9 * Author URI: https://www.hunchmanifest.com -
schema-app-structured-data-for-schemaorg/trunk/lib/HunchSchema/Thing.php
r2618480 r2631473 382 382 383 383 384 protected function get_youtube_video( $id ) {384 protected function get_youtube_video( $id = '' ) { 385 385 if ( ! empty( $id ) ) { 386 386 $transient_id = sprintf( 'HunchSchema-Markup-YouTube-%s', $id ); … … 392 392 393 393 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 ) ) ); 395 395 396 396 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 } 402 407 } 403 408 } … … 411 416 // https?://(?:[0-9A-Z-]+\.)?(?:youtu\.be/|youtube(?:-nocookie)?\.com\S*?[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:[\'"][^<>]*>|</a>))[?=&+%\w.-]* 412 417 // 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 ); 414 419 415 420 if ( isset( $matches[1] ) && count( $matches[1] ) ) { -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php
r2618480 r2631473 102 102 103 103 /** 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. 105 105 * 106 106 * @uses SchemaServer->getResource() … … 116 116 } 117 117 118 $schema_data = ''; 119 $remote_error = false; 118 $schema_data = array(); 120 119 121 120 foreach ( $this->data_sources as $data_source ) { 122 $re mote_response= wp_remote_get( $data_source );121 $request = wp_remote_get( $data_source ); 123 122 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 } 126 126 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 ); 132 128 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; 134 137 } 135 } else {136 $remote_error = true;137 138 } 138 139 } 139 140 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; 145 144 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 ); 147 150 } 148 151 -
schema-app-structured-data-for-schemaorg/trunk/readme.txt
r2618480 r2631473 9 9 Requires PHP: 5.4 10 10 Tested up to: 5.8 11 Stable tag: 1.17. 911 Stable tag: 1.17.10 12 12 License: GPL2 13 13 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 80 80 == Changelog == 81 81 82 = 1.17.10 = 83 Release 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 82 89 = 1.17.9 = 83 90 Release Date - 8 October 2021 … … 527 534 == Upgrade Notice == 528 535 529 = 1.17. 9=530 - Updated sanitization when saving data and escaping of HTML data for displaying536 = 1.17.10 = 537 - Updated YouTube URL matching, Merging of Editor and Highlighter markup
Note: See TracChangeset
for help on using the changeset viewer.