Skip to content

Commit 9776269

Browse files
committed
Merge branch 'feature/unit-blocks' into 2.1-trunk
2 parents 8975da9 + 1bd935f commit 9776269

File tree

5 files changed

+23
-22
lines changed

5 files changed

+23
-22
lines changed

build/paragraph-prefix.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => 'df0054a1a528af11bb7b');
1+
<?php return array('dependencies' => array(), 'version' => 'a10e7368f904999df961');

build/paragraph-prefix.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/classes/blocks/class-bindings.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ public function build_unit_field( $build = '', $field = '', $count = 1 ) {
550550
global $rooms;
551551
$pattern = '';
552552
$value = '';
553+
$prefix = '';
553554
$tour_operator = tour_operator();
554555

555556
switch ( $field ) {
@@ -576,6 +577,7 @@ public function build_unit_field( $build = '', $field = '', $count = 1 ) {
576577
case 'type':
577578
$value = $rooms->item_type( '', '', false );
578579
$pattern = '/(<p\s+[^>]*\bclass="[^"]*\bunit-type\b[^"]*"[^>]*>).*?(<\/p>)/is';
580+
$prefix = $this->maybe_get_prefix( 'unit-type', $build );
579581
break;
580582

581583
case 'price':
@@ -602,16 +604,20 @@ public function build_unit_field( $build = '', $field = '', $count = 1 ) {
602604
}
603605

604606
$pattern = '/(<p\s+[^>]*\bclass="[^"]*\bunit-price\b[^"]*"[^>]*>).*?(<\/p>)/is';
607+
$prefix = $this->maybe_get_prefix( 'unit-price', $build );
605608
break;
606609

607610
default:
608611
break;
609612
}
610613

611614
// if the value is emtpy than add a css class to hide the element.
612-
if ( '' === $value ) {
615+
if ( '' === $value || false === $value || empty( $value ) ) {
613616
$pattern = '/\bunit-' . $field . '-wrapper\b/';
614617
$value = 'hidden unit-' . $field . '-wrapper';
618+
} else {
619+
// Or set the prefix.
620+
$value = $prefix . $value;
615621
}
616622

617623
$replacement = '$1 ' . $value . ' $2';

patterns/room-card.php

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,26 @@
5454
<!-- /wp:heading -->
5555
5656
<!-- wp:group {"metadata":{"name":"' . esc_attr__( 'Info Items', 'tour-operator' ) . '"},"style":{"spacing":{"blockGap":"var:preset|spacing|30"}},"layout":{"type":"constrained"}} -->
57-
<div class="wp-block-group"><!-- wp:group {"metadata":{"name":"' . esc_attr__( 'From Price Row', 'tour-operator' ) . '"},"className":"unit-price-wrapper","style":{"spacing":{"blockGap":"0.3125rem"}},"layout":{"type":"flex","flexWrap":"wrap","verticalAlignment":"center"}} -->
58-
<div class="wp-block-group unit-price-wrapper"><!-- wp:group {"style":{"spacing":{"blockGap":"0.3125rem"}},"layout":{"type":"flex","flexWrap":"nowrap","verticalAlignment":"center"}} -->
59-
<div class="wp-block-group"><!-- wp:lsx-tour-operator/icons {"iconType":"outline","iconName":"priceIcon"} /-->
57+
<div class="wp-block-group">
6058
61-
<!-- wp:paragraph {"style":{"typography":{"fontStyle":"normal","fontWeight":"700"}},"fontSize":"medium"} -->
62-
<p class="has-medium-font-size" style="font-style:normal;font-weight:700">' . esc_html__( 'From:', 'tour-operator' ) . '</p>
63-
<!-- /wp:paragraph --></div>
64-
<!-- /wp:group -->
59+
<!-- wp:group {"className":"unit-price-wrapper","style":{"spacing":{"margin":{"top":"0","bottom":"0"},"blockGap":"5px"}},"layout":{"type":"flex","flexWrap":"nowrap"}} -->
60+
<div class="wp-block-group unit-price-wrapper" style="margin-top:0;margin-bottom:0"><!-- wp:lsx-tour-operator/icons {"iconName":"priceIcon"} /-->
6561
66-
<!-- wp:paragraph {"metadata":{"name":"' . esc_attr__( 'Price Value', 'tour-operator' ) . '"},"className":"unit-price","fontSize":"medium"} -->
67-
<p class="unit-price has-medium-font-size">' . esc_html__( 'Price', 'tour-operator' ) . '</p>
62+
<!-- wp:paragraph {"className":"unit-price amount","style":{"elements":{"link":{"color":{"text":"var:preset|color|primary-700"}}},"spacing":{"padding":{"top":"2px","bottom":"2px"}}},"textColor":"primary-700","prefix":"From:","prefixBold":true} -->
63+
<p class="unit-price amount has-primary-700-color has-text-color has-link-color" style="padding-top:2px;padding-bottom:2px"></p>
6864
<!-- /wp:paragraph --></div>
6965
<!-- /wp:group -->
7066
71-
<!-- wp:group {"metadata":{"name":"' . esc_attr__( 'Unit Type Row', 'tour-operator' ) . '"},"className":"unit-type-wrapper","style":{"spacing":{"blockGap":"0.3125rem"}},"layout":{"type":"flex","flexWrap":"wrap","verticalAlignment":"center"}} -->
72-
<div class="wp-block-group unit-type-wrapper"><!-- wp:group {"style":{"spacing":{"blockGap":"0.3125rem"}},"layout":{"type":"flex","flexWrap":"nowrap","verticalAlignment":"center"}} -->
73-
<div class="wp-block-group"><!-- wp:lsx-tour-operator/icons {"iconType":"solid","iconName":"accommodationTypeIcon"} /-->
7467
75-
<!-- wp:paragraph {"style":{"typography":{"fontStyle":"normal","fontWeight":"700"}},"fontSize":"medium"} -->
76-
<p class="has-medium-font-size" style="font-style:normal;font-weight:700">' . esc_html__( 'Unit Type:', 'tour-operator' ) . '</p>
68+
<!-- wp:group {"className":"unit-type-wrapper","style":{"spacing":{"margin":{"top":"0","bottom":"0"},"blockGap":"5px"}},"layout":{"type":"flex","flexWrap":"nowrap","verticalAlignment":"top"}} -->
69+
<div class="wp-block-group unit-type-wrapper" style="margin-top:0;margin-bottom:0"><!-- wp:lsx-tour-operator/icons {"iconType":"solid","iconName":"accommodationTypeIcon"} /-->
70+
71+
<!-- wp:paragraph {"className":"unit-type","style":{"elements":{"link":{"color":{"text":"var:preset|color|primary-700"}}},"typography":{"textTransform":"capitalize"},"spacing":{"padding":{"top":"2px","bottom":"2px"}}},"textColor":"primary-700","prefix":"Unit Type:","prefixBold":true} -->
72+
<p class="unit-type has-primary-700-color has-text-color has-link-color" style="padding-top:2px;padding-bottom:2px;text-transform:capitalize"></p>
7773
<!-- /wp:paragraph --></div>
7874
<!-- /wp:group -->
7975
80-
<!-- wp:paragraph {"metadata":{"name":"' . esc_attr__( 'Unit Type Value', 'tour-operator' ) . '"},"className":"unit-type","fontSize":"medium"} -->
81-
<p class="unit-type has-medium-font-size">' . esc_html__( 'Unit type', 'tour-operator' ) . '</p>
82-
<!-- /wp:paragraph --></div>
83-
<!-- /wp:group --></div>
76+
</div>
8477
<!-- /wp:group --></div>
8578
<!-- /wp:group --></div>
8679
<!-- /wp:column --></div>

src/js/blocks/paragraph-prefix.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
props.attributes.className.includes('itinerary-location') ||
2323
props.attributes.className.includes('itinerary-type') ||
2424
props.attributes.className.includes('itinerary-drinks') ||
25-
props.attributes.className.includes('itinerary-room')
25+
props.attributes.className.includes('itinerary-room') ||
26+
props.attributes.className.includes('unit-price') ||
27+
props.attributes.className.includes('unit-type')
2628
);
2729

2830
const hasBindings = hasMetadataBindings || hasSpecificClasses;

0 commit comments

Comments
 (0)