* @since 4.0.0 */ namespace Beyondwords\Wordpress\Component\Settings\PlayerUI; use Beyondwords\Wordpress\Component\Settings\SettingsUtils; /** * PlayerUI setup * * @since 4.0.0 */ class PlayerUI { public const ENABLED = 'enabled'; public const HEADLESS = 'headless'; public const DISABLED = 'disabled'; /** * Constructor */ public function __construct() { add_action('admin_init', array($this, 'init')); add_action('admin_enqueue_scripts', array($this, 'enqueueScripts')); } /** * Init setting. * * @since 4.0.0 * * @return void */ public function init() { if (! SettingsUtils::hasApiSettings()) { return; } register_setting( 'beyondwords', 'beyondwords_player_ui', [ 'default' => PlayerUI::ENABLED, ] ); add_settings_field( 'beyondwords-player-ui', __('Player UI', 'speechkit'), array($this, 'render'), 'beyondwords', 'player' ); } /** * Render setting field. * * @since 4.0.0 * * @return void **/ public function render() { $currentUi = get_option('beyondwords_player_ui', PlayerUI::ENABLED); $playerUIs = PlayerUI::getAllPlayerUIs(); ?>

%s', // phpcs:ignore Generic.Files.LineLength.TooLong esc_html__('headless mode', 'speechkit') ) ); ?>

__('Enabled', 'speechkit'), PlayerUI::HEADLESS => __('Headless', 'speechkit'), PlayerUI::DISABLED => __('Disabled', 'speechkit'), ]; } /** * Register the component scripts. * * @since 3.0.0 * * @param string $hook Page hook * * @return void */ public function enqueueScripts($hook) { if ($hook === 'settings_page_beyondwords') { wp_enqueue_script( 'beyondwords-settings--player-ui', BEYONDWORDS__PLUGIN_URI . 'src/Component/Settings/PlayerUI/settings.js', ['jquery', 'underscore'], BEYONDWORDS__PLUGIN_VERSION, true ); } } }