The previous method was relying on the idea that product pages would not
trigger the `the_content` filter since they don't have to render the
content. Testing revealed that this idea was unreliable.
In one instance WordPress was triggering `the_content` when attempting
to filter the excerpt, even though the excerpt was empty.
This changes the detection method to a much more direct inspection of
the post's content.
MAILPOET-5859
The current logic for form rendering assumes that a single product page
will trigger the filter `the_content`. This is not always true. In cases
where the product has no description, WooCommerce does not render the
description tab at all, which is where that filter usually fires (in my
testing).
This change ensures that we still give these forms a chance to render on
such pages.
MAILPOET-5859
It's possible that other plugins might define wc_get_page_id, so it's
more important to know that WC is installed/active than to know if the
function itself exists.
For good measure I'm including a cast to int even though the WC version
of the function always returns an integer. This is probably unnecessary
but it protects us from the possibility of the WC version of the
function returning something other than an integer in the future.
[MAILPOET-4834]
The WooCommerce Shop page is a special kind of page. It’s basically a post archive.
The Shop page is a placeholder for a post type archive for products. It may render differently than other pages in your install.
https://woocommerce.com/document/woocommerce-pages/#section-4
It doesn’t have any content and WooCommerce core team is also removing the the-content filter from the Shop listing page hence why we are unable to hook into the the-content filter we use for other parts of the codebase
MAILPOET-4663
The only thing Security::generateToken was providing was a default value
for the $action, which created a pattern of using the same $action
everywhere, which may not be the best way to go.
Since it was essentially a wrapper for WP's built-in nonce functions,
it seemed clearer to use those functions directly to be more explicit
about how we're handling tokens.
[MAILPOET-2030]