Files
.circleci
assets
bin
data
inc
admin-pages
api
builders
checkout
signup-fields
field-templates
class-base-signup-field.php
class-signup-field-billing-address.php
class-signup-field-checkbox.php
class-signup-field-color.php
class-signup-field-discount-code.php
class-signup-field-email.php
class-signup-field-hidden.php
class-signup-field-order-bump.php
class-signup-field-order-summary.php
class-signup-field-password.php
class-signup-field-payment.php
class-signup-field-period-selection.php
class-signup-field-pricing-table.php
class-signup-field-products.php
class-signup-field-select.php
class-signup-field-shortcode.php
class-signup-field-site-title.php
class-signup-field-site-url.php
class-signup-field-steps.php
class-signup-field-submit-button.php
class-signup-field-template-selection.php
class-signup-field-terms-of-use.php
class-signup-field-text.php
class-signup-field-username.php
class-cart.php
class-checkout-pages.php
class-checkout.php
class-legacy-checkout.php
class-line-item.php
compat
contracts
country
database
debug
deprecated
development
domain-mapping
duplication
exception
functions
gateways
helpers
installers
integrations
internal
invoices
limitations
limits
list-tables
loaders
managers
mercator
models
next
objects
site-templates
sso
tax
traits
ui
updater
class-admin-notices.php
class-admin-themes-compatibility.php
class-ajax.php
class-api.php
class-async-calls.php
class-autoloader.php
class-cron.php
class-current.php
class-dashboard-statistics.php
class-dashboard-widgets.php
class-documentation.php
class-domain-mapping.php
class-faker.php
class-geolocation.php
class-helper.php
class-hooks.php
class-license.php
class-light-ajax.php
class-logger.php
class-maintenance-mode.php
class-newsletter.php
class-requirements.php
class-scripts.php
class-session-cookie.php
class-settings.php
class-sunrise.php
class-user-switching.php
class-views.php
class-whitelabel.php
class-wp-ultimo.php
lang
patches
tests
utils
views
.gitignore
.phpcs.xml.dist
LICENSE
autoload.php
composer.json
composer.lock
constants.php
loco.xml
phpstan.neon.dist
phpunit.xml.dist
readme.txt
rector.php
sunrise.php
uninstall.php
wp-multisite-waas.php
wp-multisite-waas/inc/checkout/signup-fields/class-signup-field-terms-of-use.php
2025-02-08 13:57:32 -07:00

206 lines
4.3 KiB
PHP

<?php
/**
* Creates a cart with the parameters of the purchase being placed.
*
* @package WP_Ultimo
* @subpackage Order
* @since 2.0.0
*/
namespace WP_Ultimo\Checkout\Signup_Fields;
use WP_Ultimo\Checkout\Signup_Fields\Base_Signup_Field;
// Exit if accessed directly
defined('ABSPATH') || exit;
/**
* Creates an cart with the parameters of the purchase being placed.
*
* @package WP_Ultimo
* @subpackage Checkout
* @since 2.0.0
*/
class Signup_Field_Terms_Of_Use extends Base_Signup_Field {
/**
* Returns the type of the field.
*
* @since 2.0.0
* @return string
*/
public function get_type() {
return 'terms_of_use';
}
/**
* Returns if this field should be present on the checkout flow or not.
*
* @since 2.0.0
* @return boolean
*/
public function is_required() {
return false;
}
/**
* Is this a user-related field?
*
* If this is set to true, this field will be hidden
* when the user is already logged in.
*
* @since 2.0.0
* @return boolean
*/
public function is_user_field() {
return false;
}
/**
* Requires the title of the field/element type.
*
* This is used on the Field/Element selection screen.
*
* @since 2.0.0
* @return string
*/
public function get_title() {
return __('Terms of Use', 'wp-ultimo');
}
/**
* Returns the description of the field/element.
*
* This is used as the title attribute of the selector.
*
* @since 2.0.0
* @return string
*/
public function get_description() {
return __('Adds a terms and conditions checkbox that must be marked before the account/site can be created.', 'wp-ultimo');
}
/**
* Returns the tooltip of the field/element.
*
* This is used as the tooltip attribute of the selector.
*
* @since 2.0.0
* @return string
*/
public function get_tooltip() {
return __('Adds a terms and conditions checkbox that must be marked before the account/site can be created.', 'wp-ultimo');
}
/**
* Returns the icon to be used on the selector.
*
* Can be either a dashicon class or a wu-dashicon class.
*
* @since 2.0.0
* @return string
*/
public function get_icon() {
return 'dashicons-wu-file-text';
}
/**
* Returns the default values for the field-elements.
*
* This is passed through a wp_parse_args before we send the values
* to the method that returns the actual fields for the checkout form.
*
* @since 2.0.0
* @return array
*/
public function defaults() {
return [
'tou_name' => __('I agree with the terms of use.', 'wp-ultimo'),
];
}
/**
* List of keys of the default fields we want to display on the builder.
*
* @since 2.0.0
* @return array
*/
public function default_fields() {
return [];
}
/**
* If you want to force a particular attribute to a value, declare it here.
*
* @since 2.0.0
* @return array
*/
public function force_attributes() {
return [
'id' => 'terms_of_use',
'name' => __('Terms of Use', 'wp-ultimo'),
];
}
/**
* Returns the list of additional fields specific to this type.
*
* @since 2.0.0
* @return array
*/
public function get_fields() {
return [
'tou_name' => [
'order' => 10,
'type' => 'text',
'title' => __('Terms Checkbox Label', 'wp-ultimo'),
'placeholder' => __('e.g. I agree with the terms of use.', 'wp-ultimo'),
],
'tou_url' => [
'order' => 20,
'type' => 'url',
'title' => __('Link to the Terms Page', 'wp-ultimo'),
'desc' => __('Enter the link to the terms of use content.', 'wp-ultimo'),
'placeholder' => __('e.g. https://yoursite.com/terms', 'wp-ultimo'),
],
];
}
/**
* Returns the field/element actual field array to be used on the checkout form.
*
* @since 2.0.0
*
* @param array $attributes Attributes saved on the editor form.
* @return array An array of fields, not the field itself.
*/
public function to_fields_array($attributes) {
$checkout_fields = [];
$tou_link = sprintf('<a href="%s" target="_blank">%s</a>', $attributes['tou_url'], __('Read here', 'wp-ultimo'));
$checkout_fields['terms_of_use'] = [
'type' => 'checkbox',
'id' => 'terms_of_use',
'name' => $attributes['tou_name'] . ' - ',
'desc' => $tou_link,
'wrapper_classes' => $attributes['element_classes'],
'required' => true,
];
return $checkout_fields;
}
}