Plugin Directory

Changeset 2155544


Ignore:
Timestamp:
09/12/2019 01:28:44 PM (6 years ago)
Author:
milanmk
Message:

Release 1.14.2

Location:
schema-app-structured-data-for-schemaorg
Files:
26 added
6 edited

Legend:

Unmodified
Added
Removed
  • schema-app-structured-data-for-schemaorg/trunk/hunch-schema.php

    r2153620 r2155544  
    55 * Plugin URI: http://www.schemaapp.com
    66 * Description: This plugin adds http://schema.org structured data to your website
    7  * Version: 1.14.1
     7 * Version: 1.14.2
    88 * Author: Hunch Manifest
    99 * Author URI: https://www.hunchmanifest.com
  • schema-app-structured-data-for-schemaorg/trunk/lib/HunchSchema/Thing.php

    r2097983 r2155544  
    374374
    375375            if ( ! empty( $response ) ) {
     376                // First delete then set; set method only updates expiry time if transient already exists
     377                delete_transient( $transient_id );
    376378                set_transient( $transient_id, json_decode( $response ), ( 14 * DAY_IN_SECONDS ) );
    377379
     
    422424                );
    423425
     426                // First delete then set; set method only updates expiry time if transient already exists
     427                delete_transient( $transient_id );
    424428                set_transient( $transient_id, $schema, ( 14 * DAY_IN_SECONDS ) );
    425429
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaFront.php

    r2129926 r2155544  
    103103
    104104    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
    105113        $request_data = json_decode( $request->get_body() );
    106114
    107115        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
    108120            return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid JSON data' ), 400 );
    109121        } 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
    110126            return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid @type, @id or @graph property' ), 400 );
    111127        } else {
    112128            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
    113133                return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid @id property, url does not match' ), 400 );
    114134            }
     
    119139                case 'EntityCreated':
    120140                case 'EntityUpdated':
     141                    // First delete then set; set method only updates expiry time if transient already exists
     142                    delete_transient( $transient_id );
    121143                    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
    122149                    return new WP_REST_Response( array( 'status' => 'ok', 'message' => 'Cache updated' ), 200 );
    123150                    break;
    124151                case 'EntityDeleted':
    125152                    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
    126158                    return new WP_REST_Response( array( 'status' => 'ok', 'message' => 'Cache deleted' ), 200 );
    127159                    break;
    128160                default:
     161                    if ( ! empty( $this->Settings['Debug'] ) ) {
     162                        file_put_contents( $rest_api_cache_log_file, 'Result: Invalid @type property', FILE_APPEND );
     163                    }
     164
    129165                    return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid @type property' ), 400 );
    130166            }
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php

    r2129926 r2155544  
    7979                        $schemadata = wp_remote_retrieve_body($remote_response);
    8080
     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
    8185                        if ($pretty && version_compare(phpversion(), '5.4.0', '>=')) {
    8286                                $schemadata = json_encode(json_decode($schemadata), JSON_PRETTY_PRINT);
    8387                        }
    8488                }
    85 
    86                 set_transient($transient_id, $schemadata, 86400);
    8789
    8890                return $schemadata;
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaSettings.php

    r2129926 r2155544  
    147147                <?php endif; ?>
    148148                <?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; ?>
    149152            </h3>
    150153
     
    211214            <?php do_action( 'hunch_schema_settings_nav_tab_content' ); ?>
    212215
     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
    213226        </div>
    214227        <?php
     
    272285        do_action( 'hunch_schema_settings_section', 'schema_option_name', 'schema-app-setting', 'plugin_settings' );
    273286
     287
     288        add_settings_section( 'section_debug', '', array( $this, 'section_debug' ), 'schema-app-debug' );
     289
     290
    274291        // Publisher Settings       
    275292        add_settings_field(
     
    310327
    311328        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        }
    312333        add_settings_field( 'ToolbarShowTestSchema', 'Show Test Schema', array( $this, 'SettingsFieldSchemaShowTestSchema' ), 'schema-app-setting', 'schema' );     
    313334        add_settings_field( 'SchemaBreadcrumb', 'Show Breadcrumb', array( $this, 'SettingsFieldSchemaBreadcrumb' ), 'schema-app-setting', 'schema' );     
     
    509530
    510531
    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 )
    512533        {
    513534            if ( isset( $input[$FieldName] ) && $input[$FieldName] != '' )
     
    587608        print '<p>License Information required for WooCommerce schema.org structured data.</p>';       
    588609    }
     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
    589685
    590686    /**
     
    727823    }
    728824
     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   
    729834
    730835    public function SettingsFieldSchemaShowTestSchema( $Options )
  • schema-app-structured-data-for-schemaorg/trunk/readme.txt

    r2153620 r2155544  
    99Requires PHP: 5.4
    1010Tested up to: 5.2
    11 Stable tag: 1.14.1
     11Stable tag: 1.14.2
    1212License: GPL2
    1313License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8787== Changelog ==
    8888
     89= 1.14.2 =
     90- Fix, Transient cache issue
     91- Improve, added debug feature to quickly resolve common issues on client website
     92
    8993= 1.14.1 =
    9094- Fix, Remove comment schema setting for archive pages
     
    383387== Upgrade Notice ==
    384388
    385 = 1.14.1 =
    386 - Remove comment schema setting for archive pages
     389= 1.14.2 =
     390- Fix transient cache issue, added debug feature
Note: See TracChangeset for help on using the changeset viewer.