Skip to content

Commit 5dd75a2

Browse files
Version 1.6.3 - Hotfix release 🔨 (#25)
* Bump plugin version * fix: Use get_post_meta instead * Add changelog * Allow non-published terms page assignment * fix: Update argument name * fix: Remove blank line * fix: If display action is new tab check post_status * fix: Add BW for older versions * Update woo-additional-terms.pot --------- Co-authored-by: Sajedeh Gooklani <[email protected]>
1 parent 955b282 commit 5dd75a2

File tree

6 files changed

+37
-39
lines changed

6 files changed

+37
-39
lines changed

languages/woo-additional-terms.pot

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# This file is distributed under the GPL-3.0.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Woo Additional Terms 1.6.1\n"
5+
"Project-Id-Version: Woo Additional Terms 1.6.3\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-additional-terms\n"
77
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
88
"Language-Team: LANGUAGE <[email protected]>\n"
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=UTF-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
12-
"POT-Creation-Date: 2023-08-11T09:10:47+00:00\n"
12+
"POT-Creation-Date: 2023-08-23T10:14:46+00:00\n"
1313
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1414
"X-Generator: WP-CLI 2.8.1\n"
1515
"X-Domain: woo-additional-terms\n"
@@ -247,7 +247,7 @@ msgctxt "admin notice"
247247
msgid "I already did!"
248248
msgstr ""
249249

250-
#: templates/order/terms-acceptance.php:24
250+
#: templates/order/terms-acceptance.php:30
251251
msgid "Additional terms and conditions:"
252252
msgstr ""
253253

@@ -330,7 +330,3 @@ msgstr ""
330330
#: assets/js/minified/block.js:1
331331
msgid "You haven’t set up an additional Terms and Conditions page."
332332
msgstr ""
333-
334-
#: assets/js/minified/checkout.js:1
335-
msgid "Please read and accept the additional terms and conditions to proceed with your order."
336-
msgstr ""

readme.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Donate link: https://mypreview.one/woo-additional-terms
55
Requires at least: 5.0
66
Tested up to: 6.3
77
Requires PHP: 7.4
8-
Stable tag: 1.6.2
8+
Stable tag: 1.6.3
99
License: GPLv3 or later
1010
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
1111

@@ -123,6 +123,10 @@ Yes, it does. The [Woo Additional Terms PRO](https://mypreview.one/woo-additiona
123123
5. Additional terms and condition checkbox on the WooCommerce checkout block page.
124124

125125
== Changelog ==
126+
= 1.6.3 =
127+
* Fix: Resolved the issue that prevented the assignment of non-published pages as terms pages.
128+
* Fix: Addressed a PHP error that occurred when retrieving order meta information for display on the order page.
129+
126130
= 1.6.2 =
127131
* Fix: Isolated the dependency injection container package to prevent potential PHP fatal errors when utilized by other third-party plugins.
128132

src/Admin/Order.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function show_terms_acceptance( $order ) {
5353
woo_additional_terms()->service( 'template_manager' )->echo_template(
5454
'order/terms-acceptance.php',
5555
array(
56-
'value' => $order->get_meta( self::META_KEY ),
56+
'meta' => get_post_meta( $order->get_id(), self::META_KEY, true ),
5757
)
5858
);
5959
}

src/WooCommerce/Terms.php

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,27 @@ private function get_label() {
6464
*/
6565
private function get_page_uri() {
6666

67-
$terms_page_id = woo_additional_terms()->service( 'options' )->get( 'page', 0 );
68-
$terms_page = get_post( $terms_page_id );
67+
$terms_page_id = woo_additional_terms()->service( 'options' )->get( 'page', false );
6968

70-
// Check if the terms page exists.
71-
if ( ! $terms_page instanceof WP_Post ) {
69+
if ( ! is_numeric( $terms_page_id ) ) {
7270
return '';
7371
}
7472

75-
// Check if the terms page is published.
76-
if ( 'publish' !== $terms_page->post_status ) {
73+
$terms_page = get_post( $terms_page_id );
74+
75+
// Check if the terms page exists, and is a page.
76+
if ( ! ( $terms_page instanceof WP_Post ) || 'page' !== $terms_page->post_type ) {
77+
return '';
78+
}
79+
80+
$display_action = woo_additional_terms()->service( 'options' )->get( 'action', 'embed' );
81+
82+
// Bail early, in case the display action is set to "New Tab", and the terms page is not published.
83+
if ( 'publish' !== $terms_page->post_status && 'newtab' === $display_action ) {
7784
return '';
7885
}
7986

80-
return get_permalink( $terms_page_id );
87+
return get_permalink( $terms_page );
8188
}
8289

8390
/**
@@ -141,32 +148,17 @@ private function get_content() {
141148
return '';
142149
}
143150

144-
// Check if get_post() function exists.
145-
if ( ! function_exists( 'get_post' ) ) {
146-
return '';
147-
}
148-
149-
$terms_page_id = woo_additional_terms()->service( 'options' )->get( 'page', 0 );
151+
$terms_page_id = woo_additional_terms()->service( 'options' )->get( 'page', false );
150152

151-
// Bail early, in case the terms page ID is empty.
152-
if ( empty( $terms_page_id ) ) {
153+
// Bail early, in case the terms page ID is not valid.
154+
if ( empty( $terms_page_id ) || ! function_exists( 'get_post' ) ) {
153155
return '';
154156
}
155157

156158
$terms_page = get_post( $terms_page_id );
157159

158-
// Check if the terms page exists.
159-
if ( ! $terms_page instanceof WP_Post ) {
160-
return '';
161-
}
162-
163-
// Check if the terms page is published.
164-
if ( 'publish' !== $terms_page->post_status ) {
165-
return '';
166-
}
167-
168-
// Check if the terms page has content.
169-
if ( empty( $terms_page->post_content ) ) {
160+
// Check if the terms page exists, and has content.
161+
if ( ! ( $terms_page instanceof WP_Post ) || empty( $terms_page->post_content ) ) {
170162
return '';
171163
}
172164

templates/order/terms-acceptance.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,24 @@
1111
defined( 'WC_VERSION' ) || exit;
1212

1313
// Bailout, if no value found.
14-
if ( empty( $value ) ) {
14+
if ( empty( $args['meta'] ) ) {
1515
return;
1616
}
1717

18+
// This block is intended for ensuring backward compatibility with versions older than 1.6.0.
19+
// It's worth noting that in previous versions, the acceptance value was stored within an array.
20+
if ( is_array( $args['meta'] ) ) {
21+
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
22+
$args['meta'] = 'yes';
23+
}
1824
?>
1925

2026
<?php /* incorrect CSS class added here, so it adopts styling we want. */ ?>
2127
<div class="address">
2228
<p>
2329
<strong style="display:flex;gap:5px;">
2430
<?php esc_html_e( 'Additional terms and conditions:', 'woo-additional-terms' ); ?>
25-
<span class="status-<?php echo esc_attr( wc_string_to_bool( $value ) ? 'enabled' : 'disabled' ); ?>"></span>
31+
<span class="status-<?php echo esc_attr( wc_string_to_bool( $args['meta'] ) ? 'enabled' : 'disabled' ); ?>"></span>
2632
</strong>
2733
</p>
2834
</div>

woo-additioanl-terms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* Plugin Name: Woo Additional Terms
2727
* Plugin URI: https://mypreview.one/woo-additional-terms
2828
* Description: Improve your checkout process by adding an extra checkbox for terms and conditions. Keep track of acceptance to ensure transparency and security.
29-
* Version: 1.6.2
29+
* Version: 1.6.3
3030
* Author: MyPreview
3131
* Author URI: https://mypreview.one/woo-additional-terms
3232
* Requires at least: 5.9

0 commit comments

Comments
 (0)