\n"; esc_html_e('You first have to authorize Photonic to connect to your DeviantArt account.', 'photonic'); echo "
\n"; if (!isset($parameters['code']) || !isset($parameters['source']) || 'deviantart' !== $parameters['source']) { $url = add_query_arg('test', 'test'); $url = remove_query_arg('test', $url); $parameters = [ 'response_type' => 'code', 'client_id' => $photonic_deviantart_client_id, 'redirect_uri' => admin_url('admin.php?page=photonic-auth&source=deviantart'), 'scope' => 'basic browse', 'access_type' => 'offline', 'state' => md5($photonic_deviantart_client_secret . 'deviantart') . '::' . rawurlencode($url), 'prompt' => 'consent', ]; $url = 'https://www.deviantart.com/oauth2/authorize?' . DeviantArt::build_query($parameters); echo "" . esc_html__('Step 1: Authenticate', 'photonic') . ''; echo "\n";
echo esc_html__('Next, you have to obtain the token.', 'photonic') . '
';
echo "
' . esc_html__("Unfortunately Instagram is no longer supported in Photonic. This is due to a change in Meta's Terms and Conditions, that only allow businesses to access their API. As Photonic is developed by an individual, the API is no longer accessible to the developer.", 'photonic') . '
' . esc_html__('Your authentication credentials are for the old Instagram API. Please reauthenticate to keep Photonic working.', 'photonic') . '
' . esc_html__('Your authentication credentials are expiring soon. Please reauthenticate to keep Photonic working.', 'photonic') . '
' . esc_html__('Your authentication credentials have expired! Please reauthenticate to keep Photonic working.', 'photonic') . '
tags */
$this->print_auth_done_all_good(sprintf(esc_html__('You are logged in as %1$s.', 'photonic'), '' . $cached_token['user'] . ''));
}
else {
$this->print_auth_done_all_good();
}
}
}
elseif (!empty($auth['token'])) {
$this->print_auth_done_all_good();
}
echo "' . esc_html($access_token['oauth_token']) . '' . esc_html($access_token['oauth_token_secret']) . ''; esc_html_e('You have already set up your authentication. Unless you wish to regenerate the token this step is not required. ', 'photonic'); if (!empty($additional_msg)) { echo esc_html($additional_msg); } echo '
'; } private function get_login_button($provider) { /* Translators: 1: Platform, untranslated */ return sprintf(esc_html__('Login and get Access Token from %s', 'photonic'), $provider); } private function show_token_deletion_button($provider) { // echo "" . esc_html__(sprintf('Delete current %s authentication data', $provider), 'photonic') . ''; } public function obtain_token() { $provider = sanitize_text_field($_POST['provider'] ?? ''); global $photonic_flickr_api_secret, $photonic_smug_api_secret, $photonic_deviantart_client_secret; if ('flickr' === $provider && check_ajax_referer('flickr-request-token-' . $photonic_flickr_api_secret, '_ajax_nonce')) { require_once PHOTONIC_PATH . '/Platforms/Flickr.php'; $module = Flickr::get_instance(); if (empty($_POST['oauth_token']) && empty($_POST['oauth_verifier'])) { $request_token = $module->get_request_token(admin_url('admin.php?page=photonic-auth&provider=flickr')); $authorize_url = $module->get_authorize_URL($request_token); $authorize_url .= '&perms=read'; $module->save_token($request_token); echo esc_url_raw($authorize_url); } } elseif ('smug' === $provider && check_ajax_referer('smug-request-token-' . $photonic_smug_api_secret, '_ajax_nonce')) { require_once PHOTONIC_PATH . '/Platforms/SmugMug.php'; $module = SmugMug::get_instance(); if (empty($_POST['oauth_token']) && empty($_POST['oauth_verifier'])) { $request_token = $module->get_request_token(admin_url('admin.php?page=photonic-auth&provider=smug')); $authorize_url = $module->get_authorize_URL($request_token); $authorize_url .= '&Access=Full&Permissions=Read'; $module->save_token($request_token); echo esc_url_raw($authorize_url); } } elseif ('zenfolio' === $provider) { $module = Zenfolio::get_instance(); if (!empty($_POST['password'])) { $response = $module->authenticate($_POST['password']); if (!empty($response['error'])) { echo wp_kses_post($response['error']); } elseif (!empty($response['success'])) { esc_html_e('Authentication successful! All your galleries will be displayed with Authentication in place.', 'photonic'); } } } elseif ('deviantart' === $provider && check_ajax_referer('deviantart-obtain-token-' . $photonic_deviantart_client_secret, '_ajax_nonce')) { $code = sanitize_text_field($_POST['code'] ?? ''); require_once PHOTONIC_PATH . '/Platforms/DeviantArt.php'; $module = DeviantArt::get_instance(); $response = Photonic::http( $module->access_token_URL(), 'POST', [ 'code' => $code, 'grant_type' => 'authorization_code', 'client_id' => $module->client_id, 'client_secret' => $module->client_secret, 'redirect_uri' => admin_url('admin.php?page=photonic-auth&source=deviantart'), ] ); if (!is_wp_error($response) && is_array($response)) { $body = json_decode($response['body']); // Add nonce to the response. This will be used to save the information in the options. $body->nonce = wp_create_nonce('deviantart-save-token-' . $body->refresh_token); echo(wp_json_encode($body)); } } } public function delete_token_from_options() { if (isset($_POST['provider']) && check_ajax_referer($_POST['provider'] . '-delete-token')) { $provider = strtolower(sanitize_text_field($_POST['provider'])); if (in_array($provider, ['flickr', 'smug', 'zenfolio', 'google', 'instagram'], true) && current_user_can('edit_theme_options')) { $photonic_authentication = get_option('photonic_authentication'); if ('zenfolio' === $provider) { if (isset($photonic_authentication[$provider])) { unset($photonic_authentication[$provider]); } } update_option('photonic_authentication', $photonic_authentication); } } die(); } }