Changeset 1812232
- Timestamp:
- 01/30/2018 09:01:12 PM (8 years ago)
- Location:
- schema-app-structured-data-for-schemaorg/trunk
- Files:
-
- 7 edited
-
hunch-schema.php (modified) (1 diff)
-
lib/HunchSchema/Category.php (modified) (1 diff)
-
lib/HunchSchema/Page.php (modified) (1 diff)
-
lib/HunchSchema/Tag.php (modified) (1 diff)
-
lib/SchemaFront.php (modified) (1 diff)
-
lib/SchemaServer.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
schema-app-structured-data-for-schemaorg/trunk/hunch-schema.php
r1806458 r1812232 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.9. 57 * Version: 1.9.6 8 8 * Author: Hunch Manifest 9 9 * Author URI: https://www.hunchmanifest.com -
schema-app-structured-data-for-schemaorg/trunk/lib/HunchSchema/Category.php
r1504799 r1812232 19 19 $hasPart[] = array 20 20 ( 21 '@type' => 'BlogPosting',21 '@type' => ! empty( $this->Settings['SchemaDefaultTypePost'] ) ? $this->Settings['SchemaDefaultTypePost'] : 'BlogPosting', 22 22 'headline' => get_the_title(), 23 23 'url' => get_the_permalink(), -
schema-app-structured-data-for-schemaorg/trunk/lib/HunchSchema/Page.php
r1776282 r1812232 94 94 'item' => array 95 95 ( 96 '@id' => get_permalink( $PostId ) ,96 '@id' => get_permalink( $PostId ) . "#breadcrumbitem", 97 97 'name' => get_the_title( $PostId ), 98 98 ), -
schema-app-structured-data-for-schemaorg/trunk/lib/HunchSchema/Tag.php
r1623890 r1812232 20 20 $hasPart[] = array 21 21 ( 22 '@type' => 'BlogPosting',22 '@type' => ! empty( $this->Settings['SchemaDefaultTypePost'] ) ? $this->Settings['SchemaDefaultTypePost'] : 'BlogPosting', 23 23 'headline' => get_the_title(), 24 24 'url' => get_the_permalink(), -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaFront.php
r1806006 r1812232 18 18 add_action( 'init', array( $this, 'HandleCache' ) ); 19 19 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 ); 21 21 22 22 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 3 defined('ABSPATH') OR die('This script cannot be accessed directly.'); 4 2 5 /** 3 6 * Handle interactions with the http://app.schemaapp,com server … … 6 9 */ 7 10 class SchemaServer { 8 9 private $options;10 private $resource;11 private $server;12 11 13 const EDITOR = "https://app.schemaapp.com/editor";14 const ACTIVATE = "/service/activate.json";12 private $options; 13 private $resource; 15 14 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"; 18 19 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 } 31 36 } 32 37 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) { 34 45 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 } 48 49 49 50 50 $resource = '';51 $resource = ''; 51 52 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 } 59 60 60 61 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); 63 64 64 if ( $transient !== false) {65 return $transient;66 }65 if ($transient !== false) { 66 return $transient; 67 } 67 68 68 69 69 $remote_response = wp_remote_get( $this->readLink( $resource ));70 $remote_response = wp_remote_get($this->readLink($resource)); 70 71 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); 78 76 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 } 82 81 83 } 84 85 set_transient( $transient_id, $schemadata, 86400 ); 82 set_transient($transient_id, $schemadata, 86400); 86 83 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; 150 85 } 151 86 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 } 153 147 154 148 } -
schema-app-structured-data-for-schemaorg/trunk/readme.txt
r1806458 r1812232 7 7 Requires at least: 3.5 8 8 Tested up to: 4.8 9 Stable tag: 1.9. 59 Stable tag: 1.9.6 10 10 License: GPL2 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 84 84 85 85 == 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 86 92 = 1.9.5 = 87 93 - Fix, API error in PHP versions < 5.4
Note: See TracChangeset
for help on using the changeset viewer.