Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "beyondwords-wordpress-plugin",
"version": "5.5.0",
"version": "6.0.0",
"private": true,
"description": "BeyondWords WordPress Plugin",
"repository": {
Expand Down
10 changes: 9 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Contributors: beyondwords, stuartmcalpine
Donate link: https://beyondwords.io
Tags: text-to-speech, tts, audio, AI, voice cloning
Stable tag: 5.5.0
Stable tag: 6.0.0
Requires PHP: 8.0
Tested up to: 6.8
License: GPLv2 or later
Expand Down Expand Up @@ -80,6 +80,14 @@ Any questions? [Visit our website](https://beyondwords.io/?utm_source=wordpress&

== Changelog ==

= 6.0.0 =

Release date: TBC

**Enhancements and Features:**

* Make PHP methods static.

= 5.5.0 =

Release date: 2nd July 2025
Expand Down
7 changes: 3 additions & 4 deletions speechkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Description: The effortless way to make content listenable. Automatically create audio versions and embed via our customizable player.
* Author: BeyondWords
* Author URI: https://beyondwords.io
* Version: 5.5.0
* Version: 6.0.0
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: speechkit
Expand All @@ -35,11 +35,10 @@

// Define constants
// phpcs:disable
define('BEYONDWORDS__PLUGIN_VERSION', '5.5.0');
define('BEYONDWORDS__PLUGIN_VERSION', '6.0.0');
define('BEYONDWORDS__PLUGIN_DIR', plugin_dir_path(__FILE__));
define('BEYONDWORDS__PLUGIN_URI', plugin_dir_url(__FILE__));
// phpcs:enable

// Follow WordPress convention by using snakecase for variable name
$beyondwords_wordpress_plugin = new Beyondwords\Wordpress\Plugin();
$beyondwords_wordpress_plugin->init();
Beyondwords\Wordpress\Plugin::init();
8 changes: 5 additions & 3 deletions src/Compatibility/WPGraphQL/WPGraphQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ class WPGraphQL
* Init.
*
* @since 3.6.0
* @since 6.0.0 Make static.
*/
public function init()
public static function init()
{
// Actions for WPGraphQL
add_action('graphql_register_types', array($this, 'graphqlRegisterTypes'));
add_action('graphql_register_types', array(__CLASS__, 'graphqlRegisterTypes'));
}

/**
Expand All @@ -33,8 +34,9 @@ public function init()
* @since 3.6.0
* @since 4.0.0 Register contentId field, and contentId/podcastId are now String, not Int
* @since 4.7.0 Moved graphqlRegisterTypes() from Beyondwords\Wordpress\Core to here.
* @since 6.0.0 Make static.
*/
public function graphqlRegisterTypes()
public static function graphqlRegisterTypes()
{
register_graphql_object_type('Beyondwords', [
'description' => __('BeyondWords audio details. Use this data to embed an audio player using the BeyondWords JavaScript SDK.', 'speechkit'), // phpcs:ignore Generic.Files.LineLength.TooLong
Expand Down
61 changes: 42 additions & 19 deletions src/Component/Post/AddPlayer/AddPlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,42 @@ class AddPlayer
* Init.
*
* @since 4.0.0
* @since 6.0.0 Make static.
*/
public function init()
public static function init()
{
add_action('init', array($this, 'registerBlock'));
add_action('enqueue_block_editor_assets', array($this, 'addBlockEditorStylesheet'));
add_action('init', array(__CLASS__, 'registerBlock'));
add_action('enqueue_block_editor_assets', array(__CLASS__, 'addBlockEditorStylesheet'));

add_action('admin_head', array($this, 'addEditorStyles'));
add_filter('tiny_mce_before_init', array($this, 'filterTinyMceSettings'));
add_action('admin_head', array(__CLASS__, 'addEditorStyles'));
add_filter('tiny_mce_before_init', array(__CLASS__, 'filterTinyMceSettings'));

add_filter('mce_external_plugins', array($this, 'addPlugin'));
add_filter('mce_buttons', array($this, 'addButton'));
add_filter('mce_css', array($this, 'addStylesheet'));
add_filter('mce_external_plugins', array(__CLASS__, 'addPlugin'));
add_filter('mce_buttons', array(__CLASS__, 'addButton'));
add_filter('mce_css', array(__CLASS__, 'addStylesheet'));
}

/**
* Register Block.
*
* @since 3.2.0
* @since 6.0.0 Make static.
*/
public function registerBlock()
public static function registerBlock()
{
\register_block_type(__DIR__);
}

/**
* Add TinyMCE buttons.
*
* @since 6.0.0 Make static.
*
* @param array TinyMCE plugin array
*
* @return array
*/
public function addPlugin($plugin_array)
public static function addPlugin($plugin_array)
{
$plugin_array['beyondwords_player'] = BEYONDWORDS__PLUGIN_URI . 'src/Component/Post/AddPlayer/tinymce.js';
return $plugin_array;
Expand All @@ -64,9 +72,13 @@ public function addPlugin($plugin_array)
/**
* Register TinyMCE buttons.
*
* @since 6.0.0 Make static.
*
* @param array TinyMCE buttons array
*
* @return array
*/
public function addButton($buttons)
public static function addButton($buttons)
{
$advIndex = array_search('wp_adv', $buttons);

Expand All @@ -81,8 +93,14 @@ public function addButton($buttons)

/**
* Filters the comma-delimited list of stylesheets to load in TinyMCE.
*
* @since 6.0.0 Make static.
*
* @param string $stylesheets Comma-delimited list of stylesheets.
*
* @return string Comma-delimited list of stylesheets with the "Add Player" CSS appended.
*/
public function addStylesheet($stylesheets)
public static function addStylesheet($stylesheets)
{
return $stylesheets . ',' . BEYONDWORDS__PLUGIN_URI . 'src/Component/Post/AddPlayer/AddPlayer.css';
}
Expand All @@ -93,10 +111,11 @@ public function addStylesheet($stylesheets)
* Player preview uses the CSS :after to set the content so we pass the CSS through WordPress i18n functions here.
*
* @since 3.3.0
* @since 6.0.0 Make static.
*
* @return string CSS Block for player preview i18n delcerations.
*/
public function playerPreviewI18nStyles()
public static function playerPreviewI18nStyles()
{
return sprintf(
self::PLAYER_PREVIEW_STYLE_FORMAT,
Expand All @@ -110,17 +129,18 @@ public function playerPreviewI18nStyles()
* Adds i18n-compatible TinyMCE Classic Editor CSS for the player placeholder.
*
* @since 3.3.0
* @since 6.0.0 Make static.
*
* @param mixed[] $setings An array with TinyMCE config.
*
* @return mixed[] An array with TinyMCE config.
*/
public function filterTinyMceSettings($settings)
public static function filterTinyMceSettings($settings)
{
if (isset($settings['content_style'])) {
$settings['content_style'] .= ' ' . $this->playerPreviewI18nStyles() . ' ';
$settings['content_style'] .= ' ' . self::playerPreviewI18nStyles() . ' ';
} else {
$settings['content_style'] = $this->playerPreviewI18nStyles() . ' ';
$settings['content_style'] = self::playerPreviewI18nStyles() . ' ';
}

return $settings;
Expand All @@ -132,23 +152,26 @@ public function filterTinyMceSettings($settings)
* Adds i18n-compatible Block Editor CSS for the player placeholder.
*
* @since 3.3.0
* @since 6.0.0 Make static.
*/
public function addEditorStyles()
public static function addEditorStyles()
{
$allowed_html = array(
'style' => array(),
);

echo wp_kses(
sprintf('<style>%s</style>', $this->playerPreviewI18nStyles()),
sprintf('<style>%s</style>', self::playerPreviewI18nStyles()),
$allowed_html
);
}

/**
* Add Block Editor Stylesheet.
*
* @since 6.0.0 Make static.
*/
public function addBlockEditorStylesheet($hook)
public static function addBlockEditorStylesheet($hook)
{
// Only enqueue for Gutenberg/Post screens
if (CoreUtils::isGutenbergPage() || $hook === 'post.php' || $hook === 'post-new.php') {
Expand Down
20 changes: 13 additions & 7 deletions src/Component/Post/BlockAttributes/BlockAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ class BlockAttributes
* Init.
*
* @since 4.0.0
* @since 6.0.0 Make static.
*/
public function init()
public static function init()
{
add_filter('register_block_type_args', array($this, 'registerAudioAttribute'));
add_filter('register_block_type_args', array($this, 'registerMarkerAttribute'));
add_filter('render_block', array($this, 'renderBlock'), 10, 2);
add_filter('register_block_type_args', array(__CLASS__, 'registerAudioAttribute'));
add_filter('register_block_type_args', array(__CLASS__, 'registerMarkerAttribute'));
add_filter('render_block', array(__CLASS__, 'renderBlock'), 10, 2);
}

/**
* Register "Audio" attribute for Gutenberg blocks.
*
* @since 6.0.0 Make static.
*/
public function registerAudioAttribute($args)
public static function registerAudioAttribute($args)
{
// Setup attributes if needed.
if (! isset($args['attributes'])) {
Expand All @@ -59,8 +62,10 @@ public function registerAudioAttribute($args)

/**
* Register "Segment marker" attribute for Gutenberg blocks.
*
* @since 6.0.0 Make static.
*/
public function registerMarkerAttribute($args)
public static function registerMarkerAttribute($args)
{
// Setup attributes if needed.
if (! isset($args['attributes'])) {
Expand All @@ -85,13 +90,14 @@ public function registerMarkerAttribute($args)
*
* @since 4.0.0
* @since 4.2.2 Rename method to renderBlock.
* @since 6.0.0 Make static.
*
* @param string $blockContent The block content (HTML).
* @param string $block The full block, including name and attributes.
*
* @return string Block Content (HTML).
*/
public function renderBlock($blockContent, $block)
public static function renderBlock($blockContent, $block)
{
// Skip adding marker if player UI is disabled
if (get_option('beyondwords_player_ui', PlayerUI::ENABLED) === PlayerUI::DISABLED) {
Expand Down
13 changes: 9 additions & 4 deletions src/Component/Post/DisplayPlayer/DisplayPlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ class DisplayPlayer
* Init.
*
* @since 4.0.0
* @since 6.0.0 Make static.
*/
public function init()
public static function init()
{
add_action('wp_loaded', function () {
$postTypes = SettingsUtils::getCompatiblePostTypes();

if (is_array($postTypes)) {
foreach ($postTypes as $postType) {
add_action("save_post_{$postType}", array($this, 'save'), 20);
add_action("save_post_{$postType}", array(__CLASS__, 'save'), 20);
}
}
});
Expand All @@ -43,9 +44,11 @@ public function init()
/**
* Save the meta when the post is saved.
*
* @since 6.0.0 Make static.
*
* @param int $postId The ID of the post being saved.
*/
public function save($postId)
public static function save($postId)
{
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $postId;
Expand Down Expand Up @@ -74,9 +77,11 @@ public function save($postId)
/**
* Render the element.
*
* @since 6.0.0 Make static.
*
* @param WP_Post $post The post object.
*/
public function element($post)
public static function element($post)
{
if (!($post instanceof \WP_Post)) {
return;
Expand Down
12 changes: 9 additions & 3 deletions src/Component/Post/ErrorNotice/ErrorNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ class ErrorNotice
* Init.
*
* @since 4.0.0
* @since 6.0.0 Make static.
*/
public function init()
public static function init()
{
add_action('enqueue_block_assets', array($this, 'enqueueBlockAssets'));
add_action('enqueue_block_assets', array(__CLASS__, 'enqueueBlockAssets'));
}

public function enqueueBlockAssets()
/**
* Enqueue Block Editor assets.
*
* @since 6.0.0 Make static.
*/
public static function enqueueBlockAssets()
{
// Only enqueue for Gutenberg screens
if (CoreUtils::isGutenbergPage()) {
Expand Down
Loading