roperty value. * * @since 1.8.2 * * @param string $raw_value Value from a GET param, always a string. * @param string $input Represent a subfield inside the field. May be empty. * @param array $properties Field properties. * @param array $field Current field specific data. * * @return array Modified field properties. */ protected function get_field_populated_single_property_value( $raw_value, $input, $properties, $field ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh if ( ! is_string( $raw_value ) ) { return $properties; } if ( ! $this->is_user_defined( $field ) ) { return $properties; } $get_value = stripslashes( sanitize_text_field( $raw_value ) ); $get_value = ! empty( $get_value ) ? wpforms_sanitize_amount( $get_value ) : ''; $get_value_formatted = ! empty( $get_value ) ? wpforms_format_amount( $get_value ) : ''; // `primary` by default. if ( ! empty( $input ) && isset( $properties['inputs'][ $input ] ) ) { $properties['inputs'][ $input ]['attr']['value'] = $get_value_formatted; } return $properties; } /** * Field options panel inside the builder. * * @since 1.8.2 * * @param array $field Field data and settings. */ public function field_options( $field ) { /* * Basic field options. */ $this->field_option( 'basic-options', $field, [ 'markup' => 'open' ] ); $this->field_option( 'label', $field ); $this->field_option( 'description', $field ); $this->price_option( $field ); $this->format_option( $field ); $this->min_price_option( $field ); $this->field_option( 'quantity', $field, [ 'hidden' => ! $this->is_single_item( $field ) ] ); $this->field_option( 'required', $field ); $this->field_option( 'basic-options', $field, [ 'markup' => 'close' ] ); $this->field_option( 'advanced-options', $field, [ 'markup' => 'open' ] ); $this->field_option( 'size', $field ); $this->price_label_option( $field ); $visibility = ! empty( $field['format'] ) && $this->is_user_defined( $field ) ? '' : 'wpforms-hidden'; $this->field_option( 'placeholder', $field, [ 'class' => $visibility ] ); $this->field_option( 'css', $field ); $this->field_option( 'label_hide', $field ); $this->field_option( 'advanced-options', $field, [ 'markup' => 'close' ] ); } /** * Price label option. * * @since 1.8.8 * * @param array $field Field Data. * * @return void */ private function price_label_option( array $field ) { // Price display. $output = $this->field_element( 'label', $field, [ 'slug' => 'price_label', 'value' => esc_html__( 'Price Display', 'wpforms-lite' ), 'tooltip' => esc_html__( 'Specify how the price is displayed under the product name.', 'wpforms-lite' ), ], false ); $output .= $this->field_element( 'text', $field, [ 'slug' => 'price_label', 'class' => 'wpforms-single-item-price-label-display', 'value' => $this->get_single_item_price_label( $field ), ], false ); $this->field_element( 'row', $field, [ 'slug' => 'price_label', 'content' => $output, 'class' => $this->is_single_item( $field ) ? '' : 'wpforms-hidden', ] ); } /** * Get price label for single item type. * * @since 1.8.8 * * @param array $field Field data and settings. */ private function get_single_item_price_label( array $field ) { if ( ! isset( $field['price_label'] ) ) { return sprintf( /* translators: %s - Single item field price label. */ esc_html__( 'Price: %s', 'wpforms-lite' ), '{price}' ); } return $field['price_label']; } /** * Field price option. * * @since 1.8.6 * * @param array $field Field data and settings. */ private function price_option( $field ) { $price = ! empty( $field['price'] ) ? wpforms_format_amount( wpforms_sanitize_amount( $field['price'] ) ) : ''; $tooltip = esc_html__( 'Enter the price of the item, without a currency symbol.', 'wpforms-lite' ); $output = $this->field_element( 'label', $field, [ 'slug' => 'price', 'value' => esc_html__( 'Item Price', 'wpforms-lite' ), 'tooltip' => $tooltip, ], false ); $output .= $this->field_element( 'text', $field, [ 'slug' => 'price', 'value' => $price, 'class' => 'wpforms-money-input', 'placeholder' => wpforms_format_amount( 0 ), ], false ); $this->field_element( 'row', $field, [ 'slug' => 'price', 'content' => $output, ] ); } /** * Field format option. * * @since 1.8.6 * * @param array $field Field data and settings. */ private function format_option( $field ) { $format = ! empty( $field['format'] ) ? esc_attr( $field['format'] ) : self::FORMAT_SINGLE; $tooltip = esc_html__( 'Select the item type.', 'wpforms-lite' ); $options = [ self::FORMAT_SINGLE => esc_html__( 'Single Item', 'wpforms-lite' ), self::FORMAT_USER => esc_html__( 'User Defined', 'wpforms-lite' ), self::FORMAT_HIDDEN => esc_html__( 'Hidden', 'wpforms-lite' ), ]; $output = $this->field_element( 'label', $field, [ 'slug' => 'format', 'value' => esc_html__( 'Item Type', 'wpforms-lite' ), 'tooltip' => $tooltip, ], false ); $output .= $this->field_element( 'select', $field, [ 'slug' => 'format', 'value' => $format, 'options' => $options, ], false ); $this->field_element( 'row', $field, [ 'slug' => 'format', 'content' => $output, ] ); } /** * Field minimum price option. * * @since 1.8.6 * * @param array $field Field data and settings. */ private function min_price_option( $field ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( isset( $_POST['action'] ) && $_POST['action'] === 'wpforms_new_field_payment-single' ) { // Use a default minimum price when adding new field. $min_price = wpforms_format_amount( self::MIN_PRICE_DEFAULT ); } elseif ( isset( $field['min_price'] ) ) { // Use saved minimum price if it exists. $min_price = wpforms_format_amount( wpforms_sanitize_amount( $field['min_price'] ) ); } else { // Use 0 as a fallback for old forms. $min_price = 0; } $tooltip = esc_html__( 'Enter the minimum price of the item, without a currency symbol.', 'wpforms-lite' ); $is_hidden = empty( $field['format'] ) || ! $this->is_user_defined( $field ) ? 'wpforms-hidden' : ''; $output = $this->field_element( 'label', $field, [ 'slug' => 'min_price', 'value' => esc_html__( 'Minimum Price', 'wpforms-lite' ), 'tooltip' => $tooltip, ], false ); $output .= $this->field_element( 'text', $field, [ 'slug' => 'min_price', 'value' => $min_price, 'data' => [ 'minimum-price' => self::MIN_PRICE_DEFAULT, ], 'class' => 'wpforms-money-input', ], false ); $notice = sprintf( /* translators: %1$s - the default minimum price. */ esc_html__( 'Requiring a minimum price of at least %1$s helps protect you against card testing by fraudsters.', 'wpforms-lite' ), esc_html( wpforms_format_amount( self::MIN_PRICE_DEFAULT, true ) ) ); $is_notice_hidden = $this->is_min_price_passed( $field ) || $is_hidden ? 'wpforms-hidden' : ''; $output .= sprintf( '

%2$s

%3$s

', esc_attr( $is_notice_hidden ), esc_html__( 'Security Recommendation', 'wpforms-lite' ), $notice ); $this->field_element( 'row', $field, [ 'slug' => 'min_price', 'content' => $output, 'class' => $is_hidden, ] ); } /** * Field preview inside the builder. * * @since 1.8.2 * * @param array $field Field data and settings. */ public function field_preview( $field ) { $price = ! empty( $field['price'] ) ? wpforms_format_amount( wpforms_sanitize_amount( $field['price'] ), true ) : wpforms_format_amount( 0, true ); $min_price = ! empty( $field['min_price'] ) ? wpforms_format_amount( wpforms_sanitize_amount( $field['min_price'] ), true ) : wpforms_format_amount( self::MIN_PRICE_DEFAULT, true ); $placeholder = ! empty( $field['placeholder'] ) ? $field['placeholder'] : wpforms_format_amount( 0 ); $format = ! empty( $field['format'] ) ? $field['format'] : self::FORMAT_SINGLE; $value = ! empty( $field['price'] ) ? wpforms_format_amount( wpforms_sanitize_amount( $field['price'] ) ) : ''; $is_single = $this->is_single_item( $field ); $single_label = str_replace( '{price}', '' . esc_html( $price ) . '', wp_kses( $this->get_single_item_price_label( $field ), wpforms_builder_preview_get_allowed_tags() ) ); $this->field_preview_option( 'label', $field ); echo '
'; $hidden = ! $is_single ? 'wpforms-hidden' : ''; echo '

'; echo wp_kses( '' . $single_label . '', [ 'span' => [ 'class' => [], ], ] ); echo '

'; $hidden = ! $this->is_hidden( $field ) ? 'wpforms-hidden' : ''; echo '

'; printf( wp_kses( /* translators: %1$s - Item Price value. */ __( 'Price: %1$s', 'wpforms-lite' ), [ 'span' => [ 'class' => [], ], ] ), esc_html( $price ) ); echo '

'; $hidden = ! $is_single ? 'wpforms-hidden' : ''; $this->field_preview_option( 'quantity', $field, [ 'class' => $hidden ] ); echo '
'; printf( '', esc_attr( $placeholder ), esc_attr( $value ) ); $hidden = $this->is_min_price_passed( $field ) ? 'wpforms-hidden' : ''; echo ''; echo '
'; $this->field_preview_option( 'description', $field ); $hidden = ! isset( $field['min_price'] ) || empty( (float) wpforms_sanitize_amount( $field['min_price'] ) ) ? 'wpforms-hidden' : ''; echo '
'; printf( wp_kses( /* translators: %1$s - Minimum Price value. */ __( 'Minimum Price: %1$s', 'wpforms-lite' ), [ 'span' => [ 'class' => [], ], ] ), esc_html( $min_price ) ); echo '
'; echo '

'; esc_html_e( 'Note: Item type is set to hidden and will not be visible when viewing the form.', 'wpforms-lite' ); echo '

'; echo '
'; } /** * Field display on the form front-end. * * @since 1.8.2 * * @param array $field Field data and settings. * @param array $deprecated Deprecated field attributes. * @param array $form_data Form data and settings. */ public function field_display( $field, $deprecated, $form_data ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh // Shortcut for easier access. $primary = $field['properties']['inputs']['primary']; $field_format = ! empty( $field['format'] ) ? $field['format'] : self::FORMAT_SINGLE; // Placeholder attribute is only applicable to password, search, tel, text and url inputs, not hidden. // aria-errormessage attribute is not allowed for hidden inputs. if ( ! $this->is_user_defined( $field ) ) { unset( $primary['attr']['placeholder'], $primary['attr']['aria-errormessage'] ); } switch ( $field_format ) { case self::FORMAT_SINGLE: case self::FORMAT_HIDDEN: if ( $field_format === self::FORMAT_SINGLE ) { $price = ! empty( $field['price'] ) ? $field['price'] : 0; $field_label = str_replace( '{price}', '' . esc_html( wpforms_format_amount( wpforms_sanitize_amount( $price ), true ) ) . '', $this->get_single_item_price_label( $field ) ); echo '
'; echo '
'; echo wp_kses( $field_label, [ 'span' => [ 'class' => [], ], ] ); echo '
'; $this->display_quantity_dropdown( $field ); echo '
'; } // Primary price field. printf( '', wpforms_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ); break; case self::FORMAT_USER: printf( '', wpforms_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ); break; default: break; } } /** * Validate field on form submit. * * @since 1.8.2 * * @param int $field_id Field ID. * @param string $field_submit Submitted field value (raw data). * @param array $form_data Form data and settings. */ public function validate( $field_id, $field_submit, $form_data ) { $is_required = ! empty( $form_data['fields'][ $field_id ]['required'] ); // If field is required, check for data. if ( empty( $field_submit ) && $is_required ) { wpforms()->obj( 'process' )->errors[ $form_data['id'] ][ $field_id ] = wpforms_get_required_label(); return; } /** * Whether to validate amount or not of the Payment Single item field. * * @since 1.8.4 * * @param bool $validate Whether to validate amount or not. Default true. * @param int $field_id Field ID. * @param string $field_submit Field data submitted by a user. * @param array $form_data Form data and settings. */ $validate_amount = apply_filters( 'wpforms_forms_fields_payment_single_field_validate_amount', true, $field_id, $field_submit, $form_data ); // If field format is not user provided, validate the amount posted. if ( ! empty( $field_submit ) && $validate_amount && ! $this->is_user_defined( $form_data['fields'][ $field_id ] ) ) { $price = wpforms_sanitize_amount( $form_data['fields'][ $field_id ]['price'] ); $submit = wpforms_sanitize_amount( $field_submit ); if ( $price !== $submit ) { wpforms()->obj( 'process' )->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'Amount mismatch', 'wpforms-lite' ); } } // If field format is provided by user, additionally compare the amount with a minimum price. if ( ! empty( $field_submit ) && $validate_amount && $this->is_user_defined( $form_data['fields'][ $field_id ] ) ) { $submit = wpforms_sanitize_amount( $field_submit ); if ( $submit < 0 ) { wpforms()->obj( 'process' )->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'Amount can\'t be negative' , 'wpforms-lite' ); } if ( empty( $form_data['fields'][ $field_id ]['min_price'] ) && ! $is_required ) { return; } $min_price = wpforms_sanitize_amount( $form_data['fields'][ $field_id ]['min_price'] ); if ( $submit < $min_price ) { wpforms()->obj( 'process' )->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'Amount can\'t be less than the required minimum.' , 'wpforms-lite' ); } } } /** * Format and sanitize field. * * @since 1.8.2 * * @param int $field_id Field ID. * @param string $field_submit Field data submitted by a user. * @param array $form_data Form data and settings. */ public function format( $field_id, $field_submit, $form_data ) { $field = $form_data['fields'][ $field_id ]; $name = ! empty( $field['label'] ) ? sanitize_text_field( $field['label'] ) : ''; // Only trust the value if the field has the user defined format OR it is the entry preview. if ( $this->is_user_defined( $field ) || wpforms_is_ajax( 'wpforms_get_entry_preview' ) ) { $amount = wpforms_sanitize_amount( $field_submit ); } else { $amount = wpforms_sanitize_amount( $field['price'] ); } $field_data = [ 'name' => $name, 'value' => wpforms_format_amount( $amount, true ), 'amount' => wpforms_format_amount( $amount ), 'amount_raw' => $amount, 'currency' => wpforms_get_currency(), 'id' => absint( $field_id ), 'type' => sanitize_key( $this->type ), ]; if ( $this->is_payment_quantities_enabled( $field ) ) { $field_data['quantity'] = $this->get_submitted_field_quantity( $field, $form_data ); } wpforms()->obj( 'process' )->fields[ $field_id ] = $field_data; } /** * Display the minimum price description for the field. * * @since 1.8.6 * * @param array $field Field data and settings. * @param array $form_data Form data and settings. */ public function field_minimum_price_description( $field, $form_data ) { if ( ! $this->is_user_defined( $field ) || ! isset( $field['min_price'] ) || empty( (float) wpforms_sanitize_amount( $field['min_price'] ) ) ) { return; } $description = sprintf( /* translators: %1$s - Minimum Price value. */ __( 'Minimum Price: %1$s', 'wpforms-lite' ), wpforms_format_amount( wpforms_sanitize_amount( $field['min_price'] ), true ) ); printf( '
%s
', esc_html( $description ) ); } /** * Add class to the builder field preview. * * @since 1.8.6 * * @param string $css Class names. * @param array $field Field properties. * * @return string */ public function preview_field_class( $css, $field ) { $css = parent::preview_field_class( $css, $field ); if ( $field['type'] !== $this->type ) { return $css; } if ( ! $this->is_user_defined( $field ) ) { return $css; } if ( $this->is_min_price_passed( $field ) ) { return $css; } $css .= ' min-price-warning'; return $css; } /** * Define if format of field is User Defined. * * @since 1.8.6 * * @param array $field Field data. * * @return bool */ private function is_user_defined( $field ) { return ! empty( $field['format'] ) && $field['format'] === self::FORMAT_USER; } /** * Define if format of field is Single Item. * * @since 1.8.7 * * @param array $field Field data. * * @return bool */ private function is_single_item( $field ) { return empty( $field['format'] ) || $field['format'] === self::FORMAT_SINGLE; } /** * Define if format of field is Hidden. * * @since 1.8.8 * * @param array $field Field data. * * @return bool */ private function is_hidden( $field ) { return empty( $field['format'] ) || $field['format'] === self::FORMAT_HIDDEN; } /** * Define if minimum price is equal or more than default one. * * @since 1.8.6 * * @param array $field Field data. * * @return bool */ private function is_min_price_passed( $field ) { return isset( $field['min_price'] ) && (float) wpforms_sanitize_amount( $field['min_price'] ) >= (float) self::MIN_PRICE_DEFAULT; } } roperty value. * * @since 1.8.2 * * @param string $raw_value Value from a GET param, always a string. * @param string $input Represent a subfield inside the field. May be empty. * @param array $properties Field properties. * @param array $field Current field specific data. * * @return array Modified field properties. */ protected function get_field_populated_single_property_value( $raw_value, $input, $properties, $field ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh if ( ! is_string( $raw_value ) ) { return $properties; } if ( ! $this->is_user_defined( $field ) ) { return $properties; } $get_value = stripslashes( sanitize_text_field( $raw_value ) ); $get_value = ! empty( $get_value ) ? wpforms_sanitize_amount( $get_value ) : ''; $get_value_formatted = ! empty( $get_value ) ? wpforms_format_amount( $get_value ) : ''; // `primary` by default. if ( ! empty( $input ) && isset( $properties['inputs'][ $input ] ) ) { $properties['inputs'][ $input ]['attr']['value'] = $get_value_formatted; } return $properties; } /** * Field options panel inside the builder. * * @since 1.8.2 * * @param array $field Field data and settings. */ public function field_options( $field ) { /* * Basic field options. */ $this->field_option( 'basic-options', $field, [ 'markup' => 'open' ] ); $this->field_option( 'label', $field ); $this->field_option( 'description', $field ); $this->price_option( $field ); $this->format_option( $field ); $this->min_price_option( $field ); $this->field_option( 'quantity', $field, [ 'hidden' => ! $this->is_single_item( $field ) ] ); $this->field_option( 'required', $field ); $this->field_option( 'basic-options', $field, [ 'markup' => 'close' ] ); $this->field_option( 'advanced-options', $field, [ 'markup' => 'open' ] ); $this->field_option( 'size', $field ); $this->price_label_option( $field ); $visibility = ! empty( $field['format'] ) && $this->is_user_defined( $field ) ? '' : 'wpforms-hidden'; $this->field_option( 'placeholder', $field, [ 'class' => $visibility ] ); $this->field_option( 'css', $field ); $this->field_option( 'label_hide', $field ); $this->field_option( 'advanced-options', $field, [ 'markup' => 'close' ] ); } /** * Price label option. * * @since 1.8.8 * * @param array $field Field Data. * * @return void */ private function price_label_option( array $field ) { // Price display. $output = $this->field_element( 'label', $field, [ 'slug' => 'price_label', 'value' => esc_html__( 'Price Display', 'wpforms-lite' ), 'tooltip' => esc_html__( 'Specify how the price is displayed under the product name.', 'wpforms-lite' ), ], false ); $output .= $this->field_element( 'text', $field, [ 'slug' => 'price_label', 'class' => 'wpforms-single-item-price-label-display', 'value' => $this->get_single_item_price_label( $field ), ], false ); $this->field_element( 'row', $field, [ 'slug' => 'price_label', 'content' => $output, 'class' => $this->is_single_item( $field ) ? '' : 'wpforms-hidden', ] ); } /** * Get price label for single item type. * * @since 1.8.8 * * @param array $field Field data and settings. */ private function get_single_item_price_label( array $field ) { if ( ! isset( $field['price_label'] ) ) { return sprintf( /* translators: %s - Single item field price label. */ esc_html__( 'Price: %s', 'wpforms-lite' ), '{price}' ); } return $field['price_label']; } /** * Field price option. * * @since 1.8.6 * * @param array $field Field data and settings. */ private function price_option( $field ) { $price = ! empty( $field['price'] ) ? wpforms_format_amount( wpforms_sanitize_amount( $field['price'] ) ) : ''; $tooltip = esc_html__( 'Enter the price of the item, without a currency symbol.', 'wpforms-lite' ); $output = $this->field_element( 'label', $field, [ 'slug' => 'price', 'value' => esc_html__( 'Item Price', 'wpforms-lite' ), 'tooltip' => $tooltip, ], false ); $output .= $this->field_element( 'text', $field, [ 'slug' => 'price', 'value' => $price, 'class' => 'wpforms-money-input', 'placeholder' => wpforms_format_amount( 0 ), ], false ); $this->field_element( 'row', $field, [ 'slug' => 'price', 'content' => $output, ] ); } /** * Field format option. * * @since 1.8.6 * * @param array $field Field data and settings. */ private function format_option( $field ) { $format = ! empty( $field['format'] ) ? esc_attr( $field['format'] ) : self::FORMAT_SINGLE; $tooltip = esc_html__( 'Select the item type.', 'wpforms-lite' ); $options = [ self::FORMAT_SINGLE => esc_html__( 'Single Item', 'wpforms-lite' ), self::FORMAT_USER => esc_html__( 'User Defined', 'wpforms-lite' ), self::FORMAT_HIDDEN => esc_html__( 'Hidden', 'wpforms-lite' ), ]; $output = $this->field_element( 'label', $field, [ 'slug' => 'format', 'value' => esc_html__( 'Item Type', 'wpforms-lite' ), 'tooltip' => $tooltip, ], false ); $output .= $this->field_element( 'select', $field, [ 'slug' => 'format', 'value' => $format, 'options' => $options, ], false ); $this->field_element( 'row', $field, [ 'slug' => 'format', 'content' => $output, ] ); } /** * Field minimum price option. * * @since 1.8.6 * * @param array $field Field data and settings. */ private function min_price_option( $field ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( isset( $_POST['action'] ) && $_POST['action'] === 'wpforms_new_field_payment-single' ) { // Use a default minimum price when adding new field. $min_price = wpforms_format_amount( self::MIN_PRICE_DEFAULT ); } elseif ( isset( $field['min_price'] ) ) { // Use saved minimum price if it exists. $min_price = wpforms_format_amount( wpforms_sanitize_amount( $field['min_price'] ) ); } else { // Use 0 as a fallback for old forms. $min_price = 0; } $tooltip = esc_html__( 'Enter the minimum price of the item, without a currency symbol.', 'wpforms-lite' ); $is_hidden = empty( $field['format'] ) || ! $this->is_user_defined( $field ) ? 'wpforms-hidden' : ''; $output = $this->field_element( 'label', $field, [ 'slug' => 'min_price', 'value' => esc_html__( 'Minimum Price', 'wpforms-lite' ), 'tooltip' => $tooltip, ], false ); $output .= $this->field_element( 'text', $field, [ 'slug' => 'min_price', 'value' => $min_price, 'data' => [ 'minimum-price' => self::MIN_PRICE_DEFAULT, ], 'class' => 'wpforms-money-input', ], false ); $notice = sprintf( /* translators: %1$s - the default minimum price. */ esc_html__( 'Requiring a minimum price of at least %1$s helps protect you against card testing by fraudsters.', 'wpforms-lite' ), esc_html( wpforms_format_amount( self::MIN_PRICE_DEFAULT, true ) ) ); $is_notice_hidden = $this->is_min_price_passed( $field ) || $is_hidden ? 'wpforms-hidden' : ''; $output .= sprintf( '

%2$s

%3$s

', esc_attr( $is_notice_hidden ), esc_html__( 'Security Recommendation', 'wpforms-lite' ), $notice ); $this->field_element( 'row', $field, [ 'slug' => 'min_price', 'content' => $output, 'class' => $is_hidden, ] ); } /** * Field preview inside the builder. * * @since 1.8.2 * * @param array $field Field data and settings. */ public function field_preview( $field ) { $price = ! empty( $field['price'] ) ? wpforms_format_amount( wpforms_sanitize_amount( $field['price'] ), true ) : wpforms_format_amount( 0, true ); $min_price = ! empty( $field['min_price'] ) ? wpforms_format_amount( wpforms_sanitize_amount( $field['min_price'] ), true ) : wpforms_format_amount( self::MIN_PRICE_DEFAULT, true ); $placeholder = ! empty( $field['placeholder'] ) ? $field['placeholder'] : wpforms_format_amount( 0 ); $format = ! empty( $field['format'] ) ? $field['format'] : self::FORMAT_SINGLE; $value = ! empty( $field['price'] ) ? wpforms_format_amount( wpforms_sanitize_amount( $field['price'] ) ) : ''; $is_single = $this->is_single_item( $field ); $single_label = str_replace( '{price}', '' . esc_html( $price ) . '', wp_kses( $this->get_single_item_price_label( $field ), wpforms_builder_preview_get_allowed_tags() ) ); $this->field_preview_option( 'label', $field ); echo '
'; $hidden = ! $is_single ? 'wpforms-hidden' : ''; echo '

'; echo wp_kses( '' . $single_label . '', [ 'span' => [ 'class' => [], ], ] ); echo '

'; $hidden = ! $this->is_hidden( $field ) ? 'wpforms-hidden' : ''; echo '

'; printf( wp_kses( /* translators: %1$s - Item Price value. */ __( 'Price: %1$s', 'wpforms-lite' ), [ 'span' => [ 'class' => [], ], ] ), esc_html( $price ) ); echo '

'; $hidden = ! $is_single ? 'wpforms-hidden' : ''; $this->field_preview_option( 'quantity', $field, [ 'class' => $hidden ] ); echo '
'; printf( '', esc_attr( $placeholder ), esc_attr( $value ) ); $hidden = $this->is_min_price_passed( $field ) ? 'wpforms-hidden' : ''; echo ''; echo '
'; $this->field_preview_option( 'description', $field ); $hidden = ! isset( $field['min_price'] ) || empty( (float) wpforms_sanitize_amount( $field['min_price'] ) ) ? 'wpforms-hidden' : ''; echo '
'; printf( wp_kses( /* translators: %1$s - Minimum Price value. */ __( 'Minimum Price: %1$s', 'wpforms-lite' ), [ 'span' => [ 'class' => [], ], ] ), esc_html( $min_price ) ); echo '
'; echo '

'; esc_html_e( 'Note: Item type is set to hidden and will not be visible when viewing the form.', 'wpforms-lite' ); echo '

'; echo '
'; } /** * Field display on the form front-end. * * @since 1.8.2 * * @param array $field Field data and settings. * @param array $deprecated Deprecated field attributes. * @param array $form_data Form data and settings. */ public function field_display( $field, $deprecated, $form_data ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh // Shortcut for easier access. $primary = $field['properties']['inputs']['primary']; $field_format = ! empty( $field['format'] ) ? $field['format'] : self::FORMAT_SINGLE; // Placeholder attribute is only applicable to password, search, tel, text and url inputs, not hidden. // aria-errormessage attribute is not allowed for hidden inputs. if ( ! $this->is_user_defined( $field ) ) { unset( $primary['attr']['placeholder'], $primary['attr']['aria-errormessage'] ); } switch ( $field_format ) { case self::FORMAT_SINGLE: case self::FORMAT_HIDDEN: if ( $field_format === self::FORMAT_SINGLE ) { $price = ! empty( $field['price'] ) ? $field['price'] : 0; $field_label = str_replace( '{price}', '' . esc_html( wpforms_format_amount( wpforms_sanitize_amount( $price ), true ) ) . '', $this->get_single_item_price_label( $field ) ); echo '
'; echo '
'; echo wp_kses( $field_label, [ 'span' => [ 'class' => [], ], ] ); echo '
'; $this->display_quantity_dropdown( $field ); echo '
'; } // Primary price field. printf( '', wpforms_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ); break; case self::FORMAT_USER: printf( '', wpforms_html_attributes( $primary['id'], $primary['class'], $primary['data'], $primary['attr'] ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ); break; default: break; } } /** * Validate field on form submit. * * @since 1.8.2 * * @param int $field_id Field ID. * @param string $field_submit Submitted field value (raw data). * @param array $form_data Form data and settings. */ public function validate( $field_id, $field_submit, $form_data ) { $is_required = ! empty( $form_data['fields'][ $field_id ]['required'] ); // If field is required, check for data. if ( empty( $field_submit ) && $is_required ) { wpforms()->obj( 'process' )->errors[ $form_data['id'] ][ $field_id ] = wpforms_get_required_label(); return; } /** * Whether to validate amount or not of the Payment Single item field. * * @since 1.8.4 * * @param bool $validate Whether to validate amount or not. Default true. * @param int $field_id Field ID. * @param string $field_submit Field data submitted by a user. * @param array $form_data Form data and settings. */ $validate_amount = apply_filters( 'wpforms_forms_fields_payment_single_field_validate_amount', true, $field_id, $field_submit, $form_data ); // If field format is not user provided, validate the amount posted. if ( ! empty( $field_submit ) && $validate_amount && ! $this->is_user_defined( $form_data['fields'][ $field_id ] ) ) { $price = wpforms_sanitize_amount( $form_data['fields'][ $field_id ]['price'] ); $submit = wpforms_sanitize_amount( $field_submit ); if ( $price !== $submit ) { wpforms()->obj( 'process' )->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'Amount mismatch', 'wpforms-lite' ); } } // If field format is provided by user, additionally compare the amount with a minimum price. if ( ! empty( $field_submit ) && $validate_amount && $this->is_user_defined( $form_data['fields'][ $field_id ] ) ) { $submit = wpforms_sanitize_amount( $field_submit ); if ( $submit < 0 ) { wpforms()->obj( 'process' )->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'Amount can\'t be negative' , 'wpforms-lite' ); } if ( empty( $form_data['fields'][ $field_id ]['min_price'] ) && ! $is_required ) { return; } $min_price = wpforms_sanitize_amount( $form_data['fields'][ $field_id ]['min_price'] ); if ( $submit < $min_price ) { wpforms()->obj( 'process' )->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'Amount can\'t be less than the required minimum.' , 'wpforms-lite' ); } } } /** * Format and sanitize field. * * @since 1.8.2 * * @param int $field_id Field ID. * @param string $field_submit Field data submitted by a user. * @param array $form_data Form data and settings. */ public function format( $field_id, $field_submit, $form_data ) { $field = $form_data['fields'][ $field_id ]; $name = ! empty( $field['label'] ) ? sanitize_text_field( $field['label'] ) : ''; // Only trust the value if the field has the user defined format OR it is the entry preview. if ( $this->is_user_defined( $field ) || wpforms_is_ajax( 'wpforms_get_entry_preview' ) ) { $amount = wpforms_sanitize_amount( $field_submit ); } else { $amount = wpforms_sanitize_amount( $field['price'] ); } $field_data = [ 'name' => $name, 'value' => wpforms_format_amount( $amount, true ), 'amount' => wpforms_format_amount( $amount ), 'amount_raw' => $amount, 'currency' => wpforms_get_currency(), 'id' => absint( $field_id ), 'type' => sanitize_key( $this->type ), ]; if ( $this->is_payment_quantities_enabled( $field ) ) { $field_data['quantity'] = $this->get_submitted_field_quantity( $field, $form_data ); } wpforms()->obj( 'process' )->fields[ $field_id ] = $field_data; } /** * Display the minimum price description for the field. * * @since 1.8.6 * * @param array $field Field data and settings. * @param array $form_data Form data and settings. */ public function field_minimum_price_description( $field, $form_data ) { if ( ! $this->is_user_defined( $field ) || ! isset( $field['min_price'] ) || empty( (float) wpforms_sanitize_amount( $field['min_price'] ) ) ) { return; } $description = sprintf( /* translators: %1$s - Minimum Price value. */ __( 'Minimum Price: %1$s', 'wpforms-lite' ), wpforms_format_amount( wpforms_sanitize_amount( $field['min_price'] ), true ) ); printf( '
%s
', esc_html( $description ) ); } /** * Add class to the builder field preview. * * @since 1.8.6 * * @param string $css Class names. * @param array $field Field properties. * * @return string */ public function preview_field_class( $css, $field ) { $css = parent::preview_field_class( $css, $field ); if ( $field['type'] !== $this->type ) { return $css; } if ( ! $this->is_user_defined( $field ) ) { return $css; } if ( $this->is_min_price_passed( $field ) ) { return $css; } $css .= ' min-price-warning'; return $css; } /** * Define if format of field is User Defined. * * @since 1.8.6 * * @param array $field Field data. * * @return bool */ private function is_user_defined( $field ) { return ! empty( $field['format'] ) && $field['format'] === self::FORMAT_USER; } /** * Define if format of field is Single Item. * * @since 1.8.7 * * @param array $field Field data. * * @return bool */ private function is_single_item( $field ) { return empty( $field['format'] ) || $field['format'] === self::FORMAT_SINGLE; } /** * Define if format of field is Hidden. * * @since 1.8.8 * * @param array $field Field data. * * @return bool */ private function is_hidden( $field ) { return empty( $field['format'] ) || $field['format'] === self::FORMAT_HIDDEN; } /** * Define if minimum price is equal or more than default one. * * @since 1.8.6 * * @param array $field Field data. * * @return bool */ private function is_min_price_passed( $field ) { return isset( $field['min_price'] ) && (float) wpforms_sanitize_amount( $field['min_price'] ) >= (float) self::MIN_PRICE_DEFAULT; } } Pdci-Rda : Quel avenir après les décès de Bédié et Ouassenan ? - JusteInfos- Information générale
topheader

Pdci-Rda : Quel avenir après les décès de Bédié et Ouassenan ?

Les décès tragiques du président Bédié et du vice-président Ouassenan amènent à s'interroger sur l'avenir de la Côte d'Ivoire.
92
S'inscrire à la newsletter

- Advertisement -

Listen to this article

Le Pdci-Rda est encore en deuil depuis le mardi 08 août 2023. Le général Gaston Ouassenan Koné est décédé ce mardi 8 août 2023. En l’espace d’une semaine jour pour jour, c’est un nouveau grand malheur qui vient de frapper la Côte d’Ivoire en général et le Parti démocratique de Côte d’Ivoire le (Pdci-Rda), en particulier.

Alors que l’on s’attendait le moins voire pas du tout, au moment où les uns et les autres s’activent pour les élections municipales et régionales prévues le 2 septembre 2023, le Pdci-Rda, parti fondé par Felix Houphouët Boigny, a perdu son second président, Henri Konan Bédié.

Lire aussi: https://www.citoday.net/mali-burkina-faso-resurrection-de-la-grande-commission-mixte-de-cooperation-13-ans-apres/

Un malheur pour lequel les Ivoiriens et surtout les partis de l’opposition dont en particulier le Pdci-Rda ne s’en remettront pas de sitôt. Car le président Bédié représentait surtout pour son parti 60% de sa force de frappe. Tant au plan financier qu’au plan politique et idéologique. La perte brutale du président Henri Konan Bédié à une période aussi politiquement importante ne peux qu’être un coup de Jarnac pour son parti.

Et comme cela ne suffisait pas, un autre décès aussi important, une semaine plus tard. Le général Gaston Ouassenan Konan, vice-président, un autre pilier, un autre baobab du parti septuagénaire a rendu l’âme. Dans presque les mêmes conditions. Sans avoir été déclaré malade. Et pourtant, il était aux funérailles la veille du président Bédié, avec le ministre et vice-président Emile Constant Bombet.

Quel malheur s’abat-il sur le parti du père fondateur Félix Houphouët-Boigny ? Même si l’on a l’habitude de dire qu’un malheur n’arrive jamais seul, mais il y a de quoi s’inquiéter. Pourquoi ce malheur frappe-t-il que seulement la tête du Pdci-Rda? Est-ce le signe annonciateur que le Pdci-Rda va disparaître dans les jours à venir. Car à quoi sert un parti sans ses hommes forts ? Surtout qu’au niveau du parti au pouvoir, l’on n’hésite pas à toujours jeter l’appât pour vider la mare Pdci-Rda ?

Pour certains observateurs de la vie politique ivoirienne, les décès de Henri Konan Bédié 89 ans, président du parti et Gaston Ouassenan Koné, 84 ans, tous deux grands serviteurs de l’Etat et de leur parti, qui a gouverné le pays pendant 40 ans dans la paix et a amorcé la modernisation du pays avec les actions du premier président ivoirien, Félix Houphouët-Boigny prolongées par les 12 chantiers de l’Eléphant d’Afrique de Henri Konan Bédié, malheureusement interrompu par un coup d’Etat qualifié d’incongru par les partisans de l’ex-parti au pouvoir, peuvent susciter deux réactions.

La première, c’est que cela peut entrainer la disparition du premier parti ivoirien qui peut se fondre dans l’actuel parti au pouvoir. Ce qui a été toujours le souhait du président du Rhdp et de ses partisans. Chose à laquelle s’est opposé avec énergie le président Bédié. Aujourd’hui qu’il n’est plus là, est-ce à dire que les voies sont grandement dégagées pour faire disparaître le Pdci-Rda, héritage d’Houphouët-Boigny, au profit du Rhdp de Alassane Ouattara se réclamant aussi d’houphouëtiste ?

Lire aussi: https://justeinfos.net/communaute-abel-long-integre-le-reseau-ecpat-international/

La deuxième réaction que pourraient susciter ces deux décès c’est que cela peut servir de catalyseur, de déclencheurs, d’excitant pour les fidèles militants en vue de resserrer les rangs, donner un nouveau souffle, réorganiser le parti et le rendre plus dynamique, plus conquérant afin de mieux tenir tête aux parti au pouvoir. Comme le dise les Anglais « wait and se. »

Benoît Kadjo et Antoine Kouakou

#Benkpakla

- Advertisement -

- Advertisement -

- Advertisement -

- Advertisement -