PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.36
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.36
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.36, at Platforms/Lightroom.php

102 lines 3.0 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 protected function __construct() {
14 parent::__construct();
15 global $photonic_google_client_secret, $photonic_google_refresh_token;
16
17 $this->client_id = '6cf8382c9a9b48d8a0b91d0ed15a4e6a';
18 $this->provider = 'lr';
19 $this->oauth_version = '2.0';
20
21 $this->scope = 'https://www.googleapis.com/auth/photoslibrary.readonly';
22 $this->link_lightbox_title = false; // empty($photonic_google_disable_title_link);
23
24 // Documentation
25 $this->doc_links = [
26 'general' => 'https://aquoid.com/plugins/photonic/lightroom/',
27 ];
28
29 $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');
30 $this->oauth_done = false;
31 $this->authenticate($photonic_google_refresh_token);
32 }
33
34 public function get_gallery_images($attr = []): array { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
35 return [];
36 }
37
38 public function authentication_URL() {
39 return 'https://accounts.google.com/o/oauth2/auth';
40 }
41
42 public function access_token_URL() {
43 return 'https://accounts.google.com/o/oauth2/token';
44 }
45
46 protected function set_token_validity($validity) {
47 $this->refresh_token_valid = $validity;
48 }
49
50 public function renew_token($refresh_token): array {
51 $token = [];
52 $error = '';
53 $response = Photonic::http(
54 $this->access_token_URL(),
55 'POST',
56 [
57 'client_id' => $this->client_id,
58 'client_secret' => $this->client_secret,
59 'refresh_token' => $refresh_token,
60 'grant_type' => 'refresh_token'
61 ],
62 $this->user_agent,
63 90,
64 PHOTONIC_SSL_VERIFY
65 );
66
67 if (!is_wp_error($response)) {
68 $token = $this->parse_token($response);
69 if (!empty($token)) {
70 $token['client_id'] = $this->client_id;
71 }
72 set_transient('photonic_' . $this->provider . '_token', $token, $token['oauth_token_expires']);
73 if (empty($token)) {
74 $error = print_r(wp_remote_retrieve_body($response), true); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
75 }
76 }
77 else {
78 $error = $response->get_error_message();
79 }
80
81 return [$token, $error];
82 }
83
84 /**
85 * Not applicable for Google. We make this always return 0.
86 *
87 * @param int $soon_limit
88 * @return int|null
89 */
90 public function is_token_expiring_soon($soon_limit) {
91 return 0;
92 }
93
94 public function build_level_1_objects($response, array $short_code, $module_parameters = [], $options = []): array {
95 return [];
96 }
97
98 public function build_level_2_objects($objects_or_response, array $short_code, array $filter_list = [], array $options = [], ?Pagination &$pagination = null): array {
99 return [];
100 }
101 }
102