<?php

// If this file is called directly, abort.
if ( !defined( 'ABSPATH' ) ) {
    exit;
}
$disabled = 'disabled';
$class_disabled = 'radio-disabled';
$checkbox_disabled = 'checkbox-disabled';
?>
<div class="wrap">

    <?php 
settings_errors();
?>

    <form method="post" action="options.php" id="tabs" class="form-images">

        <?php 
settings_fields( 'YTAM-settings' );
$options = wp_parse_args( get_option( 'YTAM_settings' ), $this->default_options_main_settings( TRUE ) );
do_action( 'ytam_before_display_main_options' );
?>

        <div id="settings">
            <table id="general-options" class="form-table tabs-content">
                    <tbody>

                            <tr valign="top" class="section_openai_extractor">
                                    <th scope="row">
                                            <label for="hseparator"><?php 
esc_html_e( 'Youtube API Key', 'easy-youtube-automate' );
?></label>
                                    </th>
                                    <td id="password-openai" class="password">
                                        <input type="password" name="YTAM_settings[youtube_apikey]" class="form-control" 
                                        value="<?php 
echo ( isset( $options['youtube_apikey'] ) && !empty( esc_html( $options['youtube_apikey'] ) ) ? esc_html( $options['youtube_apikey'] ) : '' );
?>">
                                        <i id="togglePassword"></i>
                                    </td>
                                    <p class="description"><i>
                                        <?php 
echo sprintf( 
    /* translators: %s: link "here" */
    esc_html__( 'The API key is required to use Youtube. You will need to provide your own Google/Youtube API key. You need to follow the process %s', 'easy-youtube-automate' ),
    '<a target="_blank" href="https://developers.google.com/custom-search/json-api/v1/overview#prerequisites">' . esc_html__( 'here', 'easy-youtube-automate' ) . '</a>'
 );
?>
                                    </i></p>
                            </tr>


                            <?php 
if ( !isset( $options['relevanceLanguage'] ) ) {
    $wp_lang = get_bloginfo( 'language' );
    $relevanceLanguage = substr( $wp_lang, 0, 2 );
} else {
    $relevanceLanguage = esc_html( $options['relevanceLanguage'] );
}
?>

                            <tr valign="top" class="relevanceLanguage">
                                <th scope="row">
                                        <?php 
esc_html_e( 'Relevance Language', 'easy-youtube-automate' );
?>
                                </th>
                                <td class="checkbox-list">

                                        <select name="YTAM_settings[relevanceLanguage]" class="form-control form-control-lg" >
                                            <?php 
