tags // Use lookahead/lookbehind to preserve space inside text content $output = preg_replace( '/>\\s+<', $output ); // Also remove leading/trailing whitespace $output = trim( $output ); return $output; } return ''; } add_shortcode( 'dprcu-customizer', 'dprcu_customizer_shortcode' ); /** * Remove wpautop-generated markers from shortcode output. * * Hooked to 'the_content' at priority 12 (after wpautop at priority 10). * This preserves the shortcode output without wpautop interference. */ function dprcu_remove_shortcode_markers( $content ) { // Remove the temporary markers $content = str_replace( '', '', $content ); $content = str_replace( '', '', $content ); return $content; } add_filter( 'the_content', 'dprcu_remove_shortcode_markers', 12 ); /** * Replaces the WooCommerce product image gallery block with the 3D viewer canvas * when the product has Viewer Only Mode enabled. * * Hooked to render_block so it works in both classic and block-based (FSE) themes. * * @param string $block_content The rendered block HTML. * @param array $block The block data array. * @return string */ function dprcu_intercept_gallery_block( $block_content, $block ) { if ( 'woocommerce/product-image-gallery' !== ($block['blockName'] ?? '') ) { return $block_content; } ob_start(); dprcu_viewer_canvas_html(); return ob_get_clean(); } /** * Outputs the full customizer HTML (canvas + sidebar + steps). * Registered conditionally by dprcu_setup_product_hooks(). */ function dprcu_html_output() { global $post; $product_id = $post->ID; $config_json = get_post_meta( $product_id, '_dprcu_customizer_config', true ); $price = get_post_meta( $product_id, '_price', true ); if ( empty( $config_json ) ) { return; } $config_data = json_decode( $config_json, true ); $has_valid_options = false; if ( is_array( $config_data ) ) { foreach ( $config_data as $step ) { if ( !empty( $step['options'] ) ) { $has_valid_options = true; break; } } } if ( !$has_valid_options ) { return; } /** * Fires before the customizer HTML output is rendered. * * @since 3.4.0 * @param int $product_id The current product ID. * @param array $config_data The decoded customizer configuration. */ do_action( 'dprcu_before_customizer_output', $product_id, $config_data ); ?>
 );
?>)