Skip to content

Commit 8baaf38

Browse files
chore: switch to using wc_get_template() function
Update wcdp_form_style_1.php, wcdp_form_style_2.php, and 7 more files...
1 parent 6adf695 commit 8baaf38

File tree

9 files changed

+78
-24
lines changed

9 files changed

+78
-24
lines changed

includes/templates/styles/wcdp_form_style_1.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<?php
2-
/*
3-
WCDP Donation Form
2+
/**
3+
* WCDP Donation Form
4+
* @var int $product_id
5+
* @var boolean $has_child
6+
* @var WC_Product $product
7+
* @var array $value
8+
* @var string $context
9+
* @var $checkout
410
*/
511

612
if (!defined('ABSPATH')) exit;
@@ -18,4 +24,12 @@
1824
</div>
1925

2026
<?php
21-
include('wcdp_form_style_3.php');
27+
wc_get_template('wcdp_form_style_3.php',
28+
array(
29+
'product_id'=> $product_id,
30+
'has_child' => $has_child,
31+
'product' => $product,
32+
'value' => $value,
33+
'context' => $context,
34+
'checkout' => $checkout,
35+
), '', WCDP_DIR . 'includes/templates/styles/');

includes/templates/styles/wcdp_form_style_2.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@
5555
<stop offset="1" style="stop-color: var(--controls);stop-opacity:1"></stop>
5656
</linearGradient>
5757
</defs></svg>
58-
<?php include(WCDP_DIR . 'includes/templates/wcdp_step_2.php'); ?>
58+
<?php wc_get_template('wcdp_step_2.php',
59+
array(
60+
'value' => $value,
61+
'context' => $context,
62+
), '', WCDP_DIR . 'includes/templates/');
63+
?>
5964
<svg class="wcdp-divider-arrow" width="90%" height="100%" viewBox="0 0 113 4" version="1.1"
6065
xmlns="http://www.w3.org/2000/svg" xml:space="preserve"
6166
style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"><rect id="export"
@@ -88,7 +93,7 @@
8893
<stop offset="1" style="stop-color: var(--controls);stop-opacity:1"></stop>
8994
</linearGradient>
9095
</defs></svg>
91-
<?php include(WCDP_DIR . 'includes/templates/wcdp_step_3.php'); ?>
96+
<?php wc_get_template('wcdp_step_3.php', [], '', WCDP_DIR . 'includes/templates/'); ?>
9297
</form>
9398
<?php do_action('woocommerce_after_checkout_form', WC()->checkout()); ?>
9499
</div>

includes/templates/styles/wcdp_form_style_3.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<?php
22
/**
33
* WCDP Shortcode Form Style 3: steps with no header
4+
* @var int $product_id
5+
* @var boolean $has_child
6+
* @var WC_Product $product
7+
* @var array $value
8+
* @var string $context
9+
* @var $checkout
410
*/
511

612
if (!defined('ABSPATH')) exit;
@@ -21,7 +27,12 @@
2127
<form name="checkout" method="post" class="checkout woocommerce-checkout"
2228
action="<?php echo esc_url(wc_get_checkout_url()); ?>" enctype="multipart/form-data">
2329
<div class="wcdp-tab" id="wcdp-step-2">
24-
<?php include(WCDP_DIR . 'includes/templates/wcdp_step_2.php'); ?>
30+
<?php wc_get_template('wcdp_step_2.php',
31+
array(
32+
'value' => $value,
33+
'context' => $context,
34+
), '', WCDP_DIR . 'includes/templates/');
35+
?>
2536
<br>
2637
<button type="button" class="button wcdp-button wcdp-left" value="1">
2738
<div class="wcdp-arrow wcdp-left-arrow">&laquo;</div>&nbsp;<?php esc_html_e('Back', 'wc-donation-platform'); ?>
@@ -33,7 +44,7 @@
3344
</button>
3445
</div>
3546
<div class="wcdp-tab" id="wcdp-step-3">
36-
<?php include(WCDP_DIR . 'includes/templates/wcdp_step_3.php'); ?>
47+
<?php wc_get_template('wcdp_step_3.php', [], '', WCDP_DIR . 'includes/templates/'); ?>
3748
<br>
3849
<button type="button" class="button wcdp-button wcdp-left" value="2">
3950
<div class="wcdp-arrow wcdp-left-arrow">&laquo;</div>

