PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.1.0
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.1.0
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
wpvr / legacy / breakdance / elements / Wpvr / ssr.php

ssr.php in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 9.1.0, at legacy/breakdance/elements/Wpvr/ssr.php

54 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Server-side renderer for the WP VR Breakdance element.
5 *
6 * @var array $propertiesData
7 */
8
9 $settings = $propertiesData['content']['wpvr'] ?? [];
10 $tour_id = absint( $settings['tour'] ?? 0 );
11
12 if ( ! $tour_id ) {
13 echo '<p>' . esc_html__( 'No tour has been selected.', 'wpvr' ) . '</p>';
14 return true;
15 }
16
17 $to_pixels = static function ( $value, $default ) {
18 if ( '' === $value || null === $value || ! is_numeric( $value ) ) {
19 $value = $default;
20 }
21
22 return max( 0, (float) $value ) . 'px';
23 };
24
25 $width = $to_pixels( $settings['width'] ?? null, 600 );
26 $height = $to_pixels( $settings['height'] ?? null, 400 );
27 $mobile_height = $to_pixels( $settings['mobile_height'] ?? null, 300 );
28 $radius = $to_pixels( $settings['radius'] ?? null, 0 );
29
30 $shortcode = sprintf(
31 '[wpvr id="%d" width="%s" height="%s" mobile_height="%s" radius="%s"]',
32 $tour_id,
33 esc_attr( $width ),
34 esc_attr( $height ),
35 esc_attr( $mobile_height ),
36 esc_attr( $radius )
37 );
38
39 $html = do_shortcode( $shortcode );
40
41 if ( function_exists( '\Breakdance\isRequestFromBuilderSsr' ) && \Breakdance\isRequestFromBuilderSsr() ) {
42 // Scripts inserted through Breakdance's AJAX SSR are inert. The element's
43 // builder action executes these after its preview dependencies are ready.
44 $html = str_replace(
45 '<script>',
46 '<script type="application/wpvr-breakdance-preview">',
47 $html
48 );
49 }
50
51 echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
52
53 return true;
54