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/Zenfolio.php +283 -276 2.41 → 3.37 View file →
@@ -1,39 +1,40 @@
1 1 <?php
2 +
2 3 namespace Photonic_Plugin\Admin\Wizard;
3 4
4 -use Photonic_Plugin\Core\Photonic;
5 5 use Photonic_Plugin\Core\Utilities;
6 -use Requests;
6 +use WpOrg\Requests\Requests;
7 7
8 8 class Zenfolio extends Source {
9 - private static $instance;
9 + private static ?Zenfolio $instance = null;
10 10
11 11 protected function __construct() {
12 12 parent::__construct();
13 13 $this->provider = 'zenfolio';
14 + $this->api_base = Wizard::base_apis()['zenfolio'];
14 15
15 16 global $photonic_zenfolio_thumb_size, $photonic_zenfolio_tile_size, $photonic_zenfolio_main_size, $photonic_zenfolio_video_size;
16 17 $this->allowed_image_sizes['zenfolio'] = [
17 18 'thumb_size' => [
18 - '' => $this->default_from_settings,
19 - "1" => esc_html__("Square thumbnail, 60 &times; 60px, cropped square", 'photonic'),
20 - "0" => esc_html__("Small thumbnail, upto 80 &times; 80px", 'photonic'),
19 + '' => $this->default_from_settings,
20 + "1" => esc_html__("Square thumbnail, 60 &times; 60px, cropped square", 'photonic'),
21 + "0" => esc_html__("Small thumbnail, upto 80 &times; 80px", 'photonic'),
21 22 "10" => esc_html__("Medium thumbnail, upto 120 &times; 120px", 'photonic'),
22 23 "11" => esc_html__("Large thumbnail, upto 120 &times; 120px", 'photonic'),
23 - "2" => esc_html__("Small image, upto 400 &times; 400px", 'photonic'),
24 + "2" => esc_html__("Small image, upto 400 &times; 400px", 'photonic'),
24 25 ],
25 - 'tile_size' => [
26 - '' => $this->default_from_settings,
26 + 'tile_size' => [
27 + '' => $this->default_from_settings,
27 28 'same' => esc_html__('Same as Main image size', 'photonic'),
28 - '2' => esc_html__('Small image, upto 400 &times; 400px', 'photonic'),
29 - '3' => esc_html__('Medium image, upto 580 &times; 450px', 'photonic'),
30 - '4' => esc_html__('Large image, upto 800 &times; 630px', 'photonic'),
31 - '5' => esc_html__('X-Large image, upto 1100 &times; 850px', 'photonic'),
32 - '6' => esc_html__('XX-Large image, upto 1550 &times; 960px', 'photonic'),
29 + '2' => esc_html__('Small image, upto 400 &times; 400px', 'photonic'),
30 + '3' => esc_html__('Medium image, upto 580 &times; 450px', 'photonic'),
31 + '4' => esc_html__('Large image, upto 800 &times; 630px', 'photonic'),
32 + '5' => esc_html__('X-Large image, upto 1100 &times; 850px', 'photonic'),
33 + '6' => esc_html__('XX-Large image, upto 1550 &times; 960px', 'photonic'),
33 34 ],
34 - 'main_size' => [
35 - '' => $this->default_from_settings,
35 + 'main_size' => [
36 + '' => $this->default_from_settings,
36 37 '2' => esc_html__('Small image, upto 400 &times; 400px', 'photonic'),
37 38 '3' => esc_html__('Medium image, upto 580 &times; 450px', 'photonic'),
38 39 '4' => esc_html__('Large image, upto 800 &times; 630px', 'photonic'),
39 40 '5' => esc_html__('X-Large image, upto 1100 &times; 850px', 'photonic'),
@@ -39,9 +40,9 @@
39 40 '5' => esc_html__('X-Large image, upto 1100 &times; 850px', 'photonic'),
40 41 '6' => esc_html__('XX-Large image, upto 1550 &times; 960px', 'photonic'),
41 42 ],
42 43 'video_size' => [
43 - '' => $this->default_from_settings,
44 + '' => $this->default_from_settings,
44 45 '220' => esc_html__('360p resolution (MP4)', 'photonic'),
45 46 '215' => esc_html__('480p resolution (MP4)', 'photonic'),
46 47 '210' => esc_html__('720p resolution (MP4)', 'photonic'),
47 48 '200' => esc_html__('1080p resolution (MP4)', 'photonic'),
@@ -46,67 +47,66 @@
46 47 '210' => esc_html__('720p resolution (MP4)', 'photonic'),
47 48 '200' => esc_html__('1080p resolution (MP4)', 'photonic'),
48 49 ],
49 50 ];
50 - $this->allowed_image_sizes['zenfolio']['thumb_size'][''] .= ' - '.$this->allowed_image_sizes['zenfolio']['thumb_size'][$photonic_zenfolio_thumb_size];
51 - $this->allowed_image_sizes['zenfolio']['tile_size'][''] .= ' - '.$this->allowed_image_sizes['zenfolio']['tile_size'][$photonic_zenfolio_tile_size];
52 - $this->allowed_image_sizes['zenfolio']['main_size'][''] .= ' - '.$this->allowed_image_sizes['zenfolio']['main_size'][$photonic_zenfolio_main_size];
53 - $this->allowed_image_sizes['zenfolio']['video_size'][''] .= ' - '.$this->allowed_image_sizes['zenfolio']['video_size'][$photonic_zenfolio_video_size];
51 + $this->allowed_image_sizes['zenfolio']['thumb_size'][''] .= ' - ' . $this->allowed_image_sizes['zenfolio']['thumb_size'][$photonic_zenfolio_thumb_size];
52 + $this->allowed_image_sizes['zenfolio']['tile_size'][''] .= ' - ' . $this->allowed_image_sizes['zenfolio']['tile_size'][$photonic_zenfolio_tile_size];
53 + $this->allowed_image_sizes['zenfolio']['main_size'][''] .= ' - ' . $this->allowed_image_sizes['zenfolio']['main_size'][$photonic_zenfolio_main_size];
54 + $this->allowed_image_sizes['zenfolio']['video_size'][''] .= ' - ' . $this->allowed_image_sizes['zenfolio']['video_size'][$photonic_zenfolio_video_size];
54 55 }
55 56
56 - public static function get_instance() {
57 - if (self::$instance == null) {
57 + public static function get_instance(): Zenfolio {
58 + if (null === self::$instance) {
58 59 self::$instance = new Zenfolio();
59 60 }
60 61 return self::$instance;
61 62 }
62 63
63 - function get_screen_2() {
64 + public function get_screen_2(): array {
64 65 return [
65 - 'header' => esc_html__('Choose Type of Gallery', 'photonic'),
66 + 'header' => esc_html__('Choose Type of Gallery', 'photonic'),
66 67 'display' => [
67 68 'kind' => [
68 - 'type' => 'field_list',
69 + 'type' => 'field_list',
69 70 'list_type' => 'sequence',
70 - 'list' => [
71 + 'list' => [
71 72 'display_type' => [
72 - 'desc' => esc_html__('What do you want to show?', 'photonic'),
73 - 'type' => 'select',
73 + 'desc' => esc_html__('What do you want to show?', 'photonic'),
74 + 'type' => 'select',
74 75 'options' => [
75 - '' => '',
76 - 'single-photo' => esc_html__('Single Photo', 'photonic'),
77 - 'multi-photo' => esc_html__('Multiple Photos', 'photonic'),
78 - 'gallery-photo' => esc_html__('Photos from a Gallery or Collection', 'photonic'),
79 -// 'collection-photo' => esc_html__('Photos from a Collection', 'photonic'),
80 - 'multi-gallery' => esc_html__('Multiple Galleries', 'photonic'),
81 - 'multi-collection' => esc_html__('Multiple Collections', 'photonic'),
76 + '' => '',
77 + 'single-photo' => esc_html__('Single Photo', 'photonic'),
78 + 'multi-photo' => esc_html__('Multiple Photos', 'photonic'),
79 + 'gallery-photo' => esc_html__('Photos from a Gallery or Collection', 'photonic'),
80 + 'multi-gallery' => esc_html__('Multiple Galleries', 'photonic'),
81 + 'multi-collection' => esc_html__('Multiple Collections', 'photonic'),
82 82 'multi-gallery-collection' => esc_html__('Multiple Galleries and Collections', 'photonic'),
83 - 'group' => esc_html__('Single Group', 'photonic'),
84 - 'group-hierarchy' => esc_html__('Group Hierarchy', 'photonic'),
83 + 'group' => esc_html__('Single Group', 'photonic'),
84 + 'group-hierarchy' => esc_html__('Group Hierarchy', 'photonic'),
85 85 ],
86 - 'req' => 1,
86 + 'req' => 1,
87 87 ],
88 - 'for' => [
89 - 'desc' => esc_html__('For whom?', 'photonic'),
90 - 'type' => 'radio',
91 - 'options' => [
88 + 'for' => [
89 + 'desc' => esc_html__('For whom?', 'photonic'),
90 + 'type' => 'radio',
91 + 'options' => [
92 92 'current' => sprintf(esc_html__('Current user (Defined under %s)', 'photonic'), '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Default user</em>'),
93 - 'other' => esc_html__('Another user', 'photonic'),
94 - 'any' => esc_html__('All users', 'photonic'),
93 + 'other' => esc_html__('Another user', 'photonic'),
94 + 'any' => esc_html__('All users', 'photonic'),
95 95 ],
96 96 'option-conditions' => [
97 97 'current' => ['display_type' => ['single-photo', 'gallery-photo', 'collection-photo', 'multi-gallery', 'multi-collection', 'multi-gallery-collection', 'group', 'group-hierarchy']],
98 - 'other' => ['display_type' => ['single-photo', 'gallery-photo', 'collection-photo', 'multi-gallery', 'multi-collection', 'multi-gallery-collection', 'group', 'group-hierarchy']],
99 - 'any' => ['display_type' => ['multi-photo', /*'multi-gallery', 'multi-collection', */]],
98 + 'other' => ['display_type' => ['single-photo', 'gallery-photo', 'collection-photo', 'multi-gallery', 'multi-collection', 'multi-gallery-collection', 'group', 'group-hierarchy']],
99 + 'any' => ['display_type' => ['multi-photo']],
100 100 ],
101 - 'req' => 1,
101 + 'req' => 1,
102 102 ],
103 - 'login_name' => [
104 - 'desc' => sprintf(esc_html__('User name, e.g. %s', 'photonic'), 'https://<span style="text-decoration: underline">username</span>.zenfolio.com/'),
105 - 'type' => 'text',
106 - 'std' => '',
103 + 'login_name' => [
104 + 'desc' => sprintf(esc_html__('User name, e.g. %s', 'photonic'), 'https://<span style="text-decoration: underline">username</span>.zenfolio.com/'),
105 + 'type' => 'text',
106 + 'std' => '',
107 107 'conditions' => ['for' => ['other']],
108 - 'req' => 1,
108 + 'req' => 1,
109 109 ],
110 110 ],
111 111 ],
112 112 ],
@@ -112,25 +112,25 @@
112 112 ],
113 113 ];
114 114 }
115 115
116 - function get_screen_3() {
116 + public function get_screen_3(): array {
117 117 return [
118 - 'header' => esc_html__('Build your gallery', 'photonic'),
119 - 'single-photo' => [
120 - 'header' => esc_html__('Pick a photo', 'photonic'),
121 - 'desc' => esc_html__('From the list below pick the single photo you wish to display.', 'photonic'),
118 + 'header' => esc_html__('Build your gallery', 'photonic'),
119 + 'single-photo' => [
120 + 'header' => esc_html__('Pick a photo', 'photonic'),
121 + 'desc' => esc_html__('From the list below pick the single photo you wish to display.', 'photonic'),
122 122 'display' => [
123 123 'container' => [
124 124 'type' => 'thumbnail-selector',
125 125 'mode' => 'single',
126 - 'for' => 'selected_data',
126 + 'for' => 'selected_data',
127 127 ],
128 128 ],
129 129 ],
130 - 'multi-photo' => [
131 - 'header' => esc_html__('Photos from all users', 'photonic'),
132 - 'desc' => esc_html__('You can show photos from all users, and apply text or category filters to show some of them.', 'photonic'),
130 + 'multi-photo' => [
131 + 'header' => esc_html__('Photos from all users', 'photonic'),
132 + 'desc' => esc_html__('You can show photos from all users, and apply text or category filters to show some of them.', 'photonic'),
133 133 'display' => [
134 134 'text' => [
135 135 'desc' => esc_html__('With text', 'photonic'),
136 136 'type' => 'text',
@@ -136,10 +136,10 @@
136 136 'type' => 'text',
137 137 ],
138 138
139 139 'category_code' => [
140 - 'desc' => esc_html__('Category', 'photonic'),
141 - 'type' => 'select',
140 + 'desc' => esc_html__('Category', 'photonic'),
141 + 'type' => 'select',
142 142 'options' => $this->get_zenfolio_categories(),
143 143 ],
144 144
145 145 'container' => [
@@ -144,48 +144,48 @@
144 144
145 145 'container' => [
146 146 'type' => 'thumbnail-selector',
147 147 'mode' => 'none',
148 - 'for' => 'selected_data',
148 + 'for' => 'selected_data',
149 149 ],
150 150 ],
151 151 ],
152 - 'gallery-photo' => [
153 - 'header' => esc_html__('Pick your gallery', 'photonic'),
154 - 'desc' => esc_html__('From the list below pick the gallery whose photos you wish to display. Photos from that gallery will show up as thumbnails.', 'photonic'),
152 + 'gallery-photo' => [
153 + 'header' => esc_html__('Pick your gallery', 'photonic'),
154 + 'desc' => esc_html__('From the list below pick the gallery whose photos you wish to display. Photos from that gallery will show up as thumbnails.', 'photonic'),
155 155 'display' => [
156 156 'container' => [
157 157 'type' => 'thumbnail-selector',
158 158 'mode' => 'single',
159 - 'for' => 'selected_data',
159 + 'for' => 'selected_data',
160 160 ],
161 161 ],
162 162 ],
163 - 'collection-photo' => [
164 - 'header' => esc_html__('Pick your collection', 'photonic'),
165 - 'desc' => esc_html__('From the list below pick the collection whose photos you wish to display. Photos from that collection will show up as thumbnails.', 'photonic'),
163 + 'collection-photo' => [
164 + 'header' => esc_html__('Pick your collection', 'photonic'),
165 + 'desc' => esc_html__('From the list below pick the collection whose photos you wish to display. Photos from that collection will show up as thumbnails.', 'photonic'),
166 166 'display' => [
167 167 'container' => [
168 168 'type' => 'thumbnail-selector',
169 169 'mode' => 'single',
170 - 'for' => 'selected_data',
170 + 'for' => 'selected_data',
171 171 ],
172 172 ],
173 173 ],
174 - 'multi-gallery' => [
175 - 'header' => esc_html__('Pick your galleries', 'photonic'),
176 - 'desc' => esc_html__('From the list below pick the galleries you wish to display. Each album will show up as a single thumbnail. Note that text and category filters are not applied here but will be applied on the front-end.', 'photonic'),
174 + 'multi-gallery' => [
175 + 'header' => esc_html__('Pick your galleries', 'photonic'),
176 + 'desc' => esc_html__('From the list below pick the galleries you wish to display. Each album will show up as a single thumbnail. Note that text and category filters are not applied here but will be applied on the front-end.', 'photonic'),
177 177 'display' => [
178 178 'selection' => [
179 - 'desc' => esc_html__('What do you want to show?', 'photonic'),
180 - 'type' => 'select',
179 + 'desc' => esc_html__('What do you want to show?', 'photonic'),
180 + 'type' => 'select',
181 181 'options' => [
182 - 'all' => esc_html__('Automatic all (will automatically add new galleries)', 'photonic'),
183 - 'selected' => esc_html__('Selected galleries', 'photonic'),
182 + 'all' => esc_html__('Automatic all (will automatically add new galleries)', 'photonic'),
183 + 'selected' => esc_html__('Selected galleries', 'photonic'),
184 184 'not-selected' => esc_html__('All except selected galleries', 'photonic'),
185 185 ],
186 - 'req' => 1,
187 - 'hint' => esc_html__('If you pick "Automatic all" your selections below will be ignored.', 'photonic'),
186 + 'req' => 1,
187 + 'hint' => esc_html__('If you pick "Automatic all" your selections below will be ignored.', 'photonic'),
188 188 ],
189 189
190 190 'text' => [
191 191 'desc' => esc_html__('With text', 'photonic'),
@@ -192,10 +192,10 @@
192 192 'type' => 'text',
193 193 ],
194 194
195 195 'category_code' => [
196 - 'desc' => esc_html__('Category', 'photonic'),
197 - 'type' => 'select',
196 + 'desc' => esc_html__('Category', 'photonic'),
197 + 'type' => 'select',
198 198 'options' => $this->get_zenfolio_categories(),
199 199 ],
200 200
201 201 'container' => [
@@ -200,26 +200,26 @@
200 200
201 201 'container' => [
202 202 'type' => 'thumbnail-selector',
203 203 'mode' => 'multi',
204 - 'for' => 'selected_data',
204 + 'for' => 'selected_data',
205 205 ],
206 206 ],
207 207 ],
208 - 'multi-collection' => [
209 - 'header' => esc_html__('Pick your collections', 'photonic'),
210 - 'desc' => esc_html__('From the list below pick the collections you wish to display. Each collection will show up as a single thumbnail. Note that text and category filters are not applied here but will be applied on the front-end.', 'photonic'),
208 + 'multi-collection' => [
209 + 'header' => esc_html__('Pick your collections', 'photonic'),
210 + 'desc' => esc_html__('From the list below pick the collections you wish to display. Each collection will show up as a single thumbnail. Note that text and category filters are not applied here but will be applied on the front-end.', 'photonic'),
211 211 'display' => [
212 212 'selection' => [
213 - 'desc' => esc_html__('What do you want to show?', 'photonic'),
214 - 'type' => 'select',
213 + 'desc' => esc_html__('What do you want to show?', 'photonic'),
214 + 'type' => 'select',
215 215 'options' => [
216 - 'all' => esc_html__('Automatic all (will automatically add new collections)', 'photonic'),
217 - 'selected' => esc_html__('Selected collections', 'photonic'),
216 + 'all' => esc_html__('Automatic all (will automatically add new collections)', 'photonic'),
217 + 'selected' => esc_html__('Selected collections', 'photonic'),
218 218 'not-selected' => esc_html__('All except selected collections', 'photonic'),
219 219 ],
220 - 'hint' => esc_html__('If you pick "Automatic all" your selections below will be ignored.', 'photonic'),
221 - 'req' => 1,
220 + 'hint' => esc_html__('If you pick "Automatic all" your selections below will be ignored.', 'photonic'),
221 + 'req' => 1,
222 222 ],
223 223
224 224 'text' => [
225 225 'desc' => esc_html__('With text', 'photonic'),
@@ -226,10 +226,10 @@
226 226 'type' => 'text',
227 227 ],
228 228
229 229 'category_code' => [
230 - 'desc' => esc_html__('Category', 'photonic'),
231 - 'type' => 'select',
230 + 'desc' => esc_html__('Category', 'photonic'),
231 + 'type' => 'select',
232 232 'options' => $this->get_zenfolio_categories(),
233 233 ],
234 234
235 235 'container' => [
@@ -234,26 +234,26 @@
234 234
235 235 'container' => [
236 236 'type' => 'thumbnail-selector',
237 237 'mode' => 'multi',
238 - 'for' => 'selected_data',
238 + 'for' => 'selected_data',
239 239 ],
240 240 ],
241 241 ],
242 242 'multi-gallery-collection' => [
243 - 'header' => esc_html__('Pick your galleries and collections', 'photonic'),
244 - 'desc' => esc_html__('From the list below pick the galleries and collections you wish to display. Each gallery and collection will show up as a single thumbnail. Note that text and category filters are not applied here but will be applied on the front-end.', 'photonic'),
243 + 'header' => esc_html__('Pick your galleries and collections', 'photonic'),
244 + 'desc' => esc_html__('From the list below pick the galleries and collections you wish to display. Each gallery and collection will show up as a single thumbnail. Note that text and category filters are not applied here but will be applied on the front-end.', 'photonic'),
245 245 'display' => [
246 246 'selection' => [
247 - 'desc' => esc_html__('What do you want to show?', 'photonic'),
248 - 'type' => 'select',
247 + 'desc' => esc_html__('What do you want to show?', 'photonic'),
248 + 'type' => 'select',
249 249 'options' => [
250 - 'all' => esc_html__('Automatic all (will automatically add new galleries and collections)', 'photonic'),
251 - 'selected' => esc_html__('Selected galleries and collections', 'photonic'),
250 + 'all' => esc_html__('Automatic all (will automatically add new galleries and collections)', 'photonic'),
251 + 'selected' => esc_html__('Selected galleries and collections', 'photonic'),
252 252 'not-selected' => esc_html__('All except selected galleries and collections', 'photonic'),
253 253 ],
254 - 'hint' => esc_html__('If you pick "Automatic all" your selections below will be ignored.', 'photonic'),
255 - 'req' => 1,
254 + 'hint' => esc_html__('If you pick "Automatic all" your selections below will be ignored.', 'photonic'),
255 + 'req' => 1,
256 256 ],
257 257
258 258 'text' => [
259 259 'desc' => esc_html__('With text', 'photonic'),
@@ -260,10 +260,10 @@
260 260 'type' => 'text',
261 261 ],
262 262
263 263 'category_code' => [
264 - 'desc' => esc_html__('Category', 'photonic'),
265 - 'type' => 'select',
264 + 'desc' => esc_html__('Category', 'photonic'),
265 + 'type' => 'select',
266 266 'options' => $this->get_zenfolio_categories(),
267 267 ],
268 268
269 269 'container' => [
@@ -268,31 +268,31 @@
268 268
269 269 'container' => [
270 270 'type' => 'thumbnail-selector',
271 271 'mode' => 'multi',
272 - 'for' => 'selected_data',
272 + 'for' => 'selected_data',
273 273 ],
274 274 ],
275 275 ],
276 - 'group' => [
277 - 'header' => esc_html__('Pick your group', 'photonic'),
278 - 'desc' => esc_html__('From the list below pick the group you wish to display. The galleries / collections within the group will show up as single thumbnails.', 'photonic'),
276 + 'group' => [
277 + 'header' => esc_html__('Pick your group', 'photonic'),
278 + 'desc' => esc_html__('From the list below pick the group you wish to display. The galleries / collections within the group will show up as single thumbnails.', 'photonic'),
279 279 'display' => [
280 280 'container' => [
281 281 'type' => 'thumbnail-selector',
282 282 'mode' => 'single',
283 - 'for' => 'selected_data',
283 + 'for' => 'selected_data',
284 284 ],
285 285 ],
286 286 ],
287 - 'group-hierarchy' => [
288 - 'header' => esc_html__('Your group hierarchy', 'photonic'),
289 - 'desc' => esc_html__('The following group hierarchy will be displayed on your site. Only top level groups and galleries / collections are shown here. The galleries / collections within the groups will show up as single thumbnails and can be clicked to show the images within.', 'photonic'),
287 + 'group-hierarchy' => [
288 + 'header' => esc_html__('Your group hierarchy', 'photonic'),
289 + 'desc' => esc_html__('The following group hierarchy will be displayed on your site. Only top level groups and galleries / collections are shown here. The galleries / collections within the groups will show up as single thumbnails and can be clicked to show the images within.', 'photonic'),
290 290 'display' => [
291 291 'container' => [
292 292 'type' => 'thumbnail-selector',
293 293 'mode' => 'none',
294 - 'for' => 'selected_data',
294 + 'for' => 'selected_data',
295 295 ],
296 296 ],
297 297 ],
298 298 ];
@@ -297,109 +297,109 @@
297 297 ],
298 298 ];
299 299 }
300 300
301 - function get_screen_4() {
301 + public function get_screen_4(): array {
302 302 return [];
303 303 }
304 304
305 - function get_screen_5() {
305 + public function get_screen_5(): array {
306 306 global $photonic_zenfolio_media, $photonic_zenfolio_title_caption;
307 307 return [
308 308 'zenfolio' => [
309 - 'L1' => [
310 - 'media' => [
311 - 'desc' => esc_html__('Media to Show', 'photonic'),
312 - 'type' => 'select',
309 + 'L1' => [
310 + 'media' => [
311 + 'desc' => esc_html__('Media to Show', 'photonic'),
312 + 'type' => 'select',
313 313 'options' => Utilities::media_options(true, $photonic_zenfolio_media),
314 - 'std' => '',
315 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Media to show</em>'),
314 + 'std' => '',
315 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Media to show</em>'),
316 316 ],
317 - 'caption' => [
318 - 'desc' => esc_html__('Photo titles and captions', 'photonic'),
319 - 'type' => 'select',
317 + 'caption' => [
318 + 'desc' => esc_html__('Photo titles and captions', 'photonic'),
319 + 'type' => 'select',
320 320 'options' => Utilities::title_caption_options(true, $photonic_zenfolio_title_caption),
321 - 'std' => '',
322 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Photo titles and captions</em>'),
321 + 'std' => '',
322 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Photo titles and captions</em>'),
323 323 ],
324 324 'sort_order' => [
325 - 'desc' => esc_html__('Search results sort order', 'photonic'),
326 - 'type' => 'select',
325 + 'desc' => esc_html__('Search results sort order', 'photonic'),
326 + 'type' => 'select',
327 327 'options' => [
328 - '' => '',
329 - 'Date' => esc_html__('Date', 'photonic'),
328 + '' => '',
329 + 'Date' => esc_html__('Date', 'photonic'),
330 330 'Popularity' => esc_html__('Popularity', 'photonic'),
331 - 'Rank' => esc_html__('Rank (for searching by text only)', 'photonic'),
331 + 'Rank' => esc_html__('Rank (for searching by text only)', 'photonic'),
332 332 ],
333 333 ],
334 - 'password' => [
335 - 'desc' => esc_html__('Password for password-protected album', 'photonic'),
336 - 'type' => 'text',
337 - 'req' => 1,
338 - 'hint' => esc_html__('You are trying to display photos from a password-protected album. The password is mandatory for such an album.', 'photonic'),
334 + 'password' => [
335 + 'desc' => esc_html__('Password for password-protected album', 'photonic'),
336 + 'type' => 'text',
337 + 'req' => 1,
338 + 'hint' => esc_html__('You are trying to display photos from a password-protected album. The password is mandatory for such an album.', 'photonic'),
339 339 'conditions' => ['selection_passworded' => ['1']],
340 340 ],
341 341 ],
342 - 'L2' => [
342 + 'L2' => [
343 343 'sort_order' => [
344 - 'desc' => esc_html__('Search results sort order', 'photonic'),
345 - 'type' => 'select',
344 + 'desc' => esc_html__('Search results sort order', 'photonic'),
345 + 'type' => 'select',
346 346 'options' => [
347 - '' => '',
348 - 'Date' => esc_html__('Date', 'photonic'),
347 + '' => '',
348 + 'Date' => esc_html__('Date', 'photonic'),
349 349 'Popularity' => esc_html__('Popularity', 'photonic'),
350 - 'Rank' => esc_html__('Rank (for searching by text only)', 'photonic'),
350 + 'Rank' => esc_html__('Rank (for searching by text only)', 'photonic'),
351 351 ],
352 352 ],
353 353 ],
354 - 'L3' => [
354 + 'L3' => [
355 355 'structure' => [
356 - 'desc' => esc_html__('Group / Hierarchy structure', 'photonic'),
357 - 'type' => 'select',
356 + 'desc' => esc_html__('Group / Hierarchy structure', 'photonic'),
357 + 'type' => 'select',
358 358 'options' => [
359 - '' => '',
360 - 'flat' => esc_html__('All photosets shown in single level', 'photonic'),
359 + '' => '',
360 + 'flat' => esc_html__('All photosets shown in single level', 'photonic'),
361 361 'nested' => esc_html__('Photosets shown nested within groups', 'photonic'),
362 362 ],
363 - 'hint' => sprintf(esc_html__('See examples %1$shere%2$s.', 'photonic'), '<a href="https://aquoid.com/plugins/photonic/zenfolio/group-hierarchy/" target="_blank">', '</a>'),
363 + 'hint' => sprintf(esc_html__('See examples %1$shere%2$s.', 'photonic'), '<a href="https://aquoid.com/plugins/photonic/zenfolio/group-hierarchy/" target="_blank">', '</a>'),
364 364 ],
365 - 'headers' => [
366 - 'desc' => esc_html__('Show Group Header', 'photonic'),
367 - 'type' => 'select',
365 + 'headers' => [
366 + 'desc' => esc_html__('Show Group Header', 'photonic'),
367 + 'type' => 'select',
368 368 'options' => [
369 - '' => $this->default_from_settings,
370 - 'none' => esc_html__('No header', 'photonic'),
371 - 'title' => esc_html__('Title only', 'photonic'),
372 - 'counter' => esc_html__('Counts only', 'photonic'),
369 + '' => $this->default_from_settings,
370 + 'none' => esc_html__('No header', 'photonic'),
371 + 'title' => esc_html__('Title only', 'photonic'),
372 + 'counter' => esc_html__('Counts only', 'photonic'),
373 373 'title,counter' => esc_html__('Title and counts', 'photonic'),
374 374 ],
375 375 ],
376 376 ],
377 - 'main_size' => [
378 - 'desc' => esc_html__('Main image size', 'photonic'),
379 - 'type' => 'select',
377 + 'main_size' => [
378 + 'desc' => esc_html__('Main image size', 'photonic'),
379 + 'type' => 'select',
380 380 'options' => $this->allowed_image_sizes['zenfolio']['main_size'],
381 - 'std' => '',
382 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Main image size</em>'),
381 + 'std' => '',
382 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Main image size</em>'),
383 383 ],
384 384 'video_size' => [
385 - 'desc' => esc_html__('Main video size', 'photonic'),
386 - 'type' => 'select',
385 + 'desc' => esc_html__('Main video size', 'photonic'),
386 + 'type' => 'select',
387 387 'options' => $this->allowed_image_sizes['zenfolio']['video_size'],
388 - 'std' => '',
389 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Video size</em>'),
388 + 'std' => '',
389 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Video size</em>'),
390 390 ],
391 391 ]
392 392 ];
393 393 }
394 394
395 - private function get_zenfolio_categories() {
395 + private function get_zenfolio_categories(): array {
396 396 $response = wp_remote_request('https://api.zenfolio.com/api/1.8/zfapi.asmx/GetCategories', ['sslverify' => PHOTONIC_SSL_VERIFY]);
397 397 $category_list = ['' => ''];
398 398
399 399 if (!is_wp_error($response)) {
400 - if (isset($response['response']) && isset($response['response']['code'])) {
401 - if ($response['response']['code'] == 200) {
400 + if (isset($response['response']['code'])) {
401 + if (200 === $response['response']['code']) {
402 402 if (isset($response['body'])) {
403 403 $response = simplexml_load_string($response['body']);
404 404 if (!empty($response->Category)) {
405 405 $categories = $response->Category;
@@ -414,35 +414,35 @@
414 414 asort($category_list);
415 415 return $category_list;
416 416 }
417 417
418 - function get_square_size_options() {
418 + public function get_square_size_options(): array {
419 419 return [
420 420 'thumb_size' => [
421 - 'desc' => esc_html__('Thumbnail size', 'photonic'),
422 - 'type' => 'select',
421 + 'desc' => esc_html__('Thumbnail size', 'photonic'),
422 + 'type' => 'select',
423 423 'options' => $this->allowed_image_sizes['zenfolio']['thumb_size'],
424 - 'std' => '',
425 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Thumbnail size</em>'),
424 + 'std' => '',
425 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Thumbnail size</em>'),
426 426 ],
427 427 ];
428 428 }
429 429
430 - function get_random_size_options() {
430 + public function get_random_size_options(): array {
431 431 return [
432 432 'tile_size' => [
433 - 'desc' => esc_html__('Tile size', 'photonic'),
434 - 'type' => 'select',
433 + 'desc' => esc_html__('Tile size', 'photonic'),
434 + 'type' => 'select',
435 435 'options' => $this->allowed_image_sizes['zenfolio']['tile_size'],
436 - 'std' => '',
437 - 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Tile image size</em>'),
436 + 'std' => '',
437 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Tile image size</em>'),
438 438 ],
439 439 ];
440 440 }
441 441
442 - function make_request($display_type, $for, $flattened_fields) {
443 - if ((!in_array($display_type, ['multi-photo', /*'multi-gallery', 'multi-collection'*/]) && $for == 'any') ||
444 - (!in_array($display_type, ['single-photo', 'gallery-photo', 'collection-photo', 'multi-gallery', 'multi-collection', 'multi-gallery-collection', 'group', 'group-hierarchy']) && in_array($for, ['current', 'other']))) {
442 + public function make_request($display_type, $for, $flattened_fields): array {
443 + if ((!in_array($display_type, ['multi-photo'], true) && 'any' === $for) ||
444 + (!in_array($display_type, ['single-photo', 'gallery-photo', 'collection-photo', 'multi-gallery', 'multi-collection', 'multi-gallery-collection', 'group', 'group-hierarchy'], true) && in_array($for, ['current', 'other'], true))) {
445 445 $err = esc_html__('Incompatible selections:', 'photonic') . "<br/>\n";
446 446 $err .= $flattened_fields['display_type']['desc'] . ": " . $flattened_fields['display_type']['options'][$display_type] . "<br/>\n";
447 447 $err .= $flattened_fields['for']['desc'] . ": " . $flattened_fields['for']['options'][$for] . "<br/>\n";
448 448 return ['error' => $err];
@@ -447,44 +447,47 @@
447 447 $err .= $flattened_fields['for']['desc'] . ": " . $flattened_fields['for']['options'][$for] . "<br/>\n";
448 448 return ['error' => $err];
449 449 }
450 450
451 - if ($for == 'other' && empty($_POST['login_name'])) {
452 - return ['error' => $this->error_mandatory];
453 - }
451 + if (check_ajax_referer('photonic-wizard-next-' . get_current_user_id())) {
452 + if ('other' === $for && empty($_POST['login_name'])) {
453 + return ['error' => $this->error_mandatory];
454 + }
454 455
455 - $login_name = sanitize_text_field($_POST['login_name']);
456 - global $photonic_zenfolio_default_user;
457 - if ($for == 'current' && empty($photonic_zenfolio_default_user)) {
458 - 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; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Default User</em>', '<br/>')];
459 - }
456 + $login_name = sanitize_text_field(wp_unslash($_POST['login_name']));
457 + global $photonic_zenfolio_default_user;
458 + if ('current' === $for && empty($photonic_zenfolio_default_user)) {
459 + 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; Zenfolio &rarr; Zenfolio Photo Settings &rarr; Default User</em>', '<br/>')];
460 + }
460 461
461 - $parameters = [];
462 - $user = $for == 'current' ? $photonic_zenfolio_default_user : ($for == 'other' ? $login_name : '');
462 + $parameters = [];
463 + $user = esc_attr('current' === $for ? $photonic_zenfolio_default_user : ('other' === $for ? $login_name : ''));
463 464
464 - if ($display_type == 'multi-photo') {
465 - $url = 'https://api.zenfolio.com/api/1.8/zfapi.asmx/SearchPhotoByCategory';
466 - $parameters['searchId'] = '5';
467 - $parameters['sortOrder'] = 'Popularity';
468 - $parameters['categoryCode'] = '1018000';
469 - $parameters['offset'] = 0;
470 - $parameters['limit'] = 500;
465 + if ('multi-photo' === $display_type) {
466 + $url = 'https://' . $this->api_base . '/api/1.8/zfapi.asmx/SearchPhotoByCategory';
467 + $parameters['searchId'] = '5';
468 + $parameters['sortOrder'] = 'Popularity';
469 + $parameters['categoryCode'] = '1018000';
470 + $parameters['offset'] = 0;
471 + $parameters['limit'] = 500;
472 + }
473 + elseif (in_array($display_type, ['multi-gallery', 'multi-collection'], true) && 'any' === $for) {
474 + $url = 'https://' . $this->api_base . '/api/1.8/zfapi.asmx/SearchSetByCategory';
475 + $parameters['searchId'] = '5';
476 + $parameters['sortOrder'] = 'Popularity';
477 + $parameters['categoryCode'] = '1018000';
478 + $parameters['offset'] = 0;
479 + $parameters['limit'] = 500;
480 + }
481 + else {
482 + $url = 'https://' . $this->api_base . '/api/1.8/zfapi.asmx/LoadGroupHierarchy';
483 + $parameters['loginName'] = $user;
484 + }
485 +
486 + $response = wp_remote_request($url, ['sslverify' => PHOTONIC_SSL_VERIFY, 'body' => $parameters]);
487 + return [$response, ['login_name' => $user], $url];
471 488 }
472 - else if (in_array($display_type, ['multi-gallery', 'multi-collection']) && $for == 'any') {
473 - $url = 'https://api.zenfolio.com/api/1.8/zfapi.asmx/SearchSetByCategory';
474 - $parameters['searchId'] = '5';
475 - $parameters['sortOrder'] = 'Popularity';
476 - $parameters['categoryCode'] = '1018000';
477 - $parameters['offset'] = 0;
478 - $parameters['limit'] = 500;
479 - }
480 - else {
481 - $url = 'https://api.zenfolio.com/api/1.8/zfapi.asmx/LoadGroupHierarchy';
482 - $parameters['loginName'] = $user;
483 - }
484 -
485 - $response = wp_remote_request($url, ['sslverify' => PHOTONIC_SSL_VERIFY, 'body' => $parameters]);
486 - return [$response, ['login_name' => $user], $url];
489 + return ['error' => $this->error_unauthorized];
487 490 }
488 491
489 492 /**
490 493 * Processes a response from Zenfolio to build it out into a gallery of thumbnails. Zenfolio has both, L1 and L2 displays in the flow.
@@ -494,28 +497,28 @@
494 497 * @param $url
495 498 * @param array $pagination
496 499 * @return array
497 500 */
498 - function process_response($response, $display_type, $url = null, &$pagination = []) {
501 + public function process_response($response, $display_type, $url = null, &$pagination = []): array {
499 502 $body = wp_remote_retrieve_body($response);
500 503 $body = preg_replace('/"Id":(\d+)/', '"Id":"$1"', $body);
501 504 $body = simplexml_load_string($body);
502 505 $objects = [];
503 - if ($display_type != 'multi-photo') {
506 + if ('multi-photo' !== $display_type) {
504 507 if (!empty($body->Elements)) {
505 508 $elements = $body->Elements;
506 509 $this->get_zenfolio_groups($objects, $elements, $display_type);
507 510 }
508 - else if (!empty($body->PhotoSets)) {
511 + elseif (!empty($body->PhotoSets)) {
509 512 $photosets = $body->PhotoSets;
510 513 $this->get_zenfolio_groups($objects, $photosets, $display_type);
511 514 }
512 515
513 - if ($display_type == 'single-photo') {
514 - require_once(PHOTONIC_PATH.'/Modules/Zenfolio.php');
516 + if ('single-photo' === $display_type) {
517 + require_once PHOTONIC_PATH . '/Platforms/Zenfolio.php';
515 518
516 519 $photo_array = [];
517 - $gallery = \Photonic_Plugin\Modules\Zenfolio::get_instance();
520 + $gallery = \Photonic_Plugin\Platforms\Zenfolio::get_instance();
518 521 $requests = [];
519 522 foreach ($objects as $object) {
520 523 $parameters = [];
521 524 $parameters['photoSetId'] = substr($object['id'], 1);
@@ -523,23 +526,25 @@
523 526 $parameters['includePhotos'] = 'true';
524 527
525 528 $request = $gallery->prepare_request('LoadPhotoSet', $parameters);
526 529 $requests[] = [
527 - 'url' => 'https://api.zenfolio.com/api/1.8/zfapi.asmx',
528 - 'type' => 'POST',
530 + 'url' => 'https://' . $this->api_base . '/api/1.8/zfapi.asmx',
531 + 'type' => 'POST',
529 532 'headers' => $request['headers'],
530 - 'data' => $request['body'],
533 + 'data' => $request['body'],
531 534 ];
532 535 }
536 +
533 537 $responses = Requests::request_multiple($requests);
538 +
534 539 if (!empty($responses)) {
535 540 foreach ($responses as $ps_response) {
536 - if (is_a($ps_response, 'Requests_Response')) {
541 + if (is_a($ps_response, 'WpOrg\Requests\Response')) {
537 542 $ps_response = json_decode($ps_response->body);
538 543 if (!empty($ps_response->result)) {
539 544 $ps_response = $ps_response->result;
540 545 if (!empty($ps_response->Photos)) {
541 - $photo_array['psid'.$ps_response->Id] = $ps_response->Title;
546 + $photo_array['psid' . $ps_response->Id] = $ps_response->Title;
542 547 foreach ($ps_response->Photos as $ps_photo) {
543 548 if (array_key_exists($ps_photo->Id, $photo_array)) {
544 549 continue;
545 550 }
@@ -545,9 +550,9 @@
545 550 }
546 551 $photo = [];
547 552 $photo['id'] = $ps_photo->Id;
548 553 $url_parts = explode('/', $ps_photo->UrlCore);
549 - $photo['alt_id'] = 'h'.dechex((int)substr($url_parts[count($url_parts) - 1], 1));
554 + $photo['alt_id'] = 'h' . dechex((int) substr($url_parts[count($url_parts) - 1], 1));
550 555 $photo['alt_id2'] = $url_parts[count($url_parts) - 1];
551 556 $photo['title'] = esc_attr($ps_photo->Title);
552 557 $photo['thumbnail'] = 'https://' . $ps_photo->UrlHost . $ps_photo->UrlCore . '-1.jpg';
553 558 $photo_array[$ps_photo->Id] = $photo;
@@ -581,16 +586,16 @@
581 586 * @param $elements
582 587 * @param $display_type
583 588 */
584 589 private function get_zenfolio_groups(&$objects, $elements, $display_type) {
585 - if (!empty($elements->PhotoSet) && $display_type != 'group') {
590 + if (!empty($elements->PhotoSet) && 'group' !== $display_type) {
586 591 foreach ($elements->PhotoSet as $photoset) {
587 - if ((($display_type == 'gallery-photo' || $display_type == 'multi-gallery') && $photoset->Type == 'Gallery') ||
588 - (($display_type == 'collection-photo' || $display_type == 'multi-collection') && $photoset->Type == 'Collection') ||
589 - $display_type == 'multi-gallery-collection' || $display_type == 'group-hierarchy' || $display_type == 'single-photo'
592 + if ((('gallery-photo' === $display_type || 'multi-gallery' === $display_type) && 'Gallery' === (string) $photoset->Type) || // WARNING: No strict matching should be done for $photoset->Type without casting; this is an XML object that we are matching to a string
593 + (('collection-photo' === $display_type || 'multi-collection' === $display_type) && 'Collection' === (string) $photoset->Type) || // WARNING: No strict matching should be done for $photoset->Type without casting; this is an XML object that we are matching to a string
594 + 'multi-gallery-collection' === $display_type || 'group-hierarchy' === $display_type || 'single-photo' === $display_type
590 595 ) {
591 596 $object = [];
592 - $page_url = parse_url($photoset->PageUrl);
597 + $page_url = wp_parse_url($photoset->PageUrl);
593 598 $page_url = $page_url['path'];
594 599 $page_url = explode('/', $page_url);
595 600 if (count($page_url) > 1) {
596 601 $page_url = $page_url[1];
@@ -607,9 +612,9 @@
607 612
608 613 $photo = $photoset->TitlePhoto;
609 614 $object['thumbnail'] = 'https://' . $photo->UrlHost . $photo->UrlCore . '-1.jpg';
610 615
611 - if (!empty($photoset->AccessDescriptor) && !empty($photoset->AccessDescriptor->AccessType) && $photoset->AccessDescriptor->AccessType == 'Password') {
616 + if (!empty($photoset->AccessDescriptor) && !empty($photoset->AccessDescriptor->AccessType) && 'Password' === $photoset->AccessDescriptor->AccessType) {
612 617 $object['passworded'] = 1;
613 618 }
614 619
615 620 $objects[] = $object;
@@ -618,17 +623,17 @@
618 623 }
619 624
620 625 if (!empty($elements->Group)) {
621 626 foreach ($elements->Group as $group) {
622 - if ($display_type == 'group' || $display_type == 'group-hierarchy') {
627 + if ('group' === $display_type || 'group-hierarchy' === $display_type) {
623 628 $object = [];
624 629 $object['id'] = $group->Id;
625 630 $object['title'] = $group->Title;
626 - $object['thumbnail'] = PHOTONIC_URL.'include/images/placeholder-Ti.png';
631 + $object['thumbnail'] = PHOTONIC_URL . 'include/images/placeholder-Ti.png';
627 632 $objects[] = $object;
628 633 }
629 634
630 - if ($display_type != 'group-hierarchy' && !empty($group->Elements)) {
635 + if ('group-hierarchy' !== $display_type && !empty($group->Elements)) {
631 636 $this->get_zenfolio_groups($objects, $group->Elements, $display_type);
632 637 }
633 638 }
634 639 }
@@ -635,40 +640,42 @@
635 640 }
636 641
637 642 /**
638 643 * @param $display_type
639 - * @return array|mixed
644 + * @return array
640 645 */
641 - function construct_shortcode_from_screen_selections($display_type) {
646 + public function construct_shortcode_from_screen_selections($display_type): array {
642 647 $short_code = [];
643 648
644 - if ($display_type == 'multi-photo') {
645 - $short_code['view'] = 'photos';
646 - }
647 - else if ($display_type == 'single-photo') {
648 - $short_code['view'] = 'photos';
649 - $short_code['object_id'] = sanitize_text_field($_POST['selected_data']);
650 - }
651 - else if ($display_type == 'gallery-photo'/* || $display_type == 'collection-photo'*/) {
652 - $short_code['view'] = 'photosets';
653 - $short_code['object_id'] = sanitize_text_field($_POST['selected_data']);
654 - }
655 - else if ($display_type == 'multi-gallery' || $display_type == 'multi-collection' || $display_type == 'multi-gallery-collection') {
656 - $short_code['view'] = 'photosets';
657 - if ($display_type == 'multi-gallery') {
658 - $short_code['photoset_type'] = 'Gallery';
649 + if (check_ajax_referer('photonic-wizard-next-' . get_current_user_id())) {
650 + if ('multi-photo' === $display_type) {
651 + $short_code['view'] = 'photos';
659 652 }
660 - else if ($display_type == 'multi-collection') {
661 - $short_code['photoset_type'] = 'Collection';
653 + elseif ('single-photo' === $display_type) {
654 + $short_code['view'] = 'photos';
655 + $short_code['object_id'] = sanitize_text_field(wp_unslash($_POST['selected_data'] ?? ''));
662 656 }
657 + elseif ('gallery-photo' === $display_type/* || $display_type == 'collection-photo'*/) {
658 + $short_code['view'] = 'photosets';
659 + $short_code['object_id'] = sanitize_text_field(wp_unslash($_POST['selected_data'] ?? ''));
660 + }
661 + elseif ('multi-gallery' === $display_type || 'multi-collection' === $display_type || 'multi-gallery-collection' === $display_type) {
662 + $short_code['view'] = 'photosets';
663 + if ('multi-gallery' === $display_type) {
664 + $short_code['photoset_type'] = 'Gallery';
665 + }
666 + elseif ('multi-collection' === $display_type) {
667 + $short_code['photoset_type'] = 'Collection';
668 + }
669 + }
670 + elseif ('group' === $display_type) {
671 + $short_code['view'] = 'group';
672 + $short_code['object_id'] = sanitize_text_field(wp_unslash($_POST['selected_data'] ?? ''));
673 + }
674 + elseif ('group-hierarchy' === $display_type) {
675 + $short_code['view'] = 'hierarchy';
676 + }
663 677 }
664 - else if ($display_type == 'group') {
665 - $short_code['view'] = 'group';
666 - $short_code['object_id'] = sanitize_text_field($_POST['selected_data']);
667 - }
668 - else if ($display_type == 'group-hierarchy') {
669 - $short_code['view'] = 'hierarchy';
670 - }
671 678
672 679 return $short_code;
673 680 }
674 681
@@ -673,40 +680,40 @@
673 680 }
674 681
675 682 /**
676 683 * @param $input
677 - * @return array|mixed
684 + * @return array
678 685 */
679 - function deconstruct_shortcode_to_screen_selections($input) {
686 + public function deconstruct_shortcode_to_screen_selections($input): array {
680 687 $deconstructed = [];
681 688
682 689 if (!empty($input->view)) {
683 - if ($input->view == 'photos' && empty($input->object_id)) {
690 + if ('photos' === $input->view && empty($input->object_id)) {
684 691 $deconstructed['display_type'] = 'multi-photo';
685 692 }
686 - else if ($input->view == 'photos' && !empty($input->object_id)) {
693 + elseif ('photos' === $input->view && !empty($input->object_id)) {
687 694 $deconstructed['display_type'] = 'single-photo';
688 695 $deconstructed['selected_data'] = $input->object_id;
689 696 }
690 - else if ($input->view == 'photosets') {
697 + elseif ('photosets' === $input->view) {
691 698 if (!empty($input->object_id)) {
692 699 $deconstructed['display_type'] = 'gallery-photo';
693 700 $deconstructed['selected_data'] = $input->object_id;
694 701 }
695 - else if (empty($input->photoset_type)) {
702 + elseif (empty($input->photoset_type)) {
696 703 $deconstructed['display_type'] = 'multi-gallery-collection';
697 704 }
698 - else if (strtolower($input->photoset_type) == 'collection') {
705 + elseif ('collection' === strtolower($input->photoset_type)) {
699 706 $deconstructed['display_type'] = 'multi-collection';
700 707 }
701 - else if (strtolower($input->photoset_type) == 'gallery') {
708 + elseif ('gallery' === strtolower($input->photoset_type)) {
702 709 $deconstructed['display_type'] = 'multi-gallery';
703 710 }
704 711 }
705 - else if ($input->view == 'hierarchy') {
712 + elseif ('hierarchy' === $input->view) {
706 713 $deconstructed['display_type'] = 'group-hierarchy';
707 714 }
708 - else if ($input->view == 'group') {
715 + elseif ('group' === $input->view) {
709 716 $deconstructed['display_type'] = 'group';
710 717 if (!empty($input->object_id)) {
711 718 $deconstructed['selected_data'] = $input->object_id;
712 719 }
@@ -711,15 +718,15 @@
711 718 $deconstructed['selected_data'] = $input->object_id;
712 719 }
713 720 }
714 721
715 - if ($input->view == 'photosets' || $input->view == 'hierarchy' || $input->view == 'group' ||
716 - $deconstructed['display_type'] == 'single-photo') {
722 + if ('photosets' === $input->view || 'hierarchy' === $input->view || 'group' === $input->view ||
723 + 'single-photo' === $deconstructed['display_type']) {
717 724 global $photonic_zenfolio_default_user;
718 725 if (!isset($input->login_name) && !empty($photonic_zenfolio_default_user)) {
719 726 $deconstructed['for'] = 'current';
720 727 }
721 - else if (!empty($input->login_name)) {
728 + elseif (!empty($input->login_name)) {
722 729 $deconstructed['login_name'] = $input->login_name;
723 730 $deconstructed['for'] = 'other';
724 731 }
725 732 }
@@ -726,5 +733,5 @@
726 733 }
727 734
728 735 return $deconstructed;
729 736 }
730 -}
737 +}