|string $atts Shortcode attributes * @return string|false Rendered HTML or false on failure */ public function renderModelViewer($atts) { $atts = shortcode_atts([ 'id' => '', ], $atts); $id = absint($atts['id']); if (!$id) { return false; } $post_type = get_post_type($id); $isGutenberg = get_post_meta($id, '_bp3d_is_gutenberg', true); if ($isGutenberg === '') { $isGutenberg = get_post_meta($id, 'isGutenberg', true); } if (!in_array($post_type, ['bp3d-model-viewer', 'product'], true) || !self::isViewable((int) $id)) { return false; } if ($isGutenberg) { return Block::instance()->render_block((int) $id); } ob_start(); $meta = Utils::getPostMeta((int) $id, '_bp3dimages_'); $finalData = Utils::buildViewerAttributes($meta, $id); /** @var array $finalData */ $finalData = apply_filters('bp3d_classic_model_attribute', $finalData); $model_url = $finalData['model']['modelUrl'] ?? ''; ?>
|string $attrs Shortcode attributes * @return string|false Rendered HTML or false on failure */ public function renderProductModelViewer($attrs) { $attrs = shortcode_atts([ 'id' => (string) get_the_ID(), ], $attrs); $id = absint($attrs['id']); if (get_post_type($id) !== 'product' || !function_exists('wc_get_product')) { return false; } // The model comes from the product named by id, not from the page the shortcode sits on. global $product; $current = $product; $product = wc_get_product($id); $html = Product::instance()->get_3d_model_html(true, 'shortcode'); $product = $current; return $html; } }