includes/templates/styles/wcdp_form_style_5.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<?php
2-
/*
3-
WCDP Shortcode Form Style 5: 3 steps with banner header
4-
*/
2+
/**
3+
* WCDP Shortcode Form Style 5: 3 steps with banner header
4+
* @var int $product_id
5+
* @var boolean $has_child
6+
* @var WC_Product $product
7+
* @var array $value
8+
* @var string $context
9+
* @var $checkout
10+
*/
511

612
if (!defined('ABSPATH')) exit;
713
?>
@@ -19,4 +25,12 @@
1925
</div>
2026

2127
<?php
22-
include('wcdp_form_style_3.php');
28+
wc_get_template('wcdp_form_style_3.php',
29+
array(
30+
'product_id'=> $product_id,
31+
'has_child' => $has_child,
32+
'product' => $product,
33+
'value' => $value,
34+
'context' => $context,
35+
'checkout' => $checkout,
36+
), '', WCDP_DIR . 'includes/templates/styles/');

includes/templates/wcdp_step_1.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@
9393
), '', WCDP_DIR . 'includes/templates/');
9494

9595
//Variation fields
96-
include('wcdp_step_1_variations.php');
96+
wc_get_template('wcdp_step_1_variations.php',
97+
array(
98+
'has_child'=> $has_child,
99+
'product' => $product,
100+
'attributes' => $attributes,
101+
'product_id' => $product_id,
102+
), '', WCDP_DIR . 'includes/templates/');
97103
?>
98104
<?php if ($value['style'] == 1 || $value['style'] == 3 || $value['style'] == 5) : ?>
99105
<button class="button wcdp-button wcdp-right" type="button" id="wcdp-ajax-button" value="2">

includes/templates/wcdp_step_1_variations.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*
55
* @var bool $has_child
66
* @var WC_product $product
7+
* @var array $attributes
8+
* @var int $product_id
79
*/
810

911
if (!defined('ABSPATH')) exit;
@@ -16,14 +18,14 @@
1618
$esc_attribute = esc_attr(sanitize_title($attribute));
1719

1820
$terms = wc_get_product_terms(
19-
$id,
21+
$product_id,
2022
$esc_attribute,
2123
array(
2224
'fields' => 'all',
2325
)
2426
);
2527

26-
$attributeLayout = get_post_meta($id, 'wcdp-settings[wcdp-attr-' . $esc_attribute . ']', true);
28+
$attributeLayout = get_post_meta($product_id, 'wcdp-settings[wcdp-attr-' . $esc_attribute . ']', true);
2729

2830
/*
2931
* $attributeLayout = 0: Default Layout
@@ -39,7 +41,7 @@
3941
</label>
4042
<?php else :
4143
//Display Custom HTML
42-
do_action('wcdp_custom_html_' . $esc_attribute . '_' . $id);
44+
do_action('wcdp_custom_html_' . $esc_attribute . '_' . $product_id);
4345
endif;
4446

4547
//Display Box Layout
@@ -55,7 +57,7 @@
5557
if ($product && taxonomy_exists($attribute)) {
5658
// Get terms if this is a taxonomy - ordered. We need the names too.
5759
$terms = wc_get_product_terms(
58-
$id,
60+
$product_id,
5961
$attribute,
6062
array(
6163
'fields' => 'all',

includes/templates/wcdp_step_2.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?php
2-
/*
3-
WCDP Shortcode Form
4-
*/
2+
/**
3+
* WCDP Shortcode Form
4+
*
5+
* @var array $value
6+
* @var string $context
7+
*/
58

69
if (!defined('ABSPATH')) exit;
710

811
/**
912
* Add woocommerce_after_add_to_cart_form hook in step 2
1013
* needed in order to support Stripe express checkout
1114
*/
12-
/** @var array $value */
13-
/** @var boolean $context */
1415
if ($value['style'] !== 4 && $context == 'shortcode') {
1516
do_action('woocommerce_after_add_to_cart_form');
1617
}

includes/templates/wcdp_step_3.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
2-
/*
3-
WCDP Shortcode Form
4-
*/
2+
/**
3+
* WCDP Shortcode Form
4+
*/
55

66
if (!defined('ABSPATH')) exit;
77

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ fix: fee recovery checkbox not being applied
170170
fix: make $product variable global to avoid issues with some payment gateways
171171
fix: make sure order_counter only works for donation projects
172172
tweak: improve WooCommerce Analytics disabled error message
173+
chore: switch to using wc_get_template() function
173174
chore: use wc_price for amount suggestions
174175
chore: improve footer text
175176
dev: add `wcdp_skip_nonce_validation` filter that allows users to disable add2cart nonce verification

0 commit comments

Comments
 (0)