$order_choose = array(
    esc_html__( 'Afrikaans', 'easy-youtube-automate' )             => 'af',
    esc_html__( 'Afrikaans', 'easy-youtube-automate' )             => 'af',
    esc_html__( 'Albanian', 'easy-youtube-automate' )              => 'sq',
    esc_html__( 'Amharic', 'easy-youtube-automate' )               => 'sm',
    esc_html__( 'Arabic', 'easy-youtube-automate' )                => 'ar',
    esc_html__( 'Azerbaijani', 'easy-youtube-automate' )           => 'az',
    esc_html__( 'Basque', 'easy-youtube-automate' )                => 'eu',
    esc_html__( 'Belarusian', 'easy-youtube-automate' )            => 'be',
    esc_html__( 'Bengali', 'easy-youtube-automate' )               => 'bn',
    esc_html__( 'Bihari', 'easy-youtube-automate' )                => 'bh',
    esc_html__( 'Bosnian', 'easy-youtube-automate' )               => 'bs',
    esc_html__( 'Bulgarian', 'easy-youtube-automate' )             => 'bg',
    esc_html__( 'Catalan', 'easy-youtube-automate' )               => 'ca',
    esc_html__( 'Chinese (Simplified)', 'easy-youtube-automate' )  => 'zh-CN',
    esc_html__( 'Chinese (Traditional)', 'easy-youtube-automate' ) => 'zh-TW',
    esc_html__( 'Croatian', 'easy-youtube-automate' )              => 'hr',
    esc_html__( 'Czech', 'easy-youtube-automate' )                 => 'cs',
    esc_html__( 'Danish', 'easy-youtube-automate' )                => 'da',
    esc_html__( 'Dutch', 'easy-youtube-automate' )                 => 'nl',
    esc_html__( 'English', 'easy-youtube-automate' )               => 'en',
    esc_html__( 'Esperanto', 'easy-youtube-automate' )             => 'eo',
    esc_html__( 'Estonian', 'easy-youtube-automate' )              => 'et',
    esc_html__( 'Faroese', 'easy-youtube-automate' )               => 'fo',
    esc_html__( 'Finnish', 'easy-youtube-automate' )               => 'fi',
    esc_html__( 'French', 'easy-youtube-automate' )                => 'fr',
    esc_html__( 'Frisian', 'easy-youtube-automate' )               => 'fy',
    esc_html__( 'Galician', 'easy-youtube-automate' )              => 'gl',
    esc_html__( 'Georgian', 'easy-youtube-automate' )              => 'ka',
    esc_html__( 'German', 'easy-youtube-automate' )                => 'de',
    esc_html__( 'Greek', 'easy-youtube-automate' )                 => 'el',
    esc_html__( 'Gujarati', 'easy-youtube-automate' )              => 'gu',
    esc_html__( 'Hebrew', 'easy-youtube-automate' )                => 'iw',
    esc_html__( 'Hindi', 'easy-youtube-automate' )                 => 'hi',
    esc_html__( 'Hungarian', 'easy-youtube-automate' )             => 'hu',
    esc_html__( 'Icelandic', 'easy-youtube-automate' )             => 'is',
    esc_html__( 'Indonesian', 'easy-youtube-automate' )            => 'id',
    esc_html__( 'Interlingua', 'easy-youtube-automate' )           => 'ia',
    esc_html__( 'Irish', 'easy-youtube-automate' )                 => 'ga',
    esc_html__( 'Italian', 'easy-youtube-automate' )               => 'it',
    esc_html__( 'Japanese', 'easy-youtube-automate' )              => 'ja',
    esc_html__( 'Javanese', 'easy-youtube-automate' )              => 'jw',
    esc_html__( 'Kannada', 'easy-youtube-automate' )               => 'kn',
    esc_html__( 'Korean', 'easy-youtube-automate' )                => 'ko',
    esc_html__( 'Latin', 'easy-youtube-automate' )                 => 'la',
    esc_html__( 'Latvian', 'easy-youtube-automate' )               => 'lv',
    esc_html__( 'Lithuanian', 'easy-youtube-automate' )            => 'lt',
    esc_html__( 'Macedonian', 'easy-youtube-automate' )            => 'mk',
    esc_html__( 'Malay', 'easy-youtube-automate' )                 => 'ms',
    esc_html__( 'Malayam', 'easy-youtube-automate' )               => 'ml',
    esc_html__( 'Maltese', 'easy-youtube-automate' )               => 'mt',
    esc_html__( 'Marathi', 'easy-youtube-automate' )               => 'mr',
    esc_html__( 'Nepali', 'easy-youtube-automate' )                => 'ne',
    esc_html__( 'Norwegian', 'easy-youtube-automate' )             => 'no',
    esc_html__( 'Norwegian (Nynorsk)', 'easy-youtube-automate' )   => 'nn',
    esc_html__( 'Occitan', 'easy-youtube-automate' )               => 'oc',
    esc_html__( 'Persian', 'easy-youtube-automate' )               => 'fa',
    esc_html__( 'Polish', 'easy-youtube-automate' )                => 'pl',
    esc_html__( 'Portuguese (Brazil)', 'easy-youtube-automate' )   => 'pt-BR',
    esc_html__( 'Portuguese (Portugal)', 'easy-youtube-automate' ) => 'pt-PT',
    esc_html__( 'Punjabi', 'easy-youtube-automate' )               => 'pa',
    esc_html__( 'Romanian', 'easy-youtube-automate' )              => 'ro',
    esc_html__( 'Russian', 'easy-youtube-automate' )               => 'ru',
    esc_html__( 'Scots Gaelic', 'easy-youtube-automate' )          => 'gd',
    esc_html__( 'Serbian', 'easy-youtube-automate' )               => 'sr',
    esc_html__( 'Sinhalese', 'easy-youtube-automate' )             => 'si',
    esc_html__( 'Slovak', 'easy-youtube-automate' )                => 'sk',
    esc_html__( 'Slovenian', 'easy-youtube-automate' )             => 'sl',
    esc_html__( 'Spanish', 'easy-youtube-automate' )               => 'es',
    esc_html__( 'Sudanese', 'easy-youtube-automate' )              => 'su',
    esc_html__( 'Swahili', 'easy-youtube-automate' )               => 'sw',
    esc_html__( 'Swedish', 'easy-youtube-automate' )               => 'sv',
    esc_html__( 'Tagalog', 'easy-youtube-automate' )               => 'tl',
    esc_html__( 'Tamil', 'easy-youtube-automate' )                 => 'ta',
    esc_html__( 'Telugu', 'easy-youtube-automate' )                => 'te',
    esc_html__( 'Thai', 'easy-youtube-automate' )                  => 'th',
    esc_html__( 'Tigrinya', 'easy-youtube-automate' )              => 'ti',
    esc_html__( 'Turkish', 'easy-youtube-automate' )               => 'tr',
    esc_html__( 'Ukrainian', 'easy-youtube-automate' )             => 'uk',
    esc_html__( 'Urdu', 'easy-youtube-automate' )                  => 'ur',
    esc_html__( 'Uzbek', 'easy-youtube-automate' )                 => 'uz',
    esc_html__( 'Vietnamese', 'easy-youtube-automate' )            => 'vi',
    esc_html__( 'Welsh', 'easy-youtube-automate' )                 => 'cy',
    esc_html__( 'Xhosa', 'easy-youtube-automate' )                 => 'xh',
    esc_html__( 'Zulu', 'easy-youtube-automate' )                  => 'zu',
);
ksort( $order_choose );
foreach ( $order_choose as $name_order => $code_order ) {
    $choose = ( $relevanceLanguage == $code_order ? 'selected="selected"' : '' );
    echo '<option ' . esc_html( $choose ) . ' value="' . esc_html( $code_order ) . '">' . esc_html( $name_order ) . '</option>';
}
?>
                                        </select>

                                </td>
                            </tr>


                            <?php 
