settings = $settings; $this->state = $state; $this->fields = $fields; $this->dcc_applies = $dcc_applies; $this->messages_apply = $messages_apply; $this->dcc_product_status = $dcc_product_status; } /** * Returns the notice, when onboarding failed. * * @return array */ public function messages() : array { //phpcs:disable WordPress.Security.NonceVerification.Recommended //phpcs:disable WordPress.Security.NonceVerification.Missing if ( ! isset( $_GET['ppcp-onboarding-error'] ) || ! empty( $_POST ) ) { return array(); } //phpcs:enable WordPress.Security.NonceVerification.Recommended //phpcs:enable WordPress.Security.NonceVerification.Missing $messages = array( new Message( __( 'We could not complete the onboarding process. Some features, such as card processing, will not be available. To fix this, please try again.', 'woocommerce-paypal-payments' ), 'error', false ), ); return $messages; } /** * Renders the multiselect field. * * @param string $field The current field HTML. * @param string $key The current key. * @param array $config The configuration array. * @param string $value The current value. * * @return string */ public function render_multiselect( $field, $key, $config, $value ): string { if ( 'ppcp-multiselect' !== $config['type'] ) { return $field; } $options = array(); foreach ( $config['options'] as $option_key => $option_value ) { $selected = ( in_array( $option_key, $value, true ) ) ? 'selected="selected"' : ''; $options[] = ''; } $html = sprintf( '', esc_attr( implode( ' ', $config['class'] ) ), esc_attr( $key ) . '[]', implode( '', $options ) ); return $html; } /** * Renders the password input field. * * @param string $field The current field HTML. * @param string $key The current key. * @param array $config The configuration array. * @param string $value The current value. * * @return string */ public function render_password( $field, $key, $config, $value ): string { if ( 'ppcp-password' !== $config['type'] ) { return $field; } $html = sprintf( '', esc_attr( implode( ' ', $config['class'] ) ), esc_attr( $key ), esc_attr( $value ) ); return $html; } /** * Renders the text input field. * * @param string $field The current field HTML. * @param string $key The current key. * @param array $config The configuration array. * @param string $value The current value. * * @return string */ public function render_text_input( $field, $key, $config, $value ): string { if ( 'ppcp-text-input' !== $config['type'] ) { return $field; } $html = sprintf( '', esc_attr( implode( ' ', $config['class'] ) ), esc_attr( $key ), esc_attr( $value ) ); return $html; } /** * Renders the heading field. * * @param string $field The current field HTML. * @param string $key The current key. * @param array $config The configuration array. * @param string $value The current value. * * @return string */ public function render_heading( $field, $key, $config, $value ): string { if ( 'ppcp-heading' !== $config['type'] ) { return $field; } $html = sprintf( '
', '' ) ); ?>