<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class Score777_ThemeOptions
{
    private $regular = '400';
    private $bold = '600';
    private $small = '10px';
    private $medium = '12px';
    private $large = '14px';
    private $on = 'true';
    private $off = 'false';
    private $langs = array(
        'en' => '',
        'fr' => '',
        'pt' => '',
        'de' => '',
        'id' => '',
        'it' => '',
        'ko' => '',
        'pl' => '',
        'ru' => '',
        'es' => '',
        'th' => '',
        'tr' => '',
        'uk' => '',
        'vi' => '',
        'nl' => '',
        'ro' => '',
        'ka' => '',
        'hy' => '',
        'az' => '',
        'el' => '',
        'uz' => ''
    );
    private static $instance = null;
    public $options;

    public static function getInstance() {

        if (null == self::$instance) {
            self::$instance = new self;
        }

        return self::$instance;

    }

    private function __construct() {

        // Add the page to the admin menu
        add_action('admin_menu', array(&$this, 'addPage'));

        // Register page options
        add_action('admin_init', array(&$this, 'registerPageOptions'));

        // Register javascript
        add_action('admin_enqueue_scripts', array($this, 'enqueueAdminJs'));

        // Get registered option
        $this->options = get_option('cfg777_settings_options');

    }

    public function enqueueAdminJs() {
        // admin styles
        wp_enqueue_style('cfg777_custom_css', plugins_url('assets/styles.css', __FILE__));

        // Make sure to add the wp-color-picker dependecy to js file
        wp_enqueue_script('cfg777_custom_js', plugins_url('assets/jquery.custom.js', __FILE__), array('jquery', 'wp-color-picker'), '', true);

        // Css rules for Color Picker
        wp_enqueue_style('wp-color-picker');
    }

    public function addPage() {
        add_options_page('Theme Options', 'Sport LiveScores', 'manage_options', __FILE__, array($this, 'displayPage'));
    }

    public function displayPage() {
    ?>
    <div class="wrap cfg777">
        <h2>777score plugin Config</h2>
        <blockquote>
            Include the latest outcomes of top football teams and competitions on your website.
            Ad-free, consistently current, and a rapidly refreshed widget displaying results in real-time
        </blockquote>
        <form method="post" action="options.php">
        <?php
            submit_button();
            settings_fields(__FILE__);
            do_settings_sections(__FILE__);
            submit_button();
        ?>
        </form>
        <h2>Using the Plugin:</h2>
        <div>
            Please select the "On" option in the "Activation of shortcode" settings.
            Use the [777score] shortcode where you want to display real-time results for today.
        </div>
        <div>Additional customization options include:</div>
        <ol>
            <li>
                Specifying the time period, such as "live," "tomorrow," "yesterday" (e.g., [777score path=/live]).
            </li>
            <li>
                Filtering by different leagues, for example, [777score path=/football/tournaments/england/premier-league]
            </li>
            <li>
                Filtering by time period for different leagues, such as "fixtures," "results" (for example, [777score path=/football/tournaments/england/premier-league/results])
            </li>
            <li>
                Displaying league standings using the "standings" parameter for different leagues (for example, [777score path=/football/tournaments/england/premier-league/standings]).
            </li>
        </ol>
        <div>
            A comprehensive list of leagues and countries is available on the 777score.com website.
        </div>
    </div>
    <?php
    }

    public function registerPageOptions() {
        $white = '#FFFFFF';
        $iron = '#D5D7E4';
        $lightGray = '#30365B';
        $blackPearl = '#020223';
        $cultured = '#D9E8FF';
        $blueZodiac = '#22294B';
        $lava = '#E84848';
        $blue = '#257CFF';
        $midnight = '#111936';
        $cloudyBlue = '#BCBFD6';

        $regular = $this->regular;
        $bold = $this->bold;

        $small = $this->small;
        $medium = $this->medium;
        $large = $this->large;

        $on = $this->on;

        // Add Section for option fields
        add_settings_section('cfg777_section',           'General Settings',          array($this, 'displaySection'),            __FILE__, array('before_section' => '<div class="cfg777-gen-section">', 'after_section' => '</div>'));
        add_settings_field(  'cfg777_777_timezone',      'Timezone',                  array($this, 'timezoneField'),             __FILE__, 'cfg777_section'                                                                );
        add_settings_field(  'cfg777_777_lang',          'Language',                  array($this, 'langSettingsField'),         __FILE__, 'cfg777_section'                                                                );
        add_settings_field(  'cfg777_777_main_font',     'Main font',                 array($this, 'mainFontSettingsField'),     __FILE__, 'cfg777_section'                                                                );
        add_settings_field(  'cfg777_777_main_bg_color', 'Main Background color',     array($this, 'color'),                     __FILE__, 'cfg777_section', array('o_name' => 'main_bg_color', 'def_color' => $blackPearl));
        add_settings_field(  'cfg777_777_main_color',    'Main Font color',           array($this, 'color'),                     __FILE__, 'cfg777_section', array('o_name' => 'main_color',    'def_color' => $white     ));
        add_settings_field(  'cfg777_777_main_size',     'Main Font size',            array($this, 'fsRadioBtn'),                __FILE__, 'cfg777_section', array('o_name' => 'main_size',     'def'       => $large     ));
        add_settings_field(  'cfg777_777_main_weight',   'Main Font weight',          array($this, 'fwRadioBtn'),                __FILE__, 'cfg777_section', array('o_name' => 'main_weight',   'def'       => $regular   ));
        add_settings_field(  'cfg777_your_word',         '',                          array($this, 'textNumber'),                __FILE__, 'cfg777_section'                                                                );

        add_settings_section('cfg777_section_matches', 'Matches settings',  array($this, 'displaySection'), __FILE__);

        add_settings_section('cfg777_section_matches_comp_row',           'Tournament Row',                       array($this, 'displaySection'), __FILE__, array('before_section' => '<div class="cfg777-sub-section">', 'after_section' => '</div>'));
        add_settings_field(  'cfg777_com_row_mtr_bg_color',               'Main Background color',                array($this, 'color'),          __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_bg_color',               'def_color' => $blueZodiac));
        add_settings_field(  'cfg777_com_row_mtr_bg_color_category_logo', 'Background color for <b>Category</b> logo', array($this, 'color'),          __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_bg_color_category_logo', 'def_color' => $blackPearl));
        add_settings_field(  'cfg777_com_row_mtr_dividers_color',         '<b>Dividers</b> row color',                 array($this, 'color'),          __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_dividers_color',         'def_color' => $blackPearl));
        add_settings_field(  'cfg777_com_row_mtr_category_name_color',    'Font color <b>Category</b> name ',          array($this, 'color'),          __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_category_name_color',    'def_color' => $iron      ));
        add_settings_field(  'cfg777_com_row_mtr_category_name_size',     'Font size <b>Category</b> name',            array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_category_name_size',     'def'       => $small     ));
        add_settings_field(  'cfg777_com_row_mtr_category_name_weight',   'Font weight <b>Category</b> name',          array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_category_name_weight',   'def'       => $regular   ));
        add_settings_field(  'cfg777_com_row_mtr_tournament_name_color',  'Font color <b>Tournament</b> name',         array($this, 'color'),          __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_tournament_name_color',  'def_color' => $white     ));
        add_settings_field(  'cfg777_com_row_mtr_tournament_name_size',   'Font size <b>Tournament</b> name',          array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_tournament_name_size',   'def'       => $medium    ));
        add_settings_field(  'cfg777_com_row_mtr_tournament_name_weight', 'Font weight <b>Tournament</b> name',        array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_tournament_name_weight', 'def'       => $regular   ));
        add_settings_field(  'cfg777_com_row_mtr_date_color',             'Font color <b>Date</b>',                    array($this, 'color'),          __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_date_color',             'def_color' => $iron      ));
        add_settings_field(  'cfg777_com_row_mtr_date_size',              'Font size <b>Date</b>',                     array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_date_size',              'def'       => $medium    ));
        add_settings_field(  'cfg777_com_row_mtr_date_weight',            'Font weight <b>Date</b>',                   array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_comp_row', array('o_name' => 'mtr_date_weight',            'def'       => $regular   ));

        add_settings_section('cfg777_section_matches_date_row',    'Single Date Row',       array($this, 'displaySection'), __FILE__, array('before_section' => '<div class="cfg777-sub-section">', 'after_section' => '</div>'));
        add_settings_field(  'cfg777_date_row_msdr_bg_color',      'Main Background color', array($this, 'color'),          __FILE__, 'cfg777_section_matches_date_row', array('o_name' => 'msdr_bg_color',      'def_color' => $blueZodiac));
        add_settings_field(  'cfg777_date_row_msd_dividers_color', '<b>Dividers</b> row color',  array($this, 'color'),          __FILE__, 'cfg777_section_matches_date_row', array('o_name' => 'msd_dividers_color', 'def_color' => $lightGray ));
        add_settings_field(  'cfg777_date_row_msdr_font_color',    'Font color <b>Date</b>',     array($this, 'color'),          __FILE__, 'cfg777_section_matches_date_row', array('o_name' => 'msdr_font_color',    'def_color' => $iron      ));
        add_settings_field(  'cfg777_date_row_msdr_font_size',     'Font size <b>Date</b>',      array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_date_row', array('o_name' => 'msdr_font_size',     'def'       => $large     ));
        add_settings_field(  'cfg777_date_row_msdr_font_weight',   'Font weight <b>Date</b>',    array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_date_row', array('o_name' => 'msdr_font_weight',   'def'       => $regular   ));

        add_settings_section('cfg777_section_matches_match_row',             'Match Row',                           array($this, 'displaySection'), __FILE__,array('before_section' => '<div class="cfg777-sub-section">', 'after_section' => '</div>'));
        add_settings_field(  'cfg777_match_row_mmr_bg_color',                'Main Background color',               array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_bg_color',                'def_color' => $blackPearl));
        add_settings_field(  'cfg777_match_row_mmr_dividers_color',          '<b>Dividers</b> row color',                array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_dividers_color',          'def_color' => $lightGray ));
        add_settings_field(  'cfg777_match_row_mmr_hover_color',             'Row color on <b>hover</b>',                array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_hover_color',             'def_color' => $cultured  ));
        add_settings_field(  'cfg777_match_row_mmr_team_name_color',         'Font color <b>Team</b> name',              array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_team_name_color',         'def_color' => $iron      ));
        add_settings_field(  'cfg777_match_row_mmr_team_name_size',          'Font size <b>Team</b> name',               array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_date_row',  array('o_name' => 'mmr_team_name_size',          'def'       => $large     ));
        add_settings_field(  'cfg777_match_row_mmr_team_name_weight',        'Font weight <b>Team</b> name',             array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_team_name_weight',        'def'       => $regular   ));
        add_settings_field(  'cfg777_match_row_mmr_status_finished_color',   'Font color match Status <b>Finished</b>',  array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_status_finished_color',   'def_color' => $white     ));
        add_settings_field(  'cfg777_match_row_mmr_status_finished_size',    'Font size match Status <b>Finished</b>',   array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_date_row',  array('o_name' => 'mmr_status_finished_size',    'def'       => $medium    ));
        add_settings_field(  'cfg777_match_row_mmr_status_finished_weight',  'Font weight match Status <b>Finished</b>', array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_status_finished_weight',  'def'       => $regular   ));
        add_settings_field(  'cfg777_match_row_mmr_status_live_color',       'Font color match Status <b>Live</b>',      array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_status_live_color',       'def_color' => $lava      ));
        add_settings_field(  'cfg777_match_row_mmr_status_live_size',        'Font size match Status <b>Live</b>',       array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_date_row',  array('o_name' => 'mmr_status_live_size',        'def'       => $medium    ));
        add_settings_field(  'cfg777_match_row_mmr_status_live_weight',      'Font weight match Status <b>Live</b>',     array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_status_live_weight',      'def'       => $regular   ));
        add_settings_field(  'cfg777_match_row_mmr_score_win_team_color',    'Font color <b>Score</b> of win team',      array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_score_win_team_color',    'def_color' => $blue      ));
        add_settings_field(  'cfg777_match_row_mmr_score_win_team_size',     'Font size <b>Score</b> of win team',       array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_date_row',  array('o_name' => 'mmr_score_win_team_size',     'def'       => $large     ));
        add_settings_field(  'cfg777_match_row_mmr_score_win_team_weight',   'Font weight <b>Score</b> of win team',     array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_score_win_team_weight',   'def'       => $regular   ));
        add_settings_field(  'cfg777_match_row_mmr_details_activation',      'Activation Details button',           array($this, 'onOffRadioBtn'),  __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_details_activation',      'def'       => $on        ));
        add_settings_field(  'cfg777_match_row_mmr_details_bg_color',        'Background color <b>Details button</b>',   array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_details_bg_color',        'def_color' => $blue      ));
        add_settings_field(  'cfg777_match_row_mmr_details_button_bg_color', 'Font color <b>Details button</b>',         array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_details_button_bg_color', 'def_color' => $white     ));
        add_settings_field(  'cfg777_match_row_mmr_details_button_size',     'Font size <b>Details button</b>',          array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_date_row',  array('o_name' => 'mmr_details_button_size',     'def'       => $medium    ));
        add_settings_field(  'cfg777_match_row_mmr_details_button_weight',   'Font weight <b>Details button</b>',        array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_details_button_weight',   'def'       => $regular   ));
        add_settings_field(  'cfg777_match_row_mmr_score_team_color',        'Font color <b>Score team</b>',             array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_score_team_color',        'def_color' => $white     ));
        add_settings_field(  'cfg777_match_row_mmr_score_team_size',         'Font size <b>Score team</b>',              array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_date_row',  array('o_name' => 'mmr_score_team_size',         'def'       => $large     ));
        add_settings_field(  'cfg777_match_row_mmr_score_team_weight',       'Font weight <b>Score team</b>',            array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_score_team_weight',       'def'       => $regular   ));
        add_settings_field(  'cfg777_match_row_mmr_time_color',              'Font color <b>Match time</b>',             array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_time_color',              'def_color' => $white     ));
        add_settings_field(  'cfg777_match_row_mmr_time_size',               'Font size <b>Match time</b>',              array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_date_row',  array('o_name' => 'mmr_time_size',               'def'       => $medium    ));
        add_settings_field(  'cfg777_match_row_mmr_time_weight',             'Font weight <b>Match time</b>',            array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_time_weight',             'def'       => $bold      ));
        add_settings_field(  'cfg777_match_row_mmr_score_team_color_basket', 'Font color <b>Score by quarters</b>',      array($this, 'color'),          __FILE__, 'cfg777_section_matches_match_row', array('o_name' => 'mmr_score_team_color_basket', 'def_color' => $cloudyBlue));

        add_settings_section('cfg777_section_matches_details',                'Match details',                               array($this, 'displaySection'), __FILE__, array('before_section' => '<div class="cfg777-sub-section">', 'after_section' => '</div>'));
        add_settings_field(  'cfg777_details_md_commands_info_bg_color',      'Background color <b>Team name</b>',                array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_commands_info_bg_color',      'def_color' => $midnight  ));
        add_settings_field(  'cfg777_details_md_commands_info_color',         'Font color <b>Team name</b>',                      array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_commands_info_color',         'def_color' => $white     ));
        add_settings_field(  'cfg777_details_md_commands_info_divider_color', 'Dividers color <b>Team name</b>',                  array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_commands_info_divider_color', 'def_color' => $lightGray ));
        add_settings_field(  'cfg777_details_md_commands_info_size',          'Font size <b>Team name</b>',                       array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_commands_info_size',          'def'       => $large     ));
        add_settings_field(  'cfg777_details_md_commands_info_weight',        'Font weight <b>Team name</b>',                     array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_commands_info_weight',        'def'       => $regular   ));
        add_settings_field(  'cfg777_details_md_bg_color',                    'Main Background color',                       array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_bg_color',                    'def_color' => $midnight  ));
        add_settings_field(  'cfg777_details_md_dividers_color',              '<b>Dividers</b> row color',                        array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_dividers_color',              'def_color' => $lightGray ));
        add_settings_field(  'cfg777_details_md_1st_player_name_color',       'Font color <b>Player name (1st)</b>',              array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_1st_player_name_color',       'def_color' => $white     ));
        add_settings_field(  'cfg777_details_md_1st_player_name_size',        'Font size <b>Player name (1st)</b>',               array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_1st_player_name_size',        'def'       => $medium    ));
        add_settings_field(  'cfg777_details_md_1st_player_name_weight',      'Font weight <b>Player name (1st)</b>',             array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_1st_player_name_weight',      'def'       => $regular   ));
        add_settings_field(  'cfg777_details_md_2nd_player_name_color',       'Font color <b>Player name (2nd)</b>',              array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_2nd_player_name_color',       'def_color' => $cloudyBlue));
        add_settings_field(  'cfg777_details_md_2nd_player_name_size',        'Font size <b>Player name (2nd)</b>',               array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_2nd_player_name_size',        'def'       => $small     ));
        add_settings_field(  'cfg777_details_md_2nd_player_name_weight',      'Font weight <b>Player name (2nd)</b>',             array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_2nd_player_name_weight',      'def'       => $regular   ));
        add_settings_field(  'cfg777_details_md_score_color',                 'Font color match <b>Score</b>',                    array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_score_color',                 'def_color' => $white     ));
        add_settings_field(  'cfg777_details_md_score_size',                  'Font size match <b>Score</b>',                     array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_score_size',                  'def'       => $large     ));
        add_settings_field(  'cfg777_details_md_score_weight',                'Font weight match <b>Score</b>',                   array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_score_weight',                'def'       => $regular   ));
        add_settings_field(  'cfg777_details_md_points_color',                'Font color incidents <b>Points</b> (Basketball)',  array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_points_color',                'def_color' => $blue      ));
        add_settings_field(  'cfg777_details_md_points_size',                 'Font size incidents <b>Points</b> (Basketball)',   array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_points_size',                 'def'       => $large     ));
        add_settings_field(  'cfg777_details_md_points_weight',               'Font weight incidents <b>Points</b> (Basketball)', array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_points_weight',               'def'       => $regular   ));
        add_settings_field(  'cfg777_details_md_time_goals_color',            'Font color match <b>Time (Score)</b>',             array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_time_goals_color',            'def_color' => $cloudyBlue));
        add_settings_field(  'cfg777_details_md_time_goals_size',             'Font size match <b>Time (Score)</b>',              array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_time_goals_size',             'def'       => $medium    ));
        add_settings_field(  'cfg777_details_md_time_goals_weight',           'Font weight match <b>Time (Score)</b>',            array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_time_goals_weight',           'def'       => $regular   ));
        add_settings_field(  'cfg777_details_md_time_other_color',            'Font color match <b>Time (other)</b>',             array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_time_other_color',            'def_color' => $white     ));
        add_settings_field(  'cfg777_details_md_time_other_size',             'Font size match <b>Time (other)</b>',              array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_time_other_size',             'def'       => $small     ));
        add_settings_field(  'cfg777_details_md_time_other_weight',           'Font weight match <b>Time (other)</b>',            array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_time_other_weight',           'def'       => $regular   ));
        add_settings_field(  'cfg777_details_md_period_name_bg_color',        'Background color <b>period name</b>',              array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_period_name_bg_color',        'def_color' => $blueZodiac));
        add_settings_field(  'cfg777_details_md_period_divider_color',        'Dividers color <b>period name</b>',                array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_period_divider_color',        'def_color' => $lightGray ));
        add_settings_field(  'cfg777_details_md_period_name_color',           'Font color <b>period name</b>',                    array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_period_name_color',           'def_color' => $iron      ));
        add_settings_field(  'cfg777_details_md_period_name_size',            'Font size <b>period name</b>',                     array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_period_name_size',            'def'       => $medium    ));
        add_settings_field(  'cfg777_details_md_period_name_weight',          'Font weight <b>period name</b>',                   array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_period_name_weight',          'def'       => $regular   ));
        add_settings_field(  'cfg777_details_md_placeholder_bg_color',        'Background color <b>placeholder</b>',              array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_placeholder_bg_color',        'def_color' => $midnight  ));
        add_settings_field(  'cfg777_details_md_placeholder_divider_color',   'Dividers color <b>placeholder</b>',                array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_placeholder_divider_color',   'def_color' => $lightGray ));
        add_settings_field(  'cfg777_details_md_placeholder_font_color',      'Font color <b>placeholder</b>',                    array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_placeholder_font_color',      'def_color' => $iron      ));
        add_settings_field(  'cfg777_details_md_placeholder_font_size',       'Font size <b>placeholder</b>',                     array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_placeholder_font_size',       'def'       => $large     ));
        add_settings_field(  'cfg777_details_md_placeholder_font_weight',     'Font weight <b>placeholder</b>',                   array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_placeholder_font_weight',     'def'       => $regular   ));
        add_settings_field(  'cfg777_details_md_loader_bg_color',             'Background color <b>loader</b>',                   array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_loader_bg_color',             'def_color' => $midnight  ));
        add_settings_field(  'cfg777_details_md_loader_dividers_color',       'Dividers color <b>loader</b>',                     array($this, 'color'),          __FILE__, 'cfg777_section_matches_details', array('o_name' => 'md_loader_dividers_color',       'def_color' => $lightGray ));

        add_settings_section('cfg777_section_standings', 'Standing settings',  array($this, 'displaySection'), __FILE__);

        add_settings_section('cfg777_section_standings_comp_row',          'Tournament Row',                       array($this, 'displaySection'), __FILE__, array('before_section' => '<div class="cfg777-sub-section">', 'after_section' => '</div>'));
        add_settings_field(  'cfg777_comp_row_str_bg_color',               'Main Background color',                array($this, 'color'),          __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_bg_color',               'def_color' => $blueZodiac));
        add_settings_field(  'cfg777_comp_row_str_divider_color',          'Dividers color <b>loader</b>',              array($this, 'color'),          __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_divider_color',          'def_color' => $blackPearl));
        add_settings_field(  'cfg777_comp_row_str_bg_color_category_logo', 'Background color for <b>Category</b> logo', array($this, 'color'),          __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_bg_color_category_logo', 'def_color' => $blackPearl));
        add_settings_field(  'cfg777_comp_row_str_category_name_color',    'Font color <b>Category</b> name',           array($this, 'color'),          __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_category_name_color',    'def_color' => $iron      ));
        add_settings_field(  'cfg777_comp_row_str_category_name_size',     'Font size <b>Category</b> name',            array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_category_name_size',     'def'       => $small     ));
        add_settings_field(  'cfg777_comp_row_str_category_name_weight',   'Font weight <b>Category</b> name',          array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_category_name_weight',   'def'       => $regular   ));
        add_settings_field(  'cfg777_comp_row_str_tournament_name_color',  'Font color <b>Tournament</b> name',         array($this, 'color'),          __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_tournament_name_color',  'def_color' => $white     ));
        add_settings_field(  'cfg777_comp_row_str_tournament_name_size',   'Font size <b>Tournament</b> name',          array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_tournament_name_size',   'def'       => $medium    ));
        add_settings_field(  'cfg777_comp_row_str_tournament_name_weight', 'Font weight <b>Tournament</b> name',        array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_tournament_name_weight', 'def'       => $regular   ));
        add_settings_field(  'cfg777_comp_row_str_season_color',           'Font color <b>Season</b>',                  array($this, 'color'),          __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_season_color',           'def_color' => $cloudyBlue));
        add_settings_field(  'cfg777_comp_row_str_season_size',            'Font size <b>Season</b>',                   array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_season_size',            'def'       => $medium    ));
        add_settings_field(  'cfg777_comp_row_str_season_weight',          'Font weight <b>Season</b>',                 array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_standings_comp_row', array('o_name' => 'str_season_weight',          'def'       => $regular   ));

        add_settings_section('cfg777_section_standings_body_row',                'Body standings',                                    array($this, 'displaySection'), __FILE__, array('before_section' => '<div class="cfg777-sub-section">', 'after_section' => '</div>'));
        add_settings_field(  'cfg777_body_row_sn_bg_color',                      'Background color <b>standings filter</b>',               array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sn_bg_color',                      'def_color' => $midnight  ));
        add_settings_field(  'cfg777_body_row_sn_btn_bg_color',                  'Background color active button <b>standings filter</b>', array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sn_btn_bg_color',                  'def_color' => $blue      ));
        add_settings_field(  'cfg777_body_row_sn_btn_active_color',              'Font color active button <b>standings filter</b>',       array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sn_btn_active_color',              'def_color' => $white     ));
        add_settings_field(  'cfg777_body_row_sn_btn_color',                     'Font color inactive button <b>standings filter</b>',     array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sn_btn_color',                     'def_color' => $blue      ));
        add_settings_field(  'cfg777_body_row_sn_divider_color',                 'Dividers color <b>standings filter</b>',                 array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sn_divider_color',                 'def_color' => $lightGray ));
        add_settings_field(  'cfg777_body_row_sb_bg_color',                      'Main background color',                             array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_bg_color',                      'def_color' => $blackPearl));
        add_settings_field(  'cfg777_body_row_sb_team_row_dividers_color',       '<b>Dividers</b> team row color',                         array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_team_row_dividers_color',       'def_color' => $lightGray ));
        add_settings_field(  'cfg777_body_row_sb_team_row_hover',                'Team row <b>color on hover</b>',                         array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_team_row_hover',                'def_color' => $cultured  ));
        add_settings_field(  'cfg777_body_row_sb_standing_name_color',           'Font color standings <b>Name</b>',                       array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_standing_name_color',           'def_color' => $cloudyBlue));
        add_settings_field(  'cfg777_body_row_sb_standing_name_size',            'Font size standings <b>Name</b>',                        array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_standing_name_size',            'def'       => $medium    ));
        add_settings_field(  'cfg777_body_row_sb_standing_name_weight',          'Font weight standings <b>Name</b>',                      array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_standing_name_weight',          'def'       => $regular   ));
        add_settings_field(  'cfg777_body_row_sb_header_bg_color',               'Background color <b>columns</b>',                        array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_header_bg_color',               'def_color' => $midnight  ));
        add_settings_field(  'cfg777_body_row_sb_header_divider_color',          'Dividers color <b>columns</b>',                          array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_header_divider_color',          'def_color' => $lightGray ));
        add_settings_field(  'cfg777_body_row_sb_columns_and_numbering_color',   'Font color <b>columns</b>',                              array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_columns_and_numbering_color',   'def_color' => $cloudyBlue));
        add_settings_field(  'cfg777_body_row_sb_columns_and_numbering_size',    'Font size <b>columns</b>',                               array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_columns_and_numbering_size',    'def'       => $medium    ));
        add_settings_field(  'cfg777_body_row_sb_columns_and_numbering_weight',  'Font weight <b>columns</b>',                             array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_columns_and_numbering_weight',  'def'       => $regular   ));
        add_settings_field(  'cfg777_body_row_sb_team_name_color',               'Font color <b>Team</b> name',                            array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_team_name_color',               'def_color' => $white     ));
        add_settings_field(  'cfg777_body_row_sb_team_name_size',                'Font size <b>Team</b> name',                             array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_team_name_size',                'def'       => $medium    ));
        add_settings_field(  'cfg777_body_row_sb_team_name_weight',              'Font weight <b>Team</b> name',                           array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_team_name_weight',              'def'       => $regular   ));
        add_settings_field(  'cfg777_body_row_sb_standing_value_color',          'Font color Standing <b>values and numbering</b>',        array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_standing_value_color',          'def_color' => $white     ));
        add_settings_field(  'cfg777_body_row_sb_standing_value_size',           'Font size Standing <b>values and numbering</b>',         array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_standing_value_size',           'def'       => $medium    ));
        add_settings_field(  'cfg777_body_row_sb_standing_value_weight',         'Font weight Standing <b>values and numbering</b>',       array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_standing_value_weight',         'def'       => $regular   ));
        add_settings_field(  'cfg777_body_row_sb_standing_legend_bg_color',      'Background color Standing <b>legend</b>',                array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_standing_legend_bg_color',      'def_color' => $midnight  ));
        add_settings_field(  'cfg777_body_row_sb_standing_legend_divider_color', 'Dividers color Standing <b>legend</b>',                  array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_standing_legend_divider_color', 'def_color' => $lightGray ));
        add_settings_field(  'cfg777_body_row_sb_standing_legend_color',         'Font color Standing <b>legend</b>',                      array($this, 'color'),          __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_standing_legend_color',         'def_color' => $white     ));
        add_settings_field(  'cfg777_body_row_sb_standing_legend_size',          'Font size Standing <b>legend</b>',                       array($this, 'fsRadioBtn'),     __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_standing_legend_size',          'def'       => $medium    ));
        add_settings_field(  'cfg777_body_row_sb_standing_legend_weight',        'Font weight Standing <b>legend</b>',                     array($this, 'fwRadioBtn'),     __FILE__, 'cfg777_section_standings_body_row', array('o_name' => 'sb_standing_legend_weight',        'def'       => $regular   ));

        // Register Settings
        register_setting(__FILE__, 'cfg777_settings_options', array($this, 'validateOptions'));
    }

    public function validateOptions($fields) {
        $valid_fields = array();
        //language
        $lang_is = trim($fields['777_lang']);

        if (!in_array($lang_is, array_keys($this->langs))) {
            $lang_is = 'en';
        }

        $valid_fields['777_lang'] = strip_tags(stripslashes($lang_is));
        $valid_fields['777_your_word_num'] = rand(0, 9);

        $other_fields = array(
            'main_font',
            'main_size',
            'main_weight',
            'mtr_category_name_size',
            'mtr_category_name_weight',
            'mtr_tournament_name_size',
            'mtr_tournament_name_weight',
            'mtr_date_size',
            'mtr_date_weight',
            'msdr_font_size',
            'msdr_font_weight',
            'mmr_team_name_size',
            'mmr_team_name_weight',
            'mmr_status_finished_size',
            'mmr_status_finished_weight',
            'mmr_status_live_size',
            'mmr_status_live_weight',
            'mmr_score_win_team_size',
            'mmr_score_win_team_weight',
            'mmr_details_activation',
            'mmr_details_button_size',
            'mmr_details_button_weight',
            'mmr_score_team_size',
            'mmr_score_team_weight',
            'mmr_time_size',
            'mmr_time_weight',
            'md_commands_info_size',
            'md_commands_info_weight',
            'md_1st_player_name_size',
            'md_1st_player_name_weight',
            'md_2nd_player_name_size',
            'md_2nd_player_name_weight',
            'md_score_size',
            'md_score_weight',
            'md_points_size',
            'md_points_weight',
            'md_time_goals_size',
            'md_time_goals_weight',
            'md_time_other_size',
            'md_time_other_weight',
            'md_period_name_size',
            'md_period_name_weight',
            'md_placeholder_font_size',
            'md_placeholder_font_weight',
            'str_category_name_size',
            'str_category_name_weight',
            'str_tournament_name_size',
            'str_tournament_name_weight',
            'str_season_size',
            'str_season_weight',
            'sb_team_row_hover',
            'sb_standing_name_size',
            'sb_standing_name_weight',
            'sb_columns_and_numbering_size',
            'sb_columns_and_numbering_weight',
            'sb_team_name_size',
            'sb_team_name_weight',
            'sb_standing_value_size',
            'sb_standing_value_weight',
            'sb_standing_legend_size',
            'sb_standing_legend_weight'
        );
        foreach($other_fields as $f) {
            // Validate Comp Background Color
            $f_is = trim($fields[$f]);
            $valid_fields[$f] = strip_tags(stripslashes($f_is));
        }

        $color_fields = array(
            'main_bg_color',
            'main_color',
            'mtr_bg_color',
            'mtr_bg_color_category_logo',
            'mtr_dividers_color',
            'mtr_category_name_color',
            'mtr_tournament_name_color',
            'mtr_date_color',
            'msdr_bg_color',
            'msd_dividers_color',
            'msdr_font_color',
            'mmr_bg_color',
            'mmr_dividers_color',
            'mmr_hover_color',
            'mmr_team_name_color',
            'mmr_status_finished_color',
            'mmr_status_live_color',
            'mmr_score_win_team_color',
            'mmr_details_bg_color',
            'mmr_details_button_bg_color',
            'mmr_score_team_color',
            'mmr_time_color',
            'mmr_score_team_color_basket',
            'md_commands_info_bg_color',
            'md_commands_info_color',
            'md_commands_info_divider_color',
            'md_bg_color',
            'md_dividers_color',
            'md_1st_player_name_color',
            'md_2nd_player_name_color',
            'md_score_color',
            'md_points_color',
            'md_time_goals_color',
            'md_time_other_color',
            'md_period_name_bg_color',
            'md_period_divider_color',
            'md_period_name_color',
            'md_placeholder_bg_color',
            'md_placeholder_divider_color',
            'md_placeholder_font_color',
            'md_loader_bg_color',
            'md_loader_dividers_color',
            'str_bg_color',
            'str_divider_color',
            'str_bg_color_category_logo',
            'str_category_name_color',
            'str_tournament_name_color',
            'str_season_color',
            'sn_bg_color',
            'sn_btn_bg_color',
            'sn_btn_active_color',
            'sn_btn_color',
            'sn_divider_color',
            'sb_bg_color',
            'sb_team_row_dividers_color',
            'sb_standing_name_color',
            'sb_header_bg_color',
            'sb_header_divider_color',
            'sb_columns_and_numbering_color',
            'sb_team_name_color',
            'sb_standing_value_color',
            'sb_standing_legend_bg_color',
            'sb_standing_legend_divider_color',
            'sb_standing_legend_color'
        );

        foreach($color_fields as $color_f) {
            // Validate Comp Background Color
            $clr_is = trim($fields[$color_f]);
            $clr_is = strip_tags(stripslashes($clr_is));
            if(FALSE === $this->checkColor($clr_is)) {
                // Set the error message
                add_settings_error('cfg777_settings_options', 'cfg777_bg_error', "Insert a valid color instead ".esc_attr($clr_is), 'error'); // $setting, $code, $message, $type

                // Get the previous valid value
                $valid_fields[$color_f] = isset($this->options[$color_f]) ? $this->options[$color_f] : '';
            } else {
                $valid_fields[$color_f] = $clr_is;
            }

        }

        return apply_filters('validateOptions', $valid_fields, $fields);

    }

    /**
     * Function that will check if value is a valid HEX color.
     */
    public function checkColor($value) {
        if (preg_match('/^#[a-f0-9]{6}$/i', $value)) { // if user insert a HEX color with #
            return true;
        }

        return false;
    }

    /**
     * Callback function for settings section
     */
    public function displaySection() { /* Leave blank */ }

    public function timezoneField() {
        echo '<div>Automatic</div><div><small>The user\'s location is used to set the time zone.</small></div>';
    }

    public function textNumber() {
        echo '<input type="hidden" name="cfg777_settings_options[777_your_word_num]" value="" />';
    }

    public function mainFontSettingsField() {
        $val = isset($this->options['main_font']) ? $this->options['main_font'] : 'Roboto';

        if (!$val) {
            $val = 'Roboto';
        }

        $selected_one = array(
            'Roboto' => '',
            'Arial' => '',
            'Inter' => '',
            'Helvetica' => '',
            'Lato' => '',
            '"Noto Sans"' => '',
            'Rubik' => ''
        );
        $selected_one[$val] = 'selected="selected"';
        echo "
        <select name='cfg777_settings_options[main_font]'>
            <option value='Roboto' ".esc_html($selected_one['Roboto']).">Roboto</option>
            <option value='Arial' ".esc_html($selected_one['Arial']).">Arial</option>
            <option value='Inter' ".esc_html($selected_one['Inter']).">Inter</option>
            <option value='Helvetica' ".esc_html($selected_one['Helvetica']).">Helvetica</option>
            <option value='Lato' ".esc_html($selected_one['Lato']).">Lato</option>
            <option value='\"Noto Sans\"' ".esc_html($selected_one['"Noto Sans"']).">Noto Sans</option>
            <option value='Rubik' ".esc_html($selected_one['Rubik']).">Rubik</option>
        </select>
        ";
    }

    public function langSettingsField() {
        $locale = substr(get_locale(),0,2);
        $selected_one = $this->langs;
        $val = isset($this->options['777_lang']) ? $this->options['777_lang'] : 'en';

        if (!$val) {
            $val = in_array($locale, array_keys($this->langs)) ? $locale : 'en';
        }

        $selected_one[$val] = 'selected="selected"';

        echo "
        <select name='cfg777_settings_options[777_lang]'>
            <option value='en' ".esc_html($selected_one['en']).">English</option>
            <option value='fr' ".esc_html($selected_one['fr']).">Français</option>
            <option value='pt' ".esc_html($selected_one['pt']).">Português</option>
            <option value='de' ".esc_html($selected_one['de']).">Deutsch</option>
            <option value='id' ".esc_html($selected_one['id']).">Indonesian</option>
            <option value='it' ".esc_html($selected_one['it']).">İtaliano</option>
            <option value='ko' ".esc_html($selected_one['ko']).">한국인</option>
            <option value='pl' ".esc_html($selected_one['pl']).">Polski</option>
            <option value='ru' ".esc_html($selected_one['ru']).">Русский</option>
            <option value='es' ".esc_html($selected_one['es']).">Española</option>
            <option value='th' ".esc_html($selected_one['th']).">แบบไทย</option>
            <option value='tr' ".esc_html($selected_one['tr']).">Türkçe</option>
            <option value='uk' ".esc_html($selected_one['uk']).">Українська</option>
            <option value='vi' ".esc_html($selected_one['vi']).">Tiếng Việt</option>
            <option value='nl' ".esc_html($selected_one['nl']).">Nederlands</option>
            <option value='ro' ".esc_html($selected_one['ro']).">Română</option>
            <option value='ka' ".esc_html($selected_one['ka']).">ქართული</option>
            <option value='hy' ".esc_html($selected_one['hy']).">հայերեն</option>
            <option value='az' ".esc_html($selected_one['az']).">Azərbaycan</option>
            <option value='el' ".esc_html($selected_one['el']).">Ελληνικά</option>
            <option value='uz' ".esc_html($selected_one['uz']).">O'zbek</option>
        </select>
        ";
    }

    public function color(array $args) {
        $val = isset($this->options[$args['o_name']]) ? $this->options[$args['o_name']] : $args['def_color'];
        if (!$val) {
            $val = $args['def_color'];
        }

        echo "
        <input type='text' name='cfg777_settings_options[".esc_attr($args['o_name'])."]' value='".esc_attr($val)."' class='cpa-color-picker'/>
        ";
    }

    public function fsRadioBtn(array $args) {
        $val = isset($this->options[$args['o_name']]) ? $this->options[$args['o_name']] : $args['def'];
        if (!$val) {
            $val = $args['def'];
        }
        $checked = array(
            $this->small => '',
            $this->medium => '',
            $this->large => '',
        );
        $checked[$val] = 'checked';
        echo "
        <label>
            <input type='radio' name='cfg777_settings_options[".esc_attr($args['o_name'])."]' value='".esc_attr($this->small)."'  ".esc_attr($checked[$this->small])."/>
            ".esc_attr($this->small)."
        </label>
        <label>
            <input type='radio' name='cfg777_settings_options[".esc_attr($args['o_name'])."]' value='".esc_attr($this->medium)."'  ".esc_attr($checked[$this->medium])."/>
            ".esc_attr($this->medium)."
        </label>
        <label>
            <input type='radio' name='cfg777_settings_options[".esc_attr($args['o_name'])."]' value='".esc_attr($this->large)."'  ".esc_attr($checked[$this->large])."/>
            ".esc_attr($this->large)."
        </label>
        ";
    }

    public function fwRadioBtn(array $args) {
        $regular = $this->regular;
        $bold = $this->bold;

        $val = isset($this->options[$args['o_name']]) ? $this->options[$args['o_name']] : $args['def'];
        if (!$val) {
            $val = $args['def'];
        }

        $checked = array_combine(array($regular, $bold), array('', ''));
        $checked[$val] = 'checked';

        echo "
        <label>
            <input type='radio' name='cfg777_settings_options[".esc_attr($args['o_name'])."]' value='".esc_attr($regular)."'  ".esc_attr($checked[$regular])."/>
            Regular
        </label>
        <label>
            <input type='radio' name='cfg777_settings_options[".esc_attr($args['o_name'])."]' value='".esc_attr($bold)."'  ".esc_attr($checked[$bold])."/>
            Bold
        </label>
        ";
    }

    public function onOffRadioBtn(array $args) {
        $on = $this->on;
        $off = $this->off;

        $val = isset($this->options[$args['o_name']]) ? $this->options[$args['o_name']] : $args['def'];
        if (!$val) {
            $val = $args['def'];
        }

        $checked = array_combine(array($on, $off), array('', ''));
        $checked[$val] = 'checked';

        echo "
        <label>
            <input type='radio' name='cfg777_settings_options[".esc_attr($args['o_name'])."]' value='".esc_attr($on)."'  ".esc_attr($checked[$on])."/>
            On
        </label>
        <label>
            <input type='radio' name='cfg777_settings_options[".esc_attr($args['o_name'])."]' value='".esc_attr($off)."'  ".esc_attr($checked[$off])."/>
            Off
        </label>
        ";
    }
}