if ( !isset( $options['order'] ) ) {
    $order = 'relevance';
} else {
    $order = esc_html( $options['order'] );
}
?>

                            <tr valign="top" class="order">
                                <th scope="row">
                                        <?php 
esc_html_e( 'Order', 'easy-youtube-automate' );
?>
                                </th>
                                <td class="checkbox-list">

                                        <select name="YTAM_settings[order]" class="form-control form-control-lg" >
                                            <?php 
$order_choose = array(
    esc_html__( 'Date', 'easy-youtube-automate' )        => 'date',
    esc_html__( 'Rating', 'easy-youtube-automate' )      => 'rating',
    esc_html__( 'Relevance', 'easy-youtube-automate' )   => 'relevance',
    esc_html__( 'Title', 'easy-youtube-automate' )       => 'title',
    esc_html__( 'Video Count', 'easy-youtube-automate' ) => 'videoCount',
    esc_html__( 'View Count', 'easy-youtube-automate' )  => 'viewCount',
);
ksort( $order_choose );
foreach ( $order_choose as $name_order => $code_order ) {
    $choose = ( $order == $code_order ? 'selected="selected"' : '' );
    echo '<option ' . esc_html( $choose ) . ' value="' . esc_html( $code_order ) . '">' . esc_html( $name_order ) . '</option>';
}
?>
                                        </select>

                                </td>
                            </tr>

                    </tbody>
            </table>
        </div>

        <?php 
submit_button();
?>

    </form>
</div>