PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.37
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.37
3.37 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 All 142 releases
← All changes | Admin/Wizard/SmugMug.php +286 -292 2.43 → 3.37 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 namespace Photonic_Plugin\Admin\Wizard;
3 4
4 5 use Photonic_Plugin\Core\Photonic;
5 6 use Photonic_Plugin\Core\Utilities;
@@ -4,114 +5,115 @@
4 5 use Photonic_Plugin\Core\Photonic;
5 6 use Photonic_Plugin\Core\Utilities;
6 7
7 8 class SmugMug extends Source {
8 - private static $instance;
9 + private static ?SmugMug $instance = null;
9 10
10 11 protected function __construct() {
11 12 parent::__construct();
12 13 $this->provider = 'smugmug';
14 + $this->api_base = Wizard::base_apis()['smugmug'];
13 15
14 16 global $photonic_smug_thumb_size, $photonic_smug_tile_size, $photonic_smug_main_size, $photonic_smug_video_size;
15 17 $this->allowed_image_sizes['smugmug'] = [
16 18 'thumb_size' => [
17 - '' => $this->default_from_settings,
18 - 'Tiny' => esc_html__('Tiny', 'photonic'),
19 - 'Thumb' => esc_html__('Thumb', 'photonic'),
20 - 'Small' => esc_html__('Small', 'photonic'),
19 + '' => $this->default_from_settings,
20 + 'Tiny' => esc_html__('Tiny', 'photonic'),
21 + 'Thumb' => esc_html__('Thumb', 'photonic'),
22 + 'Small' => esc_html__('Small', 'photonic'),
21 23 'custom' => esc_html__('Custom', 'photonic'),
22 24 ],
23 - 'tile_size' => [
24 - '' => $this->default_from_settings,
25 - 'same' => esc_html__('Same as Main image size', 'photonic'),
26 - '4K' => esc_html__('4K (not always available)', 'photonic'),
27 - '5K' => esc_html__('5K (not always available)', 'photonic'),
28 - 'Medium' => esc_html__('Medium', 'photonic'),
25 + 'tile_size' => [
26 + '' => $this->default_from_settings,
27 + 'same' => esc_html__('Same as Main image size', 'photonic'),
28 + '4K' => esc_html__('4K (not always available)', 'photonic'),
29 + '5K' => esc_html__('5K (not always available)', 'photonic'),
30 + 'Medium' => esc_html__('Medium', 'photonic'),
29 31 'Original' => esc_html__('Original (not always available)', 'photonic'),
30 - 'Large' => esc_html__('Large', 'photonic'),
31 - 'Largest' => esc_html__('Largest available', 'photonic'),
32 - 'XLarge' => esc_html__('XLarge (not always available)', 'photonic'),
33 - 'X2Large' => esc_html__('X2Large (not always available)', 'photonic'),
34 - 'X3Large' => esc_html__('X3Large (not always available)', 'photonic'),
35 - 'X4Large' => esc_html__('X4Large (not always available)', 'photonic'),
36 - 'X5Large' => esc_html__('X5Large (not always available)', 'photonic'),
32 + 'Large' => esc_html__('Large', 'photonic'),
33 + 'Largest' => esc_html__('Largest available', 'photonic'),
34 + 'XLarge' => esc_html__('XLarge (not always available)', 'photonic'),
35 + 'X2Large' => esc_html__('X2Large (not always available)', 'photonic'),
36 + 'X3Large' => esc_html__('X3Large (not always available)', 'photonic'),
37 + 'X4Large' => esc_html__('X4Large (not always available)', 'photonic'),
38 + 'X5Large' => esc_html__('X5Large (not always available)', 'photonic'),
37 39 ],
38 - 'main_size' => [
39 - '' => $this->default_from_settings,
40 - '4K' => esc_html__('4K (not always available)', 'photonic'),
41 - '5K' => esc_html__('5K (not always available)', 'photonic'),
42 - 'Medium' => esc_html__('Medium', 'photonic'),
40 + 'main_size' => [
41 + '' => $this->default_from_settings,
42 + '4K' => esc_html__('4K (not always available)', 'photonic'),
43 + '5K' => esc_html__('5K (not always available)', 'photonic'),
44 + 'Medium' => esc_html__('Medium', 'photonic'),
43 45 'Original' => esc_html__('Original (not always available)', 'photonic'),
44 - 'Large' => esc_html__('Large', 'photonic'),
45 - 'Largest' => esc_html__('Largest available', 'photonic'),
46 - 'XLarge' => esc_html__('XLarge (not always available)', 'photonic'),
47 - 'X2Large' => esc_html__('X2Large (not always available)', 'photonic'),
48 - 'X3Large' => esc_html__('X3Large (not always available)', 'photonic'),
49 - 'X4Large' => esc_html__('X4Large (not always available)', 'photonic'),
50 - 'X5Large' => esc_html__('X5Large (not always available)', 'photonic'),
46 + 'Large' => esc_html__('Large', 'photonic'),
47 + 'Largest' => esc_html__('Largest available', 'photonic'),
48 + 'XLarge' => esc_html__('XLarge (not always available)', 'photonic'),
49 + 'X2Large' => esc_html__('X2Large (not always available)', 'photonic'),
50 + 'X3Large' => esc_html__('X3Large (not always available)', 'photonic'),
51 + 'X4Large' => esc_html__('X4Large (not always available)', 'photonic'),
52 + 'X5Large' => esc_html__('X5Large (not always available)', 'photonic'),
51 53 ],
52 54 'video_size' => [
53 - '' => $this->default_from_settings,
54 - '110' => esc_html__('110px along longest side', 'photonic'),
55 - '200' => esc_html__('200px along longest side', 'photonic'),
56 - '320' => esc_html__('320px along longest side', 'photonic'),
57 - '640' => esc_html__('640px along longest side', 'photonic'),
58 - '1280' => esc_html__('1280px along longest side', 'photonic'),
59 - '1920' => esc_html__('1920px along longest side', 'photonic'),
55 + '' => $this->default_from_settings,
56 + '110' => esc_html__('110px along longest side', 'photonic'),
57 + '200' => esc_html__('200px along longest side', 'photonic'),
58 + '320' => esc_html__('320px along longest side', 'photonic'),
59 + '640' => esc_html__('640px along longest side', 'photonic'),
60 + '1280' => esc_html__('1280px along longest side', 'photonic'),
61 + '1920' => esc_html__('1920px along longest side', 'photonic'),
60 62 'Largest' => esc_html__('Largest available', 'photonic'),
61 63 ],
62 64 ];
63 65
64 - $this->allowed_image_sizes['smugmug']['thumb_size'][''] .= ' - '.$this->allowed_image_sizes['smugmug']['thumb_size'][$photonic_smug_thumb_size];
65 - $this->allowed_image_sizes['smugmug']['tile_size'][''] .= ' - '.$this->allowed_image_sizes['smugmug']['tile_size'][$photonic_smug_tile_size];
66 - $this->allowed_image_sizes['smugmug']['main_size'][''] .= ' - '.$this->allowed_image_sizes['smugmug']['main_size'][$photonic_smug_main_size];
67 - $this->allowed_image_sizes['smugmug']['video_size'][''] .= ' - '.$this->allowed_image_sizes['smugmug']['video_size'][$photonic_smug_video_size];
66 + $this->allowed_image_sizes['smugmug']['thumb_size'][''] .= ' - ' . $this->allowed_image_sizes['smugmug']['thumb_size'][$photonic_smug_thumb_size];
67 + $this->allowed_image_sizes['smugmug']['tile_size'][''] .= ' - ' . $this->allowed_image_sizes['smugmug']['tile_size'][$photonic_smug_tile_size];
68 + $this->allowed_image_sizes['smugmug']['main_size'][''] .= ' - ' . $this->allowed_image_sizes['smugmug']['main_size'][$photonic_smug_main_size];
69 + $this->allowed_image_sizes['smugmug']['video_size'][''] .= ' - ' . $this->allowed_image_sizes['smugmug']['video_size'][$photonic_smug_video_size];
68 70 }
69 71
70 - public static function get_instance() {
71 - if (self::$instance == null) {
72 + public static function get_instance(): SmugMug {
73 + if (null === self::$instance) {
72 74 self::$instance = new SmugMug();
73 75 }
74 76 return self::$instance;
75 77 }
76 78
77 - function get_screen_2() {
79 + public function get_screen_2(): array {
78 80 return [
79 - 'header' => esc_html__('Choose Type of Gallery', 'photonic'),
81 + 'header' => esc_html__('Choose Type of Gallery', 'photonic'),
80 82 'display' => [
81 83 'kind' => [
82 - 'type' => 'field_list',
84 + 'type' => 'field_list',
83 85 'list_type' => 'sequence',
84 - 'list' => [
86 + 'list' => [
85 87 'display_type' => [
86 - 'desc' => esc_html__('What do you want to show?', 'photonic'),
87 - 'type' => 'select',
88 + 'desc' => esc_html__('What do you want to show?', 'photonic'),
89 + 'type' => 'select',
88 90 'options' => [
89 - '' => '',
90 - 'album-photo' => esc_html__('Photos from an Album', 'photonic'),
91 + '' => '',
92 + 'album-photo' => esc_html__('Photos from an Album', 'photonic'),
91 93 'folder-photo' => esc_html__('Photos from a Folder', 'photonic'),
92 - 'user-photo' => esc_html__('Photos from a User', 'photonic'),
93 - 'multi-album' => esc_html__('Multiple Albums', 'photonic'),
94 - 'folder' => esc_html__('Albums in a Folder', 'photonic'),
95 - 'tree' => esc_html__('User Tree', 'photonic'),
94 + 'user-photo' => esc_html__('Photos from a User', 'photonic'),
95 + 'multi-album' => esc_html__('Multiple Albums', 'photonic'),
96 + 'folder' => esc_html__('Albums in a Folder', 'photonic'),
97 + 'tree' => esc_html__('User Tree', 'photonic'),
96 98 ],
97 - 'req' => 1,
99 + 'req' => 1,
98 100 ],
99 - 'for' => [
100 - 'desc' => esc_html__('For whom?', 'photonic'),
101 - 'type' => 'radio',
101 + 'for' => [
102 + 'desc' => esc_html__('For whom?', 'photonic'),
103 + 'type' => 'radio',
102 104 'options' => [
103 105 'current' => sprintf(esc_html__('Current user (Defined under %s)', 'photonic'), '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Default user</em>'),
104 - 'other' => esc_html__('Another user', 'photonic'),
106 + 'other' => esc_html__('Another user', 'photonic'),
105 107 ],
106 - 'req' => 1,
108 + 'req' => 1,
107 109 ],
108 - 'user' => [
109 - 'desc' => sprintf(esc_html__('User name, e.g. %s', 'photonic'), 'https://<span style="text-decoration: underline">username</span>.smugmug.com/'),
110 - 'type' => 'text',
111 - 'std' => '',
110 + 'user' => [
111 + 'desc' => sprintf(esc_html__('User name, e.g. %s', 'photonic'), 'https://<span style="text-decoration: underline">username</span>.smugmug.com/'),
112 + 'type' => 'text',
113 + 'std' => '',
112 114 'conditions' => ['for' => ['other']],
113 - 'req' => 1,
115 + 'req' => 1,
114 116 ],
115 117 ],
116 118 ],
117 119 ],
@@ -117,121 +119,121 @@
117 119 ],
118 120 ];
119 121 }
120 122
121 - function get_screen_3() {
123 + public function get_screen_3(): array {
122 124 return [
123 - 'header' => esc_html__('Build your gallery', 'photonic'),
124 - 'album-photo' => [
125 - 'header' => esc_html__('Pick your album', 'photonic'),
126 - 'desc' => esc_html__('From the list below pick the album whose photos you wish to display. Photos from that album will show up as thumbnails.', 'photonic'),
125 + 'header' => esc_html__('Build your gallery', 'photonic'),
126 + 'album-photo' => [
127 + 'header' => esc_html__('Pick your album', 'photonic'),
128 + 'desc' => esc_html__('From the list below pick the album whose photos you wish to display. Photos from that album will show up as thumbnails.', 'photonic'),
127 129 'display' => [
128 - 'text' => [
130 + 'text' => [
129 131 'desc' => esc_html__('Only show photos with this text', 'photonic'),
130 132 'type' => 'text',
131 - 'std' => '',
133 + 'std' => '',
132 134 'hint' => esc_html__('Comma-separated list of values. Filters will be applied on the front-end, not on the display below', 'photonic'),
133 135 ],
134 - 'keywords' => [
136 + 'keywords' => [
135 137 'desc' => esc_html__('Only show photos with these keywords', 'photonic'),
136 138 'type' => 'text',
137 - 'std' => '',
139 + 'std' => '',
138 140 'hint' => esc_html__('Comma-separated list of values. Filters will be applied on the front-end, not on the display below', 'photonic'),
139 141 ],
140 142 'container' => [
141 143 'type' => 'thumbnail-selector',
142 144 'mode' => 'single',
143 - 'for' => 'selected_data',
145 + 'for' => 'selected_data',
144 146 ],
145 147 ],
146 148 ],
147 149 'folder-photo' => [
148 - 'header' => esc_html__('Pick your folder', 'photonic'),
149 - 'desc' => esc_html__('From the list below pick the folder whose photos you wish to display. Photos from that folder will show up as thumbnails.', 'photonic'),
150 + 'header' => esc_html__('Pick your folder', 'photonic'),
151 + 'desc' => esc_html__('From the list below pick the folder whose photos you wish to display. Photos from that folder will show up as thumbnails.', 'photonic'),
150 152 'display' => [
151 - 'text' => [
153 + 'text' => [
152 154 'desc' => esc_html__('Only show photos with this text', 'photonic'),
153 155 'type' => 'text',
154 - 'std' => '',
156 + 'std' => '',
155 157 'hint' => esc_html__('Comma-separated list of values. Filters will be applied on the front-end, not on the display below', 'photonic'),
156 158 ],
157 - 'keywords' => [
159 + 'keywords' => [
158 160 'desc' => esc_html__('Only show photos with these keywords', 'photonic'),
159 161 'type' => 'text',
160 - 'std' => '',
162 + 'std' => '',
161 163 'hint' => esc_html__('Comma-separated list of values. Filters will be applied on the front-end, not on the display below.', 'photonic'),
162 164 ],
163 165 'container' => [
164 166 'type' => 'thumbnail-selector',
165 167 'mode' => 'single',
166 - 'for' => 'selected_data',
168 + 'for' => 'selected_data',
167 169 ],
168 170 ],
169 171 ],
170 - 'user-photo' => [
171 - 'header' => esc_html__('Photos for a User', 'photonic'),
172 - 'desc' => esc_html__('The following lists the top-level folders and albums for the selected user. All photos from these folders will show up as thumbnails.', 'photonic'),
172 + 'user-photo' => [
173 + 'header' => esc_html__('Photos for a User', 'photonic'),
174 + 'desc' => esc_html__('The following lists the top-level folders and albums for the selected user. All photos from these folders will show up as thumbnails.', 'photonic'),
173 175 'display' => [
174 - 'text' => [
176 + 'text' => [
175 177 'desc' => esc_html__('Only show photos with this text', 'photonic'),
176 178 'type' => 'text',
177 - 'std' => '',
179 + 'std' => '',
178 180 'hint' => esc_html__('Comma-separated list of values', 'photonic'),
179 181 ],
180 - 'keywords' => [
182 + 'keywords' => [
181 183 'desc' => esc_html__('Only show photos with these keywords', 'photonic'),
182 184 'type' => 'text',
183 - 'std' => '',
185 + 'std' => '',
184 186 'hint' => esc_html__('Comma-separated list of values', 'photonic'),
185 187 ],
186 188 'container' => [
187 189 'type' => 'thumbnail-selector',
188 190 'mode' => 'none',
189 - 'for' => 'selected_data',
191 + 'for' => 'selected_data',
190 192 ],
191 193 ],
192 194 ],
193 - 'multi-album' => [
194 - 'header' => esc_html__('Pick your albums', 'photonic'),
195 - 'desc' => esc_html__('From the list below pick the albums you wish to display. Each album will show up as a single thumbnail.', 'photonic'),
195 + 'multi-album' => [
196 + 'header' => esc_html__('Pick your albums', 'photonic'),
197 + 'desc' => esc_html__('From the list below pick the albums you wish to display. Each album will show up as a single thumbnail.', 'photonic'),
196 198 'display' => [
197 199 'selection' => [
198 - 'desc' => esc_html__('What do you want to show?', 'photonic'),
199 - 'type' => 'select',
200 + 'desc' => esc_html__('What do you want to show?', 'photonic'),
201 + 'type' => 'select',
200 202 'options' => [
201 - 'all' => esc_html__('Automatic all (will automatically add new albums)', 'photonic'),
202 - 'selected' => esc_html__('Selected albums', 'photonic'),
203 + 'all' => esc_html__('Automatic all (will automatically add new albums)', 'photonic'),
204 + 'selected' => esc_html__('Selected albums', 'photonic'),
203 205 'not-selected' => esc_html__('All except selected albums', 'photonic'),
204 206 ],
205 - 'hint' => esc_html__('If you pick "Automatic all" your selections below will be ignored.', 'photonic'),
206 - 'req' => 1,
207 + 'hint' => esc_html__('If you pick "Automatic all" your selections below will be ignored.', 'photonic'),
208 + 'req' => 1,
207 209 ],
208 210 'container' => [
209 211 'type' => 'thumbnail-selector',
210 212 'mode' => 'multi',
211 - 'for' => 'selected_data',
213 + 'for' => 'selected_data',
212 214 ],
213 215 ],
214 216 ],
215 - 'folder' => [
216 - 'header' => esc_html__('Pick your folder', 'photonic'),
217 - 'desc' => esc_html__('From the list below pick the folder you wish to display. The albums within the folder will show up as single thumbnails.', 'photonic'),
217 + 'folder' => [
218 + 'header' => esc_html__('Pick your folder', 'photonic'),
219 + 'desc' => esc_html__('From the list below pick the folder you wish to display. The albums within the folder will show up as single thumbnails.', 'photonic'),
218 220 'display' => [
219 221 'container' => [
220 222 'type' => 'thumbnail-selector',
221 223 'mode' => 'single',
222 - 'for' => 'selected_data',
224 + 'for' => 'selected_data',
223 225 ],
224 226 ],
225 227 ],
226 - 'tree' => [
227 - 'header' => esc_html__('User Tree', 'photonic'),
228 - 'desc' => esc_html__('The following user tree will be displayed on your site. Only top level folders and albums are shown here. The albums within the folders will show up as single thumbnails and can be clicked to show the images within.', 'photonic'),
228 + 'tree' => [
229 + 'header' => esc_html__('User Tree', 'photonic'),
230 + 'desc' => esc_html__('The following user tree will be displayed on your site. Only top level folders and albums are shown here. The albums within the folders will show up as single thumbnails and can be clicked to show the images within.', 'photonic'),
229 231 'display' => [
230 232 'container' => [
231 233 'type' => 'thumbnail-selector',
232 234 'mode' => 'none',
233 - 'for' => 'selected_data',
235 + 'for' => 'selected_data',
234 236 ],
235 237 ],
236 238 ],
237 239 ];
@@ -236,92 +238,78 @@
236 238 ],
237 239 ];
238 240 }
239 241
240 - function get_screen_4() {
242 + public function get_screen_4(): array {
241 243 return [];
242 244 }
243 245
244 - function get_screen_5() {
246 + public function get_screen_5(): array {
245 247 global $photonic_smug_media, $photonic_smug_title_caption;
246 248 return [
247 249 'smugmug' => [
248 - 'L1' => [
249 - 'media' => [
250 - 'desc' => esc_html__('Media to Show', 'photonic'),
251 - 'type' => 'select',
250 + 'L1' => [
251 + 'media' => [
252 + 'desc' => esc_html__('Media to Show', 'photonic'),
253 + 'type' => 'select',
252 254 'options' => Utilities::media_options(true, $photonic_smug_media),
253 - 'std' => '',
254 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Media to show</em>'),
255 + 'std' => '',
256 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Media to show</em>'),
255 257 ],
256 - 'caption' => [
257 - 'desc' => esc_html__('Photo titles and captions', 'photonic'),
258 - 'type' => 'select',
258 + 'caption' => [
259 + 'desc' => esc_html__('Photo titles and captions', 'photonic'),
260 + 'type' => 'select',
259 261 'options' => Utilities::title_caption_options(true, $photonic_smug_title_caption),
260 - 'std' => '',
261 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Photo titles and captions</em>'),
262 + 'std' => '',
263 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Photo titles and captions</em>'),
262 264 ],
263 - 'password' => [
264 - 'desc' => esc_html__('Password for password-protected album', 'photonic'),
265 - 'type' => 'text',
266 - 'req' => 1,
267 - 'hint' => esc_html__('You are trying to display photos from a password-protected album. The password is mandatory for such an album.', 'photonic'),
265 + 'password' => [
266 + 'desc' => esc_html__('Password for password-protected album', 'photonic'),
267 + 'type' => 'text',
268 + 'req' => 1,
269 + 'hint' => esc_html__('You are trying to display photos from a password-protected album. The password is mandatory for such an album.', 'photonic'),
268 270 'conditions' => ['selection_passworded' => ['1']],
269 271 ],
270 272 'sort_method' => [
271 - 'desc' => esc_html__('Sort photos by', 'photonic'),
272 - 'type' => 'select',
273 + 'desc' => esc_html__('Sort photos by', 'photonic'),
274 + 'type' => 'select',
273 275 'options' => [
274 - '' => '',
275 - 'DateTaken' => esc_html__('Date Taken', 'photonic'),
276 + '' => '',
277 + 'DateTaken' => esc_html__('Date Taken', 'photonic'),
276 278 'DateUploaded' => esc_html__('Date Uploaded', 'photonic'),
277 - 'Popular' => esc_html__('Popular', 'photonic'),
279 + 'Popular' => esc_html__('Popular', 'photonic'),
278 280 ],
279 281 ],
280 - 'sort_order' => [
281 - 'desc' => esc_html__('Sort order', 'photonic'),
282 - 'type' => 'select',
282 + 'sort_order' => [
283 + 'desc' => esc_html__('Sort order', 'photonic'),
284 + 'type' => 'select',
283 285 'options' => [
284 - '' => '',
285 - 'Ascending' => esc_html__('Ascending', 'photonic'),
286 + '' => '',
287 + 'Ascending' => esc_html__('Ascending', 'photonic'),
286 288 'Descending' => esc_html__('Descending', 'photonic'),
287 289 ],
288 290 ],
289 - 'headers' => [
290 - 'desc' => esc_html__('Show Header', 'photonic'),
291 - 'type' => 'select',
292 - 'options' => [
293 - '' => $this->default_from_settings,
294 - 'none' => esc_html__('No header', 'photonic'),
295 - 'title' => esc_html__('Title only', 'photonic'),
296 - 'thumbnail' => esc_html__('Thumbnail only', 'photonic'),
297 - 'counter' => esc_html__('Counts only', 'photonic'),
298 - 'title,counter' => esc_html__('Title and counts', 'photonic'),
299 - 'thumbnail,counter' => esc_html__('Thumbnail and counts', 'photonic'),
300 - 'thumbnail,title' => esc_html__('Thumbnail and title', 'photonic'),
301 - 'thumbnail,title,counter' => esc_html__('Thumbnail, title and counts', 'photonic'),
302 - ],
303 - ],
291 + 'headers' => $this->get_header_options(),
304 292 ],
305 - 'L2' => [
306 - 'site_password' => [
293 + 'L2' => [
294 + 'site_password' => [
307 295 'desc' => esc_html__('Site Password for password-protected sites', 'photonic'),
308 296 'type' => 'text',
309 297 'hint' => esc_html__('If you SmugMug site is password-protected you will need to provide the password to be able to show your photos.', 'photonic'),
310 298 ],
311 299 'album_sort_order' => [
312 - 'desc' => esc_html__('Album sort order', 'photonic'),
313 - 'type' => 'select',
300 + 'desc' => esc_html__('Album sort order', 'photonic'),
301 + 'type' => 'select',
314 302 'options' => [
315 - '' => $this->default_from_settings,
303 + '' => $this->default_from_settings,
316 304 'Last Updated (Descending)' => esc_html__('Last Updated (Descending)', 'photonic'),
317 - 'Last Updated (Ascending)' => esc_html__('Last Updated (Ascending)', 'photonic'),
318 - 'Date Added (Descending)' => esc_html__('Date Added (Descending)', 'photonic'),
319 - 'Date Added (Ascending)' => esc_html__('Date Added (Ascending)', 'photonic'),
305 + 'Last Updated (Ascending)' => esc_html__('Last Updated (Ascending)', 'photonic'),
306 + 'Date Added (Descending)' => esc_html__('Date Added (Descending)', 'photonic'),
307 + 'Date Added (Ascending)' => esc_html__('Date Added (Ascending)', 'photonic'),
320 308 ],
321 309 ],
322 310 ],
323 - 'L3' => [
311 + 'L3' => [
324 312 'site_password' => [
325 313 'desc' => esc_html__('Site Password for password-protected sites', 'photonic'),
326 314 'type' => 'text',
327 315 'hint' => esc_html__('If you SmugMug site is password-protected you will need to provide the password to be able to show your photos.', 'photonic'),
@@ -326,128 +314,132 @@
326 314 'type' => 'text',
327 315 'hint' => esc_html__('If you SmugMug site is password-protected you will need to provide the password to be able to show your photos.', 'photonic'),
328 316 ],
329 317 ],
330 - 'main_size' => [
331 - 'desc' => esc_html__('Main image size', 'photonic'),
332 - 'type' => 'select',
318 + 'main_size' => [
319 + 'desc' => esc_html__('Main image size', 'photonic'),
320 + 'type' => 'select',
333 321 'options' => $this->allowed_image_sizes['smugmug']['main_size'],
334 - 'std' => '',
335 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Main image size</em>'),
322 + 'std' => '',
323 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Main image size</em>'),
336 324 ],
337 325 'video_size' => [
338 - 'desc' => esc_html__('Main video size', 'photonic'),
339 - 'type' => 'select',
326 + 'desc' => esc_html__('Main video size', 'photonic'),
327 + 'type' => 'select',
340 328 'options' => $this->allowed_image_sizes['smugmug']['video_size'],
341 - 'std' => '',
342 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Video size</em>'),
329 + 'std' => '',
330 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Video size</em>'),
343 331 ],
344 332 ]
345 333 ];
346 334 }
347 335
348 - function get_square_size_options() {
336 + public function get_square_size_options(): array {
349 337 return [
350 - 'thumb_size' => [
351 - 'desc' => esc_html__('Thumbnail size', 'photonic'),
352 - 'type' => 'select',
338 + 'thumb_size' => [
339 + 'desc' => esc_html__('Thumbnail size', 'photonic'),
340 + 'type' => 'select',
353 341 'options' => $this->allowed_image_sizes['smugmug']['thumb_size'],
354 - 'std' => '',
355 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Thumbnail size</em>'),
342 + 'std' => '',
343 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Thumbnail size</em>'),
356 344 ],
357 345 'custom_thumb_size' => [
358 - 'desc' => esc_html__('Size of custom thumbnail', 'photonic'),
359 - 'type' => 'text',
360 - 'hint' => esc_html__('E.g. 300x300 for an image that is 300px on the longest side and 300x300! (with the "!") for a square image', 'photonic'),
346 + 'desc' => esc_html__('Size of custom thumbnail', 'photonic'),
347 + 'type' => 'text',
348 + 'hint' => esc_html__('E.g. 300x300 for an image that is 300px on the longest side and 300x300! (with the "!") for a square image', 'photonic'),
361 349 'conditions' => ['thumb_size' => ['custom']],
362 350 ],
363 351 ];
364 352 }
365 353
366 - function get_random_size_options() {
354 + public function get_random_size_options(): array {
367 355 return [
368 356 'tile_size' => [
369 - 'desc' => esc_html__('Tile size', 'photonic'),
370 - 'type' => 'select',
357 + 'desc' => esc_html__('Tile size', 'photonic'),
358 + 'type' => 'select',
371 359 'options' => $this->allowed_image_sizes['smugmug']['tile_size'],
372 - 'std' => '',
373 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Tile image size</em>'),
360 + 'std' => '',
361 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Tile image size</em>'),
374 362 ],
375 363 ];
376 364 }
377 365
378 - function make_request($display_type, $for, $flattened_fields) {
379 - global $photonic_smug_access_token, $photonic_smug_default_user;
380 - require_once(PHOTONIC_PATH.'/Modules/SmugMug.php');
381 - $module = \Photonic_Plugin\Modules\SmugMug::get_instance();
366 + public function make_request($display_type, $for, $flattened_fields): array {
367 + if (check_ajax_referer('photonic-wizard-next-' . get_current_user_id())) {
368 + global $photonic_smug_access_token, $photonic_smug_default_user;
369 + require_once PHOTONIC_PATH . '/Platforms/SmugMug.php';
370 + $module = \Photonic_Plugin\Platforms\SmugMug::get_instance();
382 371
383 - if ($for == 'current' && empty($photonic_smug_default_user)) {
384 - return ['error' => sprintf(esc_html__('Default user not defined under %1$s. %2$sSelect "Another user" and put in your user id.', 'photonic'), '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Default User</em>', '<br/>')];
385 - }
372 + if ('current' === $for && empty($photonic_smug_default_user)) {
373 + return ['error' => sprintf(esc_html__('Default user not defined under %1$s. %2$sSelect "Another user" and put in your user id.', 'photonic'), '<em>Photonic &rarr; Settings &rarr; SmugMug &rarr; SmugMug Settings &rarr; Default User</em>', '<br/>')];
374 + }
386 375
387 - if ($for == 'other' && empty($_POST['user'])) {
388 - return ['error' => $this->error_mandatory];
389 - }
376 + if ('other' === $for && empty($_POST['user'])) {
377 + return ['error' => $this->error_mandatory];
378 + }
390 379
391 - $nick_name = sanitize_text_field($_POST['user']);
392 - $user = $for == 'current' ? $photonic_smug_default_user : ($for == 'other' ? $nick_name : '');
393 - $args = [
394 - 'APIKey' => $module->api_key,
395 - '_accept' => 'application/json',
396 - '_expandmethod' => 'inline',
397 - '_verbosity' => '1',
398 - ];
380 + $nick_name = sanitize_text_field(wp_unslash($_POST['user']));
381 + $user = 'current' === $for ? $photonic_smug_default_user : ('other' === $for ? $nick_name : '');
382 + $args = [
383 + 'APIKey' => $module->api_key,
384 + '_accept' => 'application/json',
385 + '_expandmethod' => 'inline',
386 + '_verbosity' => '1',
387 + ];
399 388
400 - if ($display_type == 'album-photo' || $display_type == 'multi-album') {
401 - $call = "https://api.smugmug.com/api/v2/user/$user!albums";
402 - $args['_expand'] = 'HighlightImage.ImageSizes';
403 - $args['count'] = 500;
404 - }
405 - else {
406 - $call = "https://api.smugmug.com/api/v2/user/$user";
407 - }
389 + if ('album-photo' === $display_type || 'multi-album' === $display_type) {
390 + $call = "https://{$this->api_base}/api/v2/user/$user!albums";
391 + $args['_expand'] = 'HighlightImage.ImageSizes';
392 + $args['count'] = 500;
393 + }
394 + else {
395 + $call = "https://{$this->api_base}/api/v2/user/$user";
396 + }
408 397
409 - if (!empty($photonic_smug_access_token)) {
410 - $args = $module->sign_call($call, 'GET', $args);
411 - }
398 + if (!empty($photonic_smug_access_token)) {
399 + $args = $module->sign_call($call, 'GET', $args);
400 + }
412 401
413 - if ($display_type == 'folder' || $display_type == 'tree' || $display_type == 'folder-photo' || $display_type == 'user-photo') {
414 - // Not able to use wp_remote_request - getting a signature_invalid response
415 - $temp = Photonic::http($call, 'GET', $args, null, 300);
416 - $temp = $this->process_response($temp, 'smugmug', 'user');
402 + if ('folder' === $display_type || 'tree' === $display_type || 'folder-photo' === $display_type || 'user-photo' === $display_type) {
403 + // Not able to use wp_remote_request - getting a signature_invalid response
404 + $temp = Photonic::http($call, 'GET', $args, null, 300);
405 + $temp = $this->process_response($temp, 'smugmug', 'user');
417 406
418 - if (!empty($temp['success'])) {
419 - $node = $temp['success'];
420 - $call = 'https://api.smugmug.com' . $node . '!children';
421 - if ($display_type == 'tree' || $display_type == 'user-photo') {
422 - $args['_expand'] = 'NodeCoverImage.ImageSizes';
407 + if (!empty($temp['success'])) {
408 + $node = $temp['success'];
409 + $call = 'https://' . $this->api_base . $node . '!children';
410 + if ('tree' === $display_type || 'user-photo' === $display_type) {
411 + $args['_expand'] = 'NodeCoverImage.ImageSizes';
412 + }
413 + else {
414 + global $photonic_smug_nesting_levels;
415 + $config = $module->get_config_object(500, $photonic_smug_nesting_levels);
416 + $config_str = wp_json_encode($config);
417 + $args['_config'] = $config_str;
418 + }
419 +
420 + // Sign call again because we made an interim call
421 + if (!empty($photonic_smug_access_token)) {
422 + unset($args['oauth_consumer_key']);
423 + unset($args['oauth_nonce']);
424 + unset($args['oauth_signature']);
425 + unset($args['oauth_signature_method']);
426 + unset($args['oauth_timestamp']);
427 + unset($args['oauth_version']);
428 + unset($args['oauth_token']);
429 + unset($args['oauth_verifier']);
430 + $args = $module->sign_call($call, 'GET', $args);
431 + }
423 432 }
424 433 else {
425 - $config = $module->get_config_object(500);
426 - $config_str = json_encode($config);
427 - $args['_config'] = $config_str;
434 + return $temp;
428 435 }
436 + }
429 437
430 - // Sign call again because we made an interim call
431 - if (!empty($photonic_smug_access_token)) {
432 - unset($args['oauth_consumer_key']);
433 - unset($args['oauth_nonce']);
434 - unset($args['oauth_signature']);
435 - unset($args['oauth_signature_method']);
436 - unset($args['oauth_timestamp']);
437 - unset($args['oauth_version']);
438 - unset($args['oauth_token']);
439 - unset($args['oauth_verifier']);
440 - $args = $module->sign_call($call, 'GET', $args);
441 - }
442 - }
443 - else {
444 - return $temp;
445 - }
438 + $response = Photonic::http($call, 'GET', $args, null, 300);
439 + return [$response, ['nick_name' => $user], $call];
446 440 }
447 -
448 - $response = Photonic::http($call, 'GET', $args, null, 300);
449 - return [$response, ['nick_name' => $user], $call];
441 + return ['error' => $this->error_unauthorized];
450 442 }
451 443
452 444 /**
453 445 * Processes a response from SmugMug to build it out into a gallery of thumbnails. SmugMug has L1, L2 and L3 displays in the flow.
@@ -457,9 +449,9 @@
457 449 * @param null $url
458 450 * @param array $pagination
459 451 * @return array
460 452 */
461 - function process_response($response, $display_type, $url = null, &$pagination = []) {
453 + public function process_response($response, $display_type, $url = null, &$pagination = []): array {
462 454 $objects = [];
463 455 $body = json_decode(wp_remote_retrieve_body($response));
464 456 if (isset($body->Response) && isset($body->Response->Album)) {
465 457 $albums = $body->Response->Album;
@@ -482,13 +474,13 @@
482 474 if (isset($highlight->Image)) {
483 475 $thumbURL = $highlight->Image->Uris->ImageSizes->ImageSizes->ThumbImageUrl;
484 476 }
485 477 else {
486 - $thumbURL = PHOTONIC_URL.'include/images/placeholder-Th.png';
478 + $thumbURL = PHOTONIC_URL . 'include/images/placeholder-Th.png';
487 479 }
488 480
489 481 $object['thumbnail'] = $thumbURL;
490 - if (isset($album->SecurityType) && $album->SecurityType == 'Password') {
482 + if (isset($album->SecurityType) && 'Password' === $album->SecurityType) {
491 483 $object['passworded'] = 1;
492 484 }
493 485
494 486 $objects[] = $object;
@@ -500,30 +492,30 @@
500 492 $pagination['url'] = add_query_arg(['start' => $pages->Start + $pages->Count, 'count' => $pages->Count], remove_query_arg(['start', 'count'], $url));
501 493 }
502 494 }
503 495 }
504 - else if (isset($body->Response) && isset($body->Response->Node)) {
496 + elseif (isset($body->Response) && isset($body->Response->Node)) {
505 497 $nodes = $body->Response->Node;
506 498 foreach ($nodes as $node) {
507 - if ($display_type == 'folder' && $node->Type == 'Album') {
499 + if ('folder' === $display_type && 'Album' === $node->Type) {
508 500 continue;
509 501 }
510 - else if ($display_type == 'folder') {
502 + elseif ('folder' === $display_type) {
511 503 $this->get_smugmug_folders($objects, $node);
512 504 }
513 505 else {
514 506 $object = [];
515 - if ($node->Type == 'Album') {
507 + if ('Album' === $node->Type) {
516 508 $uri = $node->Uris->Album->Uri;
517 509 $uri = explode('/', $uri);
518 510 $uri = $uri[count($uri) - 1];
519 511 $object['id'] = $uri;
520 512 }
521 - else if ($node->Type == 'Folder') {
513 + elseif ('Folder' === $node->Type) {
522 514 $object['id'] = $node->NodeID;
523 515 }
524 516 $object['title'] = !empty($node->Name) ? esc_attr($node->Name) : '';
525 - if ($display_type == 'tree') {
517 + if ('tree' === $display_type) {
526 518 $object['title'] .= " ({$node->Type})";
527 519 }
528 520 if (isset($node->Uris->NodeCoverImage->Image->Uris->ImageSizes->ImageSizes->ThumbImageUrl)) {
529 521 $object['thumbnail'] = $node->Uris->NodeCoverImage->Image->Uris->ImageSizes->ImageSizes->ThumbImageUrl;
@@ -528,15 +520,15 @@
528 520 if (isset($node->Uris->NodeCoverImage->Image->Uris->ImageSizes->ImageSizes->ThumbImageUrl)) {
529 521 $object['thumbnail'] = $node->Uris->NodeCoverImage->Image->Uris->ImageSizes->ImageSizes->ThumbImageUrl;
530 522 }
531 523 else {
532 - $object['thumbnail'] = PHOTONIC_URL.'include/images/placeholder-Th.png';
524 + $object['thumbnail'] = PHOTONIC_URL . 'include/images/placeholder-Th.png';
533 525 }
534 526 $objects[] = $object;
535 527 }
536 528 }
537 529 }
538 - else if (isset($body->Response) && isset($body->Response->User)) {
530 + elseif (isset($body->Response) && isset($body->Response->User)) {
539 531 $user = $body->Response->User;
540 532 return ['success' => $user->Uris->Node->Uri];
541 533 }
542 534 else {
@@ -556,9 +548,9 @@
556 548 * @param $node
557 549 */
558 550 private function get_smugmug_folders(&$objects, $node) {
559 551 $object = [];
560 - if ($node->Type == 'Folder') {
552 + if ('Folder' === $node->Type) {
561 553 $object['id'] = $node->NodeID;
562 554 $object['title'] = !empty($node->Name) ? esc_attr($node->Name) : '';
563 555
564 556 if (isset($node->Uris->NodeCoverImage->Image->Uris->ImageSizes->ImageSizes->ThumbImageUrl)) {
@@ -564,9 +556,9 @@
564 556 if (isset($node->Uris->NodeCoverImage->Image->Uris->ImageSizes->ImageSizes->ThumbImageUrl)) {
565 557 $object['thumbnail'] = $node->Uris->NodeCoverImage->Image->Uris->ImageSizes->ImageSizes->ThumbImageUrl;
566 558 }
567 559 else {
568 - $object['thumbnail'] = PHOTONIC_URL.'include/images/placeholder-Th.png';
560 + $object['thumbnail'] = PHOTONIC_URL . 'include/images/placeholder-Th.png';
569 561 }
570 562
571 563 if (isset($node->Uris->ChildNodes->Node)) {
572 564 $child_nodes = $node->Uris->ChildNodes->Node;
@@ -581,34 +573,36 @@
581 573 }
582 574
583 575 /**
584 576 * @param $display_type
585 - * @return array|mixed
577 + * @return array
586 578 */
587 - function construct_shortcode_from_screen_selections($display_type) {
579 + public function construct_shortcode_from_screen_selections($display_type): array {
588 580 $short_code = [];
589 581
590 - if ($display_type == 'album-photo') {
591 - $short_code['view'] = 'album';
592 - $short_code['album'] = sanitize_text_field($_POST['selected_data']);
582 + if (check_ajax_referer('photonic-wizard-next-' . get_current_user_id())) {
583 + if ('album-photo' === $display_type) {
584 + $short_code['view'] = 'album';
585 + $short_code['album'] = sanitize_text_field(wp_unslash($_POST['selected_data'] ?? ''));
586 + }
587 + elseif ('folder-photo' === $display_type) {
588 + $short_code['view'] = 'images';
589 + $short_code['folder'] = sanitize_text_field(wp_unslash($_POST['selected_data'] ?? ''));
590 + }
591 + elseif ('user-photo' === $display_type) {
592 + $short_code['view'] = 'images';
593 + }
594 + elseif ('multi-album' === $display_type) {
595 + $short_code['view'] = 'albums';
596 + }
597 + elseif ('tree' === $display_type) {
598 + $short_code['view'] = 'tree';
599 + }
600 + elseif ('folder' === $display_type) {
601 + $short_code['view'] = 'folder';
602 + $short_code['folder'] = sanitize_text_field(wp_unslash($_POST['selected_data'] ?? ''));
603 + }
593 604 }
594 - else if ($display_type == 'folder-photo') {
595 - $short_code['view'] = 'images';
596 - $short_code['folder'] = sanitize_text_field($_POST['selected_data']);
597 - }
598 - else if ($display_type == 'user-photo') {
599 - $short_code['view'] = 'images';
600 - }
601 - else if ($display_type == 'multi-album') {
602 - $short_code['view'] = 'albums';
603 - }
604 - else if ($display_type == 'tree') {
605 - $short_code['view'] = 'tree';
606 - }
607 - else if ($display_type == 'folder') {
608 - $short_code['view'] = 'folder';
609 - $short_code['folder'] = sanitize_text_field($_POST['selected_data']);
610 - }
611 605
612 606 return $short_code;
613 607 }
614 608
@@ -613,31 +607,31 @@
613 607 }
614 608
615 609 /**
616 610 * @param $input
617 - * @return array|mixed
611 + * @return array
618 612 */
619 - function deconstruct_shortcode_to_screen_selections($input) {
613 + public function deconstruct_shortcode_to_screen_selections($input): array {
620 614 $deconstructed = [];
621 615
622 616 if (!empty($input->view)) {
623 - if ($input->view == 'tree') {
617 + if ('tree' === $input->view) {
624 618 $deconstructed['display_type'] = 'tree';
625 619 }
626 - else if ($input->view == 'folder') {
620 + elseif ('folder' === $input->view) {
627 621 $deconstructed['display_type'] = 'folder';
628 622 }
629 - else if ($input->view == 'albums') {
623 + elseif ('albums' === $input->view) {
630 624 $deconstructed['display_type'] = 'multi-album';
631 625 }
632 - else if ($input->view == 'images' || $input->view == 'album') {
626 + elseif ('images' === $input->view || 'album' === $input->view) {
633 627 if (!empty($input->album) || !empty($input->album_key) || !empty($input->album_id)) {
634 628 $deconstructed['display_type'] = 'album-photo';
635 629 }
636 - else if (!empty($input->folder)) {
630 + elseif (!empty($input->folder)) {
637 631 $deconstructed['display_type'] = 'folder-photo';
638 632 }
639 - else if (!empty($input->nick_name)) {
633 + elseif (!empty($input->nick_name)) {
640 634 $deconstructed['display_type'] = 'user-photo';
641 635 }
642 636 }
643 637
@@ -643,17 +637,17 @@
643 637
644 638 if (!empty($input->folder)) {
645 639 $deconstructed['selected_data'] = trim($input->folder);
646 640 }
647 - else if (!empty($input->album_key)) { // old syntax
641 + elseif (!empty($input->album_key)) { // old syntax
648 642 $deconstructed['selected_data'] = $input->album_key;
649 643 }
650 - else if (!empty($input->album)) {
644 + elseif (!empty($input->album)) {
651 645 $album = explode('_', $input->album);
652 - if (count($album) == 2) {
646 + if (count($album) === 2) {
653 647 $deconstructed['selected_data'] = $album[1];
654 648 }
655 - else if (count($album) == 1) {
649 + elseif (count($album) === 1) {
656 650 $deconstructed['selected_data'] = $album[0];
657 651 }
658 652 }
659 653
@@ -664,5 +658,5 @@
664 658 }
665 659
666 660 return $deconstructed;
667 661 }
668 -}
662 +}