PluginProbe
Panorama – Turn Photos into Immersive Virtual Tours / 1.7.2
Panorama – Turn Photos into Immersive Virtual Tours v1.7.2
1.8.0 1.7.4 1.7.3 1.7.2 1.7.1 1.7.0 1.6.1 trunk 1.0.0 1.0.1 1.0.10 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.3 1.1.4 1.1.5 1.1.6 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 All 38 releases
panorama / shortcode.php

shortcode.php in Panorama – Turn Photos into Immersive Virtual Tours 1.7.2, at shortcode.php

97 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 // Shortcode for Panorama (free).
6
7 function bppiv_image_viewer( $atts ) {
8 $atts = shortcode_atts( array( 'id' => 0 ), $atts, 'panorama' );
9 $id = absint( $atts['id'] );
10
11 if ( ! $id ) {
12 return '';
13 }
14
15 $bppiv_block = null;
16 // Check Post-Type.
17 $post_type = get_post_type( $id );
18 if ( 'bppiv-image-viewer' !== $post_type ) {
19 return '';
20 }
21 // Meta Data.
22 $bppiv_meta = get_post_meta( $id, '_bppivimages_', true );
23 if ( ! is_array( $bppiv_meta ) ) {
24 $bppiv_meta = array();
25 }
26
27 $bppiv_width = '100%';
28 $bppiv_height = '320px';
29
30 if ( isset( $bppiv_meta['bppiv_image_width']['width'] ) ) {
31 $bppiv_width = $bppiv_meta['bppiv_image_width']['width'] . $bppiv_meta['bppiv_image_width']['unit'];
32 }
33 if ( isset( $bppiv_meta['bppiv_image_height']['height'] ) ) {
34 $bppiv_height = $bppiv_meta['bppiv_image_height']['height'] . $bppiv_meta['bppiv_image_height']['unit'];
35 }
36
37 $pan_type = isset( $bppiv_meta['bppiv_type'] ) ? sanitize_key( $bppiv_meta['bppiv_type'] ) : '';
38 $get_value = bppiv_isset( $bppiv_meta );
39
40 if ( file_exists( BPPIV_PATH . "blocks/{$pan_type}.php" ) ) {
41 include BPPIV_PATH . "blocks/{$pan_type}.php";
42 }
43
44 return render_block( $bppiv_block );
45 }
46 add_shortcode( 'panorama', 'bppiv_image_viewer' );
47
48
49 // Shortcode for Product Spot Panorama viewer.
50 function bppiv_panorama_product_viewer_callback( $attrs ) {
51
52 ob_start();
53
54 $meta = get_post_meta( get_the_ID(), '_bppiv_product_', true );
55 if ( ! is_array( $meta ) ) {
56 return '';
57 }
58
59 $video360 = isset( $meta['video360'] ) ? $meta['video360'] : '0';
60 $type = isset( $meta['type'] ) ? sanitize_key( $meta['type'] ) : '';
61
62 if ( '1' === $video360 && 'video' === $type ) {
63 wp_enqueue_script( 'bppiv-panolens' );
64 } elseif ( 'image' === $type ) {
65 wp_enqueue_script( 'bppiv-pannellum-js' );
66 wp_enqueue_style( 'bppiv-pannellum-css' );
67 }
68
69 wp_enqueue_script( 'bppiv-product' );
70 wp_enqueue_style( 'bppiv-product' );
71
72 $attributes = '';
73 if ( ! empty( $meta['video_autoplay'] ) ) {
74 $attributes .= ' autoplay';
75 }
76 if ( ! empty( $meta['video_mute'] ) ) {
77 $attributes .= ' muted';
78 }
79 if ( ! empty( $meta['video_loop'] ) ) {
80 $attributes .= ' loop';
81 }
82 if ( ! empty( $meta['video_show_controls'] ) ) {
83 $attributes .= ' controls';
84 }
85
86 $video_src = isset( $meta['video_src'] ) ? esc_url( $meta['video_src'] ) : '';
87 ?>
88 <div id="bppiv_product_panorama" data-settings="<?php echo esc_attr( wp_json_encode( $meta ) ); ?>">
89 <?php if ( 'video' === $type && '0' === $video360 ) : ?>
90 <video style="max-width: 100%;" <?php echo esc_attr( $attributes ); ?> src="<?php echo esc_url( $video_src ); ?>"></video>
91 <?php endif; ?>
92 </div>
93 <?php
94 return ob_get_clean();
95 }
96 add_shortcode( 'panorama_product_viewer', 'bppiv_panorama_product_viewer_callback' );
97