golden hour
/var/www/html/wp-content/plugins/designthemes-webinar/modules/google-classroom/settings
⬆️ Go Up
Upload
File/Folder
Size
Actions
add-course.php
27 B
Del
OK
classroom-template.php
3.23 KB
Del
OK
general.php
4.37 KB
Del
OK
index.php
1.57 KB
Del
OK
list-course.php
1.73 KB
Del
OK
Edit: general.php
<?php if(!function_exists('dtwebinar_gcr_general_settings')) { function dtwebinar_gcr_general_settings() { $output = ''; $output .= '<form name="dtWebinarOptionSettings" class="dtWebinarOptionSettings" method="post">'; $output .= '<div class="dtwebinar-settings-options-holder">'; $output .= '<div class="dtwebinar-column dtwebinar-one-fifth first">'; $output .= '<label>'.esc_html__( 'JSON Credentials', 'dtwebinar' ).'</label>'; $output .= '</div>'; $output .= '<div class="dtwebinar-column dtwebinar-four-fifth">'; $credentials_json = dtwebinar_gcr_option('general', 'credentials-json'); $output .= '<textarea id="credentials-json" name="dtwebinar-gcr[general][credentials-json]" rows="6" cols="120">'.stripslashes($credentials_json).'</textarea>'; $output .= '<div class="dtwebinar-note">'.esc_html__('Add your JSON credentials here.', 'dtwebinar').'</div>'; $output .= '</div>'; $output .= '</div>'; $output .= '<div class="dtwebinar-option-settings-response-holder"></div>'; $output .= '<a href="#" class="custom-button-style dtwebinar-save-options-settings" data-settings="general" data-validate-settings="true">'.esc_html__('Save Settings', 'dtwebinar').'</a>'; $output .= '<div class="dtwebinar-settings-options-container">'; $output .= dtwebinar_gcr_general_authenticate_settings(); $output .= '</div>'; $output .= '</form>'; echo $output; } } if(!function_exists('dtwebinar_gcr_general_authenticate_settings')) { function dtwebinar_gcr_general_authenticate_settings() { $credentials_json = dtwebinar_gcr_option('general', 'credentials-json'); $credentials = json_decode(stripslashes($credentials_json)); if((isset($credentials->web->client_id) && !empty($credentials->web->client_id)) && (isset($credentials->web->project_id) && !empty($credentials->web->project_id))) { $config = [ 'client_secret' => $credentials->web->client_secret, 'client_id' => $credentials->web->client_id, 'redirect_uri' => $credentials->web->redirect_uris[0], 'project_id' => $credentials->web->project_id ]; $redirect_uri = $config['redirect_uri']; $client = new Google_Client($config); $client->addScope('https://www.googleapis.com/auth/classroom.courses'); $client->addScope('https://www.googleapis.com/auth/classroom.rosters'); $client->addScope('https://www.googleapis.com/auth/classroom.coursework.students'); $client->addScope('https://www.googleapis.com/auth/classroom.announcements'); $client->addScope('https://www.googleapis.com/auth/classroom.profile.emails'); $client->addScope('https://www.googleapis.com/auth/spreadsheets'); $client->setAccessType('offline'); $client->setApprovalPrompt('force'); $authUrl = $client->createAuthUrl(); if (isset($_GET['code'])) { $issue = false; try { $token = $client->fetchAccessTokenWithAuthCode($_GET['code']); } catch(Exception $exception) { $errors = $exception->getErrors(); $issue = true; delete_option('dtwebinar_gcr_auth_token'); } if(!$issue) { //$client->setAccessToken($token); update_option( 'dtwebinar_gcr_auth_token', $token); echo '<script> window.location.replace('.$redirect_uri.'); </script>'; } } return '<a class="dtwebinar-gcr-auth-login" href="'.esc_url($authUrl).'">'.esc_html__('Connect / Reconnect To Google Classroom', 'dtwebinar').'</a>'; } else { delete_option('dtwebinar_gcr_auth_token'); return '<div class="dtwebinar-notes dtwebinar-notes-info">'.esc_html__('Credentials are invalid, please recheck.', 'dtwebinar').'</div>'; } } } // Produce HTML dtwebinar_gcr_general_settings(); ?>
Save