Back compat
This commit is contained in:
parent
3140a0fb62
commit
212a8a180f
|
@ -158,7 +158,7 @@ class WC_Settings_Payment_Gateways extends WC_Settings_Page {
|
|||
|
||||
array(
|
||||
'title' => __( 'Terms and conditions', 'woocommerce' ),
|
||||
'desc' => __( 'If you define a "Terms" page the customer will be asked if they accept them when checking out.', 'woocommerce' ),
|
||||
'desc' => __( 'This lets WooCommerce know where to send users to view your website terms and conditions.', 'woocommerce' ),
|
||||
'id' => 'woocommerce_terms_page_id',
|
||||
'default' => '',
|
||||
'class' => 'wc-enhanced-select-nostd',
|
||||
|
|
|
@ -656,27 +656,6 @@ class WC_Shop_Customizer {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pages to show in settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_page_choices() {
|
||||
return wc_list_pluck( get_pages( array(
|
||||
'depth' => 0,
|
||||
'child_of' => 0,
|
||||
) ), 'post_title', 'ID' );
|
||||
}
|
||||
|
||||
/**
|
||||
* See if checkbox is active or not.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_terms_and_conditions_checkbox_active() {
|
||||
return wc_string_to_bool( get_option( 'woocommerce_checkout_terms_and_conditions_checkbox' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkout section.
|
||||
*
|
||||
|
@ -739,7 +718,7 @@ class WC_Shop_Customizer {
|
|||
$wp_customize->add_setting(
|
||||
'woocommerce_checkout_terms_and_conditions_checkbox',
|
||||
array(
|
||||
'default' => 'no',
|
||||
'default' => woocommerce_terms_and_conditions_checkbox_enabled() ? 'yes' : 'no',
|
||||
'type' => 'option',
|
||||
'capability' => 'manage_woocommerce',
|
||||
'sanitize_callback' => 'wc_bool_to_string',
|
||||
|
@ -814,7 +793,7 @@ class WC_Shop_Customizer {
|
|||
'description' => __( 'Optionally change the default terms and conditions checkbox label.', 'woocommerce' ),
|
||||
'section' => 'woocommerce_checkout',
|
||||
'settings' => 'woocommerce_checkout_terms_and_conditions_checkbox_text',
|
||||
'active_callback' => array( $this, 'is_terms_and_conditions_checkbox_active' ),
|
||||
'active_callback' => 'woocommerce_terms_and_conditions_checkbox_enabled',
|
||||
'type' => 'textarea',
|
||||
'input_attrs' => array(
|
||||
'placeholder' => __( 'I have read and agree to the website [terms]', 'woocommerce' ),
|
||||
|
|
|
@ -549,6 +549,18 @@ function wc_query_string_form_fields( $values = null, $exclude = array(), $curre
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See if the checkbox is enabled or not.
|
||||
*
|
||||
* Defaults to yes or no based on existance of a terms page for backwards compatibilty.
|
||||
*
|
||||
* @since 3.4.0
|
||||
* @return bool
|
||||
*/
|
||||
function woocommerce_terms_and_conditions_checkbox_enabled() {
|
||||
return wc_string_to_bool( get_option( 'woocommerce_checkout_terms_and_conditions_checkbox', 0 < wc_get_page_id( 'terms' ) ? 'yes' : 'no' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Output t&c text. This is custom text which can be added via the customizer.
|
||||
*
|
||||
|
@ -564,7 +576,7 @@ function woocommerce_output_terms_and_conditions_text() {
|
|||
* @since 3.4.0
|
||||
*/
|
||||
function woocommerce_output_terms_and_conditions_page_content() {
|
||||
$terms_page = wc_get_page_id( 'terms' ) > 0 ? get_post( wc_get_page_id( 'terms' ) ) : false;
|
||||
$terms_page = 0 < wc_get_page_id( 'terms' ) ? get_post( wc_get_page_id( 'terms' ) ) : false;
|
||||
|
||||
if ( $terms_page && 'publish' === $terms_page->post_status && $terms_page->post_content && ! has_shortcode( $terms_page->post_content, 'woocommerce_checkout' ) ) {
|
||||
echo wp_kses_post( wc_format_content( $terms_page->post_content ) );
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$terms_checkbox_enabled = wc_string_to_bool( get_option( 'woocommerce_checkout_terms_and_conditions_checkbox' ) );
|
||||
|
||||
if ( apply_filters( 'woocommerce_checkout_show_terms', true ) ) {
|
||||
if ( apply_filters( 'woocommerce_checkout_show_terms', true ) && function_exists( 'woocommerce_terms_and_conditions_checkbox_enabled' ) ) {
|
||||
do_action( 'woocommerce_checkout_before_terms_and_conditions' );
|
||||
|
||||
?>
|
||||
|
@ -25,7 +23,7 @@ if ( apply_filters( 'woocommerce_checkout_show_terms', true ) ) {
|
|||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $terms_checkbox_enabled ) : ?>
|
||||
<?php if ( woocommerce_terms_and_conditions_checkbox_enabled() ) : ?>
|
||||
<p class="form-row validate-required">
|
||||
<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
|
||||
<input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="terms" <?php checked( apply_filters( 'woocommerce_terms_is_checked_default', isset( $_POST['terms'] ) ), true ); // WPCS: input var ok, csrf ok. ?> id="terms" />
|
||||
|
|
Loading…
Reference in New Issue