From 06e5762386935ccc1f98c8a2d61a45ec21a82d61 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 21 Nov 2024 16:05:46 +0800 Subject: [PATCH 01/15] Block Visibility: Support non-inline Forms --- .github/workflows/tests.yml | 2 +- .../blocks/class-convertkit-block-form.php | 7 +++ includes/blocks/class-convertkit-block.php | 45 +++++++++++++++++ .../blocks-shortcodes/PageBlockFormCest.php | 49 +++++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b8a65247f..f8852ad78 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,7 +31,7 @@ jobs: DB_USER: root DB_PASS: root DB_HOST: localhost - INSTALL_PLUGINS: "admin-menu-editor autoptimize beaver-builder-lite-version contact-form-7 classic-editor custom-post-type-ui elementor forminator jetpack-boost woocommerce wordpress-seo wpforms-lite litespeed-cache wp-crontrol wp-super-cache w3-total-cache wp-fastest-cache wp-optimize sg-cachepress" # Don't include this repository's Plugin here. + INSTALL_PLUGINS: "admin-menu-editor autoptimize beaver-builder-lite-version block-visibility contact-form-7 classic-editor custom-post-type-ui elementor forminator jetpack-boost woocommerce wordpress-seo wpforms-lite litespeed-cache wp-crontrol wp-super-cache w3-total-cache wp-fastest-cache wp-optimize sg-cachepress" # Don't include this repository's Plugin here. INSTALL_PLUGINS_URLS: "https://downloads.wordpress.org/plugin/convertkit-for-woocommerce.1.6.4.zip http://cktestplugins.wpengine.com/wp-content/uploads/2024/01/convertkit-action-filter-tests.zip" # URLs to specific third party Plugins CONVERTKIT_API_KEY: ${{ secrets.CONVERTKIT_API_KEY }} # ConvertKit API Key, stored in the repository's Settings > Secrets CONVERTKIT_API_SECRET: ${{ secrets.CONVERTKIT_API_SECRET }} # ConvertKit API Secret, stored in the repository's Settings > Secrets diff --git a/includes/blocks/class-convertkit-block-form.php b/includes/blocks/class-convertkit-block-form.php index 9831500a0..dfb0081fc 100644 --- a/includes/blocks/class-convertkit-block-form.php +++ b/includes/blocks/class-convertkit-block-form.php @@ -290,6 +290,13 @@ public function get_default_values() { */ public function render( $atts ) { + // Check if the Block Visibility Plugin permits displaying this block. + if ( ! $this->is_block_visible( $atts ) ) { + // Block should not be displayed due to Block Visibility Plugin conditions. + // Return a blank string now. + return ''; + } + // Parse shortcode attributes, defining fallback defaults if required. $atts = shortcode_atts( $this->get_default_values(), diff --git a/includes/blocks/class-convertkit-block.php b/includes/blocks/class-convertkit-block.php index a4440627a..61eeded22 100644 --- a/includes/blocks/class-convertkit-block.php +++ b/includes/blocks/class-convertkit-block.php @@ -382,4 +382,49 @@ public function is_block_editor_request() { } + /** + * If the Block Visiblity Plugin is active, run the block through its conditions now. + * We don't wait for Block Visibility to do this, as it performs this on the + * `render_block` filter, by which time the code in this method has fully executed, + * meaning any non-inline Forms will have had their scripts added to the + * `convertkit_output_scripts_footer` hook. + * As a result, the non-inline Form will always display, regardless of whether + * Block Visibility's conditions are met. + * We deliberately don't output non-inline Forms in their block, instead deferring + * to the `convertkit_output_scripts_footer` hook, to ensure the non-inline Forms + * styling are not constrained by the Theme's width, layout or other properties. + * + * @since 2.6.6 + * + * @param array $atts Block Attributes. + * @return bool Display Block + */ + public function is_block_visible( $atts ) { + + // Display the block if the Block Visibility Plugin isn't active. + if ( ! function_exists( '\BlockVisibility\Frontend\render_with_visibility' ) ) { + return true; + } + + // Determine whether the block should display. + $display_block = \BlockVisibility\Frontend\render_with_visibility( + 'block', + array( + 'blockName' => 'convertkit-' . $this->get_name(), + 'attrs' => $atts, + ) + ); + + // If the content returned is a blank string, conditions on this block set + // by the user in the Block Visibility Plugin resulted in the block not displaying. + // Don't display it. + if ( empty( $display_block ) ) { + return false; + } + + // If here, the block can be displayed. + return true; + + } + } diff --git a/tests/acceptance/forms/blocks-shortcodes/PageBlockFormCest.php b/tests/acceptance/forms/blocks-shortcodes/PageBlockFormCest.php index 8790b3fae..edd5cb436 100644 --- a/tests/acceptance/forms/blocks-shortcodes/PageBlockFormCest.php +++ b/tests/acceptance/forms/blocks-shortcodes/PageBlockFormCest.php @@ -1026,6 +1026,55 @@ public function testFormBlockWithWPRocketPluginMinifyJS(AcceptanceTester $I) $I->deactivateThirdPartyPlugin($I, 'wp-rocket'); } + /** + * Test that a non-inline Form is not displayed when specified in the Form Block and the + * Block Visibility Plugin sets the block to not display. + * + * @since 2.6.6 + * + * @param AcceptanceTester $I Tester. + */ + public function testFormBlockWithNonInlineFormAndBlockVisibilityPlugin(AcceptanceTester $I) + { + // Setup Plugin and Resources. + $I->setupConvertKitPlugin($I); + $I->setupConvertKitPluginResources($I); + + // Activate Block Visibility Plugin. + $I->activateThirdPartyPlugin($I, 'block-visibility'); + + // Create a Page as if it were create in Gutenberg with the Form block + // set to display a non-inline Form, and the Block Visibility Plugin + // set to hide the block. + $pageID = $I->havePostInDatabase( + [ + 'post_type' => 'page', + 'post_title' => 'Kit: Page: Form: Block: Block Visibility', + 'post_content' => '', + 'meta_input' => [ + // Configure ConvertKit Plugin to not display a default Form. + '_wp_convertkit_post_meta' => [ + 'form' => '0', + 'landing_page' => '', + 'tag' => '', + ], + ], + ] + ); + + // Load Page. + $I->amOnPage('?p=' . $pageID); + + // Check that no PHP warnings or notices were output. + $I->checkNoWarningsAndNoticesOnScreen($I); + + // Confirm that no ConvertKit Form is displayed. + $I->dontSeeElementInDOM('form[data-sv-form]'); + + // Deactivate Block Visibility Plugin. + $I->deactivateThirdPartyPlugin($I, 'block-visibility'); + } + /** * Deactivate and reset Plugin(s) after each test, if the test passes. * We don't use _after, as this would provide a screenshot of the Plugin From 01294735c550c3c7ef0d4f977a58b5d7199ea012 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Sat, 23 Nov 2024 09:47:56 +0800 Subject: [PATCH 02/15] Fix characater encoding when inserting Form after specific HTML element --- includes/class-convertkit-output.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/includes/class-convertkit-output.php b/includes/class-convertkit-output.php index 69cb16bb7..41eb38078 100644 --- a/includes/class-convertkit-output.php +++ b/includes/class-convertkit-output.php @@ -391,6 +391,15 @@ public function append_form_to_content( $content ) { */ private function inject_form_after_element( $content, $tag, $index, $form ) { + // Wrap content in , and tags now, so we can inject the UTF-8 Content-Type meta tag. + $content = '' . $content . ''; + + // Forcibly tell DOMDocument that this HTML uses the UTF-8 charset. + // isn't enough, as DOMDocument still interprets the HTML as ISO-8859, which breaks character encoding + // Use of mb_convert_encoding() with HTML-ENTITIES is deprecated in PHP 8.2, so we have to use this method. + // If we don't, special characters render incorrectly. + $content = str_replace( '', '' . "\n" . '', $content ); + // Load Page / Post content into DOMDocument. libxml_use_internal_errors( true ); $html = new DOMDocument(); From 1ab25aa64f7824f00c2a271a3c866e91b69e27df Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 09:01:02 +0800 Subject: [PATCH 03/15] Added tests --- .../Helper/Acceptance/WPGutenberg.php | 2 +- .../forms/post-types/CPTFormCest.php | 12 +++++ .../forms/post-types/PageFormCest.php | 48 +++++++++++++++++++ .../forms/post-types/PostFormCest.php | 12 +++++ 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/tests/_support/Helper/Acceptance/WPGutenberg.php b/tests/_support/Helper/Acceptance/WPGutenberg.php index 4e80ec56b..3b76886e6 100644 --- a/tests/_support/Helper/Acceptance/WPGutenberg.php +++ b/tests/_support/Helper/Acceptance/WPGutenberg.php @@ -405,7 +405,7 @@ public function addGutenbergPageToDatabase($I, $postType = 'page', $title = 'Gut -

