Add $context param to beyondwords_player_html filter#481
Merged
Conversation
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds a $context parameter to the beyondwords_player_html filter to distinguish between players that are automatically prepended to content and those added via shortcode. This enables developers to apply different filtering logic based on how the player is being rendered, particularly useful when using shortcodes in custom template locations like footers.
Changes:
- Added
$contextparameter ('auto' or 'shortcode') to thebeyondwords_player_htmlfilter and all player renderer methods - Updated player HTML to include a
data-beyondwords-player-contextattribute - Added comprehensive PHPUnit and Cypress tests to validate the new functionality
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Core/Player/Player.php | Updated renderPlayer() to accept and pass $context parameter; modified shortcode and auto-prepend logic to use appropriate context values |
| src/Core/Player/Renderer/Javascript.php | Added $context parameter to render() method and included it as a data attribute in the script tag |
| src/Core/Player/Renderer/Amp.php | Added $context parameter to render() method and included it as a data attribute in the amp-iframe element |
| tests/phpunit/Core/PlayerTest.php | Updated existing tests and added new test for legacy player to verify correct context values in player HTML |
| tests/cypress/e2e/filters.cy.js | Added test to verify dual players with different contexts when shortcode is used in footer |
| tests/fixtures/wp-content/plugins/beyondwords-shortcode-in-footer.php | New test fixture plugin that outputs a player shortcode in the footer |
| speechkit.php | Bumped version to 6.1.0-beta.1 |
| package.json | Updated version to 6.1.0-beta.1; modified cypress:run script |
| readme.txt | Added changelog entry for version 6.1.0 documenting the new feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
nklhtv
approved these changes
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces enhancements to the BeyondWords WordPress plugin, focusing on improving the flexibility of the audio player rendering and its integration with WordPress filters. The main change is the addition of a
$contextparameter to thebeyondwords_player_htmlfilter, allowing developers to distinguish between players auto-inserted into content and those added via shortcode. The update also includes improvements to player rendering, test coverage, and documentation.Enhancements to player rendering and filtering:
$contextparameter to thebeyondwords_player_htmlfilter, enabling filtering based on whether the player was auto-prepended tothe_contentor inserted via shortcode. This allows for more granular control over player display in themes and templates. [1] [2]renderPlayer,Renderer\Amp::render, andRenderer\Javascript::render) to accept and propagate the$contextparameter, and added adata-beyondwords-player-contextattribute to the player HTML output. [1] [2] [3] [4] [5]Testing improvements:
Documentation and metadata updates:
6.1.0-beta.1inpackage.json,readme.txt, andspeechkit.php, and documented the new enhancement in the changelog. [1] [2] [3] [4] [5]Build and CI adjustments:
cypress:runscript to improve compatibility with CI environments.