Skip to content

Commit

Permalink
Merge pull request #1 from damircalusic/mutilingual-patch
Browse files Browse the repository at this point in the history
Make sure that description converts properly with multiplingual brackets
  • Loading branch information
damircalusic authored May 9, 2021
2 parents 0a97c6c + 0f308ca commit 569ef1a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions includes/fbproduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public function set_use_parent_image( $setting ) {

public function get_fb_description() {
if ( $this->fb_description ) {
return $this->fb_description;
return apply_filters( 'the_content', $this->fb_description );
}

$description = get_post_meta(
Expand All @@ -306,18 +306,18 @@ public function get_fb_description() {
);

if ( $description ) {
return $description;
return apply_filters( 'the_content', $description );
}

if ( WC_Facebookcommerce_Utils::is_variation_type( $this->woo_product->get_type() ) ) {

$description = WC_Facebookcommerce_Utils::clean_string( $this->woo_product->get_description() );

if ( $description ) {
return $description;
return apply_filters( 'the_content', $description );
}
if ( $this->main_description ) {
return $this->main_description;
return apply_filters( 'the_content', $this->main_description );
}
}

Expand All @@ -344,7 +344,7 @@ public function get_fb_description() {
$description = $post_title;
}

return $description;
return apply_filters( 'the_content', $description );
}

public function add_sale_price( $product_data, $for_items_batch = false ) {
Expand Down Expand Up @@ -430,7 +430,7 @@ public function get_grouped_product_option_names( $key, $option_values ) {
// Convert all slug_names in $option_values into the visible names that
// advertisers have set to be the display names for a given attribute value
$terms = get_the_terms( $this->id, $key );
return ! is_array( $terms ) ? array() : array_map(
return ! is_array( $terms ) ? [] : array_map(
function ( $slug_name ) use ( $terms ) {
foreach ( $terms as $term ) {
if ( $term->slug === $slug_name ) {
Expand Down Expand Up @@ -565,7 +565,7 @@ public function prepare_product( $retailer_id = null, $type_to_prepare_for = sel
'title' => WC_Facebookcommerce_Utils::clean_string(
$this->get_title()
),
'description' => $this->get_fb_description(),
'description' => strip_tags($this->get_fb_description()),
'image_link' => $image_urls[0],
'additional_image_link' => $this->get_additional_image_urls( $image_urls ),
'link' => $product_url,
Expand All @@ -581,7 +581,7 @@ public function prepare_product( $retailer_id = null, $type_to_prepare_for = sel
'name' => WC_Facebookcommerce_Utils::clean_string(
$this->get_title()
),
'description' => $this->get_fb_description(),
'description' => strip_tags($this->get_fb_description()),
'image_url' => $image_urls[0],
'additional_image_urls' => $this->get_additional_image_urls( $image_urls ),
'url' => $product_url,
Expand Down Expand Up @@ -695,21 +695,20 @@ private function apply_enhanced_catalog_fields_from_attributes( $product_data, $
* Filters list of attributes to only those available for a given product
*
* @param \WC_Product $product WooCommerce Product
* @param array $all_attributes List of Enhanced Catalog attributes to match
* @param array $all_attributes List of Enhanced Catalog attributes to match
* @return array
*/
public function get_matched_attributes_for_product( $product, $all_attributes ) {
$matched_attributes = array();
$sanitized_keys = array_map(
$sanitized_keys = array_map(
function( $key ) {
return \WC_Facebookcommerce_Utils::sanitize_variant_name( $key, false );
},
array_keys( $product->get_attributes() )
);

$matched_attributes = array_filter(
$all_attributes,
function( $attribute ) use ( $sanitized_keys ) {
$matched_attributes = array_filter( $all_attributes,
function( $attribute ) use ($sanitized_keys) {
return in_array( $attribute['key'], $sanitized_keys );
}
);
Expand Down

0 comments on commit 569ef1a

Please sign in to comment.