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

Screen_Flow.php in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 3.36, at Admin/Wizard/Screen_Flow.php

147 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Photonic_Plugin\Admin\Wizard;
4
5 /**
6 * Contains the flow layout skeleton. Cannot be overridden by a theme file
7 *
8 * Screen 1: Provider selection
9 * Screen 2: Display Type selection; input: Provider
10 * Screen 3: Gallery selection; input: Display Type
11 * Screen 4: Layout selection; input: Gallery & Display Type
12 *
13 * @since 2.00
14 */
15
16 if (!current_user_can('edit_posts')) {
17 wp_die(esc_html__('You are not authorized to use this capability.', 'photonic'));
18 }
19
20 class Screen_Flow {
21 private array $editor_shortcode;
22 private $input_shortcode;
23 private ?string $editor_shortcode_text;
24
25 public function __construct() {
26 if (wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['nonce'] ?? '')), 'photonic-wizard-' . get_current_user_id())) {
27 if (isset($_REQUEST['shortcode'])) {
28 $this->input_shortcode = sanitize_text_field($_REQUEST['shortcode']);
29 $this->input_shortcode = base64_decode($this->input_shortcode); // The in-flight shortcode is passed from screen to screen using the JS function `btoa`, in wizard.js, which encodes it
30 $this->input_shortcode = json_decode($this->input_shortcode);
31 }
32
33 $this->editor_shortcode = [
34 'provider' => '',
35 ];
36
37 if (!empty($this->input_shortcode) && !empty($this->input_shortcode->shortcode)) {
38 $this->editor_shortcode_text = esc_attr($this->input_shortcode->content);
39 $shortcode = $this->input_shortcode->shortcode;
40 $attrs = $shortcode->attrs;
41 $attrs = $attrs->named;
42 if ((!empty($attrs->type) && in_array($attrs->type, ['wp', 'flickr', 'smugmug', 'zenfolio', 'deviantart'], true)) ||
43 (empty($attrs->type) && !empty($attrs->style)) && in_array($attrs->style, ['square', 'circle', 'random', 'masonry', 'masonry-horizontal', 'mosaic', 'strip-above', 'strip-below', 'strip-right', 'no-strip'], true)) {
44 $this->editor_shortcode['provider'] = !empty($attrs->type) ? $attrs->type : 'wp';
45 }
46 }
47 }
48 }
49
50 public function render() {
51 if (wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['nonce'] ?? '')), 'photonic-wizard-' . get_current_user_id())) {
52 ?>
53 <div id="photonic-flow-wrapper" data-current-screen="1">
54 <form id="photonic-flow" data-photonic-submission="" data-photonic-submission-pending="">
55 <input type="hidden" name="post_id" value="<?php echo esc_attr(sanitize_text_field(wp_unslash($_REQUEST['post_id'] ?? 0))); ?>"/>
56 <input name="photonic-editor-shortcode" id="photonic-editor-shortcode" type="hidden"
57 value="<?php echo !empty($this->editor_shortcode_text) ? esc_attr($this->editor_shortcode_text) : ''; ?>"/>
58 <input name="photonic-editor-shortcode-raw" id="photonic-editor-shortcode-raw" type="hidden"
59 value="<?php echo !empty($_REQUEST['shortcode']) ? esc_attr($_REQUEST['shortcode']) : ''; ?>"/>
60 <input name="photonic-editor-json" id="photonic-editor-json" type="hidden" value=""/>
61 <input name="photonic-gutenberg-active" id="photonic-gutenberg-active" type="hidden" value=""/>
62
63 <div id="photonic-flow-provider" class="photonic-flow-screen photonic-gallery" data-screen="1">
64 <!-- Provider selection -->
65 <h1><?php esc_html_e('Choose Gallery Source', 'photonic'); ?></h1>
66 <div class='photonic-flow-selector-container photonic-flow-provider'
67 data-photonic-flow-selector-mode='single-no-plus' data-photonic-flow-selector-for="provider">
68 <input type="hidden" id="provider" name="provider"
69 value="<?php echo esc_attr($this->editor_shortcode['provider']); ?>"/>
70
71 <?php
72 $providers = [
73 'wp' => 'WordPress',
74 'flickr' => 'Flickr',
75 'smugmug' => 'SmugMug',
76 // 'google' => 'Google Photos',
77 'zenfolio' => 'Zenfolio',
78 // 'instagram' => 'Instagram',
79 // 'deviantart' => 'DeviantArt',
80 ];
81 foreach ($providers as $provider => $desc) {
82 ?>
83 <div class="photonic-flow-selector photonic-flow-provider-<?php echo esc_attr($provider); ?> <?php echo $provider === $this->editor_shortcode['provider'] ? 'selected' : ''; ?>"
84 title="<?php echo esc_attr($desc); ?>">
85 <span class="photonic-flow-selector-inner photonic-provider"
86 data-photonic-selection-id="<?php echo esc_attr($provider); ?>">&nbsp;</span>
87 <div class='photonic-flow-selector-info'><?php echo wp_kses_post($desc); ?></div>
88 </div>
89 <?php
90 }
91 ?>
92
93 </div>
94 <div class="photonic-editor-info">
95 <?php
96 if (empty($this->editor_shortcode_text)) {
97 echo '<div>' . sprintf(esc_html__('%1$sHint:%2$s To edit an existing shortcode select the shortcode before clicking on the "Add / Edit Photonic Gallery" button.', 'photonic'), '<strong>', '</strong>') . '</div>';
98 }
99 ?>
100 </div>
101 </div>
102
103 <!-- "Display Type" selection -->
104 <div class="photonic-flow-screen" data-submitted="" data-screen="2">
105 </div>
106
107 <!-- Gallery Builder -->
108 <div class="photonic-flow-screen" data-submitted="" data-screen="3">
109 </div>
110
111 <!-- Layout Selection -->
112 <div class="photonic-flow-screen" data-submitted="" data-screen="4">
113 </div>
114
115 <!-- Layout Options -->
116 <div class="photonic-flow-screen" data-submitted="" data-screen="5">
117 </div>
118
119 <!-- Final shortcode -->
120 <div class="photonic-flow-screen" data-submitted="" data-screen="6">
121 </div>
122
123 <div id="photonic-flow-navigation" class="photonic-flow-navigation">
124 <?php
125 $user = get_current_user_id();
126 if (0 === $user) {
127 $user = wp_rand(1);
128 }
129 $nonce = wp_create_nonce('photonic-wizard-next-' . $user);
130 ?>
131 <a href="#" id="photonic-nav-previous" class="previous disabled">Previous</a>
132 <a href="#" id="photonic-nav-next" class="next" data-photonic-nonce="<?php echo esc_attr($nonce); ?>">Next</a>
133 </div>
134
135 <input type="hidden" id="selected_data" name="selected_data"/>
136 <input type="hidden" id="selection_passworded" name="selection_passworded"/>
137 </form>
138 </div>
139 <div class="photonic-waiting"></div>
140 <?php
141 }
142 }
143 }
144
145 $photonic_screen_flow = new Screen_Flow();
146 $photonic_screen_flow->render();
147