Skip to content

Add $context param to beyondwords_player_html filter#481

Merged
galbus merged 9 commits intomainfrom
s-7903-wordpress-two-players-appearing-on-page-since-v6
Feb 17, 2026
Merged

Add $context param to beyondwords_player_html filter#481
galbus merged 9 commits intomainfrom
s-7903-wordpress-two-players-appearing-on-page-since-v6

Conversation

@galbus
Copy link
Contributor

@galbus galbus commented Jan 31, 2026

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 $context parameter to the beyondwords_player_html filter, 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:

  • Added a $context parameter to the beyondwords_player_html filter, enabling filtering based on whether the player was auto-prepended to the_content or inserted via shortcode. This allows for more granular control over player display in themes and templates. [1] [2]
  • Updated the player rendering methods (renderPlayer, Renderer\Amp::render, and Renderer\Javascript::render) to accept and propagate the $context parameter, and added a data-beyondwords-player-context attribute to the player HTML output. [1] [2] [3] [4] [5]

Testing improvements:

  • Expanded PHPUnit and Cypress test coverage to verify correct player rendering and context differentiation, including scenarios where both auto and shortcode players are present. [1] [2] [3] [4] [5] [6] [7] [8]

Documentation and metadata updates:

  • Updated plugin version to 6.1.0-beta.1 in package.json, readme.txt, and speechkit.php, and documented the new enhancement in the changelog. [1] [2] [3] [4] [5]

Build and CI adjustments:

  • Modified the cypress:run script to improve compatibility with CI environments.

@galbus galbus self-assigned this Jan 31, 2026
@galbus galbus added enhancement php Pull requests that update Php code javascript Pull requests that update Javascript code labels Jan 31, 2026
@linear
Copy link

linear bot commented Jan 31, 2026

@github-actions
Copy link

github-actions bot commented Jan 31, 2026

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 $context parameter ('auto' or 'shortcode') to the beyondwords_player_html filter and all player renderer methods
  • Updated player HTML to include a data-beyondwords-player-context attribute
  • 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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@galbus galbus merged commit 0513236 into main Feb 17, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement javascript Pull requests that update Javascript code php Pull requests that update Php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants