Changeset 2155544
- Timestamp:
- 09/12/2019 01:28:44 PM (6 years ago)
- Location:
- schema-app-structured-data-for-schemaorg
- Files:
-
- 26 added
- 6 edited
-
tags/1.14.2 (added)
-
tags/1.14.2/css (added)
-
tags/1.14.2/css/schemaStyle.css (added)
-
tags/1.14.2/data (added)
-
tags/1.14.2/data/tree.jsonld (added)
-
tags/1.14.2/hunch-schema.php (added)
-
tags/1.14.2/js (added)
-
tags/1.14.2/js/schema.js (added)
-
tags/1.14.2/js/schemaAdmin.js (added)
-
tags/1.14.2/js/schemaEditor.js (added)
-
tags/1.14.2/lib (added)
-
tags/1.14.2/lib/HunchSchema (added)
-
tags/1.14.2/lib/HunchSchema/Author.php (added)
-
tags/1.14.2/lib/HunchSchema/Blog.php (added)
-
tags/1.14.2/lib/HunchSchema/Category.php (added)
-
tags/1.14.2/lib/HunchSchema/Page.php (added)
-
tags/1.14.2/lib/HunchSchema/Post.php (added)
-
tags/1.14.2/lib/HunchSchema/Search.php (added)
-
tags/1.14.2/lib/HunchSchema/Tag.php (added)
-
tags/1.14.2/lib/HunchSchema/Thing.php (added)
-
tags/1.14.2/lib/SchemaEditor.php (added)
-
tags/1.14.2/lib/SchemaFront.php (added)
-
tags/1.14.2/lib/SchemaServer.php (added)
-
tags/1.14.2/lib/SchemaSettings.php (added)
-
tags/1.14.2/lib/classmap.php (added)
-
tags/1.14.2/readme.txt (added)
-
trunk/hunch-schema.php (modified) (1 diff)
-
trunk/lib/HunchSchema/Thing.php (modified) (2 diffs)
-
trunk/lib/SchemaFront.php (modified) (2 diffs)
-
trunk/lib/SchemaServer.php (modified) (1 diff)
-
trunk/lib/SchemaSettings.php (modified) (7 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
schema-app-structured-data-for-schemaorg/trunk/hunch-schema.php
r2153620 r2155544 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.14. 17 * Version: 1.14.2 8 8 * Author: Hunch Manifest 9 9 * Author URI: https://www.hunchmanifest.com -
schema-app-structured-data-for-schemaorg/trunk/lib/HunchSchema/Thing.php
r2097983 r2155544 374 374 375 375 if ( ! empty( $response ) ) { 376 // First delete then set; set method only updates expiry time if transient already exists 377 delete_transient( $transient_id ); 376 378 set_transient( $transient_id, json_decode( $response ), ( 14 * DAY_IN_SECONDS ) ); 377 379 … … 422 424 ); 423 425 426 // First delete then set; set method only updates expiry time if transient already exists 427 delete_transient( $transient_id ); 424 428 set_transient( $transient_id, $schema, ( 14 * DAY_IN_SECONDS ) ); 425 429 -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaFront.php
r2129926 r2155544 103 103 104 104 public function rest_api_cache_modify( $request ) { 105 // Log request when debug is on 106 if ( ! empty( $this->Settings['Debug'] ) ) { 107 $upload_dir_param = wp_upload_dir( null, false ); 108 $rest_api_cache_log_file = $upload_dir_param['basedir'] . DIRECTORY_SEPARATOR . 'schema_app_rest_api_cache_log.txt'; 109 110 file_put_contents( $rest_api_cache_log_file, "\n\n\nTime: " . date( 'c' ) . "\nBody:\n" . $request->get_body() . "\n", FILE_APPEND ); 111 } 112 105 113 $request_data = json_decode( $request->get_body() ); 106 114 107 115 if ( empty( $request->get_body() ) || empty( $request_data ) ) { 116 if ( ! empty( $this->Settings['Debug'] ) ) { 117 file_put_contents( $rest_api_cache_log_file, 'Result: Invalid JSON data', FILE_APPEND ); 118 } 119 108 120 return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid JSON data' ), 400 ); 109 121 } elseif ( empty( $request_data->{"@type"} ) || empty( $request_data->{"@id"} ) || empty( $request_data->{"@graph"} ) ) { 122 if ( ! empty( $this->Settings['Debug'] ) ) { 123 file_put_contents( $rest_api_cache_log_file, 'Result: Invalid @type, @id or @graph property', FILE_APPEND ); 124 } 125 110 126 return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid @type, @id or @graph property' ), 400 ); 111 127 } else { 112 128 if ( stripos( $request_data->{"@id"}, site_url() ) === false ) { 129 if ( ! empty( $this->Settings['Debug'] ) ) { 130 file_put_contents( $rest_api_cache_log_file, 'Result: Invalid @id property, url does not match', FILE_APPEND ); 131 } 132 113 133 return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid @id property, url does not match' ), 400 ); 114 134 } … … 119 139 case 'EntityCreated': 120 140 case 'EntityUpdated': 141 // First delete then set; set method only updates expiry time if transient already exists 142 delete_transient( $transient_id ); 121 143 set_transient( $transient_id, json_encode( reset( $request_data->{"@graph"} ) ), 86400 ); 144 145 if ( ! empty( $this->Settings['Debug'] ) ) { 146 file_put_contents( $rest_api_cache_log_file, 'Result: Cache updated', FILE_APPEND ); 147 } 148 122 149 return new WP_REST_Response( array( 'status' => 'ok', 'message' => 'Cache updated' ), 200 ); 123 150 break; 124 151 case 'EntityDeleted': 125 152 delete_transient( $transient_id ); 153 154 if ( ! empty( $this->Settings['Debug'] ) ) { 155 file_put_contents( $rest_api_cache_log_file, 'Result: Cache deleted', FILE_APPEND ); 156 } 157 126 158 return new WP_REST_Response( array( 'status' => 'ok', 'message' => 'Cache deleted' ), 200 ); 127 159 break; 128 160 default: 161 if ( ! empty( $this->Settings['Debug'] ) ) { 162 file_put_contents( $rest_api_cache_log_file, 'Result: Invalid @type property', FILE_APPEND ); 163 } 164 129 165 return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid @type property' ), 400 ); 130 166 } -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php
r2129926 r2155544 79 79 $schemadata = wp_remote_retrieve_body($remote_response); 80 80 81 // First delete then set; set method only updates expiry time if transient already exists 82 delete_transient( $transient_id ); 83 set_transient($transient_id, $schemadata, 86400); 84 81 85 if ($pretty && version_compare(phpversion(), '5.4.0', '>=')) { 82 86 $schemadata = json_encode(json_decode($schemadata), JSON_PRETTY_PRINT); 83 87 } 84 88 } 85 86 set_transient($transient_id, $schemadata, 86400);87 89 88 90 return $schemadata; -
schema-app-structured-data-for-schemaorg/trunk/lib/SchemaSettings.php
r2129926 r2155544 147 147 <?php endif; ?> 148 148 <?php do_action( 'hunch_schema_settings_nav_tab' ); ?> 149 <?php if ( isset( $_GET['debug'] ) && ! empty( $this->Settings['Debug'] ) ) : // Only show Debugging when manually triggered ?> 150 <a class="nav-tab" href="<?php echo admin_url() ?>options-general.php?page=schema-app-debug">Debugging</a> 151 <?php endif; ?> 149 152 </h3> 150 153 … … 211 214 <?php do_action( 'hunch_schema_settings_nav_tab_content' ); ?> 212 215 216 <?php if ( isset( $_GET['debug'] ) && ! empty( $this->Settings['Debug'] ) ) : // Only show Debugging when manually triggered ?> 217 <section id="schema-app-debug"> 218 <form method="post" action=""> 219 <?php 220 do_settings_sections( 'schema-app-debug' ); 221 ?> 222 </form> 223 </section> 224 <?php endif; ?> 225 213 226 </div> 214 227 <?php … … 272 285 do_action( 'hunch_schema_settings_section', 'schema_option_name', 'schema-app-setting', 'plugin_settings' ); 273 286 287 288 add_settings_section( 'section_debug', '', array( $this, 'section_debug' ), 'schema-app-debug' ); 289 290 274 291 // Publisher Settings 275 292 add_settings_field( … … 310 327 311 328 add_settings_section( 'schema', 'Other Schema Options', null, 'schema-app-setting' ); 329 // Only show Debugging when manually triggered 330 if ( isset( $_GET['debug'] ) ) { 331 add_settings_field( 'Debug', 'Debugging', array( $this, 'SettingsFieldSchemaDebug' ), 'schema-app-setting', 'schema' ); 332 } 312 333 add_settings_field( 'ToolbarShowTestSchema', 'Show Test Schema', array( $this, 'SettingsFieldSchemaShowTestSchema' ), 'schema-app-setting', 'schema' ); 313 334 add_settings_field( 'SchemaBreadcrumb', 'Show Breadcrumb', array( $this, 'SettingsFieldSchemaBreadcrumb' ), 'schema-app-setting', 'schema' ); … … 509 530 510 531 511 foreach ( array( 'publisher_type', 'publisher_name', 'publisher_image', 'SchemaDefaultLocation', 'SchemaDefaultTypePost', 'SchemaDefaultTypePage', 'SchemaDefaultImage', ' 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 ) 512 533 { 513 534 if ( isset( $input[$FieldName] ) && $input[$FieldName] != '' ) … … 587 608 print '<p>License Information required for WooCommerce schema.org structured data.</p>'; 588 609 } 610 611 612 public function section_debug() { 613 global $wpdb; 614 615 $upload_dir_param = wp_upload_dir( null, false ); 616 $rest_api_cache_log_file = $upload_dir_param['basedir'] . DIRECTORY_SEPARATOR . 'schema_app_rest_api_cache_log.txt'; 617 618 619 if ( count( $_POST ) ) { 620 if ( count( $_POST ) && ! empty( $_POST['debug_delete_transient'] ) ) { 621 if ( $_POST['debug_delete_transient'] == 'all' ) { 622 $transients = $wpdb->get_col( "SELECT DISTINCT option_name FROM {$wpdb->options} WHERE option_name LIKE '_transient_HunchSchema-Markup-%'" ); 623 624 if ( $transients ) { 625 foreach ( $transients as $transient ) { 626 $transient_id = str_ireplace( '_transient_', '', $transient ); 627 628 delete_transient( $transient_id ); 629 } 630 631 print '<div class="notice notice-success is-dismissible"> <p>Debugging: All schema cache deleted.</p> </div>'; 632 } 633 } else { 634 delete_transient( $_POST['debug_delete_transient'] ); 635 636 printf( '<div class="notice notice-success is-dismissible"> <p>Debugging: Schema cache deleted with Id: %s</p> </div>', $_POST['debug_delete_transient'] ); 637 } 638 } 639 640 641 if ( count( $_POST ) && ! empty( $_POST['debug_delete_file'] ) ) { 642 if ( $_POST['debug_delete_file'] == 'rest_api_cache_log' ) { 643 unlink( $rest_api_cache_log_file ); 644 645 print '<div class="notice notice-success is-dismissible"> <p>Debugging: Log file deleted.</p> </div>'; 646 } 647 } 648 } 649 650 651 $transients = $wpdb->get_col( "SELECT DISTINCT option_name FROM {$wpdb->options} WHERE option_name LIKE '_transient_HunchSchema-Markup-%'" ); 652 653 654 print '<h3>Cached Schema Items</h3>'; 655 656 if ( $transients ) { 657 print '<ol>'; 658 659 foreach ( $transients as $transient ) { 660 $transient_id = str_ireplace( '_transient_', '', $transient ); 661 $transient_timeout = date( 'c', get_option( "_transient_timeout_{$transient_id}" ) ); 662 663 printf( "<li> <p>Id: %s</p> <p>Expiry: %s</p> <p>Data: <br> <textarea rows='5' class='large-text code'>%s</textarea></p> <p>Action: <button type='submit' class='button button-secondary' name='debug_delete_transient' value='%s'>Delete</button></p> </li>", $transient_id, $transient_timeout, print_r( get_transient( $transient_id ), true ), $transient_id ); 664 } 665 666 print '</ol>'; 667 668 print '<br><button type="submit" class="button button-secondary" name="debug_delete_transient" value="all">Delete All Cache</button>'; 669 } else { 670 print '<p>No cached items found.</p>'; 671 } 672 673 674 print '<br><br> <hr> <h3>Cache REST API Log</h3>'; 675 676 if ( file_exists( $rest_api_cache_log_file ) ) { 677 printf( '<textarea rows="20" class="large-text code">%s</textarea>', file_get_contents( $rest_api_cache_log_file ) ); 678 679 print '<br><br><button type="submit" class="button button-secondary" name="debug_delete_file" value="rest_api_cache_log">Delete log file</button>'; 680 } else { 681 print '<p>File not found.</p>'; 682 } 683 } 684 589 685 590 686 /** … … 727 823 } 728 824 825 826 public function SettingsFieldSchemaDebug( $Options ) 827 { 828 $Value = empty( $this->Settings['Debug'] ) ? 0 : $this->Settings['Debug']; 829 830 print '<input type="checkbox" name="schema_option_name[Debug]" value="1" ' . checked( 1, $Value, false ) . '>'; 831 print '<p>Enable debugging functionality.</p>'; 832 } 833 729 834 730 835 public function SettingsFieldSchemaShowTestSchema( $Options ) -
schema-app-structured-data-for-schemaorg/trunk/readme.txt
r2153620 r2155544 9 9 Requires PHP: 5.4 10 10 Tested up to: 5.2 11 Stable tag: 1.14. 111 Stable tag: 1.14.2 12 12 License: GPL2 13 13 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 87 87 == Changelog == 88 88 89 = 1.14.2 = 90 - Fix, Transient cache issue 91 - Improve, added debug feature to quickly resolve common issues on client website 92 89 93 = 1.14.1 = 90 94 - Fix, Remove comment schema setting for archive pages … … 383 387 == Upgrade Notice == 384 388 385 = 1.14. 1=386 - Remove comment schema setting for archive pages389 = 1.14.2 = 390 - Fix transient cache issue, added debug feature
Note: See TracChangeset
for help on using the changeset viewer.