array(), 'colorMode' => $default_color_mode, ); if ( ! is_array( $index ) ) { return $payload; } // Merge logic strictly for Parts // This populates the array as: 'parts' => [ 'header-global' => { ...node data... } ] . if ( ! empty( $index['parts'] ) && is_array( $index['parts'] ) ) { foreach ( $index['parts'] as $id ) { $template = addifect_get_template( $id ); // Assuming your publish payload saves the root node inside 'blocks'. if ( is_array( $template ) && ! empty( $template['blocks'] ) ) { $payload['parts'][ $id ] = $template['blocks']; } } } $payload = array_merge( $payload, $global_data ); return $payload; } /** * Render Addifect template payload page. */ function addifect_render_template_payload() { $hash = sanitize_text_field( get_query_var( 'addifect_hash' ) ); /** * Clear output buffer to prevent corrupted JSON payload * if other plugins/themes leak whitespace. */ if ( ob_get_length() ) { ob_clean(); } status_header( 200 ); header( 'Pragma: public' ); header( 'Cache-Control: public, max-age=31536000, immutable' ); header( 'Content-Type: text/html; charset=utf-8' ); header( 'X-Content-Type-Options: nosniff' ); header( 'X-Robots-Tag: noindex, nofollow', true ); $payload = array( 'hash' => $hash, 'generated' => time(), 'templates' => addifect_collect_templates_payload(), ); ?> > <?php esc_html_e( 'Addifect Templates', 'addifect' ); ?>