PluginProbe
Panorama – Turn Photos into Immersive Virtual Tours / trunk
Panorama – Turn Photos into Immersive Virtual Tours vtrunk
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 trunk, at shortcode.php

54 lines 1.9 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 (Pro Feature).
50 function bppiv_panorama_product_viewer_callback( $attrs ) {
51 return '<div class="bppiv-pro-shortcode-notice" style="padding: 12px 16px; background: #fff8f6; border-left: 4px solid #cf222e; border-radius: 4px; font-size: 13px; color: #cf222e;">' . esc_html__( 'Product shortcode is a Pro feature. Please upgrade to Panorama Viewer Pro to use this shortcode.', 'panorama' ) . '</div>';
52 }
53 add_shortcode( 'panorama_product_viewer', 'bppiv_panorama_product_viewer_callback' );
54