Skip to content

Commit 9ce210a

Browse files
authored
Merge pull request #834 from lightspeedwp/hotfix/sticky-menu-filter-build
Fix: Sticky Menu Filter File Missing in Production Builds
2 parents 26ad5db + c558b52 commit 9ce210a

File tree

14 files changed

+256
-137
lines changed

14 files changed

+256
-137
lines changed

build/blocks/icons/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => 'e6c6daf9eaf99c8b3e12');
1+
<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => 'd9fe694a87a741e153ac');

build/blocks/icons/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: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* Filters for the sticky menu block
4+
*
5+
* This file contains WordPress filters that modify block rendering to add
6+
* mobile-specific functionality for sticky menu sections. It is loaded
7+
* directly by the plugin and not via block.json's render callback.
8+
*
9+
* @package tour-operator
10+
*/
11+
12+
// Prevent direct access.
13+
if ( ! defined( 'ABSPATH' ) ) {
14+
exit;
15+
}
16+
17+
if ( ! function_exists( 'add_mobile_section_headers' ) ) {
18+
/**
19+
* Add mobile header for sticky menu sections
20+
*
21+
* This function adds collapsible mobile headers to group blocks that have
22+
* sticky menu functionality enabled. It wraps the block content with
23+
* interactive controls for mobile navigation.
24+
*
25+
* @since 2.1.0
26+
* @param string $block_content The block's rendered HTML content.
27+
* @param array $block The full block, including name and attributes.
28+
* @return string Modified block content with mobile headers added if applicable.
29+
*/
30+
function add_mobile_section_headers( $block_content, $block ) {
31+
// Only process group blocks with sticky menu enabled
32+
if ( 'core/group' !== $block['blockName'] ) {
33+
return $block_content;
34+
}
35+
36+
$attributes = $block['attrs'] ?? array();
37+
38+
if ( empty( $attributes['addToStickyMenu'] ) || empty( $attributes['stickyMenuId'] ) ) {
39+
return $block_content;
40+
}
41+
42+
$section_id = esc_attr( $attributes['stickyMenuId'] );
43+
$section_title = ! empty( $attributes['stickyMenuTitle'] ) ? esc_html( $attributes['stickyMenuTitle'] ) : esc_html( $section_id );
44+
45+
// Create the mobile header button
46+
$mobile_header = sprintf(
47+
'<button class="lsx-to-section-header" aria-expanded="false" id="%1$s-header" aria-controls="%1$s-content" aria-describedby="%1$s-desc">
48+
<span>%2$s</span>
49+
<span class="lsx-to-sticky-caret"><svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M16.25 6.875L10 13.125L3.75 6.875" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg></span>
50+
</button>
51+
<div id="%1$s-desc" class="lsx-to-sr-only">%3$s</div>',
52+
$section_id,
53+
$section_title,
54+
esc_html__( 'Toggle section content visibility', 'tour-operator' )
55+
);
56+
57+
// Wrap the entire block content with the header button outside
58+
// This ensures the button stays visible when content is collapsed
59+
$wrapped_content = sprintf(
60+
'<div class="lsx-to-sticky-menu-section-wrapper" role="region" aria-labelledby="%1$s-header">%2$s<div class="lsx-to-sticky-menu-section-content" id="%1$s-content">%3$s</div></div>',
61+
$section_id,
62+
$mobile_header,
63+
$block_content
64+
);
65+
66+
return $wrapped_content;
67+
}
68+
69+
add_filter( 'render_block', 'add_mobile_section_headers', 10, 2 );
70+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'ebef7ac41b1918a95ad5');
1+
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'fa65b64a582e57260221');

build/blocks/sticky-menu/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.

changelog.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Changelog
22

3-
## [[2.1.0]](https://github.com/lightspeedwp/tour-operator/releases/tag/2.1.0) - In Dev
3+
## [[2.1.1]](https://github.com/lightspeedwp/tour-operator/releases/tag/2.1.1) - 2026-01-05
4+
5+
### Fixed
6+
7+
#### Build & Deployment
8+
9+
- **Sticky Menu Block Filter File in Production** - Renamed `render.php` to `filters.php` in sticky-menu block and configured webpack to copy it to build folder using CopyWebpackPlugin. This ensures the mobile section headers filter is available in production releases (which only include the build/ folder). Added `function_exists()` check to prevent redeclaration errors - PR [#834](https://github.com/lightspeedwp/tour-operator/pull/834)
10+
11+
## [[2.1.0]](https://github.com/lightspeedwp/tour-operator/releases/tag/2.1.0) - 2025-12-19
412

513
### Added
614

docs/css-class-audit.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ These classes are actively used in PHP templates, JavaScript files, or block ren
167167
| `lsx-to-sticky-menu-item` | `src/blocks/sticky-menu/index.js` |
168168
| `lsx-to-sticky-menu-button` | `src/blocks/sticky-menu/index.js`, `view.js` |
169169
| `lsx-to-sticky-menu-section` | `src/blocks/sticky-menu/` |
170-
| `lsx-to-sticky-menu-section-wrapper` | `src/blocks/sticky-menu/render.php`, `view.js` |
171-
| `lsx-to-sticky-menu-section-content` | `src/blocks/sticky-menu/render.php` |
172-
| `lsx-to-section-header` | `src/blocks/sticky-menu/render.php`, `view.js` |
173-
| `lsx-to-sticky-caret` | `src/blocks/sticky-menu/render.php` |
174-
| `lsx-to-sr-only` | `src/blocks/sticky-menu/render.php`, `view.js` |
170+
| `lsx-to-sticky-menu-section-wrapper` | `src/blocks/sticky-menu/filters.php`, `view.js` |
171+
| `lsx-to-sticky-menu-section-content` | `src/blocks/sticky-menu/filters.php` |
172+
| `lsx-to-section-header` | `src/blocks/sticky-menu/filters.php`, `view.js` |
173+
| `lsx-to-sticky-caret` | `src/blocks/sticky-menu/filters.php` |
174+
| `lsx-to-sr-only` | `src/blocks/sticky-menu/filters.php`, `view.js` |
175175
| `lsx-to-sticky-menu-placeholder` | `src/blocks/sticky-menu/index.js` |
176176
| `wp-block-lsx-tour-operator-sticky-menu` | `src/blocks/sticky-menu/view.js` |
177177

package-lock.json

Lines changed: 82 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tour-operator",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Tour Operators for LSX",
55
"author": "LightSpeed",
66
"license": "ISC",
@@ -42,6 +42,7 @@
4242
"@wordpress/prettier-config": "4.37.0",
4343
"@wordpress/scripts": "^31.2.0",
4444
"@wordpress/stylelint-config": "^23.29.0",
45+
"copy-webpack-plugin": "^13.0.1",
4546
"eslint": "9.39.2",
4647
"jest": "30.2.0",
4748
"npm-package-json-lint": "9.1.0",

readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tags: tour operator, travel, itinerary, tours, destinations, accommodations, tou
55
Requires at least: 6.7
66
Tested up to: 6.9
77
Requires PHP: 8.0
8-
Stable tag: 2.1.0
8+
Stable tag: 2.1.1
99
License: GPLv3 or later
1010
License URI: https://www.gnu.org/licenses/gpl-3.0.html
1111

0 commit comments

Comments
 (0)