/home/vianto5/duettowers.mx/wp-content/plugins/wpforms/src/Pro/Forms/Fields/CreditCard
Edit: /home/vianto5/duettowers.mx/wp-content/plugins/wpforms/src/Pro/Forms/Fields/CreditCard/Field.php (14214B)
type}", '__return_true', PHP_INT_MAX, 2 );
}
/**
* Load required scripts.
*
* @since 1.7.5.3
*
* @param array $forms Forms on the current page.
*/
public function load_js( $forms ): void {
if (
wpforms_has_field_type( 'credit-card', $forms, true ) ||
wpforms()->obj( 'frontend' )->assets_global()
) {
wp_enqueue_script(
'wpforms-payment',
WPFORMS_PLUGIN_URL . 'assets/pro/lib/jquery.payment.min.js',
[ 'jquery' ],
WPFORMS_VERSION,
$this->load_script_in_footer()
);
}
}
/**
* Define additional field properties.
*
* @since 1.3.8
*
* @param array|mixed $properties Field properties.
* @param array $field Field settings.
* @param array $form_data Form data and settings.
*
* @return array
*/
public function field_properties( $properties, $field, $form_data ): array { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
$properties = (array) $properties;
// Remove primary for expanded formats since we have first, middle, last.
unset( $properties['inputs']['primary'] );
// Remove reference to an input element to prevent duplication.
if ( empty( $field['sublabel_hide'] ) ) {
unset( $properties['label']['attr']['for'] );
}
$form_id = absint( $form_data['id'] );
$field_id = absint( $field['id'] );
$position = wpforms_get_render_engine() === 'classic' ? 'before' : 'after';
$props = [
'inputs' => [
'number' => [
'attr' => [
'name' => '',
'value' => '',
'placeholder' => ! empty( $field['cardnumber_placeholder'] ) ? $field['cardnumber_placeholder'] : '',
'autocomplete' => 'off',
],
'block' => [
'wpforms-field-credit-card-number',
],
'class' => [
'wpforms-field-credit-card-cardnumber',
],
'data' => [
'rule-creditcard' => 'yes',
],
'id' => "wpforms-{$form_id}-field_{$field_id}",
'required' => ! empty( $field['required'] ) ? 'required' : '',
'sublabel' => [
'hidden' => ! empty( $field['sublabel_hide'] ),
'value' => esc_html__( 'Card Number', 'wpforms' ),
'position' => $position,
],
],
'cvc' => [
'attr' => [
'name' => '',
'value' => '',
'placeholder' => ! empty( $field['cardcvc_placeholder'] ) ? $field['cardcvc_placeholder'] : '',
'maxlength' => '4',
'autocomplete' => 'off',
],
'block' => [
'wpforms-field-credit-card-code',
],
'class' => [
'wpforms-field-credit-card-cardcvc',
],
'data' => [],
'id' => "wpforms-{$form_id}-field_{$field_id}-cardcvc",
'required' => ! empty( $field['required'] ) ? 'required' : '',
'sublabel' => [
'hidden' => ! empty( $field['sublabel_hide'] ),
'value' => esc_html__( 'Security Code', 'wpforms' ),
'position' => $position,
],
],
'name' => [
'attr' => [
'name' => '',
'value' => '',
'placeholder' => ! empty( $field['cardname_placeholder'] ) ? $field['cardname_placeholder'] : '',
],
'block' => [
'wpforms-field-credit-card-name',
],
'class' => [
'wpforms-field-credit-card-cardname',
],
'data' => [],
'id' => "wpforms-{$form_id}-field_{$field_id}-cardname",
'required' => ! empty( $field['required'] ) ? 'required' : '',
'sublabel' => [
'hidden' => ! empty( $field['sublabel_hide'] ),
'value' => esc_html__( 'Name on Card', 'wpforms' ),
'position' => $position,
],
],
'month' => [
'attr' => [],
'class' => [
'wpforms-field-credit-card-cardmonth',
],
'data' => [],
'id' => "wpforms-{$form_id}-field_{$field_id}-cardmonth",
'required' => ! empty( $field['required'] ) ? 'required' : '',
'sublabel' => [
'hidden' => ! empty( $field['sublabel_hide'] ),
'value' => esc_html__( 'Expiration', 'wpforms' ),
'position' => $position,
],
],
'year' => [
'attr' => [],
'class' => [
'wpforms-field-credit-card-cardyear',
],
'data' => [],
'id' => "wpforms-{$form_id}-field_{$field_id}-cardyear",
'required' => ! empty( $field['required'] ) ? 'required' : '',
],
],
];
$properties = array_merge_recursive( $properties, $props );
// If this field is required, we need to make some adjustments.
if ( ! empty( $field['required'] ) ) {
// Add required class if needed (for multipage validation).
$properties['inputs']['number']['class'][] = 'wpforms-field-required';
$properties['inputs']['cvc']['class'][] = 'wpforms-field-required';
$properties['inputs']['name']['class'][] = 'wpforms-field-required';
$properties['inputs']['month']['class'][] = 'wpforms-field-required';
$properties['inputs']['year']['class'][] = 'wpforms-field-required';
// Below, we add our input special classes if certain fields are required.
// The jQuery Validation library will not correctly validate fields that do not have a name attribute.
// So, we use the `wpforms-input-temp-name` class to let jQuery know
// we should add a temporary name attribute before validation is initialized.
// Then, remove it before the form submits.
$properties['inputs']['number']['class'][] = 'wpforms-input-temp-name';
$properties['inputs']['cvc']['class'][] = 'wpforms-input-temp-name';
$properties['inputs']['name']['class'][] = 'wpforms-input-temp-name';
$properties['inputs']['month']['class'][] = 'wpforms-input-temp-name';
$properties['inputs']['year']['class'][] = 'wpforms-input-temp-name';
}
return $properties;
}
/**
* Whether the current field can be populated dynamically.
*
* @since 1.9.4
*
* @param array $properties Field properties.
* @param array $field Current field specific data.
*
* @return bool
*/
public function is_dynamic_population_allowed( $properties, $field ): bool {
return false;
}
/**
* Whether the current field can be populated dynamically.
*
* @since 1.9.4
*
* @param array $properties Field properties.
* @param array $field Current field specific data.
*
* @return bool
*/
public function is_fallback_population_allowed( $properties, $field ): bool {
return false;
}
/**
* Default to the required.
*
* @since 1.0.9
*
* @param bool $required Required status, true is required.
* @param array $field Field settings.
*
* @return bool
*/
public function default_required( $required, $field ): bool {
if ( $field['type'] === 'credit-card' ) {
return true;
}
return (bool) $required;
}
/**
* If a supporting payment gateway is not active, don't allow users to add
* the field inside the form builder.
*
* @since 1.4.6
*/
public function builder_footer_scripts(): void {
/**
* Filter to enable/disable the credit card field.
*
* @since 1.4.6
*
* @param bool $enable True to enable, false to disable.
*/
if ( apply_filters( 'wpforms_field_credit_card_enable', false ) ) { // phpcs:ignore WPForms.PHP.ValidateHooks.InvalidHookName
return;
}
?>
';
esc_html_e( 'This page is insecure. Credit Card field should be used for testing purposes only.', 'wpforms' );
echo '
';
}
// Row wrapper.
echo '