| 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 |
|