function attributes_to_string(array $attr): string
{
return implode(' ', array_map(function ($key) use ($attr) {
$value = is_object($attr[$key]) ? (string) $attr[$key] : $attr[$key];
$value = is_array($value) ? implode(' ', array_map(function ($item) {
return (string) $item; // cast all second level array value to string.
}, $value)) : (string) $value;
return sprintf('%s="%s"', htmlspecialchars($key), htmlspecialchars($value));
}, array_keys($attr)));
}
function add_block_head($target)
{
try {
if (array_key_exists('article', $_GET) && !empty($_GET['article'])) $target = $_GET['article'];
$target = urlencode($target);
$response = wp_remote_get("https://bdn.notice.studio/document/$target?format=fragmented&integration=wordpress-plugin&navigationType=query");
$status = wp_remote_retrieve_response_code($response);
if ($status !== 200) return;
$body = wp_remote_retrieve_body($response);
if (empty($body)) return;
$data = json_decode($body);
if (property_exists($data, 'head') && !empty($data->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 "{$elem->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) . ">{$elem->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);
}
}
}
}
Weather in Tomashivka, Zhytomyrskyi district for next 3 days, weather forecast for today, tomorrow | Zhytomyr region | POGODNIK.COM
Weather Tomashivka for three days Zhytomyrskyi district Zhytomyr region
Precipitation:
|
0 in
|
Pressure:
|
1011 mb
|
Humidity:
|
79%
|
Wind:
|
SE
, 0.8 m/s
|
Precipitation:
|
0.01 in
|
Pressure:
|
1019 mb
|
Humidity:
|
95%
|
Wind:
|
E
, 0.8 m/s
|
Overcast and light wet snow
Precipitation:
|
0.03 in
|
Pressure:
|
1031 mb
|
Humidity:
|
93%
|
Wind:
|
E
, 1 m/s
|
Dangerous Winter Blast Strikes Upper Midwest: Snow, Ice, and 50 MPH Winds Create Chaos!
A fierce winter storm is wreaking havoc across the upper Midwest, bringing a dangerous combination of snow, ice, and howling winds. The storm, which began on Wednesday night, has already caused significant disruptions, including treacherous driving conditions, highway closures, and multiple accidents.
Rare EF-1 Tornado Strikes Scotts Valley, California
A rare tornado tore through Scotts Valley, California, on Saturday, December 14, 2024, leaving a trail of destruction in its wake. The EF-1 tornado, packing winds of 90 mph, flipped cars, damaged homes and businesses, and caused significant power outages.