Skip to content

Commit

Permalink
Merge pull request #2108 from ahmedkaludi/1.31
Browse files Browse the repository at this point in the history
1.31
  • Loading branch information
shridhamdeveloper authored Apr 29, 2024
2 parents d1010e7 + bce1c4a commit eb75250
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 79 deletions.
4 changes: 2 additions & 2 deletions admin_section/common-function.php
Original file line number Diff line number Diff line change
Expand Up @@ -4424,7 +4424,7 @@ function saswp_get_condition_list($condition, $search = '', $saved_data = ''){
$args['name'] = $saved_data;
}
$choices = get_post_types( $args, 'names');
unset($choices['attachment'], $choices['amp_acf'], $choices['saswp-collections'], $choices['saswp_reviews'], $choices['saswp_reviews_server'], $choices['saswp'] );
unset($choices['amp_acf'], $choices['saswp-collections'], $choices['saswp_reviews'], $choices['saswp_reviews_server'], $choices['saswp'] );

if($choices){
foreach($choices as $key =>$value){
Expand Down Expand Up @@ -4473,7 +4473,7 @@ function saswp_get_condition_list($condition, $search = '', $saved_data = ''){
}else{

$post_types = get_post_types();
unset( $post_types['page'], $post_types['attachment'], $post_types['revision'] , $post_types['nav_menu_item'], $post_types['acf'] , $post_types['amp_acf'],$post_types['saswp'] );
unset( $post_types['page'], $post_types['revision'] , $post_types['nav_menu_item'], $post_types['acf'] , $post_types['amp_acf'],$post_types['saswp'] );

}

Expand Down
5 changes: 4 additions & 1 deletion admin_section/fields-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ class saswp_fields_generator {
"name" => "guaranteed"),
array(
"image" => "/admin_section/images/reviews_platform_icon/webwinkelkeur-img.png",
"name" => "webwinkelkeur"),
"name" => "webwinkelkeur"),
array(
"image" => "/admin_section/images/reviews_platform_icon/dreams-co-img.png",
"name" => "dreams.co.uk")
);

