• Resolved bt_dev

    (@biotrace)


    Hi there – I am using the strip HTML filter but when generating the feed, the plugin will return an error after “processing” a while.

    We are using the following code and version 1.13.1:

    function strip_tags_from_short_description( $attributes, $feed_id, $product_id ) {
    	$attributes['description'] = strip_tags( $attributes['description'] );
    	return $attributes;
    }
    
    add_filter( 'wppfm_feed_item_value', 'strip_tags_from_short_description' );
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Michel Jongbloed

    (@michel-jongbloed)

    Hello @biotrace,

    Just to make sure it its the code that is causing the issue, could you try to deactivate it and see if you then can generate the feed again?

    If the feed still keeps hanging in the processing mode, please try the steps from this FAQ list: https://www.wpmarketingrobot.com/support/faq/#toggle-id-16

    Thread Starter bt_dev

    (@biotrace)

    Hi Michel,

    I can confirm the feed only hangs when the filter is activated.

    I followed all the steps in the FAQ list you supplied and none of the suggestions resolved the issue.

    When the code filter is active, the browser console returns the error:
    POST 500 – https://XXXXX/wp-admin/admin-ajax.php – load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=4.9.8:4

    Plugin Contributor Michel Jongbloed

    (@michel-jongbloed)

    OK, I tested the code and it seems to work alright on my system.

    The function description of strip_tags states the following warning: Because strip_tags() does not actually validate the HTML, partial or broken tags can result in the removal of more text/data than expected.

    So could it be that one of the descriptions is generating an html error when stripped?

    Could you perform a feed generation that fails and then check the feed file to see what product was added last to the file, then check if the next product has something strange in its description?

    Could you also try to generate a feed using only one category and if that works, see if you can single out any category that contains a failing product?

    Also, could you try alternatives for the strip_tags() function, like wp_filter_nohtml_kses() or even use the following line?

    $attributes['description'] = preg_replace ('/<[^>]*>/', ' ', $attributes['description']);

    I know this does not give the same results, but it’s just meant to check.

    Thread Starter bt_dev

    (@biotrace)

    Hi Michel,

    Using the preg_replace function with the suggested line worked perfectly. The full code snippet used is:

    function alter_feed_item( $attributes, $feed_id, $product_id ) {
    	
    	$attributes['description'] = preg_replace("/<[^>]*>/", "", $attributes['description'] );
      
    	// IMPORTANT! Always return the $attributes
    	return $attributes;
    }
    
    add_filter( 'wppfm_feed_item_value', 'alter_feed_item', 10, 3 );

    Thanks for your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Error when using the strip HTML filter’ is closed to new replies.