Changeset 2266757
- Timestamp:
- 03/24/2020 05:37:45 PM (6 years ago)
- Location:
- schema-app-structured-data-for-schemaorg
- Files:
-
- 26 added
- 6 edited
-
tags/1.15.1 (added)
-
tags/1.15.1/css (added)
-
tags/1.15.1/css/schemaStyle.css (added)
-
tags/1.15.1/data (added)
-
tags/1.15.1/data/tree.jsonld (added)
-
tags/1.15.1/hunch-schema.php (added)
-
tags/1.15.1/js (added)
-
tags/1.15.1/js/schema.js (added)
-
tags/1.15.1/js/schemaAdmin.js (added)
-
tags/1.15.1/js/schemaEditor.js (added)
-
tags/1.15.1/lib (added)
-
tags/1.15.1/lib/HunchSchema (added)
-
tags/1.15.1/lib/HunchSchema/Author.php (added)
-
tags/1.15.1/lib/HunchSchema/Blog.php (added)
-
tags/1.15.1/lib/HunchSchema/Category.php (added)
-
tags/1.15.1/lib/HunchSchema/Page.php (added)
-
tags/1.15.1/lib/HunchSchema/Post.php (added)
-
tags/1.15.1/lib/HunchSchema/Search.php (added)
-
tags/1.15.1/lib/HunchSchema/Tag.php (added)
-
tags/1.15.1/lib/HunchSchema/Thing.php (added)
-
tags/1.15.1/lib/SchemaEditor.php (added)
-
tags/1.15.1/lib/SchemaFront.php (added)
-
tags/1.15.1/lib/SchemaServer.php (added)
-
tags/1.15.1/lib/SchemaSettings.php (added)
-
tags/1.15.1/lib/classmap.php (added)
-
tags/1.15.1/readme.txt (added)
-
trunk/hunch-schema.php (modified) (1 diff)
-
trunk/lib/SchemaEditor.php (modified) (8 diffs)
-
trunk/lib/SchemaFront.php (modified) (2 diffs)
-
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
r2263337 r2266757 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.15. 07 * Version: 1.15.1 8 8 * Author: Hunch Manifest 9 9 * Author URI: https://www.hunchmanifest.com -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaEditor.php
r2263337 r2266757 76 76 $MarkupDefault = ''; 77 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 78 $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 79 93 80 // Add an nonce field so we can check for it later. … … 123 110 <div id="schemapostlinks"> 124 111 <?php 125 if ( $show_markup_final)112 if ( ! $markup_disable ) 126 113 { 127 114 if ( empty($replacelink) ) { … … 146 133 <div class="MetaSchemaMarkup" style="position: relative;"> 147 134 <div class="ErrorMessage" style="color: red;"></div> 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): ?>135 <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 ! $markup_disable ? esc_attr($jsonLd) : ''; ?></textarea> 136 <?php if ( ! $markup_disable ): ?> 150 137 <a class="Edit dashicons dashicons-edit" style="<?php print $MarkupCustom ? 'display: none;' : ''; ?> position: absolute; bottom: 10px; right: 32px;" href="#"></a> 151 138 <a class="Delete dashicons dashicons-trash" style="<?php print $MarkupCustom ? '' : 'display: none;'; ?> position: absolute; bottom: 10px; right: 32px;" href="#"></a> … … 153 140 <?php endif; ?> 154 141 </div> 155 <?php if ( isset( $schemaObj ) && $show_markup_final) : ?>142 <?php if ( isset( $schemaObj ) && ! $markup_disable ) : ?> 156 143 <strong>Note: </strong> 157 144 <span id="MetaSchemaMarkupNote" style="color: grey"><em> … … 172 159 <tr> 173 160 <td style="width: 30%;"> 161 URL 162 </td> 163 <td> 164 <?php print $schema_server->page_url; ?> 165 </td> 166 </tr> 167 <tr> 168 <td style="width: 30%;"> 174 169 Transient 175 170 </td> 176 171 <td> 177 <?php print $schema_server->transient ; ?>172 <?php print $schema_server->transient ? 'Yes' : 'No'; ?> 178 173 </td> 179 174 </tr> … … 191 186 </td> 192 187 <td> 193 < ?php print $schema_server->api_url; ?>188 <a href="<?php print $schema_server->api_url; ?>" target="_blank"><?php print $schema_server->api_url; ?></a> 194 189 </td> 195 190 </tr> … … 206 201 <tbody> 207 202 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; ?> 203 <tr> 204 <td style="width: 30%;"> 205 <?php _e('Disable Schema markup', 'schema_textdomain'); ?> 206 </td> 207 <td> 208 <input type="checkbox" name="HunchSchemaDisableMarkup" value="1" <?php $this->CheckSelected(1, $markup_disable, 'checkbox'); ?>> 209 </td> 210 </tr> 227 211 228 212 <?php if ( $PostType == 'page' ) : ?> … … 267 251 } else { 268 252 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');275 253 } 276 254 -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaFront.php
r2263337 r2266757 126 126 return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid @type, @id or @graph property' ), 400 ); 127 127 } else { 128 if ( stripos( $request_data->{"@id"}, site_url() ) === false ) { 128 $site_domain = str_replace( array( 'http://', 'https://' ), '', site_url() ); 129 $home_domain = str_replace( array( 'http://', 'https://' ), '', home_url() ); 130 131 if ( stripos( $request_data->{"@id"}, $site_domain ) === false && stripos( $request_data->{"@id"}, $home_domain ) === false ) { 129 132 if ( ! empty( $this->Settings['Debug'] ) ) { 130 file_put_contents( $rest_api_cache_log_file, 'Result: Invalid @id property, url does not match', FILE_APPEND );133 file_put_contents( $rest_api_cache_log_file, sprintf( 'Result: Invalid @id property, url does not match. @id: %s Site Domain: %s Home Domain: %s', $request_data->{"@id"}, $site_domain, $home_domain ), FILE_APPEND ); 131 134 } 132 135 … … 193 196 $PostType = get_post_type(); 194 197 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 { 206 $SchemaThing = HunchSchema_Thing::factory( $PostType ); 207 $SchemaServer = new SchemaServer(); 208 $SchemaMarkup = $SchemaServer->getResource(); 209 210 $JSONSchemaMarkup = array(); 211 $SchemaMarkupType = ''; 212 213 // If Custom schema markup is empty or not found 214 if ( $SchemaMarkup === "" || $SchemaMarkup === false ) { 215 216 $SchemaMarkupCustom = get_post_meta( $post->ID, '_HunchSchemaMarkup', true ); 217 218 if ( $SchemaMarkupCustom ) 219 { 220 $SchemaMarkupType = 'Custom'; 221 $SchemaMarkup = $SchemaMarkupCustom; 222 } 223 else if ( isset( $SchemaThing ) ) 224 { 225 $SchemaMarkupType = 'Default'; 226 $SchemaMarkup = $SchemaThing->getResource(); 227 } 198 if ( is_singular() ) { 199 $markup_disable = get_post_meta( $post->ID, '_HunchSchemaDisableMarkup', true ); 200 201 if ( $markup_disable ) { 202 return; 203 } 204 } 205 206 207 $SchemaThing = HunchSchema_Thing::factory( $PostType ); 208 $SchemaServer = new SchemaServer(); 209 $SchemaMarkup = $SchemaServer->getResource(); 210 211 $JSONSchemaMarkup = array(); 212 $SchemaMarkupType = ''; 213 214 // If Custom schema markup is empty or not found 215 if ( $SchemaMarkup === "" || $SchemaMarkup === false ) { 216 217 $SchemaMarkupCustom = get_post_meta( $post->ID, '_HunchSchemaMarkup', true ); 218 219 if ( $SchemaMarkupCustom ) 220 { 221 $SchemaMarkupType = 'Custom'; 222 $SchemaMarkup = $SchemaMarkupCustom; 223 } 224 else if ( isset( $SchemaThing ) ) 225 { 226 $SchemaMarkupType = 'Default'; 227 $SchemaMarkup = $SchemaThing->getResource(); 228 } 229 } 230 else 231 { 232 $SchemaMarkupType = 'App'; 233 } 234 235 do_action( 'hunch_schema_markup_render', $SchemaMarkup, $SchemaMarkupType, $post, $PostType, $JSON ); 236 237 $SchemaMarkup = apply_filters( 'hunch_schema_markup', $SchemaMarkup, $SchemaMarkupType, $post, $PostType ); 238 239 if ( $SchemaMarkup !== "" && ! is_null( $SchemaMarkup ) ) 240 { 241 if ( $JSON ) 242 { 243 $JSONSchemaMarkup[] = json_decode( $SchemaMarkup ); 228 244 } 229 245 else 230 246 { 231 $SchemaMarkupType = 'App'; 232 } 233 234 do_action( 'hunch_schema_markup_render', $SchemaMarkup, $SchemaMarkupType, $post, $PostType, $JSON ); 235 236 $SchemaMarkup = apply_filters( 'hunch_schema_markup', $SchemaMarkup, $SchemaMarkupType, $post, $PostType ); 237 238 if ( $SchemaMarkup !== "" && ! is_null( $SchemaMarkup ) ) 247 printf( '<script type="application/ld+json" data-schema="%s-%s-%s">%s</script>' . "\n", $post->ID, $PostType, $SchemaMarkupType, $SchemaMarkup ); 248 } 249 } 250 251 if ( ! empty( $this->Settings['SchemaWebSite'] ) && is_front_page() ) 252 { 253 $SchemaMarkupWebSite = apply_filters( 'hunch_schema_markup_website', $SchemaThing->getWebSite(), $PostType ); 254 255 if ( ! empty( $SchemaMarkupWebSite ) ) 239 256 { 240 257 if ( $JSON ) 241 258 { 242 $JSONSchemaMarkup[] = json_decode( $SchemaMarkup );259 $JSONSchemaMarkup[] = json_decode( $SchemaMarkupWebSite ); 243 260 } 244 261 else 245 262 { 246 printf( '<script type="application/ld+json" data-schema="%s-%s-%s">%s</script>' . "\n", $post->ID, $PostType, $SchemaMarkupType, $SchemaMarkup ); 247 } 248 } 249 250 if ( ! empty( $this->Settings['SchemaWebSite'] ) && is_front_page() ) 251 { 252 $SchemaMarkupWebSite = apply_filters( 'hunch_schema_markup_website', $SchemaThing->getWebSite(), $PostType ); 253 254 if ( ! empty( $SchemaMarkupWebSite ) ) 263 printf( '<script type="application/ld+json" data-schema="Website">%s</script>' . "\n", $SchemaMarkupWebSite ); 264 } 265 } 266 } 267 268 if ( ! empty( $this->Settings['SchemaBreadcrumb'] ) && method_exists( $SchemaThing, 'getBreadcrumb' ) ) 269 { 270 $SchemaMarkupBreadcrumb = apply_filters( 'hunch_schema_markup_breadcrumb', $SchemaThing->getBreadcrumb(), $PostType ); 271 272 if ( ! empty( $SchemaMarkupBreadcrumb ) ) 273 { 274 if ( $JSON ) 255 275 { 256 if ( $JSON ) 257 { 258 $JSONSchemaMarkup[] = json_decode( $SchemaMarkupWebSite ); 259 } 260 else 261 { 262 printf( '<script type="application/ld+json" data-schema="Website">%s</script>' . "\n", $SchemaMarkupWebSite ); 263 } 264 } 265 } 266 267 if ( ! empty( $this->Settings['SchemaBreadcrumb'] ) && method_exists( $SchemaThing, 'getBreadcrumb' ) ) 268 { 269 $SchemaMarkupBreadcrumb = apply_filters( 'hunch_schema_markup_breadcrumb', $SchemaThing->getBreadcrumb(), $PostType ); 270 271 if ( ! empty( $SchemaMarkupBreadcrumb ) ) 272 { 273 if ( $JSON ) 274 { 275 $JSONSchemaMarkup[] = json_decode( $SchemaMarkupBreadcrumb ); 276 } 277 else 278 { 279 printf( '<script type="application/ld+json" data-schema="Breadcrumb">%s</script>' . "\n", $SchemaMarkupBreadcrumb ); 280 } 281 } 282 } 283 284 if ( $JSON && ! empty( $JSONSchemaMarkup ) ) 285 { 286 if ( count( $JSONSchemaMarkup ) == 1 ) 287 { 288 $JSONSchemaMarkup = reset( $JSONSchemaMarkup ); 289 290 print json_encode( $JSONSchemaMarkup ); 276 $JSONSchemaMarkup[] = json_decode( $SchemaMarkupBreadcrumb ); 291 277 } 292 278 else 293 279 { 294 print json_encode( $JSONSchemaMarkup ); 295 } 296 } 297 } 280 printf( '<script type="application/ld+json" data-schema="Breadcrumb">%s</script>' . "\n", $SchemaMarkupBreadcrumb ); 281 } 282 } 283 } 284 285 if ( $JSON && ! empty( $JSONSchemaMarkup ) ) 286 { 287 if ( count( $JSONSchemaMarkup ) == 1 ) 288 { 289 $JSONSchemaMarkup = reset( $JSONSchemaMarkup ); 290 291 print json_encode( $JSONSchemaMarkup ); 292 } 293 else 294 { 295 print json_encode( $JSONSchemaMarkup ); 296 } 297 } 298 298 } 299 299 -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php
r2263337 r2266757 13 13 private $resource; 14 14 public $transient_id; 15 public $transient = 'No'; 15 public $transient = false; 16 public $page_url; 16 17 public $api_url; 17 18 … … 63 64 64 65 // Decode accent characters 65 $ resource = urldecode( $resource );66 $this->page_url = $resource = urldecode( $resource ); 66 67 67 68 $this->readLink($resource); … … 72 73 // Check for missing, empty or 'null' transient 73 74 if ($transient !== false && $transient !== 'null') { 74 $this->transient = 'Yes';75 $this->transient = true; 75 76 return $transient; 76 77 } -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaSettings.php
r2263337 r2266757 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' );321 319 add_settings_field( 'SchemaDefaultLocation', 'Location where to put the schema markup', array( $this, 'SettingsFieldSchemaDefaultLocation' ), 'schema-app-setting', 'schema-default' ); 322 320 add_settings_field( 'SchemaDefaultTypePost', 'Post Default Schema Type', array( $this, 'SettingsFieldSchemaDefaultTypePost' ), 'schema-app-setting', 'schema-default' ); … … 532 530 533 531 534 foreach ( array( 'publisher_type', 'publisher_name', 'publisher_image', 'SchemaDefault ShowOnPost', 'SchemaDefaultShowOnPage', 'SchemaDefaultLocation', 'SchemaDefaultTypePost', 'SchemaDefaultTypePage', 'SchemaDefaultImage', 'Debug', 'ToolbarShowTestSchema', 'SchemaBreadcrumb', 'SchemaWebSite', 'SchemaArticleBody', 'SchemaHideComments', 'SchemaLinkedOpenData', 'SchemaRemoveMicrodata', 'SchemaRemoveWPSEOMarkup', 'Version', 'NoticeDismissWooCommerceAddon' ) as $FieldName )532 foreach ( array( 'publisher_type', 'publisher_name', 'publisher_image', 'SchemaDefaultLocation', 'SchemaDefaultTypePost', 'SchemaDefaultTypePage', 'SchemaDefaultImage', 'Debug', 'ToolbarShowTestSchema', 'SchemaBreadcrumb', 'SchemaWebSite', 'SchemaArticleBody', 'SchemaHideComments', 'SchemaLinkedOpenData', 'SchemaRemoveMicrodata', 'SchemaRemoveWPSEOMarkup', 'Version', 'NoticeDismissWooCommerceAddon' ) as $FieldName ) 535 533 { 536 534 if ( isset( $input[$FieldName] ) && $input[$FieldName] != '' ) … … 753 751 754 752 } 755 756 757 public function SettingsFieldSchemaDefaultShowOnPost( $Options )758 {759 // Default enabled760 $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 <?php770 771 }772 773 774 public function SettingsFieldSchemaDefaultShowOnPage( $Options )775 {776 // Default enabled777 $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 <?php787 788 }789 753 790 754 -
schema-app-structured-data-for-schemaorg/trunk/readme.txt
r2263337 r2266757 9 9 Requires PHP: 5.4 10 10 Tested up to: 5.3 11 Stable tag: 1.15. 011 Stable tag: 1.15.1 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.1 = 90 - Fix, Rollback global options for Post/Page schema markup 91 - Fix, Webhook check for different home and site url 92 89 93 = 1.15.0 = 90 94 - Feature, Added global options for Post/Page to enable or disable schema markup … … 397 401 == Upgrade Notice == 398 402 399 = 1.15. 0=400 - Added global options for Post/Page to enable or disable schema markup403 = 1.15.1 = 404 - Rollback global options for Post/Page schema markup
Note: See TracChangeset
for help on using the changeset viewer.