woocommerce / facebook-for-woocommerce

A first-party extension plugin built for WooCommerce. Development is managed by Ventures.
https://woocommerce.com/products/facebook/
GNU General Public License v2.0
211 stars 138 forks source link

Allow the description to be filtered by themes or plugins #1761

Open smarx80 opened 3 years ago

smarx80 commented 3 years ago

Hi, using the plugin I noticed a problem in sending title, content and excerpt of products to Facebook. In the file include/fbproduct.php it seems that are used directly $post->content , $post->title etc… which is almost fine, but it doesn’t apply all the filters that are needed and that are set by theme and plugins. In a context where plugins like wpglobus are used for translations, incorrect data are sent, (will be sent also all amount of its placeholders for example, obviously). I have therefore corrected it using the corresponding functions (get_the_title, get_the_excerpt) and applied the corresponding content filter, removing the wptexturize to avoid problems of incorrect rendering of some characters that are not then reconverted on Facebook. Here the diff so you can push in next release if you want. Thanks, Simone.

patch.txt

jconroy commented 3 years ago

Hi @smarx80

Thanks for the issue - seems sensible - we'll need to investigate / double-check. At face value there might be some historic reasons this might not be happening if it is the case.

smarx80 commented 3 years ago

Hi, have you made any progress internally? Is there anything I can do to help you in your decision to merge the patch? Thanks, Simone.

smarx80 commented 3 years ago

@haszari @jconroy can you give me feedback on this issue? At least to know if there is anything I can do, if there are any doubts, and in case there are no obstacles when you plan to publish the changes. Thank you. Simone.

smarx80 commented 2 years ago

Hello @haszari @jconroy, is there anyone on this topic?? Give me a feedback on this issue please. Now ~ 10 month have passed, without any progress, it seems to be quite long time to have an answer. An answer to decide if apply or not apply my patch, or another one that you want. Please answer. Thank you, Simone.

mikkamp commented 2 years ago

Thanks for the patch @smarx80 and sorry for the delayed response.

We have discussed the suggested solution and we prefer to handle this slightly differently.

First of all we'd like to make use of the WC_Product::get_description function (like is done for the variable products). Instead of applying the filter the_content, we would prefer to process the description and prepare it for the feed as needed. This would allow us to apply some specific rules required for the descriptions (like no HTML, maximum length, etc.).

The final description can then be passed through a filter so any plugins/themes can hook into this filter if the content needs to be changed. You can see a similar example of how this is done for one of our other extensions here.

We don't have this solution ready, but we'll leave this issue open so it can be prioritized and a PR can be created.

mikkamp commented 2 years ago

Until this has been resolved a temporary workaround is to use the facebook_for_woocommerce_integration_prepare_product filter to modify the description. Which will still allow you to call the appropriate filters for wpglobus to populate the correct content.

jconroy commented 2 years ago

Marking as low for now as there is a workaround available