Version Description
- Fix local business @id property
=
Download this release
Release Info
Developer | kcseopro |
Plugin | WP SEO Structured Data Schema |
Version | 2.6.17.2 |
Comparing to | |
See all releases |
Code changes from version 2.6.17.1 to 2.6.17.2
- README.txt +4 -1
- lib/classes/KcSeoOutput.php +217 -213
- lib/models/KcSeoSchemaModel.php +24 -16
- wp-seo-structured-data-schema.php +1 -1
README.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link:
|
|
4 |
Tags: seo, schema, structured data, rich snippets, microdata, json-ld, search engine optimization, local seo, google, sitelinks, schema.org, microformat, serp
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.7
|
7 |
-
Stable tag: 2.6.17.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -114,6 +114,9 @@ You'll find the [FAQ on WPSEMPlugins.com](https://wpsemplugins.com/wordpress-seo
|
|
114 |
|
115 |
== Changelog ==
|
116 |
|
|
|
|
|
|
|
117 |
== 2.6.17.1 =
|
118 |
* Fix post save issue
|
119 |
|
4 |
Tags: seo, schema, structured data, rich snippets, microdata, json-ld, search engine optimization, local seo, google, sitelinks, schema.org, microformat, serp
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.7
|
7 |
+
Stable tag: 2.6.17.2
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
114 |
|
115 |
== Changelog ==
|
116 |
|
117 |
+
== 2.6.17.2 =
|
118 |
+
* Fix local business @id property
|
119 |
+
|
120 |
== 2.6.17.1 =
|
121 |
* Fix post save issue
|
122 |
|
lib/classes/KcSeoOutput.php
CHANGED
@@ -1,216 +1,220 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if (
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
|
|
|
|
|
|
216 |
endif;
|
1 |
<?php
|
2 |
|
3 |
+
if (!class_exists('KcSeoOutput')):
|
4 |
+
|
5 |
+
class KcSeoOutput
|
6 |
+
{
|
7 |
+
function __construct() {
|
8 |
+
add_action('wp_footer', array($this, 'footer'), 99);
|
9 |
+
add_action('amp_post_template_footer', array($this, 'footer'), 999); // AMP support
|
10 |
+
add_action('kcseo_footer', array($this, 'debug_mark'), 2);
|
11 |
+
add_action('kcseo_footer', array($this, 'load_schema'), 3);
|
12 |
+
}
|
13 |
+
|
14 |
+
private function head_product_name() {
|
15 |
+
return 'WP SEO Structured Data Plugin';
|
16 |
+
}
|
17 |
+
|
18 |
+
public function debug_mark($echo = true) {
|
19 |
+
$marker = sprintf(
|
20 |
+
'<!-- This site is optimized with Phil Singleton\'s ' . $this->head_product_name() . ' v%1$s - https://kcseopro.com/wordpress-seo-structured-data-schema-plugin/ -->',
|
21 |
+
KCSEO_WP_SCHEMA_VERSION
|
22 |
+
);
|
23 |
+
|
24 |
+
if ($echo === false) {
|
25 |
+
return $marker;
|
26 |
+
} else {
|
27 |
+
echo "\n${marker}\n";
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function footer() {
|
32 |
+
|
33 |
+
global $wp_query;
|
34 |
+
|
35 |
+
$old_wp_query = null;
|
36 |
+
|
37 |
+
if (!$wp_query->is_main_query()) {
|
38 |
+
$old_wp_query = $wp_query;
|
39 |
+
wp_reset_query();
|
40 |
+
}
|
41 |
+
wp_reset_postdata(); // TODO This is for wrong theme loop
|
42 |
+
do_action('kcseo_footer');
|
43 |
+
|
44 |
+
echo "\n<!-- / ", $this->head_product_name(), ". -->\n\n";
|
45 |
+
|
46 |
+
if (!empty($old_wp_query)) {
|
47 |
+
$GLOBALS['wp_query'] = $old_wp_query;
|
48 |
+
unset($old_wp_query);
|
49 |
+
}
|
50 |
+
|
51 |
+
return;
|
52 |
+
}
|
53 |
+
|
54 |
+
function load_schema() {
|
55 |
+
global $KcSeoWPSchema;
|
56 |
+
$schemaModel = new KcSeoSchemaModel;
|
57 |
+
$html = null;
|
58 |
+
$settings = get_option($KcSeoWPSchema->options['settings']);
|
59 |
+
if (empty($settings['disable_site_schema'])) {
|
60 |
+
if (is_home() || is_front_page()) {
|
61 |
+
$metaData = array();
|
62 |
+
|
63 |
+
$metaData["@context"] = "https://schema.org/";
|
64 |
+
$metaData["@type"] = "WebSite";
|
65 |
+
$author_url = (!empty($settings['siteurl']) ? $settings['siteurl'] : get_home_url());
|
66 |
+
|
67 |
+
if (!empty($settings['homeonly']) && $settings['homeonly']) {
|
68 |
+
$metaData["url"] = $author_url;
|
69 |
+
$metaData["potentialAction"] = array(
|
70 |
+
"@type" => "SearchAction",
|
71 |
+
"target" => trailingslashit(get_home_url()) . "?s={query}",
|
72 |
+
"query-input" => "required name=query"
|
73 |
+
);
|
74 |
+
$html .= $schemaModel->get_jsonEncode($metaData);
|
75 |
+
} else {
|
76 |
+
$metaData["url"] = $KcSeoWPSchema->sanitizeOutPut($author_url, 'url');
|
77 |
+
$metaData["name"] = !empty($settings['sitename']) ? $KcSeoWPSchema->sanitizeOutPut($settings['sitename']) : null;
|
78 |
+
$metaData["alternateName"] = !empty($settings['siteaname']) ? $KcSeoWPSchema->sanitizeOutPut($settings['siteaname']) : null;
|
79 |
+
$html .= $schemaModel->get_jsonEncode($metaData);
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
$siteType = !empty($settings['site_type']) ? $KcSeoWPSchema->sanitizeOutPut($settings['site_type']) : null;
|
84 |
+
$webMeta = [
|
85 |
+
"@context" => "https://schema.org",
|
86 |
+
'@type' => $siteType,
|
87 |
+
'@id' => get_home_url()
|
88 |
+
];
|
89 |
+
if ($siteType != "Organization") {
|
90 |
+
if (!empty($settings['site_image']) && $imgID = absint($settings['site_image'])) {
|
91 |
+
$image_url = wp_get_attachment_url($imgID);
|
92 |
+
$webMeta["image"] = $KcSeoWPSchema->sanitizeOutPut($image_url, 'url');
|
93 |
+
} else {
|
94 |
+
$webMeta["image"] = null;
|
95 |
+
}
|
96 |
+
$webMeta["priceRange"] = !empty($settings['site_price_range']) ? $KcSeoWPSchema->sanitizeOutPut($settings['site_price_range']) : null;
|
97 |
+
$webMeta["telephone"] = !empty($settings['site_telephone']) ? $KcSeoWPSchema->sanitizeOutPut($settings['site_telephone']) : null;
|
98 |
+
}
|
99 |
+
|
100 |
+
if (!empty($settings['additionalType'])) {
|
101 |
+
$aType = explode("\r\n", $settings['additionalType']);
|
102 |
+
if (!empty($aType) && is_array($aType)) {
|
103 |
+
if (count($aType) == 1) {
|
104 |
+
$webMeta["additionalType"] = $aType[0];
|
105 |
+
} else if (count($aType) > 1) {
|
106 |
+
$webMeta["additionalType"] = $aType;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
if ($siteType == 'Person') {
|
112 |
+
$webMeta["name"] = !empty($settings['person']['name']) ? $KcSeoWPSchema->sanitizeOutPut($settings['person']['name']) : null;
|
113 |
+
$webMeta["worksFor"] = !empty($settings['person']['worksFor']) ? $KcSeoWPSchema->sanitizeOutPut($settings['person']['worksFor']) : null;
|
114 |
+
$webMeta["jobTitle"] = !empty($settings['person']['jobTitle']) ? $KcSeoWPSchema->sanitizeOutPut($settings['person']['jobTitle']) : null;
|
115 |
+
$webMeta["image"] = !empty($settings['person']['image']) ? $KcSeoWPSchema->sanitizeOutPut($settings['person']['image'], 'url') : null;
|
116 |
+
$webMeta["description"] = !empty($settings['person']['description']) ? $KcSeoWPSchema->sanitizeOutPut($settings['person']['description'], 'textarea') : null;
|
117 |
+
$webMeta["birthDate"] = !empty($settings['person']['birthDate']) ? $KcSeoWPSchema->sanitizeOutPut($settings['person']['birthDate']) : null;
|
118 |
+
} else {
|
119 |
+
$webMeta["name"] = !empty($settings['type_name']) ? $KcSeoWPSchema->sanitizeOutPut($settings['type_name']) : null;
|
120 |
+
if (!empty($settings['organization_logo']) && $imgID = absint($settings['organization_logo'])) {
|
121 |
+
$image_url = wp_get_attachment_url($imgID);
|
122 |
+
$webMeta["logo"] = $KcSeoWPSchema->sanitizeOutPut($image_url, 'url');
|
123 |
+
} else {
|
124 |
+
$webMeta["logo"] = null;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
if ($siteType != "Organization" && $siteType != "Person") {
|
128 |
+
$webMeta["description"] = !empty($settings['business_info']['description']) ? $KcSeoWPSchema->sanitizeOutPut($settings['business_info']['description'], 'textarea') : null;
|
129 |
+
if (!empty($settings['business_info']['openingHours'])) {
|
130 |
+
$aOhour = explode("\r\n", $settings['business_info']['openingHours']);
|
131 |
+
if (!empty($aOhour) && is_array($aOhour)) {
|
132 |
+
if (count($aOhour) == 1) {
|
133 |
+
$webMeta["openingHours"] = $aOhour[0];
|
134 |
+
} else if (count($aOhour) > 1) {
|
135 |
+
$webMeta["openingHours"] = $aOhour;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
$webMeta["geo"] = array(
|
140 |
+
"@type" => "GeoCoordinates",
|
141 |
+
"latitude" => !empty($settings['business_info']['latitude']) ? $KcSeoWPSchema->sanitizeOutPut($settings['business_info']['latitude']) : null,
|
142 |
+
"longitude" => !empty($settings['business_info']['longitude']) ? $KcSeoWPSchema->sanitizeOutPut($settings['business_info']['longitude']) : null,
|
143 |
+
);
|
144 |
+
}
|
145 |
+
|
146 |
+
if (in_array($siteType, array(
|
147 |
+
'FoodEstablishment',
|
148 |
+
'Bakery',
|
149 |
+
'BarOrPub',
|
150 |
+
'Brewery',
|
151 |
+
'CafeOrCoffeeShop',
|
152 |
+
'FastFoodRestaurant',
|
153 |
+
'IceCreamShop',
|
154 |
+
'Restaurant',
|
155 |
+
'Winery'
|
156 |
+
))) {
|
157 |
+
$webMeta["servesCuisine"] = !empty($settings['restaurant']['servesCuisine']) ? $KcSeoWPSchema->sanitizeOutPut($settings['restaurant']['servesCuisine'], 'textarea') : null;
|
158 |
+
}
|
159 |
+
|
160 |
+
$webMeta["url"] = !empty($settings['web_url']) ? $KcSeoWPSchema->sanitizeOutPut($settings['web_url'], 'url') : $KcSeoWPSchema->sanitizeOutPut(get_home_url(), 'url');
|
161 |
+
if (!empty($settings['social']) && is_array($settings['social'])) {
|
162 |
+
$link = array();
|
163 |
+
foreach ($settings['social'] as $socialD) {
|
164 |
+
if ($socialD['link']) {
|
165 |
+
$link[] = $socialD['link'];
|
166 |
+
}
|
167 |
+
}
|
168 |
+
if (!empty($link)) {
|
169 |
+
$webMeta["sameAs"] = $link;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
$webMeta["contactPoint"] = array(
|
174 |
+
"@type" => "ContactPoint",
|
175 |
+
"telephone" => !empty($settings['contact']['telephone']) ? $KcSeoWPSchema->sanitizeOutPut($settings['contact']['telephone']) : (!empty($settings['site_telephone']) ? $KcSeoWPSchema->sanitizeOutPut($settings['site_telephone']) : null),
|
176 |
+
"contactType" => !empty($settings['contact']['contactType']) ? $KcSeoWPSchema->sanitizeOutPut($settings['contact']['contactType']) : '',
|
177 |
+
"email" => !empty($settings['contact']['email']) ? $KcSeoWPSchema->sanitizeOutPut($settings['contact']['email']) : '',
|
178 |
+
"contactOption" => !empty($settings['contact']['contactOption']) ? $KcSeoWPSchema->sanitizeOutPut($settings['contact']['contactOption']) : '',
|
179 |
+
"areaServed" => !empty($settings['area_served']) ? $settings['area_served'] : '',
|
180 |
+
"availableLanguage" => !empty($settings['availableLanguage']) ? $settings['availableLanguage'] : null
|
181 |
+
);
|
182 |
+
$webMeta["address"] = array(
|
183 |
+
"@type" => "PostalAddress",
|
184 |
+
"addressCountry" => !empty($settings['address']['country']) ? $KcSeoWPSchema->sanitizeOutPut($settings['address']['country']) : null,
|
185 |
+
"addressLocality" => !empty($settings['address']['locality']) ? $KcSeoWPSchema->sanitizeOutPut($settings['address']['locality']) : null,
|
186 |
+
"addressRegion" => !empty($settings['address']['region']) ? $KcSeoWPSchema->sanitizeOutPut($settings['address']['region']) : null,
|
187 |
+
"postalCode" => !empty($settings['address']['postalcode']) ? $KcSeoWPSchema->sanitizeOutPut($settings['address']['postalcode']) : null,
|
188 |
+
"streetAddress" => !empty($settings['address']['street']) ? $KcSeoWPSchema->sanitizeOutPut($settings['address']['street']) : null
|
189 |
+
);
|
190 |
+
|
191 |
+
$main_settings = get_option($KcSeoWPSchema->options['main_settings']);
|
192 |
+
$site_schema = !empty($main_settings['site_schema']) ? $main_settings['site_schema'] : 'home_page';
|
193 |
+
|
194 |
+
if ($site_schema !== 'off') {
|
195 |
+
if ($webMeta["@type"]) {
|
196 |
+
if ($site_schema == 'home_page') {
|
197 |
+
if (is_home() || is_front_page()) {
|
198 |
+
$html .= $schemaModel->get_jsonEncode($webMeta);
|
199 |
+
}
|
200 |
+
} elseif ($site_schema == 'all') {
|
201 |
+
$html .= $schemaModel->get_jsonEncode($webMeta);
|
202 |
+
}
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
if (is_single() || is_page()) {
|
207 |
+
$post = get_queried_object();
|
208 |
+
foreach (KcSeoOptions::getSchemaTypes() as $schemaID => $schema) {
|
209 |
+
$schemaMetaId = $KcSeoWPSchema->KcSeoPrefix . $schemaID;
|
210 |
+
$metaData = get_post_meta($post->ID, $schemaMetaId, true);
|
211 |
+
$metaData = (is_array($metaData) ? $metaData : array());
|
212 |
+
if (!empty($metaData) && !empty($metaData['active'])) {
|
213 |
+
$html .= $schemaModel->schemaOutput($schemaID, $metaData);
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
echo $html;
|
218 |
+
}
|
219 |
+
}
|
220 |
endif;
|
lib/models/KcSeoSchemaModel.php
CHANGED
@@ -16,7 +16,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
16 |
switch ($schemaID) {
|
17 |
case "article":
|
18 |
$article = array(
|
19 |
-
"@context" => "
|
20 |
"@type" => "Article"
|
21 |
);
|
22 |
if (!empty($metaData['headline'])) {
|
@@ -83,7 +83,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
83 |
|
84 |
case "news_article":
|
85 |
$newsArticle = array(
|
86 |
-
"@context" => "
|
87 |
"@type" => "NewsArticle"
|
88 |
);
|
89 |
if (!empty($metaData['headline'])) {
|
@@ -147,7 +147,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
147 |
|
148 |
case "blog_posting":
|
149 |
$blogPosting = array(
|
150 |
-
"@context" => "
|
151 |
"@type" => "BlogPosting"
|
152 |
);
|
153 |
if (!empty($metaData['headline'])) {
|
@@ -211,7 +211,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
211 |
|
212 |
case 'event':
|
213 |
$event = array(
|
214 |
-
"@context" => "
|
215 |
"@type" => "Event"
|
216 |
);
|
217 |
if (!empty($metaData['name'])) {
|
@@ -267,7 +267,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
267 |
$html .= $this->get_jsonEncode(apply_filters('kcseo_snippet_event', $event, $metaData));
|
268 |
if (isset($metaData['review_active'])) {
|
269 |
$event_review = array(
|
270 |
-
"@context" => "
|
271 |
"@type" => "Review"
|
272 |
);
|
273 |
|
@@ -312,7 +312,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
312 |
|
313 |
case 'product':
|
314 |
$product = array(
|
315 |
-
"@context" => "
|
316 |
"@type" => "Product"
|
317 |
);
|
318 |
if (!empty($metaData['name'])) {
|
@@ -373,7 +373,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
373 |
|
374 |
case 'video':
|
375 |
$video = array(
|
376 |
-
"@context" => "
|
377 |
"@type" => "VideoObject"
|
378 |
);
|
379 |
if (!empty($metaData['name'])) {
|
@@ -408,7 +408,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
408 |
|
409 |
case 'service':
|
410 |
$service = array(
|
411 |
-
"@context" => "
|
412 |
"@type" => "Service"
|
413 |
);
|
414 |
if (!empty($metaData['name'])) {
|
@@ -449,7 +449,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
449 |
|
450 |
case 'review':
|
451 |
$review = array(
|
452 |
-
"@context" => "
|
453 |
"@type" => "Review"
|
454 |
);
|
455 |
if (!empty($metaData['itemName'])) {
|
@@ -491,9 +491,12 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
491 |
break;
|
492 |
case 'aggregate_rating':
|
493 |
$aRating = array(
|
494 |
-
"@context" => "
|
495 |
"@type" => !empty($metaData['schema_type']) ? $metaData['schema_type'] : "LocalBusiness"
|
496 |
);
|
|
|
|
|
|
|
497 |
if (!empty($metaData['name'])) {
|
498 |
$aRating["name"] = $KcSeoWPSchema->sanitizeOutPut($metaData['name']);
|
499 |
}
|
@@ -544,7 +547,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
544 |
|
545 |
case 'restaurant':
|
546 |
$restaurant = array(
|
547 |
-
"@context" => "
|
548 |
"@type" => "Restaurant"
|
549 |
);
|
550 |
if (!empty($metaData['name'])) {
|
@@ -582,8 +585,9 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
582 |
|
583 |
case 'localBusiness':
|
584 |
$local_business = array(
|
585 |
-
"@context" => "
|
586 |
-
"@type" => "LocalBusiness"
|
|
|
587 |
);
|
588 |
if (!empty($metaData['name'])) {
|
589 |
$local_business["name"] = $KcSeoWPSchema->sanitizeOutPut($metaData['name']);
|
@@ -616,7 +620,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
616 |
$html .= $this->get_jsonEncode(apply_filters('kcseo_snippet_local_business', $local_business, $metaData));
|
617 |
if (isset($metaData['review_active'])) {
|
618 |
$local_business_review = array(
|
619 |
-
"@context" => "
|
620 |
"@type" => "Review",
|
621 |
);
|
622 |
if (isset($metaData['review_datePublished']) && !empty($metaData['review_datePublished'])) {
|
@@ -669,7 +673,7 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
669 |
break;
|
670 |
case 'specialAnnouncement':
|
671 |
$announcement = array(
|
672 |
-
"@context" => "
|
673 |
"@type" => "SpecialAnnouncement",
|
674 |
"category" => "https://www.wikidata.org/wiki/Q81068910"
|
675 |
);
|
@@ -893,9 +897,13 @@ if (!class_exists('KcSeoSchemaModel')):
|
|
893 |
return $html;
|
894 |
}
|
895 |
|
|
|
|
|
|
|
|
|
|
|
896 |
function get_jsonEncode($data = array()) {
|
897 |
$html = null;
|
898 |
-
/** @var TYPE_NAME $data */
|
899 |
if (!empty($data) && is_array($data)) {
|
900 |
$html .= '<script type="application/ld+json">' . json_encode($data,
|
901 |
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . '</script>';
|
16 |
switch ($schemaID) {
|
17 |
case "article":
|
18 |
$article = array(
|
19 |
+
"@context" => "https://schema.org",
|
20 |
"@type" => "Article"
|
21 |
);
|
22 |
if (!empty($metaData['headline'])) {
|
83 |
|
84 |
case "news_article":
|
85 |
$newsArticle = array(
|
86 |
+
"@context" => "https://schema.org",
|
87 |
"@type" => "NewsArticle"
|
88 |
);
|
89 |
if (!empty($metaData['headline'])) {
|
147 |
|
148 |
case "blog_posting":
|
149 |
$blogPosting = array(
|
150 |
+
"@context" => "https://schema.org",
|
151 |
"@type" => "BlogPosting"
|
152 |
);
|
153 |
if (!empty($metaData['headline'])) {
|
211 |
|
212 |
case 'event':
|
213 |
$event = array(
|
214 |
+
"@context" => "https://schema.org",
|
215 |
"@type" => "Event"
|
216 |
);
|
217 |
if (!empty($metaData['name'])) {
|
267 |
$html .= $this->get_jsonEncode(apply_filters('kcseo_snippet_event', $event, $metaData));
|
268 |
if (isset($metaData['review_active'])) {
|
269 |
$event_review = array(
|
270 |
+
"@context" => "https://schema.org",
|
271 |
"@type" => "Review"
|
272 |
);
|
273 |
|
312 |
|
313 |
case 'product':
|
314 |
$product = array(
|
315 |
+
"@context" => "https://schema.org",
|
316 |
"@type" => "Product"
|
317 |
);
|
318 |
if (!empty($metaData['name'])) {
|
373 |
|
374 |
case 'video':
|
375 |
$video = array(
|
376 |
+
"@context" => "https://schema.org",
|
377 |
"@type" => "VideoObject"
|
378 |
);
|
379 |
if (!empty($metaData['name'])) {
|
408 |
|
409 |
case 'service':
|
410 |
$service = array(
|
411 |
+
"@context" => "https://schema.org",
|
412 |
"@type" => "Service"
|
413 |
);
|
414 |
if (!empty($metaData['name'])) {
|
449 |
|
450 |
case 'review':
|
451 |
$review = array(
|
452 |
+
"@context" => "https://schema.org",
|
453 |
"@type" => "Review"
|
454 |
);
|
455 |
if (!empty($metaData['itemName'])) {
|
491 |
break;
|
492 |
case 'aggregate_rating':
|
493 |
$aRating = array(
|
494 |
+
"@context" => "https://schema.org",
|
495 |
"@type" => !empty($metaData['schema_type']) ? $metaData['schema_type'] : "LocalBusiness"
|
496 |
);
|
497 |
+
if ("LocalBusiness" === $aRating['@type']) {
|
498 |
+
$aRating['@id'] = get_home_url();
|
499 |
+
}
|
500 |
if (!empty($metaData['name'])) {
|
501 |
$aRating["name"] = $KcSeoWPSchema->sanitizeOutPut($metaData['name']);
|
502 |
}
|
547 |
|
548 |
case 'restaurant':
|
549 |
$restaurant = array(
|
550 |
+
"@context" => "https://schema.org",
|
551 |
"@type" => "Restaurant"
|
552 |
);
|
553 |
if (!empty($metaData['name'])) {
|
585 |
|
586 |
case 'localBusiness':
|
587 |
$local_business = array(
|
588 |
+
"@context" => "https://schema.org",
|
589 |
+
"@type" => "LocalBusiness",
|
590 |
+
'@id' => get_home_url()
|
591 |
);
|
592 |
if (!empty($metaData['name'])) {
|
593 |
$local_business["name"] = $KcSeoWPSchema->sanitizeOutPut($metaData['name']);
|
620 |
$html .= $this->get_jsonEncode(apply_filters('kcseo_snippet_local_business', $local_business, $metaData));
|
621 |
if (isset($metaData['review_active'])) {
|
622 |
$local_business_review = array(
|
623 |
+
"@context" => "https://schema.org",
|
624 |
"@type" => "Review",
|
625 |
);
|
626 |
if (isset($metaData['review_datePublished']) && !empty($metaData['review_datePublished'])) {
|
673 |
break;
|
674 |
case 'specialAnnouncement':
|
675 |
$announcement = array(
|
676 |
+
"@context" => "https://schema.org",
|
677 |
"@type" => "SpecialAnnouncement",
|
678 |
"category" => "https://www.wikidata.org/wiki/Q81068910"
|
679 |
);
|
897 |
return $html;
|
898 |
}
|
899 |
|
900 |
+
/**
|
901 |
+
* @param array $data
|
902 |
+
*
|
903 |
+
* @return string|null
|
904 |
+
*/
|
905 |
function get_jsonEncode($data = array()) {
|
906 |
$html = null;
|
|
|
907 |
if (!empty($data) && is_array($data)) {
|
908 |
$html .= '<script type="application/ld+json">' . json_encode($data,
|
909 |
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . '</script>';
|
wp-seo-structured-data-schema.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: WP SEO Structured Data Schema
|
4 |
* Plugin URI: https://wpsemplugins.com/
|
5 |
* Description: Comprehensive JSON-LD based Structured Data solution for WordPress for adding schema for organizations, businesses, blog posts, ratings & more.
|
6 |
-
* Version: 2.6.17.
|
7 |
* Author: WPSEMPlugins
|
8 |
* Author URI: https://wpsemplugins.com/
|
9 |
* Text Domain: wp-seo-structured-data-schema
|
3 |
* Plugin Name: WP SEO Structured Data Schema
|
4 |
* Plugin URI: https://wpsemplugins.com/
|
5 |
* Description: Comprehensive JSON-LD based Structured Data solution for WordPress for adding schema for organizations, businesses, blog posts, ratings & more.
|
6 |
+
* Version: 2.6.17.2
|
7 |
* Author: WPSEMPlugins
|
8 |
* Author URI: https://wpsemplugins.com/
|
9 |
* Text Domain: wp-seo-structured-data-schema
|