* @since 3.0.0 */ namespace Beyondwords\Wordpress\Component\Post\Metabox; use Beyondwords\Wordpress\Component\GenerateAudio\GenerateAudio; use Beyondwords\Wordpress\Component\DisplayPlayer\DisplayPlayer; use Beyondwords\Wordpress\Component\Post\PostMetaUtils; use Beyondwords\Wordpress\Component\Settings\SettingsUtils; use Beyondwords\Wordpress\Core\Environment; /** * PostMetabox setup * * @since 3.0.0 */ class Metabox { public $generateAudio; public $displayPlayer; public $selectVoice; /** * Constructor */ public function __construct($generateAudio, $displayPlayer, $selectVoice) { $this->generateAudio = $generateAudio; $this->displayPlayer = $displayPlayer; $this->selectVoice = $selectVoice; add_action('admin_enqueue_scripts', array($this, 'adminEnqueueScripts')); add_action("add_meta_boxes", array($this, 'addMetaBox')); } /** * Enque JS for Bulk Edit feature. */ public function adminEnqueueScripts($hook) { // Only enqueue for Post screens if ($hook === 'post.php' || $hook === 'post-new.php') { // Register the Classic Editor "Metabox" CSS wp_enqueue_style( 'beyondwords-Metabox', BEYONDWORDS__PLUGIN_URI . 'src/Component/Post/Metabox/Metabox.css', false, BEYONDWORDS__PLUGIN_VERSION ); } } /** * Adds the meta box container. * * @param $postType */ public function addMetaBox($postType) { $postTypes = SettingsUtils::getSupportedPostTypes(); if (is_array($postTypes) && ! in_array($postType, $postTypes)) { return; } add_meta_box( 'beyondwords', __('BeyondWords', 'speechkit'), array($this, 'renderMetaBoxContent'), $postType, 'side', 'default', [ '__back_compat_meta_box' => true, ] ); } /** * Render Meta Box content. * * @param WP_Post $post The post object. * * @since 3.0.0 * @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 */ public function renderMetaBoxContent($post) { if (!($post instanceof \WP_Post)) { return; } $contentId = PostMetaUtils::getContentId($post->ID); if ($contentId) { if (get_post_status($post) === 'pending') { $this->pendingReviewNotice($post); } else { $this->playerEmbed($post); } echo '
%s', 'mailto:support@beyondwords.io', 'support@beyondwords.io') ); ?>