Skip to content

Commit 58434ad

Browse files
authored
Merge pull request #233 from ahmedkaludi/1.7
1.7
2 parents f16b3b9 + 87d3a9a commit 58434ad

File tree

9 files changed

+110
-39
lines changed

9 files changed

+110
-39
lines changed

admin_section/common-function.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,11 +1266,11 @@ function saswp_defaultSettings(){
12661266
'sd_alt_name' => $sd_name,
12671267
'sd_url' => $current_url,
12681268
'sd_logo' => array(
1269-
'url' => $logo[0],
1269+
'url' => array_key_exists(0, $logo)? $logo[0]:'',
12701270
'id' => $custom_logo_id,
1271-
'height' => $logo[2],
1272-
'width' => $logo[1],
1273-
'thumbnail' => $logo[0]
1271+
'height' => array_key_exists(2, $logo)? $logo[2]:'',
1272+
'width' => array_key_exists(1, $logo)? $logo[1]:'',
1273+
'thumbnail' => array_key_exists(0, $logo)? $logo[0]:''
12741274
),
12751275
'sd-person-name' => $username,
12761276
'sd-person-job-title'=> '',
@@ -1300,11 +1300,11 @@ function saswp_defaultSettings(){
13001300

13011301
'sd-data-logo-ampforwp' => array(
13021302

1303-
'url' => $logo[0],
1303+
'url' => array_key_exists(0, $logo)? $logo[0]:'',
13041304
'id' => $custom_logo_id,
1305-
'height' => $logo[2],
1306-
'width' => $logo[1],
1307-
'thumbnail' => $logo[0]
1305+
'height' => array_key_exists(2, $logo)? $logo[2]:'',
1306+
'width' => array_key_exists(1, $logo)? $logo[1]:'',
1307+
'thumbnail' => array_key_exists(0, $logo)? $logo[0]:''
13081308

13091309
),
13101310

@@ -1315,14 +1315,14 @@ function saswp_defaultSettings(){
13151315
'saswp-logo-height' => '60',
13161316

13171317
'sd_default_image' => array(
1318-
'url' => $logo[0],
1318+
'url' => array_key_exists(0, $logo)? $logo[0]:'',
13191319
'id' => $custom_logo_id,
1320-
'height' => $logo[2],
1321-
'width' => $logo[1],
1322-
'thumbnail' => $logo[0]
1320+
'height' => array_key_exists(2, $logo)? $logo[2]:'',
1321+
'width' => array_key_exists(1, $logo)? $logo[1]:'',
1322+
'thumbnail' => array_key_exists(0, $logo)? $logo[0]:''
13231323
),
1324-
'sd_default_image_width' => $logo[1],
1325-
'sd_default_image_height' => $logo[2],
1324+
'sd_default_image_width' => array_key_exists(1, $logo)? $logo[1]:'',
1325+
'sd_default_image_height' => array_key_exists(2, $logo)? $logo[2]:'',
13261326
'sd_initial_wizard_status' => 1,
13271327

13281328
);

admin_section/fields-generator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function saswp_field_generator( $meta_fields, $settings ) {
200200
if($note =='' || $proversion == 1){
201201
$output .= '<li><div class="saswp-knowledge-label">'.$label.'</div><div class="saswp-knowledge-field">'.$input.'<p data-id="'.esc_attr($proversion).'">'.esc_html__($note,'schema-and-structured-data-for-wp').'</p></div></li>';
202202
}else{
203-
$output .= '<li><div class="saswp-knowledge-label">'.$label.'</div><div class="saswp-knowledge-field">'.$input.'<p class="saswp_hide">'.esc_html__($note,'schema-and-structured-data-for-wp').'</p></div></li>';
203+
$output .= '<li><div class="saswp-knowledge-label">'.$label.'</div><div class="saswp-knowledge-field">'.$input.'<p class="">'.esc_html__($note,'schema-and-structured-data-for-wp').'</p></div></li>';
204204
}
205205

206206
}

admin_section/js/main-script.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,25 @@ jQuery(document).ready(function($){
280280
$(".saswp_archive_schema_type_class").parent().parent().hide();
281281
}
282282
break;
283+
284+
case 'saswp_website_schema_checkbox':
285+
286+
if ($(this).is(':checked')) {
287+
$("#saswp_website_schema").val(1);
288+
}else{
289+
$("#saswp_website_schema").val(0);
290+
}
291+
break;
292+
293+
case 'saswp_search_box_schema_checkbox':
294+
295+
if ($(this).is(':checked')) {
296+
$("#saswp_search_box_schema").val(1);
297+
}else{
298+
$("#saswp_search_box_schema").val(0);
299+
}
300+
break;
301+
283302
case 'saswp_breadcrumb_schema_checkbox':
284303

285304
if ($(this).is(':checked')) {

admin_section/settings.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,29 @@ function saswp_general_page_callback(){
378378
$settings = saswp_defaultSettings();
379379

380380
$meta_fields_default = array(
381+
array(
382+
'label' => 'Website',
383+
'id' => 'saswp_website_schema_checkbox',
384+
'name' => 'saswp_website_schema_checkbox',
385+
'type' => 'checkbox',
386+
'class' => 'checkbox saswp-checkbox',
387+
'hidden' => array(
388+
'id' => 'saswp_website_schema',
389+
'name' => 'sd_data[saswp_website_schema]',
390+
)
391+
),
392+
array(
393+
'label' => 'Sitelinks Search Box',
394+
'id' => 'saswp_search_box_schema_checkbox',
395+
'name' => 'saswp_search_box_schema_checkbox',
396+
'type' => 'checkbox',
397+
'class' => 'checkbox saswp-checkbox',
398+
'note' => 'To use this feature, Firstly enable website schema',
399+
'hidden' => array(
400+
'id' => 'saswp_search_box_schema',
401+
'name' => 'sd_data[saswp_search_box_schema]',
402+
)
403+
),
381404
array(
382405
'label' => 'Archive',
383406
'id' => 'saswp_archive_schema_checkbox',

output/output.php

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ function saswp_schema_output() {
455455
'@type' => $schema_type ,
456456
'name' => saswp_remove_warnings($schema_data, 'saswp_event_schema_name', 'saswp_string'),
457457
'description' => saswp_remove_warnings($schema_data, 'saswp_event_schema_description', 'saswp_string'),
458-
'startDate' => isset($schema_data['saswp_event_schema_start_date']) && $schema_data['saswp_event_schema_start_date'] !='' ? date('Y-m-d\TH:i:s\Z',$schema_data['saswp_event_schema_start_date']):'',
459-
'endDate' => isset($schema_data['saswp_event_schema_end_date']) && $schema_data['saswp_event_schema_end_date'] !='' ? date('Y-m-d\TH:i:s\Z',$schema_data['saswp_event_schema_end_date']):'',
458+
'startDate' => isset($schema_data['saswp_event_schema_start_date']) && $schema_data['saswp_event_schema_start_date'] !='' ? date('Y-m-d\TH:i:s\Z',strtotime($schema_data['saswp_event_schema_start_date'])):'',
459+
'endDate' => isset($schema_data['saswp_event_schema_end_date']) && $schema_data['saswp_event_schema_end_date'] !='' ? date('Y-m-d\TH:i:s\Z',strtotime($schema_data['saswp_event_schema_end_date'])):'',
460460
'image' => array(
461461
'@type' =>'ImageObject',
462462
'url' => isset($schema_data['saswp_event_schema_image']) ? esc_url($schema_data['saswp_event_schema_image']['url']):'' ,
@@ -480,7 +480,7 @@ function saswp_schema_output() {
480480
'price' => saswp_remove_warnings($schema_data, 'saswp_event_schema_price', 'saswp_string'),
481481
'priceCurrency' => saswp_remove_warnings($schema_data, 'saswp_event_schema_price_currency', 'saswp_string'),
482482
'availability' => saswp_remove_warnings($schema_data, 'saswp_event_schema_availability', 'saswp_string'),
483-
'validFrom' => isset($schema_data['saswp_event_schema_validfrom']) && $schema_data['saswp_event_schema_validfrom'] !='' ? date('Y-m-d\TH:i:s\Z',$schema_data['saswp_event_schema_validfrom']):'',
483+
'validFrom' => isset($schema_data['saswp_event_schema_validfrom']) && $schema_data['saswp_event_schema_validfrom'] !='' ? date('Y-m-d\TH:i:s\Z',strtotime($schema_data['saswp_event_schema_validfrom'])):'',
484484
),
485485
'performer' => array(
486486
'@type' => 'PerformingGroup',
@@ -2707,26 +2707,34 @@ function saswp_schema_breadcrumb_output(){
27072707
*/
27082708
function saswp_kb_website_output(){
27092709

2710+
global $sd_data;
2711+
27102712
$input = array();
27112713

2712-
$site_url = get_site_url();
2714+
if(isset($sd_data['saswp_website_schema']) && $sd_data['saswp_website_schema'] == 1 || !isset($sd_data['saswp_website_schema'])){
2715+
2716+
$site_url = get_site_url();
27132717
$site_name = get_bloginfo();
27142718

27152719
if($site_url && $site_name){
27162720

27172721
$input = array(
2718-
'@context' => 'http://schema.org',
2719-
'@type' => 'WebSite',
2720-
'id' => '#website',
2721-
'url' => $site_url,
2722-
'name' => $site_name,
2723-
'potentialAction' => array(
2724-
'@type' => 'SearchAction',
2725-
'target' => esc_url($site_url).'/?s={search_term_string}',
2726-
'query-input' => 'required name=search_term_string',
2727-
)
2728-
);
2729-
}
2722+
'@context' => 'http://schema.org',
2723+
'@type' => 'WebSite',
2724+
'id' => '#website',
2725+
'url' => $site_url,
2726+
'name' => $site_name,
2727+
);
2728+
2729+
if(isset($sd_data['saswp_search_box_schema']) && $sd_data['saswp_search_box_schema'] == 1 || !isset($sd_data['saswp_search_box_schema'])){
2730+
2731+
$input['potentialAction']['@type'] = 'SearchAction';
2732+
$input['potentialAction']['target'] = esc_url($site_url).'/?s={search_term_string}';
2733+
$input['potentialAction']['query-input'] = 'required name=search_term_string';
2734+
2735+
}
2736+
}
2737+
}
27302738

27312739
return apply_filters('saswp_modify_website_output', $input);
27322740
}

output/review-output.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,16 @@ public function saswp_get_review_box_content(){
126126
</td>
127127
<td>
128128
<div class="saswp-rvw-ov">
129-
<div class="saswp-rvw-fs">'.isset($saswp_over_all_rating)? esc_attr(number_format($saswp_over_all_rating, 2, '.', '')):''.'</div>';
129+
<div class="saswp-rvw-fs">'.isset($saswp_over_all_rating)? esc_attr(number_format((float)$saswp_over_all_rating, 2, '.', '')):''.'</div>';
130130

131131
if($saswp_over_all_rating !=''){
132132

133133
$boxdata.='<div class="tvw-fnl-str saswp-rvw-str">';
134134
$explod = explode('.', $saswp_over_all_rating);
135135

136-
for($x=0;$x<5;$x++) {
136+
if(!empty($explod)){
137+
138+
for($x=0;$x<5;$x++) {
137139

138140
if(isset($explod[1])){
139141

@@ -155,7 +157,10 @@ public function saswp_get_review_box_content(){
155157
$boxdata.='<span class="df-clr"></span>';
156158
}
157159
}
158-
}
160+
}
161+
162+
}
163+
159164
$boxdata.='</div><span class="ovs">'.esc_html__('OVERALL SCORE', 'schema-and-structured-data-for-wp').'</span>';
160165
}
161166
$boxdata.=' </div>

output/service.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,7 @@ public function saswp_get_fetaure_image(){
16351635

16361636
$resize_image = ampforwp_aq_resize( $image_details[0], $width[$i], $height[$i], true, false, true );
16371637

1638-
if(!empty($resize_image)){
1638+
if(isset($resize_image[0]) && isset($resize_image[1]) && isset($resize_image[2]) ){
16391639

16401640
$input2['image'][$i]['@type'] = 'ImageObject';
16411641
$input2['image'][$i]['url'] = esc_url($resize_image[0]);
@@ -1646,7 +1646,13 @@ public function saswp_get_fetaure_image(){
16461646

16471647

16481648
}
1649-
1649+
1650+
if(!empty($input2)){
1651+
foreach($input2 as $arr){
1652+
$input2['image'] = array_values($arr);
1653+
}
1654+
}
1655+
16501656
}else{
16511657

16521658
$input2['image']['@type'] = 'ImageObject';

readme.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: magazine3
33
Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO, AMP
44
Requires at least: 3.0
55
Tested up to: 5.1
6-
Stable tag: 1.6
6+
Stable tag: 1.7
77
License: GPLv2 or later
88
License URI: http://www.gnu.org/licenses/gpl-2.0.html
99

@@ -66,6 +66,16 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
6666
== Changelog ==
6767

6868

69+
= 1.7 (24 April 2019) =
70+
71+
* Added: Option to enable and disable website schema markup #225
72+
* Added: Option to enable and disable Sitelinks Search Box in website schema markup #196
73+
* Bug Fixed: Event Time and date is not changing as per the option #227
74+
* Bug Fixed: Two images url are null from three different image sizes in amp article schema #222
75+
* Bug Fixed: number_format() Debug error #213
76+
* Bug Fixed: Undefined offset errors #214, #232, #229
77+
78+
6979
= 1.6 (12 April 2019) =
7080

7181
* Added : Option to use URL rather than phone number for contact type in Knowledge Graph #199

structured-data-for-wp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
Plugin Name: Schema & Structured Data for WP
44
Description: Schema & Structured Data adds Google Rich Snippets markup according to Schema.org guidelines to structure your site for SEO. (AMP Compatible)
5-
Version: 1.6
5+
Version: 1.7
66
Text Domain: schema-and-structured-data-for-wp
77
Domain Path: /languages
88
Author: Magazine3
@@ -13,7 +13,7 @@
1313
// Exit if accessed directly.
1414
if ( ! defined( 'ABSPATH' ) ) exit;
1515

16-
define('SASWP_VERSION', '1.6');
16+
define('SASWP_VERSION', '1.7');
1717
define('SASWP_DIR_NAME_FILE', __FILE__ );
1818
define('SASWP_DIR_NAME', dirname( __FILE__ ));
1919
define('SASWP_DIR_URI', plugin_dir_url(__FILE__));

0 commit comments

Comments
 (0)