PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.33
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.33
3.36 3.35 3.34 3.33 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31 2.32 2.33 2.34 2.40 2.41 2.42 2.43 2.44 All 141 releases
photonic / Platforms / Lightroom.php

Lightroom.php in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 3.33, at Platforms/Lightroom.php

101 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Photonic_Plugin\Platforms;
4
5 use Photonic_Plugin\Components\Pagination;
6 use Photonic_Plugin\Core\Photonic;
7
8 require_once 'OAuth2.php';
9 require_once 'Level_One_Module.php';
10 require_once 'Level_Two_Module.php';
11
12 class Lightroom extends OAuth2 implements Level_One_Module, Level_Two_Module {
13 private static $instance = null;
14
15 protected function __construct() {
16 parent::__construct();
17 global $photonic_google_client_secret, $photonic_google_refresh_token;
18
19 $this->client_id = '6cf8382c9a9b48d8a0b91d0ed15a4e6a';
20 $this->provider = 'lr';
21 $this->oauth_version = '2.0';
22
23 $this->scope = 'https://www.googleapis.com/auth/photoslibrary.readonly';
24 $this->link_lightbox_title = false; // empty($photonic_google_disable_title_link);
25
26 // Documentation
27 $this->doc_links = [
28 'general' => 'https://aquoid.com/plugins/photonic/lightroom/',
29 ];
30
31 $this->error_date_format = esc_html__('Dates must be entered in the format Y/M/D where Y is from 0 to 9999, M is from 0 to 12 and D is from 0 to 31. You entered %s.', 'photonic');
32 $this->oauth_done = false;
33 $this->authenticate($photonic_google_refresh_token);
34 }
35
36 public function get_gallery_images($attr = []): array { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
37 return [];
38 }
39
40 public function authentication_URL() {
41 return 'https://accounts.google.com/o/oauth2/auth';
42 }
43
44 public function access_token_URL() {
45 return 'https://accounts.google.com/o/oauth2/token';
46 }
47
48 protected function set_token_validity($validity) {
49 $this->refresh_token_valid = $validity;
50 }
51
52 public function renew_token($refresh_token): array {
53 $token = [];
54 $error = '';
55 $response = Photonic::http(
56 $this->access_token_URL(),
57 'POST',
58 [
59 'client_id' => $this->client_id,
60 'client_secret' => $this->client_secret,
61 'refresh_token' => $refresh_token,
62 'grant_type' => 'refresh_token'
63 ]
64 );
65
66 if (!is_wp_error($response)) {
67 $token = $this->parse_token($response);
68 if (!empty($token)) {
69 $token['client_id'] = $this->client_id;
70 }
71 set_transient('photonic_' . $this->provider . '_token', $token, $token['oauth_token_expires']);
72 if (empty($token)) {
73 $error = print_r(wp_remote_retrieve_body($response), true);
74 }
75 }
76 else {
77 $error = $response->get_error_message();
78 }
79
80 return [$token, $error];
81 }
82
83 /**
84 * Not applicable for Google. We make this always return 0.
85 *
86 * @param int $soon_limit
87 * @return int|null
88 */
89 public function is_token_expiring_soon($soon_limit) {
90 return 0;
91 }
92
93 public function build_level_1_objects($response, array $short_code, $module_parameters = [], $options = []): array {
94 return [];
95 }
96
97 public function build_level_2_objects($objects_or_response, array $short_code, array $filter_list = [], array &$options = [], ?Pagination &$pagination = null): array {
98 return [];
99 }
100 }
101