public function saswp_tooltip_message($meta_field_id){
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion admin_section/plugin-installer/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ function saswp_select_schema_fields_callback(){
$post_types = get_post_types( array( 'public' => true ), 'names' );
// Remove Unsupported Post types

unset($post_types['attachment'], $post_types['amp_acf'], $post_types['saswp-collections'], $post_types['saswp_reviews'], $post_types['saswp_reviews_server'], $post_types['saswp'] );
unset($post_types['amp_acf'], $post_types['saswp-collections'], $post_types['saswp_reviews'], $post_types['saswp_reviews_server'], $post_types['saswp'] );
$option = '';

if(count($post_types)>0){
Expand Down
4 changes: 2 additions & 2 deletions admin_section/structure_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ function saswp_style_script_include($hook) {
add_action ( 'save_post' , 'saswp_select_save_data' );

function saswp_select_save_data ( $post_id ) {

if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;

// if our nonce isn't there, or we can't verify it, bail
Expand Down Expand Up @@ -1124,7 +1124,7 @@ function saswp_post_type_generator(){
$post_types = get_post_types( array( 'public' => true ), 'names' );

// Remove Unsupported Post types
unset($post_types['attachment'], $post_types['amp_acf'], $post_types['saswp-collections'], $post_types['saswp_reviews'], $post_types['saswp_reviews_server'], $post_types['saswp'] );
unset($post_types['amp_acf'], $post_types['saswp-collections'], $post_types['saswp_reviews'], $post_types['saswp_reviews_server'], $post_types['saswp'] );

return $post_types;
}
Expand Down
140 changes: 99 additions & 41 deletions modules/gutenberg/includes/class-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,22 @@ public static function render_faq_data( $attributes ) {
}
}

$allowed_tags_title = self::saswp_blocks_description_allowed_tags('title');
$allowed_tags_desc = self::saswp_blocks_description_allowed_tags('description');

$alignment_class = '';
if(isset($attributes['alignment']) && !empty($attributes['alignment'])){
$alignment_class = $attributes['alignment'];
if($alignment_class == 'left'){
$alignment_class = 'has-text-align-left';
}else if($alignment_class == 'right'){
$alignment_class = 'has-text-align-right';
}else if($alignment_class == 'center'){
$alignment_class = 'has-text-align-center';
}

}

foreach($attributes['items'] as $item){

$block_title = isset($item['title'])?$item['title']:'';
Expand All @@ -576,56 +592,45 @@ public static function render_faq_data( $attributes ) {
switch ($attributes['headingTag']) {

case 'h1':
echo sprintf('<h1>%s</h1>', esc_html($block_title));
echo sprintf('<h1 class="%s">%s</h1>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
break;
case 'h2':
echo sprintf('<h2>%s</h2>', esc_html($block_title));
echo sprintf('<h2 class="%s">%s</h2>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
break;
case 'h3':
echo sprintf('<h3>%s</h3>', esc_html($block_title));
echo sprintf('<h3 class="%s">%s</h3>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
break;
case 'h4':
echo sprintf('<h4>%s</h4>', esc_html($block_title));
echo sprintf('<h4 class="%s">%s</h4>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
break;
case 'h5':
echo sprintf('<h5>%s</h5>', esc_html($block_title));
echo sprintf('<h5 class="%s">%s</h5>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
break;
case 'h6':
echo sprintf('<h6>%s</h6>', esc_html($block_title));
echo sprintf('<h6 class="%s">%s</h6>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
break;
case 'div':
echo sprintf('<div>%s</div>', esc_html($block_title));
echo sprintf('<div class="%s">%s</div>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
break;
case 'p':
echo sprintf('<p>%s</p>', esc_html($block_title));
echo sprintf('<p class="%s">%s</p>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
break;
case 'strong':
echo sprintf('<strong>%s</strong>', esc_html($block_title));
echo sprintf('<strong class="%s">%s</strong>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
break;


default:
echo sprintf('<h5>%s</h5>', esc_html($block_title));
echo sprintf('<h5 class="%s">%s</h5>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
break;
}

}else{
echo sprintf('<h5 class="saswp-faq-question-title">%s</h5>', esc_html($block_title));
echo sprintf('<h5 class="saswp-faq-question-title %s">%s</h5>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
}

if(isset($item['description'])){
$allowed_tags = array('img' => array(
'class' => array(),
'id' => array(),
'style' => array(),
'src' => array(),
'key' => array(),
'alt' => array(),
'height' => array(),
'width' => array()
)
);
echo sprintf('<p class="saswp-faq-answer-text">%s</p>', wp_kses($item['description'], $allowed_tags));
echo sprintf('<p class="saswp-faq-answer-text">%s</p>', wp_kses($item['description'], $allowed_tags_desc));
}

}
Expand Down Expand Up @@ -658,6 +663,9 @@ public static function render_how_to_data( $attributes ) {
return '';
}

$allowed_tags_title = self::saswp_blocks_description_allowed_tags('title');
$allowed_tags_desc = self::saswp_blocks_description_allowed_tags('description');

echo '<div class="saswp-how-to-block-section">';

echo '<div class="saswp-how-to-block-steps">';
Expand Down Expand Up @@ -708,7 +716,7 @@ public static function render_how_to_data( $attributes ) {
echo '</p>';
}
if(isset($attributes['description'])){
echo sprintf('<p>%s</p>', esc_html($attributes['description']));
echo sprintf('<p>%s</p>', wp_kses($attributes['description'], $allowed_tags_desc));
}

if(isset($attributes['items'])){
Expand Down Expand Up @@ -749,7 +757,20 @@ public static function render_how_to_data( $attributes ) {
break;
}
}


$alignment_class = '';
if(isset($attributes['alignment']) && !empty($attributes['alignment'])){
$alignment_class = $attributes['alignment'];
if($alignment_class == 'left'){
$alignment_class = 'has-text-align-left';
}else if($alignment_class == 'right'){
$alignment_class = 'has-text-align-right';
}else if($alignment_class == 'center'){
$alignment_class = 'has-text-align-center';
}

}

foreach($attributes['items'] as $item){

$block_title = isset($item['title'])?$item['title']:'';
Expand All @@ -760,24 +781,13 @@ public static function render_how_to_data( $attributes ) {
if(isset($attributes['headingTag']) && !empty($attributes['headingTag'])){
$heading_array = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6');
if(in_array($attributes['headingTag'], $heading_array)){
echo sprintf('<%s> %s </%s>', esc_html($attributes['headingTag']), esc_html($block_title), esc_html($attributes['headingTag']));
echo sprintf('<%s class="%s"> %s </%s>', esc_html($attributes['headingTag']), esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title), esc_html($attributes['headingTag']));
}
}else{
echo sprintf('<h1 class="saswp-how-to-step-name">%s</h1>', esc_html($block_title));
echo sprintf('<h1 class="saswp-how-to-step-name %s">%s</h1>', esc_attr($alignment_class), wp_kses($block_title, $allowed_tags_title));
}
$allowed_tags = array('img' => array(
'class' => array(),
'id' => array(),
'style' => array(),
'src' => array(),
'key' => array(),
'alt' => array(),
'height' => array(),
'width' => array()
)
);

echo sprintf('<p class="saswp-how-to-step-text">%s</p>', wp_kses($item['description'], $allowed_tags));
echo sprintf('<p class="saswp-how-to-step-text">%s</p>', wp_kses($item['description'], $allowed_tags_desc));
echo '</li>';
}

Expand All @@ -799,7 +809,7 @@ public static function render_how_to_data( $attributes ) {
echo '<ul>';
foreach($attributes['tools'] as $val){
if($val['name']){
echo '<li>'. wp_kses_post($val['name']).'</li>';
echo sprintf('<li>%s</li>', wp_kses($val['name'], $allowed_tags_title));
}

}
Expand All @@ -819,7 +829,7 @@ public static function render_how_to_data( $attributes ) {
foreach($attributes['materials'] as $val){

if($val['name']){
echo '<li>'. wp_kses_post($val['name']).'</li>';
echo sprintf('<li>%s</li>', wp_kses($val['name'], $allowed_tags_title));
}

}
Expand Down Expand Up @@ -863,6 +873,54 @@ public static function get_instance() {
return self::$instance;
}

/**
* Return the allowed html tags for description text
* @since 1.31
* @return $allowed_tags Array
* */
public static function saswp_blocks_description_allowed_tags($type = '')
{
$allowed_tags = array();

if($type == 'description'){
$allowed_tags['img'] = array(
'class' => array(),
'id' => array(),
'style' => array(),
'src' => array(),
'key' => array(),
'alt' => array(),
'height' => array(),
'width' => array()
);
}

$allowed_tags['em'] = array();
$allowed_tags['strong'] = array();
$allowed_tags['a'] = array(
'href' => array(),
'target' => array(),
'class' => array(),
'data-type' => array(),
'data-id' => array(),
'rel' => array(),
);
$allowed_tags['mark'] = array(
'style' => array(),
'class' => array(),
);
$allowed_tags['code'] = array();
$allowed_tags['kbd'] = array();
$allowed_tags['bdo'] = array(
'lang' => array(),
'dir' => array()
);
$allowed_tags['s'] = array();
$allowed_tags['sub'] = array();
$allowed_tags['sup'] = array();
return $allowed_tags;
}

}

if ( class_exists( 'SASWP_Gutenberg') ) {
Expand Down
2 changes: 1 addition & 1 deletion modules/rating-box/backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function saswp_review_add_meta_box($post) {
if(saswp_remove_warnings($sd_data, 'saswp-review-module', 'saswp_string')==1){

$show_post_types = get_post_types();
unset($show_post_types['adsforwp'],$show_post_types['saswp'],$show_post_types['attachment'], $show_post_types['revision'], $show_post_types['nav_menu_item'], $show_post_types['user_request'], $show_post_types['custom_css']);
unset($show_post_types['adsforwp'],$show_post_types['saswp'], $show_post_types['revision'], $show_post_types['nav_menu_item'], $show_post_types['user_request'], $show_post_types['custom_css']);
$this->screen = $show_post_types;

if($this->screen){
Expand Down
7 changes: 4 additions & 3 deletions modules/reviews/reviews_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ function saswp_insert_platform_terms(){

$platform_inserted = get_transient('saswp_platform_inserted');

if( $platform_inserted != 104 ){
if( $platform_inserted != 105 ){

$term_array = array(
'Self',
Expand Down Expand Up @@ -531,6 +531,7 @@ function saswp_insert_platform_terms(){
'WordofMouth',
'Guaranteed',
'Webwinkelkeur',
'Dreams.co'
);

foreach($term_array as $term){
Expand All @@ -555,8 +556,8 @@ function saswp_insert_platform_terms(){

}

if( count($term_ids) == 104 ){
set_transient( 'saswp_platform_inserted', 104, 24*7*HOUR_IN_SECONDS );
if( count($term_ids) == 105 ){
set_transient( 'saswp_platform_inserted', 105, 24*7*HOUR_IN_SECONDS );
}

}
Expand Down
4 changes: 3 additions & 1 deletion output/service.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,9 @@ public function saswp_get_meta_list_value($key, $field, $schema_post_id, $schema
}

}else{
$response = get_post_meta($post->ID, $field, true );
if(is_object($post) && isset($post->ID)){
$response = get_post_meta($post->ID, $field, true );
}
}

}else{
Expand Down
Loading

0 comments on commit eb75250

Please sign in to comment.