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/Screen_Flow.php +64 -44 2.413.36 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 namespace Photonic_Plugin\Admin\Wizard;
3 4
4 5 /**
5 6 * Contains the flow layout skeleton. Cannot be overridden by a theme file
@@ -16,64 +17,75 @@
16 17 wp_die(esc_html__('You are not authorized to use this capability.', 'photonic'));
17 18 }
18 19
19 20 class Screen_Flow {
20 - var $editor_shortcode, $input_shortcode, $editor_shortcode_text;
21 - function __construct() {
22 - global $photonic_flow_input_shortcode;
23 - if (isset($_REQUEST['shortcode'])) {
24 - $this->input_shortcode = sanitize_text_field($_REQUEST['shortcode']);
25 - $this->input_shortcode = base64_decode($this->input_shortcode);
26 - $this->input_shortcode = json_decode($this->input_shortcode);
27 - }
21 + private array $editor_shortcode;
22 + private $input_shortcode;
23 + private ?string $editor_shortcode_text;
28 24
29 - $this->editor_shortcode = [
30 - 'provider' => '',
31 - ];
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 32
33 - if (!empty($this->input_shortcode) && !empty($this->input_shortcode->shortcode)) {
34 - $this->editor_shortcode_text = esc_attr($this->input_shortcode->content);
35 - $shortcode = $this->input_shortcode->shortcode;
36 - $tag = $shortcode->tag;
37 - $attrs = $shortcode->attrs;
38 - $attrs = $attrs->named;
39 - if ((!empty($attrs->type) && in_array($attrs->type, ['wp', 'flickr', 'smugmug', 'picasa', 'google', 'zenfolio', 'instagram'])) ||
40 - (empty($attrs->type) && !empty($attrs->style)) && in_array($attrs->style, ['square', 'circle', 'random', 'masonry', 'mosaic', 'strip-above', 'strip-below', 'strip-right', 'no-strip'])) {
41 - $this->editor_shortcode['provider'] = !empty($attrs->type) ? $attrs->type : 'wp';
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 + }
42 46 }
43 47 }
44 48 }
45 49
46 - function render() {
47 - ?>
50 + public function render() {
51 + if (wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['nonce'] ?? '')), 'photonic-wizard-' . get_current_user_id())) {
52 + ?>
48 53 <div id="photonic-flow-wrapper" data-current-screen="1">
49 54 <form id="photonic-flow" data-photonic-submission="" data-photonic-submission-pending="">
50 - <input type="hidden" name="post_id" value="<?php echo $_REQUEST['post_id']; ?>"/>
51 - <input name="photonic-editor-shortcode" id="photonic-editor-shortcode" type="hidden" value="<?php echo !empty($this->editor_shortcode_text) ? $this->editor_shortcode_text : ''; ?>" />
52 - <input name="photonic-editor-shortcode-raw" id="photonic-editor-shortcode-raw" type="hidden" value="<?php echo !empty($_REQUEST['shortcode']) ? sanitize_text_field($_REQUEST['shortcode']) : ''; ?>" />
53 - <input name="photonic-editor-json" id="photonic-editor-json" type="hidden" value="" />
54 - <input name="photonic-gutenberg-active" id="photonic-gutenberg-active" type="hidden" value="" />
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 +
55 63 <div id="photonic-flow-provider" class="photonic-flow-screen photonic-gallery" data-screen="1">
56 64 <!-- Provider selection -->
57 65 <h1><?php esc_html_e('Choose Gallery Source', 'photonic'); ?></h1>
58 - <div class='photonic-flow-selector-container photonic-flow-provider' data-photonic-flow-selector-mode='single-no-plus' data-photonic-flow-selector-for="provider">
59 - <input type="hidden" id="provider" name="provider" value="<?php echo $this->editor_shortcode['provider']; ?>"/>
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']); ?>"/>
60 70
61 71 <?php
62 72 $providers = [
63 - 'wp' => 'WordPress',
64 - 'flickr' => 'Flickr',
65 - 'smugmug' => 'SmugMug',
66 -// 'picasa' => 'Picasa',
67 - 'google' => 'Google Photos',
68 - 'zenfolio' => 'Zenfolio',
69 - 'instagram' => 'Instagram',
73 + 'wp' => 'WordPress',
74 + 'flickr' => 'Flickr',
75 + 'smugmug' => 'SmugMug',
76 + // 'google' => 'Google Photos',
77 + 'zenfolio' => 'Zenfolio',
78 + // 'instagram' => 'Instagram',
79 + // 'deviantart' => 'DeviantArt',
70 80 ];
71 81 foreach ($providers as $provider => $desc) {
72 82 ?>
73 - <div class="photonic-flow-selector photonic-flow-provider-<?php echo $provider; ?> <?php echo $provider == $this->editor_shortcode['provider'] ? 'selected' : ''; ?>" title="<?php echo esc_attr($desc);?>">
74 - <span class="photonic-flow-selector-inner photonic-provider" data-photonic-selection-id="<?php echo $provider; ?>">&nbsp;</span>
75 - <div class='photonic-flow-selector-info'><?php echo $desc;?></div>
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>
76 88 </div>
77 89 <?php
78 90 }
79 91 ?>
@@ -81,9 +93,9 @@
81 93 </div>
82 94 <div class="photonic-editor-info">
83 95 <?php
84 96 if (empty($this->editor_shortcode_text)) {
85 - 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>';
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>';
86 98 }
87 99 ?>
88 100 </div>
89 101 </div>
@@ -108,10 +120,17 @@
108 120 <div class="photonic-flow-screen" data-submitted="" data-screen="6">
109 121 </div>
110 122
111 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 + ?>
112 131 <a href="#" id="photonic-nav-previous" class="previous disabled">Previous</a>
113 - <a href="#" id="photonic-nav-next" class="next">Next</a>
132 + <a href="#" id="photonic-nav-next" class="next" data-photonic-nonce="<?php echo esc_attr($nonce); ?>">Next</a>
114 133 </div>
115 134
116 135 <input type="hidden" id="selected_data" name="selected_data"/>
117 136 <input type="hidden" id="selection_passworded" name="selection_passworded"/>
@@ -117,10 +136,11 @@
117 136 <input type="hidden" id="selection_passworded" name="selection_passworded"/>
118 137 </form>
119 138 </div>
120 139 <div class="photonic-waiting"></div>
121 - <?php
140 + <?php
141 + }
122 142 }
123 143 }
124 144
125 -$flow = new Screen_Flow();
126 -$flow->render();
145 +$photonic_screen_flow = new Screen_Flow();
146 +$photonic_screen_flow->render();