Plugin Directory

Changeset 2279121


Ignore:
Timestamp:
04/08/2020 09:25:49 AM (6 years ago)
Author:
sweans
Message:

1.0.2

  • Bug Fixes
Location:
wp-covid-19-schema/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-covid-19-schema/trunk/readme.txt

    r2270735 r2279121  
    33Tags: schema markup, structured data, rich snippets, schema.org, Microdata, schema
    44Requires at least: 3.0
    5 Tested up to: 5.3
     5Tested up to: 5.4
    66Requires PHP: 5.3
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    5252== Changelog ==
    5353
     54= 1.0.2 =
     55
     56* Bug Fixes
     57
    5458= 1.0.1 =
    5559
  • wp-covid-19-schema/trunk/wp-covid19-schema.php

    r2270742 r2279121  
    66 * Author URI: https://sweans.com
    77 * Description: WP COVID-19 Schema plugin adds a schema snippet in the WordPress websites of schools and hospitals to serve the specific purpose of announcements.
    8  * Version: 1.0.1
     8 * Version: 1.0.2
    99 * Text Domain: wp-covid-schema
    1010 * License: GPL3
     
    4343
    4444if (!function_exists('swwpcs_hook_schema')) {
     45
    4546    function swwpcs_hook_schema() {
    4647
    4748        $show_schema = false;
    4849        $schema_control = get_option('swwpcs_schema_control');
    49         if($schema_control == "all" || ( $schema_control == "home" && ( is_home() || is_front_page())) || ( ( $schema_control == "post" || $schema_control == "page" ) && ( get_the_ID() == get_option('swwpcs_schema_page_post_id') ) )) { ?>
    50 <!-- Schema added by WP COVID-19 Schema Plugin -->
    51 <script type="application/ld+json">
    52 {
    53     "@context": "http://schema.org",
    54     "@type": "SpecialAnnouncement",
    55     "name": "<?php echo get_option('swwpcs_name'); ?>",
    56     "text": "<?php echo get_option('swwpcs_text'); ?>",
    57     "datePosted": "<?php echo get_option('swwpcs_date_posted'); ?>",
    58     "url": "<?php echo get_option('swwpcs_article_url'); ?>",
    59     "category": "https://www.wikidata.org/wiki/Q81068910",
    60     "about" : {
    61         "@type": "CovidTestingFacility",
    62         "name": "<?php echo get_option('swwpcs_testing_facility_name'); ?>",
    63         "url": "<?php echo get_bloginfo('url'); ?>"
     50
     51        if($schema_control == "all" || ( $schema_control == "home" && ( is_home() || is_front_page())) || ( ( $schema_control == "post" || $schema_control == "page" ) && ( get_the_ID() == get_option('swwpcs_schema_page_post_id') ) )) {
     52                       
     53            $markup = '<!-- Schema added by WP COVID-19 Schema Plugin -->';
     54            $markup .= '<script type="application/ld+json">';
     55            $markup .= swwpcs_get_json_data();
     56            $markup .= '</script>';
     57            $markup .= '<!-- / Schema added by WP COVID-19 Schema Plugin -->';
     58           
     59            echo $markup;
     60
     61        }
     62       
    6463    }
    65 }
    66 </script>
    67 <!-- / Schema added by WP COVID-19 Schema Plugin -->
    68 <?php }
    69     }
     64
    7065}
    7166
     
    105100    }
    106101}
     102
     103if (!function_exists('swwpcs_get_json_data')) {
     104    function swwpcs_get_json_data(){       
     105        $array = [
     106            '@context' => 'http://schema.org',
     107            '@type' => 'SpecialAnnouncement',
     108            'name' => esc_html(get_option('swwpcs_name')),
     109            'text' => esc_html(get_option('swwpcs_text')),
     110            'datePosted' => esc_html(get_option('swwpcs_date_posted')),
     111            'url' => esc_html(get_option('swwpcs_article_url')),
     112            'category' => 'https://www.wikidata.org/wiki/Q81068910',
     113            'about' => array(
     114                '@type' => "CovidTestingFacility",
     115                'name' => esc_html(get_option('swwpcs_testing_facility_name')),
     116                'url' => esc_html(get_bloginfo('url'))
     117            )
     118        ];
     119
     120        return wp_json_encode($array);
     121
     122    }
     123}
Note: See TracChangeset for help on using the changeset viewer.