Plugin Directory

Changeset 2263337


Ignore:
Timestamp:
03/18/2020 05:50:44 PM (6 years ago)
Author:
milanmk
Message:

Release 1.15.0

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

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

    r2153620 r2263337  
    1010class SchemaEditor {
    1111
     12        private $Settings;
    1213        private $PluginURL;
    1314
     
    1718        public function __construct($HunchSchemaPluginURL) {
    1819
     20                $this->Settings = get_option( 'schema_option_name' );
    1921                $this->PluginURL = $HunchSchemaPluginURL;
    2022
     
    7072
    7173        $PostType = get_post_type();
    72         $MarkupDisable = get_post_meta( $post->ID, '_HunchSchemaDisableMarkup', true );
    7374        $MarkupType = get_post_meta( $post->ID, '_HunchSchemaType', true );
    7475        $MarkupCustom = get_post_meta( $post->ID, '_HunchSchemaMarkup', true );
    7576        $MarkupDefault = '';
    7677
     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
    7793        // Add an nonce field so we can check for it later.
    7894        wp_nonce_field('schema_inner_custom_box', 'schema_inner_custom_box_nonce');
    7995
    80         $server = new SchemaServer();
     96        $schema_server = new SchemaServer();
    8197        // Use get_post_meta to retrieve an existing value from the database.       
    82         $jsonLd = $server->getResource(get_permalink($post->ID), true);
     98        $jsonLd = $schema_server->getResource(get_permalink($post->ID), true);
    8399        $MarkupDefault = $jsonLd;
    84100
     
    87103            $MarkupDefault = $schemaObj->getResource(TRUE);
    88104            $jsonLd = $MarkupCustom ? $MarkupCustom : $MarkupDefault;
    89             $replacelink = $server->createLink();
     105            $replacelink = $schema_server->createLink();
    90106        } else {
    91             $editlink = $server->updateLink();
     107            $editlink = $schema_server->updateLink();
    92108        }
    93109        $testlink = "https://developers.google.com/structured-data/testing-tool?url=" . urlencode(get_permalink($post->ID));
     
    107123            <div id="schemapostlinks">
    108124                <?php
    109                     if ( ! $MarkupDisable )
     125                    if ( $show_markup_final )
    110126                    {
    111127                        if ( empty($replacelink) ) {
     
    130146            <div class="MetaSchemaMarkup" style="position: relative;">
    131147                <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 ): ?>
    134150                    <a class="Edit dashicons dashicons-edit" style="<?php print $MarkupCustom ? 'display: none;' : ''; ?> position: absolute; bottom: 10px; right: 32px;" href="#"></a>
    135151                    <a class="Delete dashicons dashicons-trash" style="<?php print $MarkupCustom ? '' : 'display: none;'; ?> position: absolute; bottom: 10px; right: 32px;" href="#"></a>
     
    137153                <?php endif; ?>
    138154            </div>
    139             <?php if ( isset( $schemaObj ) && ! $MarkupDisable ) : ?>
     155            <?php if ( isset( $schemaObj ) && $show_markup_final ) : ?>
    140156                <strong>Note: </strong>
    141157                <span id="MetaSchemaMarkupNote" style="color: grey"><em>
     
    146162        </p>
    147163
     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
    148203        <h4>Markup Options</h4>
    149204
     
    151206            <tbody>
    152207
    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' ) : ?>
    163229                    <tr>
    164230                        <td>
     
    201267            } else {
    202268                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');
    203275            }
    204276
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaFront.php

    r2162317 r2263337  
    191191        }
    192192
    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        {
    198206            $SchemaThing = HunchSchema_Thing::factory( $PostType );
    199 
    200207            $SchemaServer = new SchemaServer();
    201208            $SchemaMarkup = $SchemaServer->getResource();
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaServer.php

    r2155544 r2263337  
    1212        private $options;
    1313        private $resource;
     14        public $transient_id;
     15        public $transient = 'No';
     16        public $api_url;
    1417
    1518        const API_SERVER = "https://api.schemaapp.com/";
     
    6265                $resource = urldecode( $resource );
    6366
     67                $this->readLink($resource);
    6468
    65                 $transient_id = 'HunchSchema-Markup-' . md5($resource);
     69                $this->transient_id = $transient_id = 'HunchSchema-Markup-' . md5($resource);
    6670                $transient = get_transient($transient_id);
    6771
    6872                // Check for missing, empty or 'null' transient
    6973                if ($transient !== false && $transient !== 'null') {
    70                         return $transient;
     74                    $this->transient = 'Yes';
     75                    return $transient;
    7176                }
    7277
     
    99104        protected function readLink($uri = '') {
    100105                $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;
    103111        }
    104112
  • schema-app-structured-data-for-schemaorg/trunk/lib/SchemaSettings.php

    r2155544 r2263337  
    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' );
    319321        add_settings_field( 'SchemaDefaultLocation', 'Location where to put the schema markup', array( $this, 'SettingsFieldSchemaDefaultLocation' ), 'schema-app-setting', 'schema-default' );
    320322        add_settings_field( 'SchemaDefaultTypePost', 'Post Default Schema Type', array( $this, 'SettingsFieldSchemaDefaultTypePost' ), 'schema-app-setting', 'schema-default' );
     
    530532
    531533
    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 )
     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 )
    533535        {
    534536            if ( isset( $input[$FieldName] ) && $input[$FieldName] != '' )
     
    751753
    752754    }
     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    }
    753789
    754790
  • schema-app-structured-data-for-schemaorg/trunk/readme.txt

    r2162317 r2263337  
    88Requires at least: 3.7
    99Requires PHP: 5.4
    10 Tested up to: 5.2
    11 Stable tag: 1.14.4
     10Tested up to: 5.3
     11Stable tag: 1.15.0
    1212License: GPL2
    1313License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8787== Changelog ==
    8888
     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
    8993= 1.14.4 =
    9094- Improve, Webhook by caching all schema markup and better matching of permalinks
     
    393397== Upgrade Notice ==
    394398
    395 = 1.14.4 =
    396 - Improve Webhook by caching all schema markup and better matching of permalinks
     399= 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.