← All changes
|
includes/integrations/woocommerce/class-convertkit-woocommerce-product-form.php
+5
-26
2.2.2
→
3.4.4
View file →
| @@ -6,9 +6,9 @@ | ||
| 6 | 6 | * @author ConvertKit |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | - * Registers ConvertKit Forms on WooCommerce Products | |
| 10 | + * Outputs ConvertKit Forms on WooCommerce Products. | |
| 11 | 11 | * |
| 12 | 12 | * @package ConvertKit |
| 13 | 13 | * @author ConvertKit |
| 14 | 14 | */ |
| @@ -20,39 +20,18 @@ | ||
| 20 | 20 | * @since 1.9.6 |
| 21 | 21 | */ |
| 22 | 22 | public function __construct() { |
| 23 | 23 | |
| 24 | - add_filter( 'convertkit_get_supported_post_types', array( $this, 'register_post_type_support' ) ); | |
| 25 | 24 | add_action( 'convertkit_output_output_form', array( $this, 'output_form' ) ); |
| 26 | 25 | |
| 27 | 26 | } |
| 28 | 27 | |
| 29 | 28 | /** |
| 30 | - * Register ConvertKit Form support for WooCommerce Products. | |
| 29 | + * Output the ConvertKit Form after the Product's Summary, as `the_content` isn't a reliable | |
| 30 | + * hook to use for output when viewing a WooCommerce Product. | |
| 31 | 31 | * |
| 32 | 32 | * @since 1.9.6 |
| 33 | - * | |
| 34 | - * @param array $post_types Supported Post Types. | |
| 35 | - * @return array $post_types Supported Post Types | |
| 36 | 33 | */ |
| 37 | - public function register_post_type_support( $post_types ) { | |
| 38 | - | |
| 39 | - // Bail if WooCommerce isn't active. | |
| 40 | - if ( ! $this->is_active() ) { | |
| 41 | - return $post_types; | |
| 42 | - } | |
| 43 | - | |
| 44 | - // Register WooCommerce Product support. | |
| 45 | - $post_types[] = 'product'; | |
| 46 | - return $post_types; | |
| 47 | - | |
| 48 | - } | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * Output the ConvertKit Form after the Product's Summary. | |
| 52 | - * | |
| 53 | - * @since 1.9.6 | |
| 54 | - */ | |
| 55 | 34 | public function output_form() { |
| 56 | 35 | |
| 57 | 36 | // Bail if WooCommerce isn't active. |
| 58 | 37 | if ( ! $this->is_active() ) { |
| @@ -79,9 +58,9 @@ | ||
| 79 | 58 | */ |
| 80 | 59 | public function append_form_to_product_summary() { |
| 81 | 60 | |
| 82 | 61 | // Output is already escaped in append_form_to_content(). |
| 83 | - echo WP_ConvertKit()->get_class( 'output' )->append_form_to_content( '' ); // phpcs:ignore WordPress.Security.EscapeOutput | |
| 62 | + echo WP_ConvertKit()->get_class( 'output' )->append_form_to_content( '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 84 | 63 | |
| 85 | 64 | } |
| 86 | 65 | |
| 87 | 66 | /** |
| @@ -101,9 +80,9 @@ | ||
| 101 | 80 | |
| 102 | 81 | // Bootstrap. |
| 103 | 82 | add_action( |
| 104 | 83 | 'convertkit_initialize_global', |
| 105 | - function() { | |
| 84 | + function () { | |
| 106 | 85 | |
| 107 | 86 | new ConvertKit_WooCommerce_Product_Form(); |
| 108 | 87 | |
| 109 | 88 | } |