* @since 5.0.0 */ namespace Beyondwords\Wordpress\Component\Settings\Fields\TextHighlighting; use Beyondwords\Wordpress\Component\Settings\SettingsUtils; use Beyondwords\Wordpress\Component\Settings\Sync; /** * TextHighlighting * * @since 5.0.0 */ defined('ABSPATH') || exit; class TextHighlighting { /** * Default value. * * @since 5.0.0 */ public const DEFAULT_VALUE = ''; /** * Option name. * * @since 5.0.0 */ public const OPTION_NAME = 'beyondwords_player_highlight_sections'; /** * Init. * * @since 5.0.0 * @since 6.0.0 Make static. */ public static function init() { add_action('admin_init', [self::class, 'addSetting']); add_action('pre_update_option_' . self::OPTION_NAME, function ($value) { Sync::syncOptionToDashboard(self::OPTION_NAME); return $value; }); } /** * Init setting. * * @since 5.0.0 * @since 6.0.0 Make static. * * @return void */ public static function addSetting() { register_setting( 'beyondwords_player_settings', self::OPTION_NAME, [ 'type' => 'string', 'sanitize_callback' => [self::class, 'sanitize'], 'default' => self::DEFAULT_VALUE, ] ); add_settings_field( 'beyondwords-text-highlighting', __('Text highlighting', 'speechkit'), [self::class, 'render'], 'beyondwords_player', 'styling' ); } /** * Render setting field. * * @since 5.0.0 * @since 6.0.0 Make static. * * @return void **/ public static function render() { $value = get_option(self::OPTION_NAME); $lightTheme = get_option('beyondwords_player_theme_light'); $darkTheme = get_option('beyondwords_player_theme_dark'); ?>