PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.1.3
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.1.3
9.1.3 9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 8.5.37 8.5.38 8.5.39 All 222 releases
← All changes | legacy/public/classes/class-wpvr-shortcode.php +41 -4 9.0.29.1.3 View file →
@@ -58,11 +58,25 @@
58 58 $this->plugin_name = $plugin_name;
59 59 $this->streetview = new WPVR_StreetView();
60 60 $this->video = new WPVR_Video();
61 61 $this->scene = new WPVR_Scene();
62 +
63 + add_filter('no_texturize_shortcodes', array($this, 'no_texturize_wpvr_shortcode'));
62 64 }
63 65
64 66 /**
67 + * Prevent WordPress wptexturize from corrupting [wpvr] shortcode content
68 + *
69 + * @param array $tags
70 + * @return array
71 + */
72 + public function no_texturize_wpvr_shortcode($tags)
73 + {
74 + $tags[] = 'wpvr';
75 + return $tags;
76 + }
77 +
78 + /**
65 79 * Shortcode output for the plugin
66 80 *
67 81 * @param array $atts
68 82 *
@@ -181,18 +195,23 @@
181 195 }
182 196
183 197 $postdata = get_post_meta($id, 'panodata', true);
184 198 $postdata = is_array( $postdata ) ? wpvr_get_effective_panodata( $postdata ) : [];
185 - $panoid = 'pano'.$id;
186 199
187 - if (isset($postdata['streetviewdata'])){
200 + static $tour_instances = array();
201 + $tour_instances[$id] = isset($tour_instances[$id]) ? $tour_instances[$id] + 1 : 1;
202 + $instance_num = $tour_instances[$id];
203 + $panoid = ($instance_num === 1) ? ('pano' . $id) : ('pano' . $id . '_' . $instance_num);
204 +
205 + $tour_type = isset( $postdata['tour-type'] ) ? $postdata['tour-type'] : '';
206 +
207 + if ( $tour_type === 'street-view' || ( $tour_type === '' && isset( $postdata['streetviewdata'] ) ) ) {
188 208 wpvr_enqueue_frontend_scripts( 'streetview' );
189 209 $html = $this->streetview->render_streetview_shortcode($postdata, $width, $height);
190 210 return $html;
191 211 }
192 212
193 -
194 - if (isset($postdata['vidid'])) {
213 + if ( $tour_type === 'video' || ( $tour_type === '' && ( ! empty( $postdata['vidid'] ) || ! empty( $postdata['vidurl'] ) ) ) ) {
195 214 wpvr_enqueue_frontend_scripts( 'video' );
196 215 $html = $this->video->render_video_shortcode($postdata, $id, $width, $height, $radius);
197 216 return $html;
198 217 }
@@ -198,7 +217,25 @@
198 217 }
199 218
200 219 wpvr_enqueue_frontend_scripts( 'scene' );
201 220 $html = $this->scene->render_scene_shortcode($postdata, $panoid, $id, $radius, $width, $height, $mobile_height);
221 +
222 + // Extract any <script> tags so they are not corrupted by wptexturize or the_content filters
223 + $scripts = '';
224 + if (preg_match_all('/<script\b[^>]*>[\s\S]*?<\/script>/i', $html, $matches)) {
225 + $scripts = implode("\n", $matches[0]);
226 + $html = preg_replace('/<script\b[^>]*>[\s\S]*?<\/script>/i', '', $html);
227 + }
228 +
229 + if (!empty($scripts)) {
230 + if (wp_doing_ajax() || (defined('REST_REQUEST') && REST_REQUEST) || did_action('wp_footer') || get_query_var('embed_page') || isset($_GET['embed_page'])) {
231 + $html .= "\n" . $scripts;
232 + } else {
233 + add_action('wp_footer', function() use ($scripts) {
234 + echo $scripts; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
235 + }, 20);
236 + }
237 + }
238 +
202 239 return $html;
203 240 }
204 241 }