From d33ae2ea6ccc1474294a2c18a87d2ce86694808d Mon Sep 17 00:00:00 2001
From: Stuart McAlpine
Date: Fri, 11 Jul 2025 13:47:07 +0100
Subject: [PATCH 1/2] Static methods throughout
---
package.json | 2 +-
readme.txt | 10 ++-
speechkit.php | 7 +-
src/Compatibility/WPGraphQL/WPGraphQL.php | 8 +-
src/Component/Post/AddPlayer/AddPlayer.php | 61 +++++++++-----
.../Post/BlockAttributes/BlockAttributes.php | 20 +++--
.../Post/DisplayPlayer/DisplayPlayer.php | 13 ++-
.../Post/ErrorNotice/ErrorNotice.php | 12 ++-
.../Post/GenerateAudio/GenerateAudio.php | 26 ++++--
src/Component/Post/Metabox/Metabox.php | 69 ++++++++++-----
src/Component/Post/Panel/Inspect/Inspect.php | 64 +++++++++-----
.../Post/PlayerContent/PlayerContent.php | 11 ++-
.../Post/PlayerStyle/PlayerStyle.php | 22 +++--
src/Component/Post/PostContentUtils.php | 2 +-
src/Component/Post/PostMetaUtils.php | 6 +-
.../Post/SelectVoice/SelectVoice.php | 33 +++++---
src/Component/Post/Sidebar/Sidebar.php | 12 ++-
src/Component/Posts/BulkEdit/BulkEdit.php | 77 +++++++++--------
src/Component/Posts/BulkEdit/Notices.php | 29 +++++--
src/Component/Posts/Column/Column.php | 28 ++++---
.../Settings/Fields/ApiKey/ApiKey.php | 20 +++--
.../Fields/AutoPublish/AutoPublish.php | 17 ++--
.../Fields/CallToAction/CallToAction.php | 15 ++--
.../Fields/IncludeExcerpt/IncludeExcerpt.php | 13 +--
.../Fields/IncludeTitle/IncludeTitle.php | 13 +--
.../Settings/Fields/Language/Language.php | 18 ++--
.../PlaybackControls/PlaybackControls.php | 13 +--
.../PlaybackFromSegments.php | 13 +--
.../Fields/PlayerColors/PlayerColors.php | 57 +++++++------
.../Fields/PlayerStyle/PlayerStyle.php | 14 ++--
.../Settings/Fields/PlayerUI/PlayerUI.php | 15 ++--
.../PreselectGenerateAudio.php | 55 ++++++++----
.../Settings/Fields/ProjectId/ProjectId.php | 20 +++--
.../SpeakingRate/BodyVoiceSpeakingRate.php | 13 +--
.../SpeakingRate/TitleVoiceSpeakingRate.php | 13 +--
.../TextHighlighting/TextHighlighting.php | 19 +++--
.../Settings/Fields/Voice/BodyVoice.php | 15 ++--
.../Settings/Fields/Voice/TitleVoice.php | 15 ++--
src/Component/Settings/Fields/Voice/Voice.php | 3 +-
.../Fields/WidgetPosition/WidgetPosition.php | 18 ++--
.../Fields/WidgetStyle/WidgetStyle.php | 18 ++--
src/Component/Settings/Settings.php | 74 ++++++++++-------
src/Component/Settings/Sync.php | 69 +++++++--------
.../Settings/Tabs/Content/Content.php | 21 +++--
.../Settings/Tabs/Credentials/Credentials.php | 17 ++--
src/Component/Settings/Tabs/Player/Player.php | 31 +++----
.../Tabs/Pronunciations/Pronunciations.php | 13 +--
.../Tabs/Summarization/Summarization.php | 13 +--
src/Component/Settings/Tabs/Voices/Voices.php | 23 ++---
src/Component/SiteHealth/SiteHealth.php | 56 ++++++++-----
src/Core/Core.php | 75 ++++++++++-------
src/Core/Player/Player.php | 82 ++++++++++--------
src/Core/Player/PlayerInline.php | 71 +++++++++-------
src/Core/Uninstaller.php | 2 +-
src/Core/Updater.php | 22 +++--
src/Plugin.php | 62 +++++---------
tests/phpunit/Compatibility/WPGraphQLTest.php | 5 +-
.../Post/AddPlayer/AddPlayerTest.php | 59 +++++--------
.../BlockAttributes/BlockAttributesTest.php | 25 +++---
.../Post/DisplayPlayer/DisplayPlayerTest.php | 21 ++---
.../Post/ErrorNotice/ErrorNoticeTest.php | 5 +-
.../Post/GenerateAudio/GenerateAudioTest.php | 34 ++++----
.../Component/Post/Metabox/MetaboxTest.php | 25 +++---
.../Post/Panel/Inspect/InspectTest.php | 9 +-
.../Post/PlayerContent/PlayerContentTest.php | 21 ++---
.../Post/PlayerStyle/PlayerStyleTest.php | 21 ++---
.../Post/SelectVoice/SelectVoiceTest.php | 25 +++---
.../Component/Post/Sidebar/SidebarTest.php | 5 +-
.../Component/Posts/BulkEdit/BulkEditTest.php | 54 ++++++------
.../Component/Posts/BulkEdit/NoticesTest.php | 32 ++++---
.../Component/Posts/Column/ColumnTest.php | 31 ++++---
tests/phpunit/Component/SiteHealthTest.php | 5 +-
tests/phpunit/Core/CoreTest.php | 83 ++++++-------------
tests/phpunit/Core/EnvironmentTest.php | 2 -
tests/phpunit/Core/PlayerTest.php | 51 ++++++------
tests/phpunit/Core/UpdaterTest.php | 8 +-
tests/phpunit/PluginTest.php | 56 -------------
.../Settings/Fields/ApiKey/ApiKeyTest.php | 19 ++---
.../IncludeExcerpt/IncludeExcerptTest.php | 17 ++--
.../Fields/PlayerStyle/PlayerStyleTest.php | 25 ++----
.../Settings/Fields/PlayerUI/PlayerUITest.php | 15 ++--
.../PreselectGenerateAudioTest.php | 25 +++---
.../Fields/ProjectId/ProjectIdTest.php | 21 ++---
tests/phpunit/Settings/SettingsTest.php | 56 ++++++-------
tests/phpunit/Settings/SyncTest.php | 14 +---
.../Settings/Tabs/CredentialsTabTest.php | 12 +--
tests/phpunit/Settings/Tabs/PlayerTabTest.php | 11 +--
.../Settings/Tabs/PronunciationsTabTest.php | 12 +--
.../Settings/Tabs/SummarizationTabTest.php | 12 +--
tests/phpunit/Settings/Tabs/VoicesTabTest.php | 12 +--
90 files changed, 1233 insertions(+), 1135 deletions(-)
delete mode 100644 tests/phpunit/PluginTest.php
diff --git a/package.json b/package.json
index c80f3d68..534b9e49 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "beyondwords-wordpress-plugin",
- "version": "5.5.0",
+ "version": "6.0.0",
"private": true,
"description": "BeyondWords WordPress Plugin",
"repository": {
diff --git a/readme.txt b/readme.txt
index bf04d3e6..a842ab65 100755
--- a/readme.txt
+++ b/readme.txt
@@ -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
@@ -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
diff --git a/speechkit.php b/speechkit.php
index 73b65e68..0112b924 100755
--- a/speechkit.php
+++ b/speechkit.php
@@ -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
@@ -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();
diff --git a/src/Compatibility/WPGraphQL/WPGraphQL.php b/src/Compatibility/WPGraphQL/WPGraphQL.php
index 16f09476..e13bbff9 100644
--- a/src/Compatibility/WPGraphQL/WPGraphQL.php
+++ b/src/Compatibility/WPGraphQL/WPGraphQL.php
@@ -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'));
}
/**
@@ -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
diff --git a/src/Component/Post/AddPlayer/AddPlayer.php b/src/Component/Post/AddPlayer/AddPlayer.php
index 9c1ed893..a8ebda15 100644
--- a/src/Component/Post/AddPlayer/AddPlayer.php
+++ b/src/Component/Post/AddPlayer/AddPlayer.php
@@ -28,24 +28,28 @@ 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__);
}
@@ -53,9 +57,13 @@ public function registerBlock()
/**
* 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;
@@ -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);
@@ -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';
}
@@ -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,
@@ -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;
@@ -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('', $this->playerPreviewI18nStyles()),
+ sprintf('', 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') {
diff --git a/src/Component/Post/BlockAttributes/BlockAttributes.php b/src/Component/Post/BlockAttributes/BlockAttributes.php
index 2ad9ae82..aa2bc699 100644
--- a/src/Component/Post/BlockAttributes/BlockAttributes.php
+++ b/src/Component/Post/BlockAttributes/BlockAttributes.php
@@ -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'])) {
@@ -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'])) {
@@ -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) {
diff --git a/src/Component/Post/DisplayPlayer/DisplayPlayer.php b/src/Component/Post/DisplayPlayer/DisplayPlayer.php
index 8597a4cd..e223f627 100644
--- a/src/Component/Post/DisplayPlayer/DisplayPlayer.php
+++ b/src/Component/Post/DisplayPlayer/DisplayPlayer.php
@@ -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);
}
}
});
@@ -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;
@@ -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;
diff --git a/src/Component/Post/ErrorNotice/ErrorNotice.php b/src/Component/Post/ErrorNotice/ErrorNotice.php
index eb6312dc..052b381c 100644
--- a/src/Component/Post/ErrorNotice/ErrorNotice.php
+++ b/src/Component/Post/ErrorNotice/ErrorNotice.php
@@ -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()) {
diff --git a/src/Component/Post/GenerateAudio/GenerateAudio.php b/src/Component/Post/GenerateAudio/GenerateAudio.php
index 58729ed8..93ccd5ce 100644
--- a/src/Component/Post/GenerateAudio/GenerateAudio.php
+++ b/src/Component/Post/GenerateAudio/GenerateAudio.php
@@ -26,24 +26,29 @@ class GenerateAudio
* 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'), 10);
+ add_action("save_post_{$postType}", array(__CLASS__, 'save'), 10);
}
}
});
}
/**
- * todo move this function to somewhere reusable for the Block editor.
+ * Check whether the post type should preselect the "Generate audio" checkbox.
+ *
+ * @todo move this function to somewhere reusable for the Block editor.
+ *
+ * @since 6.0.0 Make static.
*/
- public function shouldPreselectGenerateAudio($post)
+ public static function shouldPreselectGenerateAudio($post)
{
$postType = get_post_type($post);
@@ -65,7 +70,12 @@ public function shouldPreselectGenerateAudio($post)
return false;
}
- public function element($post)
+ /**
+ * Render the element.
+ *
+ * @since 6.0.0 Make static.
+ */
+ public static function element($post)
{
wp_nonce_field('beyondwords_generate_audio', 'beyondwords_generate_audio_nonce');
@@ -75,7 +85,7 @@ public function element($post)
// Check whether "0" has explicitly been saved
$generateAudioMeta = PostMetaUtils::getRenamedPostMeta($post->ID, 'generate_audio', true);
- if ($generateAudioMeta !== '0' && $this->shouldPreselectGenerateAudio($post)) {
+ if ($generateAudioMeta !== '0' && self::shouldPreselectGenerateAudio($post)) {
$generateAudio = true;
}
}
@@ -97,9 +107,11 @@ public function element($post)
/**
* 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;
diff --git a/src/Component/Post/Metabox/Metabox.php b/src/Component/Post/Metabox/Metabox.php
index 0cc5f6de..b68ce753 100644
--- a/src/Component/Post/Metabox/Metabox.php
+++ b/src/Component/Post/Metabox/Metabox.php
@@ -32,17 +32,20 @@ class Metabox
* Init.
*
* @since 4.0.0
+ * @since 6.0.0 Make static.
*/
- public function init()
+ public static function init()
{
- add_action('admin_enqueue_scripts', array($this, 'adminEnqueueScripts'));
- add_action("add_meta_boxes", array($this, 'addMetaBox'));
+ add_action('admin_enqueue_scripts', array(__CLASS__, 'adminEnqueueScripts'));
+ add_action("add_meta_boxes", array(__CLASS__, 'addMetaBox'));
}
/**
* Enque JS for Bulk Edit feature.
+ *
+ * @since 6.0.0 Make static.
*/
- public function adminEnqueueScripts($hook)
+ public static function adminEnqueueScripts($hook)
{
// Only enqueue for Post screens
if ($hook === 'post.php' || $hook === 'post-new.php') {
@@ -59,9 +62,11 @@ public function adminEnqueueScripts($hook)
/**
* Adds the meta box container.
*
+ * @since 6.0.0 Make static.
+ *
* @param string $postType
*/
- public function addMetaBox($postType)
+ public static function addMetaBox($postType)
{
$postTypes = SettingsUtils::getCompatiblePostTypes();
@@ -72,7 +77,7 @@ public function addMetaBox($postType)
add_meta_box(
'beyondwords',
__('BeyondWords', 'speechkit'),
- array($this, 'renderMetaBoxContent'),
+ array(__CLASS__, 'renderMetaBoxContent'),
$postType,
'side',
'default',
@@ -91,8 +96,9 @@ public function addMetaBox($postType)
* @since 3.7.0 Show "Pending review" notice for posts with status of "pending"
* @since 4.0.0 Content ID is no longer an int
* @since 4.1.0 Add "Player style" and update component display conditions
+ * @since 6.0.0 Make static.
*/
- public function renderMetaBoxContent($post)
+ public static function renderMetaBoxContent($post)
{
$post = get_post($post);
@@ -101,32 +107,32 @@ public function renderMetaBoxContent($post)
}
// Show errors for posts with/without audio
- $this->errors($post);
+ self::errors($post);
$contentId = PostMetaUtils::getContentId($post->ID);
if ($contentId) {
// Enable these components for posts with audio
if (get_post_status($post) === 'pending') {
- $this->pendingReviewNotice($post);
+ self::pendingReviewNotice($post);
} else {
- $this->playerEmbed($post);
+ self::playerEmbed($post);
}
echo '
';
- (new DisplayPlayer())->element($post);
+ (new DisplayPlayer())::element($post);
} else {
- $this->errors($post);
+ self::errors($post);
// Enable these components for posts without audio
- (new GenerateAudio())->element($post);
+ (new GenerateAudio())::element($post);
}
// Enable these components for posts with/without audio
- (new SelectVoice())->element($post);
- (new PlayerStyle())->element($post);
- (new PlayerContent())->element($post);
+ (new SelectVoice())::element($post);
+ (new PlayerStyle())::element($post);
+ (new PlayerContent())::element($post);
echo '
';
- $this->help();
+ self::help();
}
@@ -139,10 +145,11 @@ public function renderMetaBoxContent($post)
* with { published: false }.
*
* @since 3.7.0
+ * @since 6.0.0 Make static.
*
* @var \WP_Post $post Post.
*/
- public function pendingReviewNotice($post)
+ public static function pendingReviewNotice($post)
{
$projectUrl = sprintf(
'%s/dashboard/project/%d/content',
@@ -174,8 +181,9 @@ public function pendingReviewNotice($post)
*
* @since 3.x Introduced
* @since 4.0.1 Admin player init is now all in this one function.
+ * @since 6.0.0 Make static.
*/
- public function playerEmbed($post = null)
+ public static function playerEmbed($post = null)
{
$post = get_post($post);
@@ -210,7 +218,12 @@ public function playerEmbed($post = null)
ID);
@@ -222,13 +235,18 @@ public function errors($post)
- regenerateInstructions(); ?>
+
@@ -243,7 +261,12 @@ public function help()
diff --git a/src/Component/Post/Panel/Inspect/Inspect.php b/src/Component/Post/Panel/Inspect/Inspect.php
index b6c64389..ddf178c8 100644
--- a/src/Component/Post/Panel/Inspect/Inspect.php
+++ b/src/Component/Post/Panel/Inspect/Inspect.php
@@ -25,21 +25,23 @@ class Inspect
{
/**
* Constructor
+ *
+ * @since 6.0.0 Make static.
*/
- public function init()
+ public static function init()
{
- add_action('admin_enqueue_scripts', array($this, 'adminEnqueueScripts'));
- add_action('add_meta_boxes', array($this, 'addMetaBox'));
- add_action('rest_api_init', array($this, 'restApiInit'));
+ add_action('admin_enqueue_scripts', array(__CLASS__, 'adminEnqueueScripts'));
+ add_action('add_meta_boxes', array(__CLASS__, 'addMetaBox'));
+ add_action('rest_api_init', array(__CLASS__, 'restApiInit'));
- add_filter('default_hidden_meta_boxes', array($this, 'hideMetaBox'));
+ add_filter('default_hidden_meta_boxes', array(__CLASS__, 'hideMetaBox'));
add_action('wp_loaded', function () {
$postTypes = SettingsUtils::getCompatiblePostTypes();
if (is_array($postTypes)) {
foreach ($postTypes as $postType) {
- add_action("save_post_{$postType}", array($this, 'save'), 5);
+ add_action("save_post_{$postType}", array(__CLASS__, 'save'), 5);
}
}
});
@@ -47,8 +49,10 @@ public function init()
/**
* Enqueue JS for Inspect feature.
+ *
+ * @since 6.0.0 Make static.
*/
- public function adminEnqueueScripts($hook)
+ public static function adminEnqueueScripts($hook)
{
// Only enqueue for Post screens
if ($hook === 'post.php' || $hook === 'post-new.php') {
@@ -65,9 +69,11 @@ public function adminEnqueueScripts($hook)
/**
* Hides the metabox by default.
*
+ * @since 6.0.0 Make static.
+ *
* @param string[] $hidden An array of IDs of meta boxes hidden by default.
*/
- public function hideMetaBox($hidden)
+ public static function hideMetaBox($hidden)
{
$hidden[] = 'beyondwords__inspect';
return $hidden;
@@ -78,9 +84,11 @@ public function hideMetaBox($hidden)
*
* The Block Editor UI is handled using JavaScript.
*
+ * @since 6.0.0 Make static.
+ *
* @param string $postType
*/
- public function addMetaBox($postType)
+ public static function addMetaBox($postType)
{
$postTypes = SettingsUtils::getCompatiblePostTypes();
@@ -91,7 +99,7 @@ public function addMetaBox($postType)
add_meta_box(
'beyondwords__inspect',
__('BeyondWords', 'speechkit') . ': ' . __('Inspect', 'speechkit'),
- array($this, 'renderMetaBoxContent'),
+ array(__CLASS__, 'renderMetaBoxContent'),
$postType,
'advanced',
'low',
@@ -104,20 +112,22 @@ public function addMetaBox($postType)
/**
* Render Meta Box content.
*
+ * @since 6.0.0 Make static.
+ *
* @param WP_Post $post The post object.
*/
- public function renderMetaBoxContent($post)
+ public static function renderMetaBoxContent($post)
{
$metadata = PostMetaUtils::getAllBeyondwordsMetadata($post->ID);
- $this->postMetaTable($metadata);
+ self::postMetaTable($metadata);
?>