post_type || 'publish' !== $post->post_status ) { status_header( 404 ); exit; } $show_embed = (bool) get_post_meta( $post_id, '_breznflow_show_embed', true ); if ( ! $show_embed ) { status_header( 403 ); exit; } $raw_json = get_post_meta( $post_id, '_breznflow_raw_json', true ); if ( ! $raw_json ) { status_header( 404 ); exit; } $workflow = json_decode( $raw_json, true ); if ( ! is_array( $workflow ) ) { status_header( 500 ); exit; } $allowed_themes = \BreznFlow\Features\ThemeRegistry::get_theme_ids(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $url_theme = isset( $_GET['theme'] ) ? sanitize_text_field( wp_unslash( $_GET['theme'] ) ) : ''; $theme = in_array( $url_theme, $allowed_themes, true ) ? $url_theme : ( $settings['default_theme'] ?? 'dark' ); $theme = in_array( $theme, $allowed_themes, true ) ? $theme : 'dark'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- public read-only embed page, no state change. $show_minimap_embed = isset( $_GET['minimap'] ) ? ( '0' !== sanitize_text_field( wp_unslash( $_GET['minimap'] ) ) ) : true; $body_bgs = array( 'dark' => '#1a1a2e', 'light' => '#eef2f7', 'minimal' => '#fafafa', 'tech' => '#0d1117', 'brezn' => '#001f4d', ); $body_bg = $body_bgs[ $theme ] ?? '#1a1a2e'; // Set headers. header( 'Content-Type: text/html; charset=utf-8' ); header( 'X-Robots-Tag: noindex, nofollow' ); header( 'X-Content-Type-Options: nosniff' ); header_remove( 'X-Frame-Options' ); $article_url = esc_url( get_permalink( $post_id ) ); $anchor_id = 'breznflow-' . $post_id; $blog_name = esc_html( get_bloginfo( 'name' ) ); $blog_url = esc_url( home_url( '/' ) ); $title = esc_html( $post->post_title ); $css_url = esc_url( BREZNFLOW_URL . 'assets/renderer.css' ) . '?v=' . BREZNFLOW_VERSION; $js_url = esc_url( BREZNFLOW_URL . 'assets/renderer.js' ) . '?v=' . BREZNFLOW_VERSION; $inline_data = array( array( 'id' => $post_id, 'workflow' => $workflow, 'mode' => 'visual', 'zoom' => 100, 'autofit_threshold' => (int) ( $settings['autofit_threshold'] ?? 30 ), 'show_title' => false, 'show_infobox' => false, 'show_download' => false, 'show_minimap' => $show_minimap_embed, 'show_share' => false, 'show_embed' => false, 'show_get_json' => false, 'max_code_lines' => (int) ( $settings['max_code_lines'] ?? 50 ), 'download_label' => '', 'download_url' => '', 'theme' => $theme, ), ); $icons_json = wp_json_encode( Features\NodeTypeRegistry::get_registry() ); $data_json = wp_json_encode( $inline_data ); $i18n_json = wp_json_encode( Shortcode::get_js_i18n() ); // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- intentional standalone HTML output; all dynamic values escaped above ?>