head)) { foreach ($data->head as $elem) { if (property_exists($elem, 'attributes')) { $attrs = get_object_vars($elem->attributes); } else { $attrs = []; } echo "<{$elem->tagName} " . attributes_to_string($attrs) . ">"; if (property_exists($elem, 'innerHTML')) echo $elem->innerHTML; else if (property_exists($elem, 'innerText')) echo $elem->innerText; echo "tagName}>"; } } if (property_exists($data, 'meta') && !empty($data->meta)) { foreach ($data->meta as $elem) { $attrs = get_object_vars($elem->attributes); echo "<{$elem->tagName} " . attributes_to_string($attrs) . ">tagName}>"; } } echo ''; echo ''; } catch (Exception $e) { return; } } function flatten_blocks(array $blocks, array $keys, array $flattened = []) { foreach ($blocks as $block) { if (array_key_exists($keys['detectField'], $block) && $block[$keys['detectField']] === $keys['detectValue']) { $flattened[] = $block; } if (array_key_exists($keys['recursionField'], $block) && !empty($block[$keys['recursionField']])) { $flattened = flatten_blocks($block[$keys['recursionField']], $keys, $flattened); } } return $flattened; } function notice_head() { if (is_front_page()) { global $_wp_current_template_content; $post_content = $_wp_current_template_content; $is_elementor = false; } else { $post = get_post(); if (is_null($post) || empty($post)) return; $post_content = $post->post_content; $post_id = $post->ID; $is_elementor = (bool)get_post_meta($post_id, '_elementor_edit_mode', true); } if ($is_elementor) { $document = Elementor\Plugin::$instance->documents->get($post_id); $blocks = $document->get_elements_raw_data(); if (empty($blocks)) return; $blocks = flatten_blocks($blocks, array( 'detectField' => 'widgetType', 'detectValue' => 'noticefaq', 'recursionField' => 'elements' )); foreach ($blocks as $block) { if (!array_key_exists('project_id', $block['settings'])) continue; $projectId = $block['settings']['project_id']; if (empty($projectId)) continue; add_block_head($projectId); } } else { $blocks = parse_blocks($post_content); $script_injected = false; $blocks = flatten_blocks($blocks, array( 'detectField' => 'blockName', 'detectValue' => 'noticefaq/block', 'recursionField' => 'innerBlocks' )); foreach ($blocks as $block) { // @deprecated (for compatibility) if ($block['blockName'] === 'noticefaq-block/noticefaq' && !$script_injected) { echo ''; $script_injected = true; continue; } if ($block['blockName'] === 'noticefaq/block') { if (!array_key_exists('projectId', $block['attrs'])) continue; $projectId = $block['attrs']['projectId']; if (empty($projectId)) continue; add_block_head($projectId); } } } } Impressum & DSGVO - SanaTopia-Torgau