Skip to content

Commit 8975da9

Browse files
authored
Merge pull request #815 from lightspeedwp/feature/unit-blocks
Feature: Unit Blocks – merge into 2.1-trunk
2 parents 32ab6b7 + 6f4c275 commit 8975da9

File tree

13 files changed

+80
-67
lines changed

13 files changed

+80
-67
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('wp-i18n'), 'version' => '9ba000a8a02a2bb9a226');
1+
<?php return array('dependencies' => array('wp-i18n'), 'version' => 'c99848e4f2a2d6c84956');

build/blocks/best-time-to-visit/index.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.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('wp-i18n'), 'version' => '8d09f715be4f181bbfe6');
1+
<?php return array('dependencies' => array('wp-i18n'), 'version' => 'aac926357ff1bfa1b40c');

build/blocks/destination-to-tour/index.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.

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' => '606577136053e22dca6d');
1+
<?php return array('dependencies' => array(), 'version' => 'df0054a1a528af11bb7b');

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.

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
- **Sticky Menu Block** - Added sticky navigation menu block with desktop and mobile navigation support for single post templates, includes anchor support and section group functionality - [#684](https://github.com/lightspeedwp/tour-operator/pull/684), Issue [#496](https://github.com/lightspeedwp/tour-operator/issues/496)
3535
- **TO Videos Block** - Added YouTube video gallery block for displaying videos on tours, accommodation, and destination templates in a professional gallery layout - [#598](https://github.com/lightspeedwp/tour-operator/pull/598), Issue [#397](https://github.com/lightspeedwp/tour-operator/issues/397)
3636
- **Check-in/Checkout Time Icon Blocks** - Added icon-based blocks (replacing images) for check-in and checkout times with filters to display only on relevant post types (accommodation) and related templates - [#645](https://github.com/lightspeedwp/tour-operator/pull/645)
37+
- **Unit Blocks** - Added comprehensive unit blocks functionality with refined assets and WordPress coding standards alignment - [#815](https://github.com/lightspeedwp/tour-operator/pull/815)
3738

3839
#### Features & Integrations
3940

includes/classes/blocks/class-bindings.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,18 @@ public function render_itinerary_block( $block_content, $parsed_block, $block_ob
308308
return $block_content;
309309
}
310310

311-
$pattern = $block_content;
312-
$group = array();
311+
$build_template = $block_content;
312+
$group = array();
313+
314+
//$pattern_registry = \WP_Block_Patterns_Registry::get_instance();
315+
//$pattern_registry->get_registered();
313316

314317
// Iterate through and build our itinerary from the block content template.
315318
if ( lsx_to_has_itinerary() ) {
316319
$itinerary_count = 1;
317320
while ( lsx_to_itinerary_loop() ) {
318321
lsx_to_itinerary_loop_item();
319-
$build = $pattern;
322+
$build = $build_template;
320323

321324
foreach ( $this->itinerary_fields as $field ) {
322325
$build = $this->build_itinerary_field( $build, $field, $itinerary_count );
@@ -343,6 +346,7 @@ public function render_itinerary_block( $block_content, $parsed_block, $block_ob
343346
public function build_itinerary_field( $build = '', $field = '', $count = 1 ) {
344347
$pattern = '';
345348
$value = '';
349+
$prefix = '';
346350

347351
switch ( $field ) {
348352
case 'title':
@@ -366,26 +370,31 @@ public function build_itinerary_field( $build = '', $field = '', $count = 1 ) {
366370
case 'location':
367371
$value = lsx_to_itinerary_destinations( '', '', false );
368372
$pattern = '/(<p\s+[^>]*\bclass="[^"]*\bitinerary-location\b[^"]*"[^>]*>).*?(<\/p>)/is';
373+
$prefix = $this->maybe_get_prefix( 'itinerary-location', $build );
369374
break;
370375

371376
case 'accommodation':
372377
$value = lsx_to_itinerary_accommodation( '', '', false );
373378
$pattern = '/(<p\s+[^>]*\bclass="[^"]*\bitinerary-accommodation\b[^"]*"[^>]*>).*?(<\/p>)/is';
379+
$prefix = $this->maybe_get_prefix( 'itinerary-accommodation', $build );
374380
break;
375381

376382
case 'type':
377383
$value = lsx_to_itinerary_accommodation_type( '', '', false );
378384
$pattern = '/(<p\s+[^>]*\bclass="[^"]*\bitinerary-type\b[^"]*"[^>]*>).*?(<\/p>)/is';
385+
$prefix = $this->maybe_get_prefix( 'itinerary-type', $build );
379386
break;
380387

381388
case 'drinks':
382389
$value = lsx_to_itinerary_drinks_basis( '', '', false );
383390
$pattern = '/(<p\s+[^>]*\bclass="[^"]*\bitinerary-drinks\b[^"]*"[^>]*>).*?(<\/p>)/is';
391+
$prefix = $this->maybe_get_prefix( 'itinerary-drinks', $build );
384392
break;
385393

386394
case 'room':
387395
$value = lsx_to_itinerary_room_basis( '', '', false );
388396
$pattern = '/(<p\s+[^>]*\bclass="[^"]*\bitinerary-room\b[^"]*"[^>]*>).*?(<\/p>)/is';
397+
$prefix = $this->maybe_get_prefix( 'itinerary-room', $build );
389398
break;
390399

391400
case 'included':
@@ -408,6 +417,9 @@ public function build_itinerary_field( $build = '', $field = '', $count = 1 ) {
408417
if ( '' === $value || false === $value || empty( $value ) ) {
409418
$pattern = '/\bitin-' . $field . '-wrapper\b/';
410419
$value = 'hidden itin-' . $field . '-wrapper';
420+
} else {
421+
// Or set the prefix.
422+
$value = $prefix . $value;
411423
}
412424

413425
$replacement = '$1' . $value . '$2';
@@ -416,6 +428,14 @@ public function build_itinerary_field( $build = '', $field = '', $count = 1 ) {
416428
return $build;
417429
}
418430

431+
public function maybe_get_prefix( $key, $build ) {
432+
$pattern = '/<p\s+[^>]*\bclass="[^"]*\b' . esc_attr( $key ) . '\b[^"]*"[^>]*>(.*?)<\/p>/is';
433+
if ( preg_match( $pattern, $build, $matches ) ) {
434+
return str_replace( 'Card Link', '', $matches[1] );
435+
}
436+
return '';
437+
}
438+
419439
/**
420440
* Modifies the HTML content by updating the innerHTML of any heading tag (h1-h6)
421441
* that has the class "itinerary-title" with the result of the lsx_to_itinerary_title function.

0 commit comments

Comments
 (0)