Skip to content

Commit 35d119c

Browse files
authored
Merge pull request #2061 from ahmedkaludi/1.26
1.26
2 parents afee827 + 35db463 commit 35d119c

File tree

9 files changed

+55
-14
lines changed

9 files changed

+55
-14
lines changed

modules/rating-box/frontend.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ public function saswp_review_hooks(){
2828
*/
2929
public function saswp_review_display_via_shortcode($attr){
3030

31-
$review_id = $attr['id'];
31+
$review_id = '';
32+
if(isset($attr['id'])){
33+
$review_id = $attr['id'];
34+
}
3235

33-
if(isset($review_id)){
36+
if($review_id > 0){
3437

3538
$result = $this->saswp_get_review_box_content();
3639
return $result;

modules/reviews/reviews_collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public function saswp_reviews_collection_shortcode_render($attr){
436436

437437
if(!is_admin()){
438438

439-
if(isset($attr['id'])){
439+
if(isset($attr['id']) && $attr['id'] > 0){
440440
$collection_post_status = get_post_status($attr['id']);
441441
if($collection_post_status == 'publish'){
442442
$total_reviews = array();

modules/reviews/reviews_form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function saswp_reviews_form_amp_script($data){
209209
}
210210

211211
public function saswp_reviews_form_render($attr){
212-
212+
$attr = saswp_wp_kses_post($attr);
213213
$on_button = false;
214214

215215
update_option('saswp_g_site_key', '');

modules/reviews/reviews_service.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,12 @@ public function saswp_fetch_google_reviews(){
555555
public function saswp_reviews_shortcode($attr){
556556

557557
$response = '';
558+
if(isset($attr['id'])){
559+
$attr['id'] = intval($attr['id']);
560+
if($attr['id'] <= 0){
561+
return $response;
562+
}
563+
}
558564

559565
$reviews = $this->saswp_get_reviews_list_by_parameters($attr);
560566

modules/tinymce/register-shortcodes.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function saswp_tiny_howto_render( $atts, $content = null ){
88

99
$output = '';
1010

11+
$atts = saswp_wp_kses_post($atts);
1112
$saswp_tiny_howto = shortcode_atts(
1213
[
1314
'css_class' => '',
@@ -73,7 +74,7 @@ function saswp_tiny_howto_render( $atts, $content = null ){
7374
}
7475

7576
if( !empty($saswp_tiny_howto['description']) ){
76-
$output .= '<p>'.html_entity_decode(esc_attr($saswp_tiny_howto['description'])).'</p>';
77+
$output .= '<p>'.wp_kses_post($saswp_tiny_howto['description']).'</p>';
7778
}
7879

7980
if( !empty($saswp_tiny_howto['elements']) ){
@@ -86,8 +87,8 @@ function saswp_tiny_howto_render( $atts, $content = null ){
8687
if($value['step_title'] || $value['step_description']){
8788

8889
$output .= '<li>';
89-
$output .= '<strong class="saswp-how-to-step-name">'. html_entity_decode(esc_attr($value['step_title'])).'</strong>';
90-
$output .= '<p class="saswp-how-to-step-text">'.html_entity_decode(esc_textarea($value['step_description']));
90+
$output .= '<strong class="saswp-how-to-step-name">'. wp_kses_post($value['step_title']).'</strong>';
91+
$output .= '<p class="saswp-how-to-step-text">'.wp_kses_post($value['step_description']);
9192

9293
if ( ! empty( $value['image'] ) ) {
9394

@@ -123,6 +124,7 @@ function saswp_tiny_multi_faq_render( $atts, $content = null ){
123124

124125
$output = '';
125126

127+
$atts = saswp_wp_kses_post($atts);
126128
$saswp_tiny_multi_faq = shortcode_atts(
127129
[
128130
'css_class' => '',
@@ -188,6 +190,7 @@ function saswp_tiny_faq_render( $atts, $content = null ){
188190

189191
global $saswp_tiny_faq;
190192

193+
$atts = saswp_wp_kses_post($atts);
191194
$saswp_tiny_faq = shortcode_atts(
192195
[
193196
'headline' => 'h2',
@@ -244,6 +247,7 @@ function saswp_tiny_recipe_render( $atts, $content = null ){
244247

245248
$output = '';
246249

250+
$atts = saswp_wp_kses_post($atts);
247251
$saswp_tiny_recipe = shortcode_atts(
248252
[
249253
'recipe_by' => '',
@@ -352,4 +356,20 @@ function saswp_tiny_recipe_render( $atts, $content = null ){
352356
$output .= '</div>'; // saswp-recipe-block-container div end
353357
}
354358
return $output;
359+
}
360+
361+
/**
362+
* Sanitize shortcode attributes
363+
* @since 1.26
364+
* @param $atts array
365+
* @return $atts array
366+
* */
367+
function saswp_wp_kses_post($atts=array())
368+
{
369+
if(!empty($atts) && is_array($atts)){
370+
foreach ($atts as $atts_key => $atts_value) {
371+
$atts[$atts_key] = wp_kses_post($atts_value);
372+
}
373+
}
374+
return $atts;
355375
}

output/function.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,9 +1852,12 @@ function saswp_get_the_tags(){
18521852

18531853
$meta_tag = array_column($post_meta, 'value');
18541854
$key = array_search("keywords",$meta_tag);
1855-
1856-
if(array_key_exists($key, $post_meta)){
1857-
$tag_str = $post_meta[$key]['content'];
1855+
if(!empty($key)){
1856+
if(is_numeric($key) || is_string($key)){
1857+
if(array_key_exists($key, $post_meta)){
1858+
$tag_str = $post_meta[$key]['content'];
1859+
}
1860+
}
18581861
}
18591862

18601863
}

output/service.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ public function saswp_get_meta_list_value($key, $field, $schema_post_id, $schema
155155
$response = get_site_url();
156156
break;
157157
case 'post_title':
158-
$response = @get_the_title();
158+
$response = @get_the_title();
159+
if(empty($response)){
160+
$response = @get_the_title(get_the_ID());
161+
}
159162
break;
160163
case 'post_content':
161164
$response = @get_the_content();

readme.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: Schema, Structured Data, Google Snippets, Rich Snippets, Schema.org, SEO,
44
Requires at least: 3.0
55
Tested up to: 6.4
66
Requires PHP: 5.6.20
7-
Stable tag: 1.25
7+
Stable tag: 1.26
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -121,6 +121,12 @@ You can contact us from [here](http://structured-data-for-wp.com/contact-us/)
121121

122122
== Changelog ==
123123

124+
= 1.26 (10 Jan 2024) =
125+
126+
* Fixed: Event schema automation issues #2058
127+
* Fixed: PHP warnings #2059
128+
* Fixed: Cross Site Scripting (XSS) vulnerability reported by patchstack.com
129+
124130
= 1.25 (16 Dec 2023) =
125131

126132
* Enhancement: Added ‘acceptedAnswer’ and ‘suggestedAnswer’ globally in Q&A schema #1967

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 & AMP
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.25
5+
Version: 1.26
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.25');
16+
define('SASWP_VERSION', '1.26');
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)