/home/vianto5/cititower.mx/wp-content/plugins/wpforms/src/Pro/Forms/Fields/CreditCard
NameSizeModeActions
Field.php142140644editdlrm
Frontend.php58330644editdlrm
Edit: /home/vianto5/cititower.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 '
'; // Card number. echo '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $this->field_display_sublabel( 'number', 'before', $field ); printf( '', wpforms_html_attributes( $number['id'], $number['class'], $number['data'], $number['attr'] ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ! empty( $number['required'] ) ? 'required' : '' ); $this->field_display_sublabel( 'number', 'after', $field ); $this->field_display_error( 'number', $field ); echo '
'; // CVC. echo '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $this->field_display_sublabel( 'cvc', 'before', $field ); printf( '', wpforms_html_attributes( $cvc['id'], $cvc['class'], $cvc['data'], $cvc['attr'] ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ! empty( $cvc['required'] ) ? 'required' : '' ); $this->field_display_sublabel( 'cvc', 'after', $field ); $this->field_display_error( 'cvc', $field ); echo '
'; echo '
'; // Row wrapper. echo '
'; // Name. echo '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $this->field_display_sublabel( 'name', 'before', $field ); printf( '', wpforms_html_attributes( $name['id'], $name['class'], $name['data'], $name['attr'] ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ! empty( $name['required'] ) ? 'required' : '' ); $this->field_display_sublabel( 'name', 'after', $field ); $this->field_display_error( 'name', $field ); echo '
'; // Expiration. echo '
'; // Month. $this->field_display_sublabel( 'month', 'before', $field ); printf( ''; $this->field_display_sublabel( 'month', 'after', $field ); $this->field_display_error( 'month', $field ); // Sep. echo '/'; // Year. $this->field_display_sublabel( 'year', 'before', $field ); printf( ''; $this->field_display_sublabel( 'year', 'after', $field ); $this->field_display_error( 'year', $field ); echo '
'; echo '
'; } /** * Currently validation happens on the front end. We do not do * generic server-side validation because we do not allow the card * details to POST to the server. * * @since 1.0.0 * * @param int $field_id Field ID. * @param array $field_submit Submitted field value (raw data). * @param array $form_data Form data and settings. */ public function validate( $field_id, $field_submit, $form_data ) { } /** * Format field. * * @since 1.0.0 * * @param int $field_id Field ID. * @param array $field_submit Submitted field value. * @param array $form_data Form data and settings. */ public function format( $field_id, $field_submit, $form_data ) { // Define data. $name = ! empty( $form_data['fields'][ $field_id ]['label'] ) ? $form_data['fields'][ $field_id ]['label'] : ''; // Set final field details. wpforms()->obj( 'process' )->fields[ $field_id ] = [ 'name' => sanitize_text_field( $name ), 'value' => '', 'id' => absint( $field_id ), 'type' => sanitize_key( $this->type ), ]; } }