Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Samuel Aguilera

    (@samuelaguilera)

    There’s no way to specifically detect that the function call is being used. Using DONOTCACHEPAGE would do only part of the job that Fresh Forms does, and only for caching methods that support it, many popular caching plugins and hosts don’t support it.

    I have added a new filter to the development version of the plugin that you can use to provide a list of post ID’s to Fresh Forms to force Fresh Forms run for these posts without the need of doing form detection.

    If you want to give it a try before the release download the modified class-fresh-forms-for-gravity.php file
    And use it to replace your copy of this file in your installation.

    This is an example of how to use the filter.

    add_filter( 'freshforms_post_has_gform', 'fffg_fresh_these_posts' );
    function fffg_fresh_these_posts(){
    	// Force Fresh Forms to run for posts with id 1 and 8.
    	return array( 1, 8);
    }

    I hope that helps.

    Thread Starter androweb

    (@androweb)

    Thanks very much, that’s really helpful to know going forward. Is there a filter planned for categories and tags? basically I have several hundred product pages with embedded forms via function call, that I want to exclude from caching.

    Alternatively, at mo I’m planning to use WP Super Cache, and possibly Cloudflare CDN for files only. So bearing that in mind would the alternative approach I mentioned above work?

    • This reply was modified 4 years, 2 months ago by androweb.
    Plugin Author Samuel Aguilera

    (@samuelaguilera)

    You can use the same filter to cover categories, tags or any other thing related to the post (of any type) that you want to take into consideration to exclude your posts. All that you need to do is to create your own PHP code to do whatever checks you want and return an array with the post ID(s) to exclude.

    Here’s another example that would exclude any WooCommerce product that has a product category with the slug product-category-1

    add_filter( 'freshforms_post_has_gform', 'fffg_fresh_these_products' );
    function fffg_fresh_these_products( $post_has_form ){
    	global $post;
    
    	// Run Fresh Forms for a WooCommerce product if it has one of the following categories slugs.
    	$product_categories = array( 'product-category-1' );
    	if ( is_object( $post ) && 'product' === $post->post_type && has_term( $product_categories, 'product_cat', $post->ID ) ) {
    		return array( $post->ID );
    	}
    
    	// Otherwise.
    	return $post_has_form;
    }
    Thread Starter androweb

    (@androweb)

    Great, thanks for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Function call embedding method’ is closed to new replies.