Changeset 2263337
- Timestamp:
- 03/18/2020 05:50:44 PM (6 years ago)
- Location:
- schema-app-structured-data-for-schemaorg
- Files:
-
- 26 added
- 6 edited
-
tags/1.15.0 (added)
-
tags/1.15.0/css (added)
-
tags/1.15.0/css/schemaStyle.css (added)
-
tags/1.15.0/data (added)
-
tags/1.15.0/data/tree.jsonld (added)
-
tags/1.15.0/hunch-schema.php (added)
-
tags/1.15.0/js (added)
-
tags/1.15.0/js/schema.js (added)
-
tags/1.15.0/js/schemaAdmin.js (added)
-
tags/1.15.0/js/schemaEditor.js (added)
-
tags/1.15.0/lib (added)
-
tags/1.15.0/lib/HunchSchema (added)
-
tags/1.15.0/lib/HunchSchema/Author.php (added)
-
tags/1.15.0/lib/HunchSchema/Blog.php (added)
-
tags/1.15.0/lib/HunchSchema/Category.php (added)
-
tags/1.15.0/lib/HunchSchema/Page.php (added)
-
tags/1.15.0/lib/HunchSchema/Post.php (added)
-
tags/1.15.0/lib/HunchSchema/Search.php (added)
-
tags/1.15.0/lib/HunchSchema/Tag.php (added)
-
tags/1.15.0/lib/HunchSchema/Thing.php (added)
-
tags/1.15.0/lib/SchemaEditor.php (added)
-
tags/1.15.0/lib/SchemaFront.php (added)
-
tags/1.15.0/lib/SchemaServer.php (added)
-
tags/1.15.0/lib/SchemaSettings.php (added)
-
tags/1.15.0/lib/classmap.php (added)
-
tags/1.15.0/readme.txt (added)
-
trunk/hunch-schema.php (modified) (1 diff)
-
trunk/lib/SchemaEditor.php (modified) (10 diffs)
-
trunk/lib/SchemaFront.php (modified) (1 diff)
-
trunk/lib/SchemaServer.php (modified) (3 diffs)
-
trunk/lib/SchemaSettings.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
schema-app-structured-data-for-schemaorg/trunk/hunch-schema.php
r2162317 r2263337 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.1 4.47 * Version: 1.15.0 8 8 * Author: Hunch Manifest 9 9 * Author URI: https://www.hunchmanifest.com -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaEditor.php
r2153620 r2263337 10 10 class SchemaEditor { 11 11 12 private $Settings; 12 13 private $PluginURL; 13 14 … … 17 18 public function __construct($HunchSchemaPluginURL) { 18 19 20 $this->Settings = get_option( 'schema_option_name' ); 19 21 $this->PluginURL = $HunchSchemaPluginURL; 20 22 … … 70 72 71 73 $PostType = get_post_type(); 72 $MarkupDisable = get_post_meta( $post->ID, '_HunchSchemaDisableMarkup', true );73 74 $MarkupType = get_post_meta( $post->ID, '_HunchSchemaType', true ); 74 75 $MarkupCustom = get_post_meta( $post->ID, '_HunchSchemaMarkup', true ); 75 76 $MarkupDefault = ''; 76 77 78 if ( ( $PostType == 'post' && empty( $this->Settings['SchemaDefaultShowOnPost'] ) ) || ( $PostType == 'page' && empty( $this->Settings['SchemaDefaultShowOnPage'] ) ) ) { 79 $show_markup = false; 80 } else { 81 $show_markup = true; 82 } 83 84 $markup_disable = get_post_meta( $post->ID, '_HunchSchemaDisableMarkup', true ); 85 $markup_enable = get_post_meta( $post->ID, '_HunchSchemaEnableMarkup', true ); 86 87 if ( ( $show_markup && ! $markup_disable ) || ( ! $show_markup && $markup_enable ) ) { 88 $show_markup_final = true; 89 } else { 90 $show_markup_final = false; 91 } 92 77 93 // Add an nonce field so we can check for it later. 78 94 wp_nonce_field('schema_inner_custom_box', 'schema_inner_custom_box_nonce'); 79 95 80 $s erver = new SchemaServer();96 $schema_server = new SchemaServer(); 81 97 // Use get_post_meta to retrieve an existing value from the database. 82 $jsonLd = $s erver->getResource(get_permalink($post->ID), true);98 $jsonLd = $schema_server->getResource(get_permalink($post->ID), true); 83 99 $MarkupDefault = $jsonLd; 84 100 … … 87 103 $MarkupDefault = $schemaObj->getResource(TRUE); 88 104 $jsonLd = $MarkupCustom ? $MarkupCustom : $MarkupDefault; 89 $replacelink = $s erver->createLink();105 $replacelink = $schema_server->createLink(); 90 106 } else { 91 $editlink = $s erver->updateLink();107 $editlink = $schema_server->updateLink(); 92 108 } 93 109 $testlink = "https://developers.google.com/structured-data/testing-tool?url=" . urlencode(get_permalink($post->ID)); … … 107 123 <div id="schemapostlinks"> 108 124 <?php 109 if ( ! $MarkupDisable)125 if ( $show_markup_final ) 110 126 { 111 127 if ( empty($replacelink) ) { … … 130 146 <div class="MetaSchemaMarkup" style="position: relative;"> 131 147 <div class="ErrorMessage" style="color: red;"></div> 132 <textarea class="large-text metadesc" rows="6" id="schema_new_field" name="schema_new_field" data-id="<?php print $post->ID; ?>" <?php print $MarkupCustom ? '' : 'disabled'; ?>><?php print $ MarkupDisable ? '' : esc_attr($jsonLd); ?></textarea>133 <?php if ( ! $MarkupDisable): ?>148 <textarea class="large-text metadesc" rows="6" id="schema_new_field" name="schema_new_field" data-id="<?php print $post->ID; ?>" <?php print $MarkupCustom ? '' : 'disabled'; ?>><?php print $show_markup_final ? esc_attr($jsonLd) : ''; ?></textarea> 149 <?php if ( $show_markup_final ): ?> 134 150 <a class="Edit dashicons dashicons-edit" style="<?php print $MarkupCustom ? 'display: none;' : ''; ?> position: absolute; bottom: 10px; right: 32px;" href="#"></a> 135 151 <a class="Delete dashicons dashicons-trash" style="<?php print $MarkupCustom ? '' : 'display: none;'; ?> position: absolute; bottom: 10px; right: 32px;" href="#"></a> … … 137 153 <?php endif; ?> 138 154 </div> 139 <?php if ( isset( $schemaObj ) && ! $MarkupDisable) : ?>155 <?php if ( isset( $schemaObj ) && $show_markup_final ) : ?> 140 156 <strong>Note: </strong> 141 157 <span id="MetaSchemaMarkupNote" style="color: grey"><em> … … 146 162 </p> 147 163 164 165 <?php if ( ! empty( $this->Settings['Debug'] ) ) : ?> 166 167 <h4>Debug</h4> 168 169 <table class="widefat fixed wp-list-table"> 170 <tbody> 171 172 <tr> 173 <td style="width: 30%;"> 174 Transient 175 </td> 176 <td> 177 <?php print $schema_server->transient; ?> 178 </td> 179 </tr> 180 <tr> 181 <td style="width: 30%;"> 182 Transient Id 183 </td> 184 <td> 185 <?php print $schema_server->transient_id; ?> 186 </td> 187 </tr> 188 <tr> 189 <td style="width: 30%;"> 190 API URL 191 </td> 192 <td> 193 <?php print $schema_server->api_url; ?> 194 </td> 195 </tr> 196 197 </tbody> 198 </table> 199 200 <?php endif; ?> 201 202 148 203 <h4>Markup Options</h4> 149 204 … … 151 206 <tbody> 152 207 153 <tr> 154 <td style="width: 30%;"> 155 <?php _e('Disable Schema markup', 'schema_textdomain'); ?> 156 </td> 157 <td> 158 <input type="checkbox" name="HunchSchemaDisableMarkup" value="1" <?php $this->CheckSelected(1, $MarkupDisable, 'checkbox'); ?>> 159 </td> 160 </tr> 161 162 <?php if ( $PostType == 'page') : ?> 208 <?php if ( ( $PostType == 'post' && ! empty( $this->Settings['SchemaDefaultShowOnPost'] ) ) || ( $PostType == 'page' && ! empty( $this->Settings['SchemaDefaultShowOnPage'] ) ) ) : ?> 209 <tr> 210 <td style="width: 30%;"> 211 <?php _e('Disable Schema markup', 'schema_textdomain'); ?> 212 </td> 213 <td> 214 <input type="checkbox" name="HunchSchemaDisableMarkup" value="1" <?php $this->CheckSelected(1, $markup_disable, 'checkbox'); ?>> 215 </td> 216 </tr> 217 <?php else : ?> 218 <tr> 219 <td style="width: 30%;"> 220 <?php _e('Enable Schema markup', 'schema_textdomain'); ?> 221 </td> 222 <td> 223 <input type="checkbox" name="HunchSchemaEnableMarkup" value="1" <?php $this->CheckSelected(1, $markup_enable, 'checkbox'); ?>> 224 </td> 225 </tr> 226 <?php endif; ?> 227 228 <?php if ( $PostType == 'page' ) : ?> 163 229 <tr> 164 230 <td> … … 201 267 } else { 202 268 delete_post_meta($PostId, '_HunchSchemaDisableMarkup'); 269 } 270 271 if (isset($_POST['HunchSchemaEnableMarkup'])) { 272 update_post_meta($PostId, '_HunchSchemaEnableMarkup', $_POST['HunchSchemaEnableMarkup']); 273 } else { 274 delete_post_meta($PostId, '_HunchSchemaEnableMarkup'); 203 275 } 204 276 -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaFront.php
r2162317 r2263337 191 191 } 192 192 193 $DisableMarkup = is_singular() ? get_post_meta( $post->ID, '_HunchSchemaDisableMarkup', true ) : false; 194 195 if ( ! $DisableMarkup ) 196 { 197 $PostType = get_post_type(); 193 $PostType = get_post_type(); 194 195 if ( is_singular() && ( $PostType == 'post' && empty( $this->Settings['SchemaDefaultShowOnPost'] ) ) || ( $PostType == 'page' && empty( $this->Settings['SchemaDefaultShowOnPage'] ) ) ) { 196 $show_markup = false; 197 } else { 198 $show_markup = true; 199 } 200 201 $markup_disable = is_singular() ? get_post_meta( $post->ID, '_HunchSchemaDisableMarkup', true ) : false; 202 $markup_enable = is_singular() ? get_post_meta( $post->ID, '_HunchSchemaEnableMarkup', true ) : false; 203 204 if ( ( $show_markup && ! $markup_disable ) || ( ! $show_markup && $markup_enable ) ) 205 { 198 206 $SchemaThing = HunchSchema_Thing::factory( $PostType ); 199 200 207 $SchemaServer = new SchemaServer(); 201 208 $SchemaMarkup = $SchemaServer->getResource(); -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php
r2155544 r2263337 12 12 private $options; 13 13 private $resource; 14 public $transient_id; 15 public $transient = 'No'; 16 public $api_url; 14 17 15 18 const API_SERVER = "https://api.schemaapp.com/"; … … 62 65 $resource = urldecode( $resource ); 63 66 67 $this->readLink($resource); 64 68 65 $t ransient_id = 'HunchSchema-Markup-' . md5($resource);69 $this->transient_id = $transient_id = 'HunchSchema-Markup-' . md5($resource); 66 70 $transient = get_transient($transient_id); 67 71 68 72 // Check for missing, empty or 'null' transient 69 73 if ($transient !== false && $transient !== 'null') { 70 return $transient; 74 $this->transient = 'Yes'; 75 return $transient; 71 76 } 72 77 … … 99 104 protected function readLink($uri = '') { 100 105 $uri = !empty($uri) ? $uri : $this->resource; 101 $graph = str_replace("http://schemaapp.com/db/", "", $this->options['graph_uri']); 102 return $this::DATA_SERVER . $graph . '/' . trim(base64_encode($uri), '='); 106 $graph = str_replace( array( 'http://schemaapp.com/db/', 'https://schemaapp.com/db/' ), '', $this->options['graph_uri'] ); 107 108 $this->api_url = $this::DATA_SERVER . $graph . '/' . trim(base64_encode($uri), '='); 109 110 return $this->api_url; 103 111 } 104 112 -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaSettings.php
r2155544 r2263337 317 317 318 318 add_settings_section( 'schema-default', 'Schema Default Settings', null, 'schema-app-setting' ); 319 add_settings_field( 'SchemaDefaultShowOnPost', 'Show markup on Post', array( $this, 'SettingsFieldSchemaDefaultShowOnPost' ), 'schema-app-setting', 'schema-default' ); 320 add_settings_field( 'SchemaDefaultShowOnPage', 'Show markup on Page', array( $this, 'SettingsFieldSchemaDefaultShowOnPage' ), 'schema-app-setting', 'schema-default' ); 319 321 add_settings_field( 'SchemaDefaultLocation', 'Location where to put the schema markup', array( $this, 'SettingsFieldSchemaDefaultLocation' ), 'schema-app-setting', 'schema-default' ); 320 322 add_settings_field( 'SchemaDefaultTypePost', 'Post Default Schema Type', array( $this, 'SettingsFieldSchemaDefaultTypePost' ), 'schema-app-setting', 'schema-default' ); … … 530 532 531 533 532 foreach ( array( 'publisher_type', 'publisher_name', 'publisher_image', 'SchemaDefault Location', 'SchemaDefaultTypePost', 'SchemaDefaultTypePage', 'SchemaDefaultImage', 'Debug', 'ToolbarShowTestSchema', 'SchemaBreadcrumb', 'SchemaWebSite', 'SchemaArticleBody', 'SchemaHideComments', 'SchemaLinkedOpenData', 'SchemaRemoveMicrodata', 'SchemaRemoveWPSEOMarkup', 'Version', 'NoticeDismissWooCommerceAddon' ) as $FieldName )534 foreach ( array( 'publisher_type', 'publisher_name', 'publisher_image', 'SchemaDefaultShowOnPost', 'SchemaDefaultShowOnPage', 'SchemaDefaultLocation', 'SchemaDefaultTypePost', 'SchemaDefaultTypePage', 'SchemaDefaultImage', 'Debug', 'ToolbarShowTestSchema', 'SchemaBreadcrumb', 'SchemaWebSite', 'SchemaArticleBody', 'SchemaHideComments', 'SchemaLinkedOpenData', 'SchemaRemoveMicrodata', 'SchemaRemoveWPSEOMarkup', 'Version', 'NoticeDismissWooCommerceAddon' ) as $FieldName ) 533 535 { 534 536 if ( isset( $input[$FieldName] ) && $input[$FieldName] != '' ) … … 751 753 752 754 } 755 756 757 public function SettingsFieldSchemaDefaultShowOnPost( $Options ) 758 { 759 // Default enabled 760 $Value = ( isset( $this->Settings['SchemaDefaultShowOnPost'] ) && $this->Settings['SchemaDefaultShowOnPost'] == 0 ) ? 0 : 1; 761 762 ?> 763 764 <select name="schema_option_name[SchemaDefaultShowOnPost]"> 765 <option value="1" <?php selected( $Value, 1 ); ?>>Enabled</option> 766 <option value="0" <?php selected( $Value, 0 ); ?>>Disabled</option> 767 </select> 768 769 <?php 770 771 } 772 773 774 public function SettingsFieldSchemaDefaultShowOnPage( $Options ) 775 { 776 // Default enabled 777 $Value = ( isset( $this->Settings['SchemaDefaultShowOnPage'] ) && $this->Settings['SchemaDefaultShowOnPage'] == 0 ) ? 0 : 1; 778 779 ?> 780 781 <select name="schema_option_name[SchemaDefaultShowOnPage]"> 782 <option value="1" <?php selected( $Value, 1 ); ?>>Enabled</option> 783 <option value="0" <?php selected( $Value, 0 ); ?>>Disabled</option> 784 </select> 785 786 <?php 787 788 } 753 789 754 790 -
schema-app-structured-data-for-schemaorg/trunk/readme.txt
r2162317 r2263337 8 8 Requires at least: 3.7 9 9 Requires PHP: 5.4 10 Tested up to: 5. 211 Stable tag: 1.1 4.410 Tested up to: 5.3 11 Stable tag: 1.15.0 12 12 License: GPL2 13 13 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 87 87 == Changelog == 88 88 89 = 1.15.0 = 90 - Feature, Added global options for Post/Page to enable or disable schema markup 91 - Fix, Account Id issue for fetching markup from API 92 89 93 = 1.14.4 = 90 94 - Improve, Webhook by caching all schema markup and better matching of permalinks … … 393 397 == Upgrade Notice == 394 398 395 = 1.1 4.4=396 - Improve Webhook by caching all schema markup and better matching of permalinks399 = 1.15.0 = 400 - Added global options for Post/Page to enable or disable schema markup
Note: See TracChangeset
for help on using the changeset viewer.