Item #2

+

Item #2: Adhaésionés altéram improbis mi pariendarum sit stulti triarium

diff --git a/tests/acceptance/forms/post-types/CPTFormCest.php b/tests/acceptance/forms/post-types/CPTFormCest.php index 59904c298..0a5b968cd 100644 --- a/tests/acceptance/forms/post-types/CPTFormCest.php +++ b/tests/acceptance/forms/post-types/CPTFormCest.php @@ -314,6 +314,9 @@ public function testAddNewCPTUsingDefaultFormAfterParagraphElement(AcceptanceTes // Confirm that one ConvertKit Form is output in the DOM after the third paragraph. $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'p', 3); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); } /** @@ -350,6 +353,9 @@ public function testAddNewCPTUsingDefaultFormAfterHeadingElement(AcceptanceTeste // Confirm that one ConvertKit Form is output in the DOM after the second

element. $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'h2', 2); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); } /** @@ -386,6 +392,9 @@ public function testAddNewCPTUsingDefaultFormAfterImageElement(AcceptanceTester // Confirm that one ConvertKit Form is output in the DOM after the second element. $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'img', 2); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); } /** @@ -423,6 +432,9 @@ public function testAddNewCPTUsingDefaultFormAfterOutOfBoundsElement(AcceptanceT // Confirm that one ConvertKit Form is output in the DOM after the content, as // the number of paragraphs is less than the position. $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_content'); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); } /** diff --git a/tests/acceptance/forms/post-types/PageFormCest.php b/tests/acceptance/forms/post-types/PageFormCest.php index 21831ee0c..9821fb16c 100644 --- a/tests/acceptance/forms/post-types/PageFormCest.php +++ b/tests/acceptance/forms/post-types/PageFormCest.php @@ -238,6 +238,48 @@ public function testAddNewPageUsingDefaultFormAfterParagraphElement(AcceptanceTe // Confirm that one ConvertKit Form is output in the DOM after the third paragraph. $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'p', 3); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); + } + + /** + * Test that the Default Form specified in the Plugin Settings works when + * creating and viewing a new WordPress Page, and its position is set + * to after the 2nd

element. + * + * @since 2.6.6 + * + * @param AcceptanceTester $I Tester. + */ + public function testAddNewPageUsingDefaultFormAfterHeadingElement(AcceptanceTester $I) + { + // Setup ConvertKit plugin with Default Form for CPTs set to be output after the 2nd

of content. + $I->setupConvertKitPlugin( + $I, + [ + 'article_form' => $_ENV['CONVERTKIT_API_FORM_ID'], + 'article_form_position' => 'after_element', + 'article_form_position_element' => 'h2', + 'article_form_position_element_index' => 2, + ] + ); + $I->setupConvertKitPluginResources($I); + + // Setup Article with placeholder content. + $pageID = $I->addGutenbergPageToDatabase($I, 'page', 'Kit: Page: Form: Default: After 2nd H2 Element'); + + // View the CPT on the frontend site. + $I->amOnPage('?p=' . $pageID); + + // Check that no PHP warnings or notices were output. + $I->checkNoWarningsAndNoticesOnScreen($I); + + // Confirm that one ConvertKit Form is output in the DOM after the second

element. + $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'h2', 2); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); } /** @@ -274,6 +316,9 @@ public function testAddNewPageUsingDefaultFormAfterImageElement(AcceptanceTester // Confirm that one ConvertKit Form is output in the DOM after the second element. $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'img', 2); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); } /** @@ -311,6 +356,9 @@ public function testAddNewPageUsingDefaultFormAfterOutOfBoundsElement(Acceptance // Confirm that one ConvertKit Form is output in the DOM after the content, as // the number of paragraphs is less than the position. $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_content'); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); } /** diff --git a/tests/acceptance/forms/post-types/PostFormCest.php b/tests/acceptance/forms/post-types/PostFormCest.php index bb450c65f..073f556aa 100644 --- a/tests/acceptance/forms/post-types/PostFormCest.php +++ b/tests/acceptance/forms/post-types/PostFormCest.php @@ -237,6 +237,9 @@ public function testAddNewPostUsingDefaultFormAfterParagraphElement(AcceptanceTe // Confirm that one ConvertKit Form is output in the DOM after the third paragraph. $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'p', 3); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); } /** @@ -273,6 +276,9 @@ public function testAddNewPostUsingDefaultFormAfterHeadingElement(AcceptanceTest // Confirm that one ConvertKit Form is output in the DOM after the second

element. $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'h2', 2); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); } /** @@ -309,6 +315,9 @@ public function testAddNewPostUsingDefaultFormAfterImageElement(AcceptanceTester // Confirm that one ConvertKit Form is output in the DOM after the second element. $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_element', 'img', 2); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); } /** @@ -346,6 +355,9 @@ public function testAddNewPostUsingDefaultFormAfterOutOfBoundsElement(Acceptance // Confirm that one ConvertKit Form is output in the DOM after the content, as // the number of paragraphs is less than the position. $I->seeFormOutput($I, $_ENV['CONVERTKIT_API_FORM_ID'], 'after_content'); + + // Confirm character encoding is not broken due to using DOMDocument. + $I->seeInSource('Adhaésionés altéram improbis mi pariendarum sit stulti triarium'); } /** From dd54bc1fe895625b59a641dd15492d28df80ab03 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 09:55:31 +0800 Subject: [PATCH 04/15] Tests: Update WP Crontrol URL for 1.17.1 --- tests/_support/Helper/Acceptance/WPCron.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/_support/Helper/Acceptance/WPCron.php b/tests/_support/Helper/Acceptance/WPCron.php index 7114632af..7dce90e30 100644 --- a/tests/_support/Helper/Acceptance/WPCron.php +++ b/tests/_support/Helper/Acceptance/WPCron.php @@ -9,6 +9,15 @@ */ class WPCron extends \Codeception\Module { + /** + * Holds the admin UI URL for WP Crontrol. + * + * @since 2.6.6 + * + * @var string + */ + private $adminURL = 'tools.php?page=wp-crontrol'; + /** * Asserts if the given event name is scheduled in WordPress' Cron. * @@ -49,7 +58,7 @@ public function dontSeeCronEvent($I, $name) public function runCronEvent($I, $name) { // List cron event in WP-Crontrol Plugin. - $I->amOnAdminPage('tools.php?page=crontrol_admin_manage_page&s=' . $name); + $I->amOnAdminPage($this->adminURL . '&s=' . $name); // Hover mouse over event's name. $I->moveMouseOver('#the-list tr'); @@ -74,7 +83,7 @@ public function runCronEvent($I, $name) public function deleteCronEvent($I, $name) { // List cron event in WP-Crontrol Plugin. - $I->amOnAdminPage('tools.php?page=crontrol_admin_manage_page&s=' . $name); + $I->amOnAdminPage($this->adminURL . '&s=' . $name); // Hover mouse over event's name. $I->moveMouseOver('#the-list tr'); From de1977474e558dbe427acb033b24c5c7f0b7ca61 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 13:01:58 +0800 Subject: [PATCH 05/15] =?UTF-8?q?Tests:=20Install=20=E2=80=98Disable=20doi?= =?UTF-8?q?ng=5Fit=5Fwrong=E2=80=99=20Plugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b8a65247f..834b697b0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,7 @@ jobs: DB_PASS: root DB_HOST: localhost INSTALL_PLUGINS: "admin-menu-editor autoptimize beaver-builder-lite-version contact-form-7 classic-editor custom-post-type-ui elementor forminator jetpack-boost woocommerce wordpress-seo wpforms-lite litespeed-cache wp-crontrol wp-super-cache w3-total-cache wp-fastest-cache wp-optimize sg-cachepress" # Don't include this repository's Plugin here. - INSTALL_PLUGINS_URLS: "https://downloads.wordpress.org/plugin/convertkit-for-woocommerce.1.6.4.zip http://cktestplugins.wpengine.com/wp-content/uploads/2024/01/convertkit-action-filter-tests.zip" # URLs to specific third party Plugins + INSTALL_PLUGINS_URLS: "https://downloads.wordpress.org/plugin/convertkit-for-woocommerce.1.6.4.zip http://cktestplugins.wpengine.com/wp-content/uploads/2024/01/convertkit-action-filter-tests.zip http://cktestplugins.wpengine.com/wp-content/uploads/2024/11/disable-doing-it-wrong-notices.zip" # URLs to specific third party Plugins CONVERTKIT_API_KEY: ${{ secrets.CONVERTKIT_API_KEY }} # ConvertKit API Key, stored in the repository's Settings > Secrets CONVERTKIT_API_SECRET: ${{ secrets.CONVERTKIT_API_SECRET }} # ConvertKit API Secret, stored in the repository's Settings > Secrets CONVERTKIT_API_KEY_NO_DATA: ${{ secrets.CONVERTKIT_API_KEY_NO_DATA }} # ConvertKit API Key for ConvertKit account with no data, stored in the repository's Settings > Secrets From 96193817213023a65f3680e246c251d2fbad0e63 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 13:05:27 +0800 Subject: [PATCH 06/15] Activate Plugin --- .github/workflows/tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 834b697b0..919eed39e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -137,6 +137,13 @@ jobs: working-directory: ${{ env.ROOT_DIR }} run: wp-cli plugin install ${{ env.INSTALL_PLUGINS_URLS }} + # Activates the Disable `_load_textdomain_just_in_time` `doing_it_wrong` notice Plugin, + # to prevent _load_textdomain_just_in_time PHP notices in WordPress 6.7+ due to third + # party Plugins. + - name: Activate "Disable `_load_textdomain_just_in_time` `doing_it_wrong` notice Plugin" + working-directory: ${{ env.ROOT_DIR }} + run: wp-cli plugin activate disable-doing-it-wrong-notices.php + # These should be stored as a separated list of URLs in the repository Settings > Secrets > Repository Secret > CONVERTKIT_PAID_PLUGIN_URLS. # We cannot include the URLs in this file, as they're not Plugins we are permitted to distribute. - name: Install Paid Third Party WordPress Plugins From 4f2414db6b5668388dbbd63df27f080cf8f1088d Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 13:15:34 +0800 Subject: [PATCH 07/15] Fix CLI command --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 919eed39e..5fcbfeb17 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -142,7 +142,7 @@ jobs: # party Plugins. - name: Activate "Disable `_load_textdomain_just_in_time` `doing_it_wrong` notice Plugin" working-directory: ${{ env.ROOT_DIR }} - run: wp-cli plugin activate disable-doing-it-wrong-notices.php + run: wp-cli plugin activate disable-doing-it-wrong-notices # These should be stored as a separated list of URLs in the repository Settings > Secrets > Repository Secret > CONVERTKIT_PAID_PLUGIN_URLS. # We cannot include the URLs in this file, as they're not Plugins we are permitted to distribute. From c0a0bbf78ff2b846240c56c99e290fc1b9d1aec4 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 14:20:34 +0800 Subject: [PATCH 08/15] Output all Plugins in CLI --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5fcbfeb17..fba759ad8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -142,7 +142,7 @@ jobs: # party Plugins. - name: Activate "Disable `_load_textdomain_just_in_time` `doing_it_wrong` notice Plugin" working-directory: ${{ env.ROOT_DIR }} - run: wp-cli plugin activate disable-doing-it-wrong-notices + run: wp-cli-list && wp-cli plugin listwp-cli plugin activate disable-doing-it-wrong-notices # These should be stored as a separated list of URLs in the repository Settings > Secrets > Repository Secret > CONVERTKIT_PAID_PLUGIN_URLS. # We cannot include the URLs in this file, as they're not Plugins we are permitted to distribute. From 78a83047a3a107a57e419c7439f042e9305486ab Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 14:21:57 +0800 Subject: [PATCH 09/15] Tests: List plugins --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fba759ad8..4bfaa4805 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -142,7 +142,7 @@ jobs: # party Plugins. - name: Activate "Disable `_load_textdomain_just_in_time` `doing_it_wrong` notice Plugin" working-directory: ${{ env.ROOT_DIR }} - run: wp-cli-list && wp-cli plugin listwp-cli plugin activate disable-doing-it-wrong-notices + run: wp-cli plugin list && wp-cli plugin activate disable-doing-it-wrong-notices # These should be stored as a separated list of URLs in the repository Settings > Secrets > Repository Secret > CONVERTKIT_PAID_PLUGIN_URLS. # We cannot include the URLs in this file, as they're not Plugins we are permitted to distribute. From 419cc8de552de5afa3fd271f1b505b2b2863c77d Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 14:25:35 +0800 Subject: [PATCH 10/15] Remove activation step --- .github/workflows/tests.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4bfaa4805..834b697b0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -137,13 +137,6 @@ jobs: working-directory: ${{ env.ROOT_DIR }} run: wp-cli plugin install ${{ env.INSTALL_PLUGINS_URLS }} - # Activates the Disable `_load_textdomain_just_in_time` `doing_it_wrong` notice Plugin, - # to prevent _load_textdomain_just_in_time PHP notices in WordPress 6.7+ due to third - # party Plugins. - - name: Activate "Disable `_load_textdomain_just_in_time` `doing_it_wrong` notice Plugin" - working-directory: ${{ env.ROOT_DIR }} - run: wp-cli plugin list && wp-cli plugin activate disable-doing-it-wrong-notices - # These should be stored as a separated list of URLs in the repository Settings > Secrets > Repository Secret > CONVERTKIT_PAID_PLUGIN_URLS. # We cannot include the URLs in this file, as they're not Plugins we are permitted to distribute. - name: Install Paid Third Party WordPress Plugins From bab65a6a78fa1b962a36c77e0f8f6b711fc7a77d Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 15:05:46 +0800 Subject: [PATCH 11/15] Divi: Disable notices --- tests/acceptance/integrations/other/DiviBroadcastsCest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/acceptance/integrations/other/DiviBroadcastsCest.php b/tests/acceptance/integrations/other/DiviBroadcastsCest.php index a1ea5990a..38eb78dc2 100644 --- a/tests/acceptance/integrations/other/DiviBroadcastsCest.php +++ b/tests/acceptance/integrations/other/DiviBroadcastsCest.php @@ -16,6 +16,7 @@ class DiviBroadcastsCest public function _before(AcceptanceTester $I) { $I->activateConvertKitPlugin($I); + $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->activateThirdPartyPlugin($I, 'divi-builder'); } @@ -173,6 +174,7 @@ public function testBroadcastsModuleInFrontendEditorWhenNoBroadcasts(AcceptanceT public function _passed(AcceptanceTester $I) { $I->deactivateThirdPartyPlugin($I, 'divi-builder'); + $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->deactivateConvertKitPlugin($I); $I->resetConvertKitPlugin($I); } From 51efc82154f1eded72f22bd79255e50727660471 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 15:32:59 +0800 Subject: [PATCH 12/15] Fix failing tests --- tests/acceptance/integrations/other/DiviFormCest.php | 2 ++ tests/acceptance/integrations/other/DiviFormTriggerCest.php | 2 ++ tests/acceptance/integrations/other/DiviProductCest.php | 2 ++ 3 files changed, 6 insertions(+) diff --git a/tests/acceptance/integrations/other/DiviFormCest.php b/tests/acceptance/integrations/other/DiviFormCest.php index 41aa4e428..e05178f7b 100644 --- a/tests/acceptance/integrations/other/DiviFormCest.php +++ b/tests/acceptance/integrations/other/DiviFormCest.php @@ -16,6 +16,7 @@ class DiviFormCest public function _before(AcceptanceTester $I) { $I->activateConvertKitPlugin($I); + $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->activateThirdPartyPlugin($I, 'divi-builder'); } @@ -228,6 +229,7 @@ public function testFormModuleWithNoFormParameter(AcceptanceTester $I) public function _passed(AcceptanceTester $I) { $I->deactivateThirdPartyPlugin($I, 'divi-builder'); + $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->deactivateConvertKitPlugin($I); $I->resetConvertKitPlugin($I); } diff --git a/tests/acceptance/integrations/other/DiviFormTriggerCest.php b/tests/acceptance/integrations/other/DiviFormTriggerCest.php index b4b92e6d2..4cce1333c 100644 --- a/tests/acceptance/integrations/other/DiviFormTriggerCest.php +++ b/tests/acceptance/integrations/other/DiviFormTriggerCest.php @@ -16,6 +16,7 @@ class DiviFormTriggerCest public function _before(AcceptanceTester $I) { $I->activateConvertKitPlugin($I); + $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->activateThirdPartyPlugin($I, 'divi-builder'); } @@ -193,6 +194,7 @@ public function testFormTriggerModuleWithNoFormParameter(AcceptanceTester $I) public function _passed(AcceptanceTester $I) { $I->deactivateThirdPartyPlugin($I, 'divi-builder'); + $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->deactivateConvertKitPlugin($I); $I->resetConvertKitPlugin($I); } diff --git a/tests/acceptance/integrations/other/DiviProductCest.php b/tests/acceptance/integrations/other/DiviProductCest.php index 5e0e4b59f..ebc7f47f9 100644 --- a/tests/acceptance/integrations/other/DiviProductCest.php +++ b/tests/acceptance/integrations/other/DiviProductCest.php @@ -16,6 +16,7 @@ class DiviProductCest public function _before(AcceptanceTester $I) { $I->activateConvertKitPlugin($I); + $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->activateThirdPartyPlugin($I, 'divi-builder'); } @@ -186,6 +187,7 @@ public function testProductModuleWithNoProductParameter(AcceptanceTester $I) public function _passed(AcceptanceTester $I) { $I->deactivateThirdPartyPlugin($I, 'divi-builder'); + $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->deactivateConvertKitPlugin($I); $I->resetConvertKitPlugin($I); } From 0a7d4a64224847645e9def5902b9d59f88fd0a86 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 17:34:55 +0800 Subject: [PATCH 13/15] Fix tests --- tests/_support/Helper/Acceptance/WPCron.php | 13 +++++++++++-- .../blocks-shortcodes/PageShortcodeFormCest.php | 4 ++++ .../landing-pages/PageLandingPageCest.php | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/_support/Helper/Acceptance/WPCron.php b/tests/_support/Helper/Acceptance/WPCron.php index 7114632af..f92f4834e 100644 --- a/tests/_support/Helper/Acceptance/WPCron.php +++ b/tests/_support/Helper/Acceptance/WPCron.php @@ -9,6 +9,15 @@ */ class WPCron extends \Codeception\Module { + /** + * Holds the admin UI URL for WP Crontrol. + * + * @since 2.6.6 + * + * @var string + */ + private $adminURL = 'tools.php?page=wp-crontrol'; + /** * Asserts if the given event name is scheduled in WordPress' Cron. * @@ -49,7 +58,7 @@ public function dontSeeCronEvent($I, $name) public function runCronEvent($I, $name) { // List cron event in WP-Crontrol Plugin. - $I->amOnAdminPage('tools.php?page=crontrol_admin_manage_page&s=' . $name); + $I->amOnAdminPage($this->adminURL . '&s=' . $name); // Hover mouse over event's name. $I->moveMouseOver('#the-list tr'); @@ -74,7 +83,7 @@ public function runCronEvent($I, $name) public function deleteCronEvent($I, $name) { // List cron event in WP-Crontrol Plugin. - $I->amOnAdminPage('tools.php?page=crontrol_admin_manage_page&s=' . $name); + $I->amOnAdminPage($this->adminURL . '&s=' . $name); // Hover mouse over event's name. $I->moveMouseOver('#the-list tr'); diff --git a/tests/acceptance/forms/blocks-shortcodes/PageShortcodeFormCest.php b/tests/acceptance/forms/blocks-shortcodes/PageShortcodeFormCest.php index 6e029610a..f70beb455 100644 --- a/tests/acceptance/forms/blocks-shortcodes/PageShortcodeFormCest.php +++ b/tests/acceptance/forms/blocks-shortcodes/PageShortcodeFormCest.php @@ -655,6 +655,7 @@ public function testFormShortcodeWithPerfmattersPlugin(AcceptanceTester $I) $I->setupConvertKitPluginResources($I); // Activate Perfmatters Plugin. + $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->activateThirdPartyPlugin($I, 'perfmatters'); // Enable Defer and Delay JavaScript. @@ -700,6 +701,7 @@ public function testFormShortcodeWithPerfmattersPlugin(AcceptanceTester $I) // Deactivate Perfmatters Plugin. $I->deactivateThirdPartyPlugin($I, 'perfmatters'); + $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); } /** @@ -770,6 +772,7 @@ public function testFormShortcodeWithWPRocketPlugin(AcceptanceTester $I) $I->setupConvertKitPluginResources($I); // Activate WP Rocket Plugin. + $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->activateThirdPartyPlugin($I, 'wp-rocket'); // Configure WP Rocket. @@ -806,6 +809,7 @@ public function testFormShortcodeWithWPRocketPlugin(AcceptanceTester $I) // Deactivate WP Rocket Plugin. $I->deactivateThirdPartyPlugin($I, 'wp-rocket'); + $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); } /** diff --git a/tests/acceptance/landing-pages/PageLandingPageCest.php b/tests/acceptance/landing-pages/PageLandingPageCest.php index 21d921b31..41160d055 100644 --- a/tests/acceptance/landing-pages/PageLandingPageCest.php +++ b/tests/acceptance/landing-pages/PageLandingPageCest.php @@ -328,6 +328,7 @@ public function testAddNewPageUsingDefinedLandingPageWithPerfmattersPlugin(Accep $I->setupConvertKitPluginResources($I); // Activate Perfmatters Plugin. + $I->activateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); $I->activateThirdPartyPlugin($I, 'perfmatters'); // Enable Lazy Loading. @@ -373,6 +374,7 @@ public function testAddNewPageUsingDefinedLandingPageWithPerfmattersPlugin(Accep // Deactivate Perfmatters Plugin. $I->deactivateThirdPartyPlugin($I, 'perfmatters'); + $I->deactivateThirdPartyPlugin($I, 'disable-_load_textdomain_just_in_time-doing_it_wrong-notice'); } /** From 0a7c4a630cf1d6314643a5a4b0f1f514ce91b3f8 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Mon, 25 Nov 2024 17:37:09 +0800 Subject: [PATCH 14/15] Coding standards --- tests/_support/Helper/Acceptance/WPCron.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/_support/Helper/Acceptance/WPCron.php b/tests/_support/Helper/Acceptance/WPCron.php index f92f4834e..7dce90e30 100644 --- a/tests/_support/Helper/Acceptance/WPCron.php +++ b/tests/_support/Helper/Acceptance/WPCron.php @@ -17,7 +17,7 @@ class WPCron extends \Codeception\Module * @var string */ private $adminURL = 'tools.php?page=wp-crontrol'; - + /** * Asserts if the given event name is scheduled in WordPress' Cron. * From 46b002fdc712498ed898d71f77587f0a53d7fe7e Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 26 Nov 2024 08:52:26 +0800 Subject: [PATCH 15/15] Fix failing test --- tests/acceptance/forms/post-types/PageFormCest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/acceptance/forms/post-types/PageFormCest.php b/tests/acceptance/forms/post-types/PageFormCest.php index 9821fb16c..48e461c2b 100644 --- a/tests/acceptance/forms/post-types/PageFormCest.php +++ b/tests/acceptance/forms/post-types/PageFormCest.php @@ -254,22 +254,22 @@ public function testAddNewPageUsingDefaultFormAfterParagraphElement(AcceptanceTe */ public function testAddNewPageUsingDefaultFormAfterHeadingElement(AcceptanceTester $I) { - // Setup ConvertKit plugin with Default Form for CPTs set to be output after the 2nd

of content. + // Setup ConvertKit plugin with Default Form for Pages set to be output after the 2nd

of content. $I->setupConvertKitPlugin( $I, [ - 'article_form' => $_ENV['CONVERTKIT_API_FORM_ID'], - 'article_form_position' => 'after_element', - 'article_form_position_element' => 'h2', - 'article_form_position_element_index' => 2, + 'page_form' => $_ENV['CONVERTKIT_API_FORM_ID'], + 'page_form_position' => 'after_element', + 'page_form_position_element' => 'h2', + 'page_form_position_element_index' => 2, ] ); $I->setupConvertKitPluginResources($I); - // Setup Article with placeholder content. + // Setup Page with placeholder content. $pageID = $I->addGutenbergPageToDatabase($I, 'page', 'Kit: Page: Form: Default: After 2nd H2 Element'); - // View the CPT on the frontend site. + // View the Page on the frontend site. $I->amOnPage('?p=' . $pageID); // Check that no PHP warnings or notices were output.