diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 7f18904..a76606a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -1,80 +1,95 @@ += 1.6.4 = +* Compatibility for rendering terms page content created with Elementor. + += 1.6.3 = +* Resolved the issue that prevented the assignment of non-published pages as terms pages. +* Addressed a PHP error that occurred when retrieving order meta information for display on the order page. + += 1.6.2 = +* Isolated the dependency injection container package to prevent potential PHP fatal errors when utilized by other third-party plugins. + += 1.6.1 = +* Prevented checkout error in the checkout block when additional terms & conditions are deactivated. +* Enhanced display of additional terms acceptance below the billing address. +* Ensured compatibility with the "WooCommerce PayPal Payments" plugin. +* Verified compatibility with WordPress version 6.3. +* Verified compatibility with WooCommerce version 8.0. + = 1.6.0 = -* Added: Ability to define the status of the additional terms checkbox. -* Added: Customization option to choose how the terms page is displayed (modal, embed, or new tab). -* Added: Option to make the terms and conditions checkbox skippable. -* Added: Recording the acceptance of the additional terms in the order notes. -* Improved: Optimized the underlying code structure for better performance and maintainability. +* Added ability to define the status of the additional terms checkbox. +* Added customization option to choose how the terms page is displayed (modal, embed, or new tab). +* Added new option to make the terms and conditions checkbox skippable. +* Save the acceptance of the additional terms in the order notes. +* Optimized the underlying code structure for better performance and maintainability. = 1.5.2 = -* Compatibility with WordPress 6.2 -* Compatibility with WooCommerce 7.5 +* Compatibility with WordPress 6.2. +* Compatibility with WooCommerce 7.5. = 1.5.1 = -* Update font-size for the checkout block -* Compatibility with WooCommerce 7.4 +* Updated font-size for the checkout block. +* Compatibility with WooCommerce 7.4. = 1.5.0 = -* Compatibility with WooCommerce Checkout block -* Compatibility with WooCommerce 7.3 +* Compatibility with WooCommerce Checkout block. +* Compatibility with WooCommerce 7.3. = 1.4.1 = -* Improved logic in displaying admin-notices. +* Improved logic in displaying admin notices. = 1.4.0 = -* Compatibility with WooCommerce 7.2 +* Compatibility with WooCommerce 7.2. = 1.3.6 = -* Compatibility with WordPress 6.1 -* Compatibility with WooCommerce 7.0 +* Compatibility with WordPress 6.1. +* Compatibility with WooCommerce 7.0. = 1.3.5 = -* Compatibility with WordPress 6.0 -* Compatibility with WooCommerce 6.9 +* Compatibility with WordPress 6.0. +* Compatibility with WooCommerce 6.9. = 1.3.4 = -* Compatibility with WordPress 5.6 -* Compatibility with WooCommerce 4.8 +* Compatibility with WordPress 5.6. +* Compatibility with WooCommerce 4.8. = 1.3.3 = * Multiple code standards improvements. -* Compatibility with WordPress 5.5 -* Compatibility with WooCommerce 4.4 +* Compatibility with WordPress 5.5. +* Compatibility with WooCommerce 4.4. = 1.3.2 = -* Compatibility with WooCommerce 4.3 +* Compatibility with WooCommerce 4.3. = 1.3.1 = * Display the acceptance of terms & conditions on the order edit page. = 1.3.0 = -* Additional terms content can now open up on the page when the link is clicked, and customers can review without leaving checkout. -* Compatibility with WooCommerce 4.2.0 +* Additional terms content can now open up on the page when the link is clicked, allowing customers to review without leaving checkout. +* Compatibility with WooCommerce 4.2.0. = 1.2.2 = * Added language configuration file to support WPML/Polylang. -* Compatibility with WordPress 5.4.1 -* Compatibility with WooCommerce 4.1.1 +* Compatibility with WordPress 5.4.1. +* Compatibility with WooCommerce 4.1.1. = 1.2.1 = * Multiple code standards improvements. -* Compatibility with WordPress 5.4.0 -* Compatibility with WooCommerce 4.0.1 +* Compatibility with WordPress 5.4.0. +* Compatibility with WooCommerce 4.0.1. = 1.2.0 = * Updated language file. -* Refactored and re-organized underlying code in plugin settings page/ controls. -* Compatibility with WordPress 5.3.1 -* Compatibility with WooCommerce 3.8.1 +* Refactored and re-organized underlying code in plugin settings page/controls. +* Compatibility with WordPress 5.3.1. +* Compatibility with WooCommerce 3.8.1. = 1.1.0 = -* Compatible with WordPress 4.9.6 -* Compatible with WordPress 3.4.2 - -= 1.0.3 = +* Compatible with WordPress 4.9.6. +* Compatible with WooCommerce 3.4.2. = 1.0.2 = -* Compatible with WordPress 4.7.0 -* Compatible with WordPress 2.6.9 +* Compatible with WordPress 4.7.0. +* Compatible with WooCommerce 2.6.9. = 1.0.1 = * Added screenshots. diff --git a/languages/woo-additional-terms.pot b/languages/woo-additional-terms.pot index ea34af7..1184fc7 100644 --- a/languages/woo-additional-terms.pot +++ b/languages/woo-additional-terms.pot @@ -2,14 +2,14 @@ # This file is distributed under the GPL-3.0. msgid "" msgstr "" -"Project-Id-Version: Woo Additional Terms 1.6.3\n" +"Project-Id-Version: Woo Additional Terms 1.6.4\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-additional-terms\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2023-08-23T10:14:46+00:00\n" +"POT-Creation-Date: 2023-08-27T13:06:55+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.8.1\n" "X-Domain: woo-additional-terms\n" @@ -32,25 +32,25 @@ msgid "MyPreview" msgstr "" #. translators: 1: Open anchor tag, 2: Close anchor tag. -#: src/Enhancements/Meta.php:67 +#: src/Enhancements/Meta.php:53 msgctxt "plugin link" msgid "%1$sDocs%2$s" msgstr "" #. translators: 1: Open anchor tag, 2: Close anchor tag. -#: src/Enhancements/Meta.php:75 +#: src/Enhancements/Meta.php:61 msgctxt "plugin link" msgid "%1$sCommunity support%2$s" msgstr "" #. translators: 1: Open anchor tag, 2: Close anchor tag. -#: src/Enhancements/Meta.php:101 +#: src/Enhancements/Meta.php:93 msgctxt "plugin link" msgid "%1$sGet PRO%2$s" msgstr "" #. translators: 1: Open anchor tag, 2: Close anchor tag. -#: src/Enhancements/Meta.php:109 +#: src/Enhancements/Meta.php:103 msgctxt "plugin settings page" msgid "%1$sSettings%2$s" msgstr "" @@ -201,16 +201,15 @@ msgstr "" msgid "Customer did not accept the additional terms." msgstr "" -#: src/WooCommerce/Block/Block.php:177 -#: src/WooCommerce/Checkout.php:173 -msgid "Please accept the additional terms to continue." -msgstr "" - #. translators: %s: Render the type of the variable. #: src/WooCommerce/Block/Block.php:209 msgid "Value of field %s was posted with incorrect data type." msgstr "" +#: src/WooCommerce/Terms.php:76 +msgid "Please accept the additional terms to continue." +msgstr "" + #: templates/checkout/checkbox.php:52 msgid "Required" msgstr "" diff --git a/readme.txt b/readme.txt index f688507..0a69b21 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Donate link: https://mypreview.one/woo-additional-terms Requires at least: 5.0 Tested up to: 6.3 Requires PHP: 7.4 -Stable tag: 1.6.3 +Stable tag: 1.6.4 License: GPLv3 or later License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -123,12 +123,15 @@ Yes, it does. The [Woo Additional Terms PRO](https://mypreview.one/woo-additiona 5. Additional terms and condition checkbox on the WooCommerce checkout block page. == Changelog == += 1.6.4 = +* Compatibility for rendering terms page content created with Elementor. + = 1.6.3 = -* Fix: Resolved the issue that prevented the assignment of non-published pages as terms pages. -* Fix: Addressed a PHP error that occurred when retrieving order meta information for display on the order page. +* Resolved the issue that prevented the assignment of non-published pages as terms pages. +* Addressed a PHP error that occurred when retrieving order meta information for display on the order page. = 1.6.2 = -* Fix: Isolated the dependency injection container package to prevent potential PHP fatal errors when utilized by other third-party plugins. +* Isolated the dependency injection container package to prevent potential PHP fatal errors when utilized by other third-party plugins. = 1.6.1 = * Prevented checkout error in the checkout block when additional terms & conditions are deactivated. @@ -138,11 +141,11 @@ Yes, it does. The [Woo Additional Terms PRO](https://mypreview.one/woo-additiona * Verified compatibility with WooCommerce version 8.0. = 1.6.0 = -* Added: Ability to define the status of the additional terms checkbox. -* Added: Customization option to choose how the terms page is displayed (modal, embed, or new tab). -* Added: Option to make the terms and conditions checkbox skippable. -* Added: Recording the acceptance of the additional terms in the order notes. -* Improved: Optimized the underlying code structure for better performance and maintainability. +* Added ability to define the status of the additional terms checkbox. +* Added customization option to choose how the terms page is displayed (modal, embed, or new tab). +* Added new option to make the terms and conditions checkbox skippable. +* Save the acceptance of the additional terms in the order notes. +* Optimized the underlying code structure for better performance and maintainability. = 1.5.2 = * Compatibility with WordPress 6.2. @@ -218,4 +221,3 @@ Yes, it does. The [Woo Additional Terms PRO](https://mypreview.one/woo-additiona = 1.0.0 = * Initial release. - diff --git a/src/Enhancements/Meta.php b/src/Enhancements/Meta.php index ca00546..37ab284 100644 --- a/src/Enhancements/Meta.php +++ b/src/Enhancements/Meta.php @@ -18,31 +18,17 @@ */ class Meta { - /** - * The plugin basename. - * - * @since 1.0.0 - * - * @var string - */ - private $plugin_basename; - /** * Setup hooks and filters. * * @since 1.0.0 * - * @param string $plugin_basename The plugin basename. - * * @return void */ - public function setup( $plugin_basename ) { - - // Set the plugin basename. - $this->plugin_basename = $plugin_basename; + public function setup() { add_filter( 'plugin_row_meta', array( $this, 'meta_links' ), 10, 2 ); - add_filter( "plugin_action_links_{$this->plugin_basename}", array( $this, 'action_links' ) ); + add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 2 ); } /** @@ -58,7 +44,7 @@ public function setup( $plugin_basename ) { public function meta_links( $links, $file ) { // Return early if not on the plugin page. - if ( $this->plugin_basename !== $file ) { + if ( ! $this->is_this_plugin( $file ) ) { return $links; } @@ -90,11 +76,17 @@ public function meta_links( $links, $file ) { * * @since 1.0.0 * - * @param array $links Plugin table/item action links. + * @param array $links Plugin table/item action links. + * @param string $file Path to the plugin file relative to the plugins' directory. * * @return array */ - public function action_links( $links ) { + public function action_links( $links, $file ) { + + // Leave early if the filter is not for this plugin. + if ( ! $this->is_this_plugin( $file ) ) { + return $links; + } $plugin_links = array(); $plugin_links[] = sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */ @@ -105,15 +97,32 @@ public function action_links( $links ) { ), '' ); - $plugin_links[] = sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */ - esc_html_x( '%1$sSettings%2$s', 'plugin settings page', 'woo-additional-terms' ), - sprintf( - '', - esc_url( Helper\Settings::page_uri() ) - ), - '' - ); + + if ( current_user_can( 'manage_woocommerce' ) ) { + $plugin_links[] = sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */ + esc_html_x( '%1$sSettings%2$s', 'plugin settings page', 'woo-additional-terms' ), + sprintf( + '', + esc_url( Helper\Settings::page_uri() ) + ), + '' + ); + } return array_merge( $plugin_links, $links ); } + + /** + * Check if the current plugin is the one we are looking for. + * + * @since 1.0.0 + * + * @param string $file Path to the plugin file relative to the plugins' directory. + * + * @return bool + */ + private function is_this_plugin( $file ) { + + return woo_additional_terms()->service( 'file' )->plugin_basename() === $file; + } } diff --git a/src/Plugin.php b/src/Plugin.php index b40e3bb..41e8cd0 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -170,9 +170,6 @@ private function get_classes() { ), 'Enhancements\\Meta' => array( 'condition' => $is_admin, - 'params' => array( - $this['file']->plugin_basename(), - ), ), 'Enhancements\\Notices' => array( 'condition' => $is_admin, diff --git a/src/WooCommerce/Block/Block.php b/src/WooCommerce/Block/Block.php index 71d76ef..c3aaee2 100644 --- a/src/WooCommerce/Block/Block.php +++ b/src/WooCommerce/Block/Block.php @@ -174,7 +174,7 @@ public function get_script_data() { 'display_action' => woo_additional_terms()->service( 'options' )->get( 'action', 'embed' ), 'page_content' => woo_additional_terms()->service( 'terms' )->get( 'content' ), 'checkbox_label' => woo_additional_terms()->service( 'terms' )->get( 'label' ), - 'error_message' => woo_additional_terms()->service( 'options' )->get( 'error', __( 'Please accept the additional terms to continue.', 'woo-additional-terms' ) ), + 'error_message' => woo_additional_terms()->service( 'terms' )->get( 'error' ), ); } diff --git a/src/WooCommerce/Checkout.php b/src/WooCommerce/Checkout.php index 0fc33a8..f03894d 100644 --- a/src/WooCommerce/Checkout.php +++ b/src/WooCommerce/Checkout.php @@ -157,20 +157,19 @@ public function show_checkbox() { */ public function show_error( $fields, $errors ) { - $is_required = woo_additional_terms()->service( 'options' )->get( 'required', false ); - - // Bail early, in case the additional terms checkbox is not required. - if ( ! wc_string_to_bool( $is_required ) ) { - return; - } - // Bail early, in case the additional terms checkbox is already checked. if ( ! empty( $fields['_woo_additional_terms'] ) ) { return; } // Get the error message. - $error_message = woo_additional_terms()->service( 'options' )->get( 'error', __( 'Please accept the additional terms to continue.', 'woo-additional-terms' ) ); + $error_message = woo_additional_terms()->service( 'terms' )->get( 'error' ); + + // Bail early, in case the the checkbox is not required. + // Empty error message means the checkbox is not required. + if ( empty( $error_message ) ) { + return; + } // Add the error message. // Prevent the checkout process from continuing. diff --git a/src/WooCommerce/Terms.php b/src/WooCommerce/Terms.php index 0360868..c9d78d6 100644 --- a/src/WooCommerce/Terms.php +++ b/src/WooCommerce/Terms.php @@ -12,6 +12,7 @@ namespace Woo_Additional_Terms\WooCommerce; use WP_Post; +use Elementor; /** * Terms class. @@ -55,6 +56,26 @@ private function get_label() { return $notice; } + /** + * Get the terms error message. + * Note that empty error message indicates that the terms are not required. + * + * @since 1.6.4 + * + * @return string + */ + private function get_error() { + + $is_required = woo_additional_terms()->service( 'options' )->get( 'required', 'no' ); + + // Bail early, in case the terms are not required. + if ( ! wc_string_to_bool( $is_required ) ) { + return ''; + } + + return woo_additional_terms()->service( 'options' )->get( 'error', __( 'Please accept the additional terms to continue.', 'woo-additional-terms' ) ); + } + /** * Get the terms page URI. * @@ -162,6 +183,11 @@ private function get_content() { return ''; } + // Use Elementor to render the post content, in case the page is built with Elementor. + if ( class_exists( Elementor\Plugin::class ) && Elementor\Plugin::$instance->db->is_built_with_elementor( $terms_page_id ) ) { + return Elementor\Plugin::$instance->frontend->get_builder_content_for_display( $terms_page_id, true ); + } + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound return apply_filters( 'the_content', $terms_page->post_content ); } diff --git a/templates/checkout/checkbox.php b/templates/checkout/checkbox.php index 9a14cee..9500abb 100644 --- a/templates/checkout/checkbox.php +++ b/templates/checkout/checkbox.php @@ -31,7 +31,7 @@
+ >