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
← All changes | Admin/Wizard/Source.php +162 -104 2.413.36 View file →
@@ -1,10 +1,18 @@
1 1 <?php
2 +
2 3 namespace Photonic_Plugin\Admin\Wizard;
3 4
4 5 abstract class Source {
5 - protected $default_under, $default_from_settings, $allowed_image_sizes, $column_options, $provider,
6 - $error_not_found, $error_mandatory;
6 + protected string $default_under;
7 + protected string $default_from_settings;
8 + protected array $allowed_image_sizes;
9 + protected array $column_options;
10 + protected string $provider;
11 + protected string $error_not_found;
12 + protected string $error_mandatory;
13 + protected string $error_unauthorized;
14 + public ?string $api_base;
7 15
8 16 protected function __construct() {
9 17 $this->default_under = esc_html__('Default settings can be configured under: %s', 'photonic');
10 18 $this->default_from_settings = esc_html__('Default from settings', 'photonic');
@@ -9,38 +17,29 @@
9 17 $this->default_under = esc_html__('Default settings can be configured under: %s', 'photonic');
10 18 $this->default_from_settings = esc_html__('Default from settings', 'photonic');
11 19 $this->allowed_image_sizes = [];
12 20 $this->column_options = [
13 - 'desc' => esc_html__('Number of columns in output', 'photonic'),
14 - 'type' => 'select',
21 + 'desc' => esc_html__('Number of columns in output', 'photonic'),
22 + 'type' => 'select',
15 23 'options' => [
16 - '' => '',
24 + '' => '',
17 25 'auto' => esc_html__('Automatic (Photonic calculates the columns)', 'photonic'),
18 - '1' => 1,
19 - '2' => 2,
20 - '3' => 3,
21 - '4' => 4,
22 - '5' => 5,
23 - '6' => 6,
24 - '7' => 7,
25 - '8' => 8,
26 - '9' => 9,
27 - '10' => 10,
28 - '11' => 11,
29 - '12' => 12,
30 - '13' => 13,
31 - '14' => 14,
32 - '15' => 15,
33 - '16' => 16,
34 - '17' => 17,
35 - '18' => 18,
36 - '19' => 19,
37 - '20' => 20,
26 + '1' => 1,
27 + '2' => 2,
28 + '3' => 3,
29 + '4' => 4,
30 + '5' => 5,
31 + '6' => 6,
32 + '7' => 7,
33 + '8' => 8,
34 + '9' => 9,
35 + '10' => 10,
38 36 ]
39 37 ];
40 38
41 39 $this->error_not_found = esc_html__('Not found.', 'photonic');
42 40 $this->error_mandatory = esc_html__('Please fill the mandatory fields. Mandatory fields are marked with a red "*".', 'photonic');
41 + $this->error_unauthorized = esc_html__('This action is unauthorized. Please ensure that you are logged in and refresh your page if necessary', 'photonic');
43 42 }
44 43
45 44 /**
46 45 * Gets contents of the second screen for a given provider. The second screen contains the type of content to display for a source.
@@ -45,46 +44,46 @@
45 44 /**
46 45 * Gets contents of the second screen for a given provider. The second screen contains the type of content to display for a source.
47 46 * E.g. "Multiple photos", "Photos in an album" etc.
48 47 *
49 - * @return mixed
48 + * @return array
50 49 */
51 - abstract function get_screen_2();
50 + abstract public function get_screen_2(): array;
52 51
53 52 /**
54 53 * Gets contents of the third screen for a given provider. This screen contains the photos, albums etc. resultant from Screen 2.
55 54 *
56 - * @return mixed
55 + * @return array
57 56 */
58 - abstract function get_screen_3();
57 + abstract public function get_screen_3(): array;
59 58
60 59 /**
61 60 * Shows the layout selection screen.
62 61 *
63 - * @return mixed
62 + * @return array
64 63 */
65 - abstract function get_screen_4();
64 + abstract public function get_screen_4(): array;
66 65
67 66 /**
68 67 * Shows layout-specific options for the gallery.
69 68 *
70 - * @return mixed
69 + * @return array
71 70 */
72 - abstract function get_screen_5();
71 + abstract public function get_screen_5(): array;
73 72
74 73 /**
75 74 * Add the thumbnail sizes to the screen for the square, circle and slideshow layouts
76 75 *
77 - * @return mixed
76 + * @return array
78 77 */
79 - abstract function get_square_size_options();
78 + abstract public function get_square_size_options(): array;
80 79
81 80 /**
82 81 * Add the tile sizes to the screen for the random (justified grid), masonry and mosaic layouts
83 82 *
84 - * @return mixed
83 + * @return array
85 84 */
86 - abstract function get_random_size_options();
85 + abstract public function get_random_size_options(): array;
87 86
88 87 /**
89 88 * Makes a request to a provider to fetch the contents to be displayed within the Wizard.
90 89 *
@@ -90,11 +89,11 @@
90 89 *
91 90 * @param $display_type
92 91 * @param $for
93 92 * @param $flattened_fields
94 - * @return mixed
93 + * @return array
95 94 */
96 - abstract function make_request($display_type, $for, $flattened_fields);
95 + abstract public function make_request($display_type, $for, $flattened_fields): array;
97 96
98 97 /**
99 98 * Parses the response from the provider when then wizard tries to get content from it.
100 99 *
@@ -101,141 +100,200 @@
101 100 * @param $response
102 101 * @param $display_type
103 102 * @param null $url
104 103 * @param array $pagination
105 - * @return mixed
104 + * @return array
106 105 */
107 - abstract function process_response($response, $display_type, $url = null, &$pagination = []);
106 + abstract public function process_response($response, $display_type, $url = null, &$pagination = []): array;
108 107
109 108 /**
110 109 * @param $display_type
111 - * @return mixed
110 + * @return array
112 111 */
113 - abstract function construct_shortcode_from_screen_selections($display_type);
112 + abstract public function construct_shortcode_from_screen_selections($display_type): array;
114 113
115 114 /**
116 - * @return mixed
115 + * @param $input
116 + * @return array
117 117 */
118 - abstract function deconstruct_shortcode_to_screen_selections($input);
118 + abstract public function deconstruct_shortcode_to_screen_selections($input): array;
119 119
120 - private function get_title_position_options() {
120 + private function get_title_position_options(): array {
121 121 $ret = [
122 - '' => $this->default_from_settings,
123 - 'regular' => esc_html__('Normal title display using the HTML "title" attribute', 'photonic'),
124 - 'below' => esc_html__('Below the thumbnail', 'photonic'),
125 - 'tooltip' => esc_html__('Using a JavaScript tooltip', 'photonic'),
122 + '' => $this->default_from_settings,
123 + 'regular' => esc_html__('Normal title display using the HTML "title" attribute', 'photonic'),
124 + 'below' => esc_html__('Below the thumbnail', 'photonic'),
125 + 'tooltip' => esc_html__('Using a JavaScript tooltip', 'photonic'),
126 126 'hover-slideup-show' => esc_html__('Slide up from bottom upon hover', 'photonic'),
127 - 'slideup-stick' => esc_html__('Cover the lower portion always', 'photonic'),
128 - 'none' => esc_html__('No title', 'photonic'),
127 + 'slideup-stick' => esc_html__('Cover the lower portion always', 'photonic'),
128 + 'none' => esc_html__('No title', 'photonic'),
129 129 ];
130 130
131 131 return [
132 - 'desc' => esc_html__('How do you want the title?', 'photonic'),
133 - 'type' => 'select',
132 + 'desc' => esc_html__('How do you want the title?', 'photonic'),
133 + 'type' => 'select',
134 134 'options' => $ret,
135 - 'std' => '',
135 + 'std' => '',
136 136 ];
137 137 }
138 138
139 - function get_slideshow_options() {
139 + public function get_slideshow_options(): array {
140 140 global $photonic_thumbnail_style;
141 141 return [
142 142 'slideshow-style' => [
143 - 'desc' => esc_html__('Slideshow display style', 'photonic'),
144 - 'type' => 'image-select',
143 + 'desc' => esc_html__('Slideshow display style', 'photonic'),
144 + 'type' => 'image-select',
145 145 'options' => [
146 146 'strip-below' => esc_html__('Thumbnail strip or buttons below slideshow', 'photonic'),
147 147 'strip-above' => esc_html__('Thumbnail strip above slideshow', 'photonic'),
148 - 'strip-right' => esc_html__('Thumbnail strip to the right of slideshow', 'photonic'),
149 - 'no-strip' => esc_html__('No thumbnails or buttons for the slideshow', 'photonic'),
148 + 'strip-right' => esc_html__('OBSOLETE - Thumbnail strip to the right of slideshow - will now default to a strip below the slides', 'photonic'),
149 + 'no-strip' => esc_html__('No thumbnails or buttons for the slideshow', 'photonic'),
150 150 ],
151 - 'std' => $photonic_thumbnail_style,
151 + 'std' => $photonic_thumbnail_style,
152 152 ],
153 - 'strip-style' => [
154 - 'desc' => esc_html__('Thumbnails or buttons for the strip?', 'photonic'),
155 - 'type' => 'image-select',
153 + 'strip-style' => [
154 + 'desc' => esc_html__('Thumbnails or buttons for the strip?', 'photonic'),
155 + 'type' => 'image-select',
156 156 'options' => [
157 157 'thumbs' => esc_html__('Thumbnails', 'photonic'),
158 158 'button' => esc_html__('Buttons', 'photonic'),
159 159 ],
160 - 'hint' => esc_html__('If you choose "Buttons" those are only shown below the slideshow.', 'photonic'),
161 - 'std' => 'thumbs',
160 + 'hint' => esc_html__('If you choose "Buttons" those are only shown below the slideshow.', 'photonic'),
161 + 'std' => 'thumbs',
162 162 ],
163 - 'controls' => [
164 - 'desc' => esc_html__('Slideshow Controls', 'photonic'),
165 - 'type' => 'select',
163 + 'controls' => [
164 + 'desc' => esc_html__('Slideshow Controls', 'photonic'),
165 + 'type' => 'select',
166 166 'options' => [
167 167 'hide' => esc_html__('Hide', 'photonic'),
168 168 'show' => esc_html__('Show', 'photonic'),
169 169 ],
170 - 'hint' => esc_html__('Shows Previous and Next buttons on the slideshow.', 'photonic'),
170 + 'std' => 'show',
171 + 'hint' => esc_html__('Shows Previous and Next buttons on the slideshow.', 'photonic'),
171 172 ],
172 - 'fx' => [
173 - 'desc' => esc_html__('Slideshow Effects', 'photonic'),
174 - 'type' => 'select',
173 + 'fx' => [
174 + 'desc' => esc_html__('Slideshow Effects', 'photonic'),
175 + 'type' => 'select',
175 176 'options' => [
176 - 'fade' => esc_html__('Fade', 'photonic'),
177 + 'fade' => esc_html__('Fade', 'photonic'),
177 178 'slide' => esc_html__('Slide', 'photonic'),
178 179 ],
179 - 'hint' => esc_html__('Determines if a photo in a slideshow should fade in or slide in.', 'photonic')
180 + 'hint' => esc_html__('Determines if a photo in a slideshow should fade in or slide in.', 'photonic')
180 181 ],
181 - 'timeout' => [
182 + 'timeout' => [
182 183 'desc' => esc_html__('Time between slides in ms', 'photonic'),
183 184 'type' => 'text',
184 - 'std' => '',
185 + 'std' => '',
185 186 'hint' => esc_html__('Please enter numbers only', 'photonic')
186 187 ],
187 - 'speed' => [
188 + 'speed' => [
188 189 'desc' => esc_html__('Time for each transition in ms', 'photonic'),
189 190 'type' => 'text',
190 - 'std' => '',
191 + 'std' => '',
191 192 'hint' => esc_html__('How fast do you want the fade or slide effect to happen?', 'photonic')
192 193 ],
193 - 'pause' => [
194 - 'desc' => esc_html__('Pause upon hover?', 'photonic'),
195 - 'type' => 'select',
194 + 'pause' => [
195 + 'desc' => esc_html__('Pause upon hover?', 'photonic'),
196 + 'type' => 'select',
196 197 'options' => [
197 198 '0' => esc_html__('No', 'photonic'),
198 199 '1' => esc_html__('Yes', 'photonic'),
199 200 ],
200 - 'hint' => esc_html__('Should the slideshow pause when you hover over it?', 'photonic')
201 + 'std' => '1',
202 + 'hint' => esc_html__('Should the slideshow pause when you hover over it?', 'photonic')
201 203 ],
202 - 'columns' => [
203 - 'desc' => esc_html__('Number of columns in slideshow', 'photonic'),
204 - 'type' => 'select',
204 + 'columns' => [
205 + 'desc' => esc_html__('Number of columns in slideshow', 'photonic'),
206 + 'type' => 'select',
205 207 'options' => [
206 - '' => '',
207 - '1' => 1,
208 - '2' => 2,
209 - '3' => 3,
210 - '4' => 4,
211 - '5' => 5,
212 - '6' => 6,
213 - '7' => 7,
214 - '8' => 8,
215 - '9' => 9,
208 + '' => '',
209 + '1' => 1,
210 + '2' => 2,
211 + '3' => 3,
212 + '4' => 4,
213 + '5' => 5,
214 + '6' => 6,
215 + '7' => 7,
216 + '8' => 8,
217 + '9' => 9,
216 218 '10' => 10,
217 219 ],
218 - 'hint' => esc_html__('Pick > 1 for a carousel', 'photonic'),
220 + 'hint' => esc_html__('Pick > 1 for a carousel', 'photonic'),
219 221 ],
222 + 'title_position' => $this->get_title_position_options(),
220 223 ];
221 224 }
222 225
223 - function get_square_layout_options() {
226 + public function get_square_layout_options(): array {
224 227 return [
225 - 'columns' => $this->column_options,
226 - $this->provider => $this->get_square_size_options(),
228 + 'columns' => $this->column_options,
229 + $this->provider => $this->get_square_size_options(),
227 230 'title_position' => $this->get_title_position_options(),
231 + 'load_mode' => $this->get_load_mode_options(),
228 232 ];
229 233 }
230 234
231 - function get_random_layout_options() {
235 + public function get_random_layout_options(): array {
232 236 return [
233 - $this->provider => $this->get_random_size_options(),
237 + $this->provider => $this->get_random_size_options(),
234 238 'title_position' => $this->get_title_position_options(),
239 + 'load_mode' => $this->get_load_mode_options(),
240 + 'layout_engine' => $this->get_layout_engine_options(),
235 241 ];
236 242 }
237 243
238 - function get_column_options() {
244 + public function get_column_options(): array {
239 245 return $this->column_options;
240 246 }
241 -}
247 +
248 + public function get_header_options($conditions = null): array {
249 + $options = [
250 + 'desc' => esc_html__('Show Header', 'photonic'),
251 + 'type' => 'select',
252 + 'options' => [
253 + '' => $this->default_from_settings,
254 + 'none' => esc_html__('No header', 'photonic'),
255 + 'title' => esc_html__('Title only', 'photonic'),
256 + 'thumbnail' => esc_html__('Thumbnail only', 'photonic'),
257 + 'counter' => esc_html__('Counts only', 'photonic'),
258 + 'title,counter' => esc_html__('Title and counts', 'photonic'),
259 + 'thumbnail,counter' => esc_html__('Thumbnail and counts', 'photonic'),
260 + 'thumbnail,title' => esc_html__('Thumbnail and title', 'photonic'),
261 + 'thumbnail,title,counter' => esc_html__('Thumbnail, title and counts', 'photonic'),
262 + ],
263 + ];
264 + if (!empty($conditions)) {
265 + $options['conditions'] = $conditions;
266 + }
267 + return $options;
268 + }
269 +
270 + /**
271 + * @return array
272 + */
273 + private function get_load_mode_options(): array {
274 + global $photonic_load_mode;
275 + return [
276 + 'desc' => esc_html__('Gallery loading mode', 'photonic'),
277 + 'type' => 'select',
278 + 'options' => [
279 + '' => $this->default_from_settings . ' - ' . $photonic_load_mode,
280 + 'php' => esc_attr__('PHP Mode – Gallery markup is generated by your server before your page is sent to the browser.', 'photonic'),
281 + 'js' => esc_attr__('JavaScript Mode – Gallery markup is generated by your server after your page is sent to the browser.', 'photonic'),
282 + ],
283 + 'hint' => esc_html__('You can configure Photonic to generate the galleries as a part of your page generation (PHP mode), or after your page has generated and rendered on the site user\'s browser (JS mode). The PHP mode makes your galleries crawl-able by search engines, and the JS mode helps your page load faster (the gallery shows up once it is ready). The JS mode helps if you want to use caching plugins with Google Photos setups.', 'photonic'),
284 + ];
285 + }
286 +
287 + private function get_layout_engine_options(): array {
288 + return [
289 + 'desc' => esc_html__('Gallery layout processing engine', 'photonic'),
290 + 'type' => 'select',
291 + 'options' => [
292 + '' => $this->default_from_settings,
293 + 'css' => esc_attr__('Use CSS to render the gallery.', 'photonic'),
294 + 'js' => esc_attr__('Use JS to render the gallery.', 'photonic'),
295 + ],
296 + 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; &lt;Platform&gt; &rarr; &lt;Platform&gt; Settings &rarr; Layout Processing Mode</em>'),
297 + ];
298 + }
299 +}