_text'] ) && ! wpforms_is_empty_string( $field['button_text'] ) ? $field['button_text'] : esc_html__( 'Apply', 'wpforms-lite' ), ], false ); $this->field_element( 'row', $field, [ 'slug' => 'button_text', 'content' => $button_text_label . $button_text_field, ] ); $this->field_option( 'css', $field ); $this->field_option( 'label_hide', $field ); $this->field_option( 'advanced-options', $field, [ 'markup' => 'close' ] ); } /** * Get allowed coupons' field. * * @since 1.9.4 * * @param array $coupons Coupons. * @param array $form_coupons Form coupons. * @param array $field Field data. * * @return string * @noinspection HtmlUnknownAttribute */ private function get_allowed_coupons_field( array $coupons, array $form_coupons, array $field ): string { $output = sprintf( ''; return $output; } /** * Field preview inside the builder. * * @since 1.9.4 * * @param array $field Field data. */ public function field_preview( $field ) { // Label. $this->field_preview_option( 'label', $field, [ 'label_badge' => $this->get_field_preview_badge(), ] ); $allowed_coupons = []; if ( $this->is_addon_active ) { $allowed_coupons = wpforms_coupons()->get( 'repository' )->get_form_coupons( $this->get_form_id() ); } printf( '
', esc_html( $this->get_button_text( $field ) ), empty( $allowed_coupons ) && empty( $this->is_disabled_field ) ? '' : ' wpforms-hidden' ); // Description. $this->field_preview_option( 'description', $field ); // Hide remaining elements. $this->field_preview_option( 'hide-remaining', $field ); } /** * Get form ID. In AJAX requests the $form_id property doesn't exist. * * @since 1.9.4 * * @return bool|int */ protected function get_form_id() { if ( $this->form_id ) { return $this->form_id; } // phpcs:ignore WordPress.Security.NonceVerification.Missing $this->form_id = isset( $_POST['id'] ) ? absint( $_POST['id'] ) : false; return $this->form_id; } /** * Get the apply button text. * * @since 1.9.4 * * @param array $field Field data. * * @return string */ protected function get_button_text( array $field ): string { return isset( $field['button_text'] ) && ! wpforms_is_empty_string( $field['button_text'] ) ? $field['button_text'] : __( 'Apply', 'wpforms-lite' ); } /** * Field display on the frontend. * * @since 1.9.4 * * @param array $field Field data. * @param array $deprecated Field attributes. * @param array $form_data Form data. */ public function field_display( $field, $deprecated, $form_data ) { } }