Changeset 2366035
- Timestamp:
- 08/20/2020 07:10:25 PM (5 years ago)
- Location:
- schema-app-structured-data-for-schemaorg
- Files:
-
- 26 added
- 5 edited
-
tags/1.16.1 (added)
-
tags/1.16.1/css (added)
-
tags/1.16.1/css/schemaStyle.css (added)
-
tags/1.16.1/data (added)
-
tags/1.16.1/data/tree.jsonld (added)
-
tags/1.16.1/hunch-schema.php (added)
-
tags/1.16.1/js (added)
-
tags/1.16.1/js/schema.js (added)
-
tags/1.16.1/js/schemaAdmin.js (added)
-
tags/1.16.1/js/schemaEditor.js (added)
-
tags/1.16.1/lib (added)
-
tags/1.16.1/lib/HunchSchema (added)
-
tags/1.16.1/lib/HunchSchema/Author.php (added)
-
tags/1.16.1/lib/HunchSchema/Blog.php (added)
-
tags/1.16.1/lib/HunchSchema/Category.php (added)
-
tags/1.16.1/lib/HunchSchema/Page.php (added)
-
tags/1.16.1/lib/HunchSchema/Post.php (added)
-
tags/1.16.1/lib/HunchSchema/Search.php (added)
-
tags/1.16.1/lib/HunchSchema/Tag.php (added)
-
tags/1.16.1/lib/HunchSchema/Thing.php (added)
-
tags/1.16.1/lib/SchemaEditor.php (added)
-
tags/1.16.1/lib/SchemaFront.php (added)
-
tags/1.16.1/lib/SchemaServer.php (added)
-
tags/1.16.1/lib/SchemaSettings.php (added)
-
tags/1.16.1/lib/classmap.php (added)
-
tags/1.16.1/readme.txt (added)
-
trunk/hunch-schema.php (modified) (1 diff)
-
trunk/lib/SchemaEditor.php (modified) (1 diff)
-
trunk/lib/SchemaFront.php (modified) (3 diffs)
-
trunk/lib/SchemaServer.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
schema-app-structured-data-for-schemaorg/trunk/hunch-schema.php
r2344163 r2366035 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.16. 07 * Version: 1.16.1 8 8 * Author: Hunch Manifest 9 9 * Author URI: https://www.hunchmanifest.com -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaEditor.php
r2295483 r2366035 200 200 <tr> 201 201 <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> 206 210 </td> 207 211 </tr> -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaFront.php
r2344163 r2366035 55 55 56 56 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 ); 74 61 } 75 62 } … … 260 247 else 261 248 { 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 262 259 printf( '<script type="application/ld+json" data-schema="%s-%s-%s">%s</script>' . "\n", $post->ID, $PostType, $SchemaMarkupType, $SchemaMarkup ); 263 260 } … … 350 347 351 348 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;381 349 } 382 350 -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php
r2266757 r2366035 12 12 private $options; 13 13 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(); 18 18 19 const API_SERVER = "https://api.schemaapp.com/";20 const DATA_SERVER = "https://data.schemaapp.com/";21 19 const EDITOR = "https://app.schemaapp.com/editor"; 22 const ACTIVATE = "service/activate.json";23 20 24 21 public function __construct($uri = "") { … … 47 44 */ 48 45 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 } 53 49 54 50 55 $resource = '';51 $resource = ''; 56 52 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 } 64 60 65 // Decode accent characters66 $this->page_url = $resource = urldecode( $resource );67 61 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 ); 69 68 70 $this->transient_id = $transient_id = 'HunchSchema-Markup-' . md5($resource);71 $transient = get_transient($transient_id);72 69 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 ); 78 71 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 } 80 79 81 // Check for anything unexpected82 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);86 80 87 // First delete then set; set method only updates expiry time if transient already exists88 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; 90 84 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 } 95 87 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; 97 110 } 98 111 99 /**100 * Get the Link to Update a Resource that exists101 *102 * @param type $uri103 * @return string104 */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 }113 112 114 113 /** -
schema-app-structured-data-for-schemaorg/trunk/readme.txt
r2344163 r2366035 8 8 Requires at least: 3.7 9 9 Requires PHP: 5.4 10 Tested up to: 5. 410 Tested up to: 5.5 11 11 Stable tag: 1.16.0 12 12 License: GPL2 … … 87 87 == Changelog == 88 88 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 89 95 = 1.16.0 = 90 96 - Feature, Added global option to enable or disable video schema markup
Note: See TracChangeset
for help on using the changeset viewer.