Plugin Directory

Changeset 2266757


Ignore:
Timestamp:
03/24/2020 05:37:45 PM (6 years ago)
Author:
milanmk
Message:

Release 1.15.1

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

    r2263337 r2266757  
    55 * Plugin URI: http://www.schemaapp.com
    66 * Description: This plugin adds http://schema.org structured data to your website
    7  * Version: 1.15.0
     7 * Version: 1.15.1
    88 * Author: Hunch Manifest
    99 * Author URI: https://www.hunchmanifest.com
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaEditor.php

    r2263337 r2266757  
    7676        $MarkupDefault = '';
    7777
    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 
    8478        $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         }
    9279
    9380        // Add an nonce field so we can check for it later.
     
    123110            <div id="schemapostlinks">
    124111                <?php
    125                     if ( $show_markup_final )
     112                    if ( ! $markup_disable )
    126113                    {
    127114                        if ( empty($replacelink) ) {
     
    146133            <div class="MetaSchemaMarkup" style="position: relative;">
    147134                <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 ): ?>
    150137                    <a class="Edit dashicons dashicons-edit" style="<?php print $MarkupCustom ? 'display: none;' : ''; ?> position: absolute; bottom: 10px; right: 32px;" href="#"></a>
    151138                    <a class="Delete dashicons dashicons-trash" style="<?php print $MarkupCustom ? '' : 'display: none;'; ?> position: absolute; bottom: 10px; right: 32px;" href="#"></a>
     
    153140                <?php endif; ?>
    154141            </div>
    155             <?php if ( isset( $schemaObj ) && $show_markup_final ) : ?>
     142            <?php if ( isset( $schemaObj ) && ! $markup_disable ) : ?>
    156143                <strong>Note: </strong>
    157144                <span id="MetaSchemaMarkupNote" style="color: grey"><em>
     
    172159                    <tr>
    173160                        <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%;">
    174169                            Transient
    175170                        </td>
    176171                        <td>
    177                             <?php print $schema_server->transient; ?>
     172                            <?php print $schema_server->transient ? 'Yes' : 'No'; ?>
    178173                        </td>
    179174                    </tr>
     
    191186                        </td>
    192187                        <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>
    194189                        </td>
    195190                    </tr>
     
    206201            <tbody>
    207202
    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>
    227211
    228212                <?php if ( $PostType == 'page' ) : ?>
     
    267251            } else {
    268252                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');
    275253            }
    276254
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaFront.php

    r2263337 r2266757  
    126126            return new WP_REST_Response( array( 'status' => 'error', 'message' => 'Invalid @type, @id or @graph property' ), 400 );
    127127        } 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 ) {
    129132                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 );
    131134                }
    132135
     
    193196        $PostType = get_post_type();
    194197
    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 );
    228244            }
    229245            else
    230246            {
    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 ) )
    239256            {
    240257                if ( $JSON )
    241258                {
    242                     $JSONSchemaMarkup[] = json_decode( $SchemaMarkup );
     259                    $JSONSchemaMarkup[] = json_decode( $SchemaMarkupWebSite );
    243260                }
    244261                else
    245262                {
    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 )
    255275                {
    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 );
    291277                }
    292278                else
    293279                {
    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        }
    298298    }
    299299
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php

    r2263337 r2266757  
    1313        private $resource;
    1414        public $transient_id;
    15         public $transient = 'No';
     15        public $transient = false;
     16        public $page_url;
    1617        public $api_url;
    1718
     
    6364
    6465                // Decode accent characters
    65                 $resource = urldecode( $resource );
     66                $this->page_url = $resource = urldecode( $resource );
    6667
    6768                $this->readLink($resource);
     
    7273                // Check for missing, empty or 'null' transient
    7374                if ($transient !== false && $transient !== 'null') {
    74                     $this->transient = 'Yes';
     75                    $this->transient = true;
    7576                    return $transient;
    7677                }
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaSettings.php

    r2263337 r2266757  
    317317
    318318        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' );
    321319        add_settings_field( 'SchemaDefaultLocation', 'Location where to put the schema markup', array( $this, 'SettingsFieldSchemaDefaultLocation' ), 'schema-app-setting', 'schema-default' );
    322320        add_settings_field( 'SchemaDefaultTypePost', 'Post Default Schema Type', array( $this, 'SettingsFieldSchemaDefaultTypePost' ), 'schema-app-setting', 'schema-default' );
     
    532530
    533531
    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 )
     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 )
    535533        {
    536534            if ( isset( $input[$FieldName] ) && $input[$FieldName] != '' )
     
    753751
    754752    }
    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     }
    789753
    790754
  • schema-app-structured-data-for-schemaorg/trunk/readme.txt

    r2263337 r2266757  
    99Requires PHP: 5.4
    1010Tested up to: 5.3
    11 Stable tag: 1.15.0
     11Stable tag: 1.15.1
    1212License: GPL2
    1313License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8787== Changelog ==
    8888
     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
    8993= 1.15.0 =
    9094- Feature, Added global options for Post/Page to enable or disable schema markup
     
    397401== Upgrade Notice ==
    398402
    399 = 1.15.0 =
    400 - Added global options for Post/Page to enable or disable schema markup
     403= 1.15.1 =
     404- Rollback global options for Post/Page schema markup
Note: See TracChangeset for help on using the changeset viewer.