                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                			],
			false
		);
		$fld = $this->field_element(
			'select',
			$field,
			[
				'slug'    => 'icon_size',
				'value'   => ! empty( $field['icon_size'] ) ? esc_attr( $field['icon_size'] ) : 'medium',
				'options' => [
					'small'  => esc_html__( 'Small', 'wpforms-lite' ),
					'medium' => esc_html__( 'Medium', 'wpforms-lite' ),
					'large'  => esc_html__( 'Large', 'wpforms-lite' ),
				],
			],
			false
		);

		$this->field_element(
			'row',
			$field,
			[
				'slug'    => 'icon_size',
				'content' => $lbl . $fld,
			]
		);

		$this->score_labels( $field );

		// Icon color picker.
		$lbl = $this->field_element(
			'label',
			$field,
			[
				'slug'    => 'icon_color',
				'value'   => esc_html__( 'Icon Color', 'wpforms-lite' ),
				'tooltip' => esc_html__( 'Select the color for the rating icon', 'wpforms-lite' ),
			],
			false
		);

		$icon_color = isset( $field['icon_color'] ) ? wpforms_sanitize_hex_color( $field['icon_color'] ) : '';
		$icon_color = empty( $icon_color ) ? $this->get_default_icon_color() : $icon_color;

		$fld = $this->field_element(
			'color',
			$field,
			[
				'slug'  => 'icon_color',
				'value' => $icon_color,
				'data'  => [
					'fallback-color' => $icon_color,
				],
			],
			false
		);

		$this->field_element(
			'row',
			$field,
			[
				'slug'    => 'icon_color',
				'content' => $lbl . $fld,
				'class'   => 'color-picker-row',
			]
		);

		// Custom CSS classes.
		$this->field_option( 'css', $field );

		// Hide label.
		$this->field_option( 'label_hide', $field );

		// Options close markup.
		$this->field_option(
			'advanced-options',
			$field,
			[
				'markup' => 'close',
			]
		);
	}

	/**
	 * Score labels.
	 *
	 * @since 1.9.8
	 *
	 * @param array $field Field settings.
	 */
	private function score_labels( array $field ): void {

		// Lowest score label.
		$lowest_label = $this->field_element(
			'label',
			$field,
			[
				'slug'    => 'lowest_label',
				'value'   => esc_html__( 'Lowest Score Label', 'wpforms-lite' ),
				'tooltip' => esc_html__( 'This label indicates the lowest score on the scale.', 'wpforms-lite' ),
			],
			false
		);

		$lowest_field = $this->field_element(
			'text',
			$field,
			[
				'slug'  => 'lowest_label',
				'value' => $field['lowest_label'] ?? '',
			],
			false
		);

		$this->field_element(
			'row',
			$field,
			[
				'slug'    => 'lowest_label',
				'content' => $lowest_label . $lowest_field,
			]
		);

		// Highest score label.
		$highest_label = $this->field_element(
			'label',
			$field,
			[
				'slug'    => 'highest_label',
				'value'   => esc_html__( 'Highest Score Label', 'wpforms-lite' ),
				'tooltip' => esc_html__( 'This label indicates the highest score on the scale.', 'wpforms-lite' ),
			],
			false
		);

		$highest_field = $this->field_element(
			'text',
			$field,
			[
				'slug'  => 'highest_label',
				'value' => $field['highest_label'] ?? '',
			],
			false
		);

		$this->field_element(
			'row',
			$field,
			[
				'slug'    => 'highest_label',
				'content' => $highest_label . $highest_field,
			]
		);

		// Label position.
		$label_position = $this->field_element(
			'label',
			$field,
			[
				'slug'    => 'label_position',
				'value'   => esc_html__( 'Label Position', 'wpforms-lite' ),
				'tooltip' => esc_html__( 'Select the position of the label', 'wpforms-lite' ),
			],
			false
		);

		$select_position = $this->field_element(
			'select',
			$field,
			[
				'slug'    => 'label_position',
				'value'   => ! empty( $field['label_position'] ) ? esc_attr( $field['label_position'] ) : 'below',
				'options' => [
					'above' => esc_html__( 'Above', 'wpforms-lite' ),
					'below' => esc_html__( 'Below', 'wpforms-lite' ),
				],
			],
			false
		);

		$this->field_element(
			'row',
			$field,
			[
				'slug'    => 'label_position',
				'content' => $label_position . $select_position,
			]
		);
	}

	/**
	 * Field preview inside the builder.
	 *
	 * @since 1.9.4
	 *
	 * @param array $field Field settings.
	 */
	public function field_preview( $field ): void {

		// Label.
		$this->field_preview_option(
			'label',
			$field,
			[
				'label_badge' => $this->get_field_preview_badge(),
			]
		);

		echo '<div class="wpforms-rating-field">';

		$this->get_field_preview_icons( $field );

		$this->get_field_preview_labels( $field );

		echo '</div>';

		// Description.
		$this->field_preview_option( 'description', $field );
	}

	/**
	 * Get field preview icons.
	 *
	 * @since 1.9.8
	 *
	 * @param array $field Field settings.
	 */
	private function get_field_preview_icons( array $field ): void {

		// Define data.
		$scale      = ! empty( $field['scale'] ) ? esc_attr( $field['scale'] ) : 5;
		$icon       = ! empty( $field['icon'] ) ? esc_attr( $field['icon'] ) : 'star';
		$icon_size  = ! empty( $field['icon_size'] ) ? esc_attr( $field['icon_size'] ) : 'medium';
		$icon_color = ! empty( $field['icon_color'] ) ? esc_attr( $field['icon_color'] ) : $this->get_default_icon_color();
		$icon_class = $this->get_preview_icon_class( $icon );

		// Set icon size.
		$icon_size_css = $this->get_icon_size_css( $icon_size );

		echo '<div class="wpforms-rating-field-icons">';

		// Primary input.
		for ( $i = 1; $i <= 10; $i++ ) {
			printf(
				'<i class="fa %s %s rating-icon" aria-hidden="true" style="color:%s; display:%s; font-size:%dpx;"></i>',
				esc_attr( $icon_class ),
				esc_attr( $icon_size ),
				esc_attr( $icon_color ),
				$i <= $scale ? 'inline-block' : 'none',
				esc_attr( $icon_size_css )
			);
		}

		echo '</div>';
	}

	/**
	 * Get preview icon class based on the selected icon.
	 *
	 * @since 1.9.8
	 *
	 * @param string $icon Selected icon.
	 *
	 * @return string Icon class.
	 */
	private function get_preview_icon_class( string $icon ): string {

		$icon_class = '';

		// Set icon class.
		switch ( $icon ) {
			case 'star':
				$icon_class = 'fa-star';
				break;

			case 'heart':
				$icon_class = 'fa-heart';
				break;

			case 'thumb':
				$icon_class = 'fa-thumbs-up';
				break;

			case 'smiley':
				$icon_class = 'fa-smile-o';
				break;
		}

		return $icon_class;
	}

	/**
	 * Get field preview labels.
	 *
	 * @since 1.9.8
	 *
	 * @param array $field Field settings.
	 */
	private function get_field_preview_labels( array $field ): void {

		// Lowest score label.
		$lowest_label = ! empty( $field['lowest_label'] ) ? esc_html( $field['lowest_label'] ) : '';

		// Highest score label.
		$highest_label = ! empty( $field['highest_label'] ) ? esc_html( $field['highest_label'] ) : '';

		$class = [ 'wpforms-rating-field-labels' ];

		if ( ! empty( $field['label_position'] ) && $field['label_position'] === 'above' ) {
			$class[] = 'wpforms-rating-field-labels-position-above';
		}

		if ( empty( $lowest_label ) && empty( $highest_label ) ) {
			$class[] = 'wpforms-hidden';
		}

		echo '<div class=" ' . wpforms_sanitize_classes( $class, true ) . ' ">';

		printf(
			'<span class="wpforms-rating-field-lowest-label wpforms-sub-label">%s</span>',
			esc_html( $lowest_label )
		);

		printf(
			'<span class="wpforms-rating-field-highest-label wpforms-sub-label">%s</span>',
			esc_html( $highest_label )
		);

		echo '</div>';
	}

	/**
	 * Field display on the form front-end.
	 *
	 * @since 1.9.4
	 *
	 * @param array $field      Field settings.
	 * @param array $deprecated Deprecated, don't use.
	 * @param array $form_data  Form data and settings.
	 */
	public function field_display( $field, $deprecated, $form_data ) {
	}

	/**
	 * Get icon size CSS value in pixels.
	 *
	 * @since 1.9.4
	 *
	 * @param string $icon_size Icon size value.
	 */
	protected function get_icon_size_css( $icon_size ): string {

		$render_engine = wpforms_get_render_engine();

		$icon_sizes = [
			'classic' => [
				'small'  => '18',
				'medium' => '28',
				'large'  => '38',
			],
			'modern'  => [
				'small'  => '16',
				'medium' => '24',
				'large'  => '38',
			],
		];

		$default = $render_engine === 'modern' ? '24' : '28';

		return ! empty( $icon_sizes[ $render_engine ][ $icon_size ] )
			? $icon_sizes[ $render_engine ][ $icon_size ]
			: $default;
	}

	/**
	 * Get default icon color.
	 *
	 * @since 1.9.4
	 *
	 * @return string
	 */
	public function get_default_icon_color(): string {

		$render_engine = wpforms_get_render_engine();

		return array_key_exists( $render_engine, self::DEFAULT_ICON_COLOR ) ? self::DEFAULT_ICON_COLOR[ $render_engine ] : self::DEFAULT_ICON_COLOR['modern'];
	}
}
{"id":151,"date":"2026-03-11T23:21:37","date_gmt":"2026-03-11T22:21:37","guid":{"rendered":"https:\/\/nestdomi.com\/?post_type=mphb_room_type&#038;p=151"},"modified":"2026-03-11T23:21:37","modified_gmt":"2026-03-11T22:21:37","slug":"nestdomi-prague","status":"publish","type":"mphb_room_type","link":"https:\/\/nestdomi.com\/zh\/accommodation\/nestdomi-prague\/","title":{"rendered":"Nestdomi Prague"},"content":{"rendered":"<div class=\"wpforms-container wpforms-render-modern\" id=\"wpforms-30\"><form id=\"wpforms-form-30\" class=\"wpforms-validate wpforms-form wpforms-ajax-form\" data-formid=\"30\" method=\"post\" enctype=\"multipart\/form-data\" action=\"\/zh\/wp-json\/wp\/v2\/mphb_room_type\/151\" data-token=\"2ec9e411d164f963b55e66045bc0b58f\" data-token-time=\"1784380955\"><div class=\"wpforms-head-container\"><div class=\"wpforms-title\">Contact us<\/div><div class=\"wpforms-description\">Submit your request and we will respond within 24 hours to confirm availability and finalize your reservation.<\/div><\/div><noscript class=\"wpforms-error-noscript\">\u8bf7\u5728\u6d4f\u89c8\u5668\u4e2d\u542f\u7528JavaScript\u6765\u5b8c\u6210\u6b64\u8868\u5355\u3002<\/noscript><div id=\"wpforms-error-noscript\" style=\"display: none;\">\u8bf7\u5728\u6d4f\u89c8\u5668\u4e2d\u542f\u7528JavaScript\u6765\u5b8c\u6210\u6b64\u8868\u5355\u3002<\/div><div class=\"wpforms-field-container\">\t\t<div id=\"wpforms-30-field_5-container\"\n\t\t\tclass=\"wpforms-field wpforms-field-text\"\n\t\t\tdata-field-type=\"text\"\n\t\t\tdata-field-id=\"5\"\n\t\t\t>\n\t\t\t<label class=\"wpforms-field-label\" for=\"wpforms-30-field_5\" >Subject E-mail Message<\/label>\n\t\t\t<input type=\"text\" id=\"wpforms-30-field_5\" class=\"wpforms-field-medium\" name=\"wpforms[fields][5]\" >\n\t\t<\/div>\n\t\t<div id=\"wpforms-30-field_1-container\" class=\"wpforms-field wpforms-field-name\" data-field-id=\"1\"><label class=\"wpforms-field-label\" for=\"wpforms-30-field_1\">Name <span class=\"wpforms-required-label\" aria-hidden=\"true\">*<\/span><\/label><input type=\"text\" id=\"wpforms-30-field_1\" class=\"wpforms-field-large wpforms-field-required\" name=\"wpforms[fields][1]\" aria-errormessage=\"wpforms-30-field_1-error\" required><\/div><div id=\"wpforms-30-field_2-container\" class=\"wpforms-field wpforms-field-email\" data-field-id=\"2\"><label class=\"wpforms-field-label\" for=\"wpforms-30-field_2\">E-mail <span class=\"wpforms-required-label\" aria-hidden=\"true\">*<\/span><\/label><input type=\"email\" id=\"wpforms-30-field_2\" class=\"wpforms-field-large wpforms-field-required\" name=\"wpforms[fields][2]\" spellcheck=\"false\" aria-errormessage=\"wpforms-30-field_2-error\" required><\/div><div id=\"wpforms-30-field_3-container\" class=\"wpforms-field wpforms-field-text\" data-field-id=\"3\"><label class=\"wpforms-field-label\" for=\"wpforms-30-field_3\">Subject<\/label><input type=\"text\" id=\"wpforms-30-field_3\" class=\"wpforms-field-large\" name=\"wpforms[fields][3]\" aria-errormessage=\"wpforms-30-field_3-error\" ><\/div><div id=\"wpforms-30-field_4-container\" class=\"wpforms-field wpforms-field-textarea\" data-field-id=\"4\"><label class=\"wpforms-field-label\" for=\"wpforms-30-field_4\">Message <span class=\"wpforms-required-label\" aria-hidden=\"true\">*<\/span><\/label><textarea id=\"wpforms-30-field_4\" class=\"wpforms-field-large wpforms-field-required\" name=\"wpforms[fields][4]\" aria-errormessage=\"wpforms-30-field_4-error\" required><\/textarea><\/div><script>\n\t\t\t\t( function() {\n\t\t\t\t\tconst style = document.createElement( 'style' );\n\t\t\t\t\tstyle.appendChild( document.createTextNode( '#wpforms-30-field_5-container { position: absolute !important; overflow: hidden !important; display: inline !important; height: 1px !important; width: 1px !important; z-index: -1000 !important; padding: 0 !important; } #wpforms-30-field_5-container input { visibility: hidden; } #wpforms-conversational-form-page #wpforms-30-field_5-container label { counter-increment: none; }' ) );\n\t\t\t\t\tdocument.head.appendChild( style );\n\t\t\t\t\tdocument.currentScript?.remove();\n\t\t\t\t} )();\n\t\t\t<\/script><\/div><!-- .wpforms-field-container --><div class=\"wpforms-submit-container\" ><input type=\"hidden\" name=\"wpforms[id]\" value=\"30\"><input type=\"hidden\" name=\"page_title\" value=\"\"><input type=\"hidden\" name=\"page_url\" value=\"https:\/\/nestdomi.com\/zh\/wp-json\/wp\/v2\/mphb_room_type\/151\"><input type=\"hidden\" name=\"url_referer\" value=\"\"><button type=\"submit\" name=\"wpforms[submit]\" id=\"wpforms-submit-30\" class=\"wpforms-submit\" data-alt-text=\"Sending...\" data-submit-text=\"Send\" aria-live=\"assertive\" value=\"wpforms-submit\">Send<\/button><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/nestdomi.com\/wp-content\/plugins\/wpforms-lite\/assets\/images\/submit-spin.svg\" class=\"wpforms-submit-spinner\" style=\"display: none;\" width=\"26\" height=\"26\" alt=\"\u52a0\u8f7d\"><\/div><\/form><\/div>  <!-- .wpforms-container -->\n","protected":false},"excerpt":{"rendered":"","protected":false},"featured_media":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","mphb_room_type_category":[],"mphb_room_type_tag":[],"mphb_room_type_facility":[],"class_list":["post-151","mphb_room_type","type-mphb_room_type","status-publish","hentry","mphb-room-type-adults-2","mphb-room-type-children-3",""],"_links":{"self":[{"href":"https:\/\/nestdomi.com\/zh\/wp-json\/wp\/v2\/mphb_room_type\/151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nestdomi.com\/zh\/wp-json\/wp\/v2\/mphb_room_type"}],"about":[{"href":"https:\/\/nestdomi.com\/zh\/wp-json\/wp\/v2\/types\/mphb_room_type"}],"replies":[{"embeddable":true,"href":"https:\/\/nestdomi.com\/zh\/wp-json\/wp\/v2\/comments?post=151"}],"wp:attachment":[{"href":"https:\/\/nestdomi.com\/zh\/wp-json\/wp\/v2\/media?parent=151"}],"wp:term":[{"taxonomy":"mphb_room_type_category","embeddable":true,"href":"https:\/\/nestdomi.com\/zh\/wp-json\/wp\/v2\/mphb_room_type_category?post=151"},{"taxonomy":"mphb_room_type_tag","embeddable":true,"href":"https:\/\/nestdomi.com\/zh\/wp-json\/wp\/v2\/mphb_room_type_tag?post=151"},{"taxonomy":"mphb_room_type_facility","embeddable":true,"href":"https:\/\/nestdomi.com\/zh\/wp-json\/wp\/v2\/mphb_room_type_facility?post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}