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

<form method="post" action="options.php" id="" class="egps_firebase_options">

<?php 
    settings_fields( 'egps_firebase_data' );
    do_settings_sections( 'egps_firebase_data' ); 

    $firebase_options = get_option('egps_firebase_options');

    if(!$firebase_options){
        $firebase_options = array();
        
        $firebase_options['firebase_apikey'] = "";
        $firebase_options['firebase_authdomain'] = "";
        $firebase_options['firebase_projectid'] = "";
        $firebase_options['firebase_storagebucket'] = "";
        $firebase_options['firebase_messagingsender'] = "";
        $firebase_options['firebase_appid'] = "";
    }

?>


<h3>Google Firebase API settings</h3>

    <p>
        For user authentication you have to connect the EGPS - Easy Sell for Google Photo plugin to a 
        Google Firebase project.
        Follow the steps below, to generate, and save connection data for the API.
    </p>
    <p>
        1. <a href="https://console.firebase.google.com/" target="_blank">Create a new Firebase project</a><br>
        2. Go to the Build->Authentication page<br>
        3. Get "Email/Password" sign in method enabled<br>
        4. Go to "Authentication -> Settings" and add your domain to "Authorized domains"<br>
        5. Go to "Project settings -> Your apps" and fill the form below. <br>
        5+. For more help, watch the step-by-step instruction video in the HELP menu.
    </p>
    
    <table class="form-table" role="presentation">
        <tbody>
        <tr>
            <th scope="row">apiKey</th>
            <td>
                <input 
                        type="text" 
                        class="egps_admin_fields_500 egps_remove_space" 
                        name="egps_firebase_options[firebase_apikey]" 
                        value="<?php echo esc_html($firebase_options['firebase_apikey']); ?>">                    
            </td>
        </tr>
        <tr>
            <th scope="row">authDomain</th>
            <td>
                <input 
                    type="text" 
                    class="egps_admin_fields_500 egps_remove_space" 
                    name="egps_firebase_options[firebase_authdomain]" 
                    value="<?php echo esc_html($firebase_options['firebase_authdomain']); ?>">                    
                    
            </td>
        </tr>
        <tr>
            <th scope="row">projectId</th>
            <td>
                <input 
                    type="text" 
                    class="egps_admin_fields_500 egps_remove_space" 
                    name="egps_firebase_options[firebase_projectid]" 
                    value="<?php echo esc_html($firebase_options['firebase_projectid']); ?>">                    
                    
            </td>
        </tr>
        <tr>
            <th scope="row">storageBucket</th>
            <td>
                <input 
                    type="text" 
                    class="egps_admin_fields_500 egps_remove_space" 
                    name="egps_firebase_options[firebase_storagebucket]" 
                    value="<?php echo esc_html($firebase_options['firebase_storagebucket']); ?>">                    
                    
            </td>
        </tr>
        <tr>
            <th scope="row">messagingSenderId</th>
            <td>
                <input 
                    type="text" 
                    class="egps_admin_fields_500 egps_remove_space" 
                    name="egps_firebase_options[firebase_messagingsender]" 
                    value="<?php echo esc_html($firebase_options['firebase_messagingsender']); ?>">                    
                    
            </td>
        </tr>
        <tr>
            <th scope="row">appId</th>
            <td>
                <input 
                    type="text" 
                    class="egps_admin_fields_500 egps_remove_space" 
                    name="egps_firebase_options[firebase_appid]" 
                    value="<?php echo esc_html($firebase_options['firebase_appid']); ?>">                    
                    
            </td>
        </tr>
        </tbody>
    </table>

    <?php submit_button(); ?>

</form>


