700) { continue; } $html = wp_get_attachment_image($id, $size, false, array( 'alt' => '', 'loading' => 'lazy', 'decoding' => 'async', 'sizes' => '(max-width: 767px) 72px, 112px', )); if ($html) { return $html; } } return ''; }; add_action('bnm_before_content', static function () use ($fsm_local_image, $fsm_thumb_markup) { if (!(is_home() || is_category() || is_tag()) || !in_the_loop() || !is_main_query() || get_post_type() !== 'post') { return; } static $fsm_seen = array(); $post_id = get_the_ID(); if (isset($fsm_seen[$post_id])) { return; } $fsm_seen[$post_id] = true; $image = $fsm_thumb_markup(get_post_thumbnail_id($post_id)); if (!$image) { $tags = new WP_HTML_Tag_Processor((string) get_post_field('post_content', $post_id, 'raw')); while ($tags->next_tag(array('tag_name' => 'IMG'))) { $src = $tags->get_attribute('src'); if (!is_string($src) || !$fsm_local_image($src)) { continue; } $path = (string) wp_parse_url($src, PHP_URL_PATH); $uploads = wp_get_upload_dir(); $prefix = trailingslashit((string) wp_parse_url($uploads['baseurl'], PHP_URL_PATH)); if (strpos($path, $prefix) !== 0 || preg_match('/(?:banner|tracking|pixel|spacer|affiliate|liberapay|buymeacoffee)/i', basename($path))) { continue; } $w = $tags->get_attribute('width'); $h = $tags->get_attribute('height'); if ((is_numeric($w) && (int) $w < 100) || (is_numeric($h) && (int) $h < 100)) { continue; } $id = 0; $class = $tags->get_attribute('class'); if (is_string($class) && preg_match('/\bwp-image-(\d+)\b/', $class, $match)) { $id = (int) $match[1]; } if (!$id) { $url = preg_replace('/[?#].*$/', '', $src); $id = attachment_url_to_postid($url); if (!$id) { $original = preg_replace('/-\d+x\d+(?=\.[a-z0-9]+$)/i', '', $url); if ($original !== $url) { $id = attachment_url_to_postid($original); } } } $image = $fsm_thumb_markup($id); if ($image) { break; } } } if ($image) { echo ''; } }, 10); ?> '1'); if (isset($q['h']) && is_string($q['h']) && preg_match('~^[A-Za-z0-9]+$~D', $q['h'])) $params['h'] = $q['h']; $player = 'https://player.vimeo.com/video/' . $id . '?' . http_build_query($params, '', '&', PHP_QUERY_RFC3986); $watch = 'https://vimeo.com/' . $id . (isset($params['h']) ? '/' . $params['h'] : ''); } } elseif (in_array($host, array('kickstarter.com','www.kickstarter.com'), true)) { // Only recognize campaign widgets, not arbitrary external pages. if (!preg_match('~^(/projects/[A-Za-z0-9_-]+/[A-Za-z0-9_-]+)/widget/(?:video|card)\.html/?$~D', $path, $m)) return null; $provider = 'Kickstarter'; $player = 'https://www.kickstarter.com' . $path; $watch = 'https://www.kickstarter.com' . $m[1]; } else return null; return array('provider' => $provider, 'player' => $player, 'watch' => $watch); }; /* Only these two FSM hostnames are first party. Relative URLs are resolved by the browser; dangerous or unrecognized URI schemes fail closed. */ $fsm_source = static function ($value) { if (!is_string($value)) return null; $value = trim($value); if ($value === '' || preg_match('~[\x00-\x20\x7f\\\\]~', $value)) return null; if (strpos($value, '//') === 0) $value = 'https:' . $value; $p = wp_parse_url($value); if (!is_array($p) || isset($p['user']) || isset($p['pass'])) return null; $scheme = strtolower($p['scheme'] ?? ''); $host = strtolower($p['host'] ?? ''); if (!$scheme && !$host && strpos($value, '//') !== 0) return array('url'=>$value, 'host'=>'', 'local'=>true, 'https'=>true); if (!in_array($scheme, array('http','https'), true) || !$host || !preg_match('~^[a-z0-9.-]+$~D', $host)) return null; $local = in_array($host, array('funkyspacemonkey.com','www.funkyspacemonkey.com'), true) && (!isset($p['port']) || ($scheme === 'https' && $p['port'] === 443) || ($scheme === 'http' && $p['port'] === 80)); return array('url'=>$value, 'host'=>$host, 'local'=>$local, 'https'=>$scheme === 'https'); }; $fsm_hosts = static function ($host, $domain) { return $host === $domain || str_ends_with($host, '.' . $domain); }; $fsm_name = static function ($host) use ($fsm_hosts) { foreach (array('youtube.com'=>'YouTube','youtube-nocookie.com'=>'YouTube','youtu.be'=>'YouTube','vimeo.com'=>'Vimeo','kickstarter.com'=>'Kickstarter','soundcloud.com'=>'SoundCloud','spotify.com'=>'Spotify','dailymotion.com'=>'Dailymotion','dai.ly'=>'Dailymotion','mixcloud.com'=>'Mixcloud','twitch.tv'=>'Twitch','tiktok.com'=>'TikTok','archive.org'=>'Internet Archive','apple.com'=>'Apple','brightcove.com'=>'Brightcove','brightcove.net'=>'Brightcove','ooyala.com'=>'Ooyala','viddler.com'=>'Viddler','blip.tv'=>'Blip.tv','ws.amazon.com'=>'Amazon','pbs.org'=>'PBS','vid.io'=>'Legacy video player') as $domain=>$name) { if ($fsm_hosts($host,$domain)) return $name; } return $host ?: 'external provider'; }; /* Known historical formats can be rebuilt as modern HTTPS players. Generic HTTPS iframes get the same gate without requiring a provider list. */ $fsm_convert = static function ($s, $tag) use ($fsm_video_url,$fsm_hosts,$fsm_name) { $url = $s['url']; $host = $s['host']; $p = wp_parse_url($url); $path = $p['path'] ?? ''; parse_str($p['query'] ?? '', $q); $v = $fsm_video_url($url); if ($v && $v['player']) { return array('provider'=>$v['provider'],'kind'=>'iframe','url'=>$v['player'],'watch'=>$v['watch']); } if ($fsm_hosts($host,'soundcloud.com')) { $track = $q['url'] ?? ''; if (is_string($track) && preg_match('~^https?://api\.soundcloud\.com/(tracks|playlists)/([0-9]+)$~D',$track,$m)) { $track='https://api.soundcloud.com/'.$m[1].'/'.$m[2]; return array('provider'=>'SoundCloud','kind'=>'audioframe','url'=>'https://w.soundcloud.com/player/?'.http_build_query(array('url'=>$track,'auto_play'=>'false'),'','&',PHP_QUERY_RFC3986),'watch'=>''); } if ($host === 'w.soundcloud.com' && $path === '/player/' && $s['https']) return array('provider'=>'SoundCloud','kind'=>'audioframe','url'=>$url,'watch'=>''); } if ($fsm_hosts($host,'spotify.com')) { $uri = $q['uri'] ?? ''; if (is_string($uri) && preg_match('~^spotify:(track|album|playlist|episode|show|artist):([A-Za-z0-9]+)$~D',$uri,$m)) { $slug=$m[1].'/'.$m[2]; return array('provider'=>'Spotify','kind'=>'audioframe','url'=>'https://open.spotify.com/embed/'.$slug,'watch'=>'https://open.spotify.com/'.$slug); } if ($host === 'open.spotify.com' && strpos($path,'/embed/') === 0 && $s['https']) return array('provider'=>'Spotify','kind'=>'audioframe','url'=>$url,'watch'=>''); } if ($fsm_hosts($host,'dailymotion.com') || $fsm_hosts($host,'dai.ly')) { if (preg_match($fsm_hosts($host,'dai.ly')?'~^/([a-zA-Z0-9]+)(?:/|$)~':'~^/(?:swf/|embed/)?video/([a-zA-Z0-9]+)(?:/|$)~',$path,$m)) return array('provider'=>'Dailymotion','kind'=>'iframe','url'=>'https://www.dailymotion.com/embed/video/'.$m[1],'watch'=>'https://www.dailymotion.com/video/'.$m[1]); } if ($fsm_hosts($host,'mixcloud.com')) { $feed=$q['feed'] ?? ''; if (is_string($feed) && preg_match('~^(?:https?://(?:www\.)?mixcloud\.com)?(/[A-Za-z0-9_-]+/[A-Za-z0-9_-]+/?)$~D',$feed,$m)) { $feed=rtrim($m[1],'/').'/'; return array('provider'=>'Mixcloud','kind'=>'audioframe','url'=>'https://www.mixcloud.com/widget/iframe/?'.http_build_query(array('feed'=>$feed),'','&',PHP_QUERY_RFC3986),'watch'=>'https://www.mixcloud.com'.$feed); } } if ($s['https'] && $tag === 'IFRAME' && !preg_match('~\.swf$~i',$path)) return array('provider'=>$fsm_name($host),'kind'=>'iframe','url'=>$url,'watch'=>$url); // Direct media files can use a native player, never Flash or arbitrary scripts. if (preg_match('~\.(mp4|webm|ogv|mov|m4v|mp3|ogg|oga|wav|m4a|aac|flac)$~i',$path,$m) && ($s['https'] || $fsm_hosts($host,'apple.com'))) { $kind=in_array(strtolower($m[1]),array('mp3','ogg','oga','wav','m4a','aac','flac'),true)?'audio':'video'; $url=preg_replace('~^http:~i','https:',$url); return array('provider'=>$fsm_name($host),'kind'=>$kind,'url'=>$url,'watch'=>$url); } return null; }; $fsm_panel = static function ($v) { $name=esc_html($v['provider']); $kind=$v['kind'] ?? ''; $audio=in_array($kind,array('audio','audioframe'),true); $noun=$audio?'audio':(in_array($v['provider'],array('YouTube','Vimeo','Kickstarter','Dailymotion'),true)||$kind==='video'?'video':'content'); $label=ucfirst($noun); $policy=array('YouTube'=>'https://policies.google.com/privacy','Vimeo'=>'https://vimeo.com/privacy','Kickstarter'=>'https://legal.kickstarter.com/','SoundCloud'=>'https://soundcloud.com/pages/privacy','Spotify'=>'https://www.spotify.com/legal/privacy-policy/'); $outer='
EXTERNAL '.strtoupper($noun).' / '.esc_html(strtoupper($v['provider'])).''; if (!$kind) return !empty($v['script_only']) ? $outer.'External content not loaded

This embed uses an external script rather than a supported player. It is disabled for your privacy.

' : $outer.'Legacy external content unavailable

This older embed is not loaded automatically. Its original player could not be safely restored in a modern format.

'; $payload=esc_attr(wp_json_encode($v, JSON_UNESCAPED_SLASHES)); $privacy=isset($policy[$v['provider']])?' Provider privacy policy.':''; $watch=$v['watch'] ?? ''; $link=$watch?''.($v['provider']==='Kickstarter'?'View project on Kickstarter':($noun==='video'?'Watch on '.$name:'Open external source')).' ↗':''; return $outer.''.$label.' blocked for your privacy

By choosing Load '.$noun.', you agree to connect to '.$name.', which may receive connection data and use cookies or similar storage.'.$privacy.'

'.$link.''; }; $fsm_attrs = '(?:[^>"\']|"[^"]*"|\'[^\']*\')*'; $fsm_active = static function () {return is_singular(array('post','page')) && in_the_loop() && is_main_query();}; /* Early: stored article scripts are not safe player containers. Do not execute or re-inject them. Global theme/plugin scripts and head/footer ads are not touched. This runs before normal shortcode / content rendering. */ add_filter('the_content', static function ($html) use ($fsm_attrs,$fsm_active,$fsm_source,$fsm_name,$fsm_panel) { if (!$fsm_active() || stripos($html,'.*?(*SKIP)(*F)|.*?~is'; $out=preg_replace_callback($pattern,static function($m) use($fsm_source,$fsm_name,$fsm_panel){ $t=new WP_HTML_Tag_Processor($m[0]); if (!$t->next_tag()) return ''; $type=strtolower(trim((string)$t->get_attribute('type'))); // Keep inert JSON metadata and code/data script types, not executable modules. if (in_array($type,array('application/ld+json','application/json','text/plain'),true) && !$t->get_attribute('src')) return $m[0]; $s=$fsm_source($t->get_attribute('src')); if ($s && !$s['local']) { if ($s['host']==='platform.twitter.com' && (wp_parse_url($s['url'],PHP_URL_PATH)==='/widgets.js')) return ''; if (preg_match('~(?:^|\.)(?:chitika\.(?:net|com)|bidvertiser\.com)$~i',$s['host'])) return ''; // Verge embeds also have a frame; avoid duplicating its placeholder. if ($s['host']==='assets.theverge.vid.io') return ''; return $fsm_panel(array('provider'=>$fsm_name($s['host']),'script_only'=>true)); } return ''; // inline executable code or local script with unknown outward requests },$html); return is_string($out)?$out:$html; },1); /* Late: suppress known player bootstrap scripts emitted during shortcode rendering. Do not blanket-remove scripts inserted by other plugins. */ add_filter('the_content', static function ($html) use ($fsm_attrs,$fsm_active,$fsm_source,$fsm_hosts) { if (!$fsm_active() || stripos($html,'.*?(*SKIP)(*F)|.*?~is'; $out=preg_replace_callback($pattern, static function($m) use($fsm_source,$fsm_hosts){ $t=new WP_HTML_Tag_Processor($m[0]); if(!$t->next_tag()) return $m[0]; $s=$fsm_source($t->get_attribute('src')); if(!$s || $s['local']) return $m[0]; $p=wp_parse_url($s['url']); $path=$p['path']??''; if ($s['host']==='platform.twitter.com' && $path==='/widgets.js') return ''; foreach(array('ooyala.com','vid.io','player.vimeo.com','w.soundcloud.com','geo.dailymotion.com','player.twitch.tv','embed.twitch.tv','player.ex.co') as $d) if($fsm_hosts($s['host'],$d)) return ''; if (($fsm_hosts($s['host'],'youtube.com') && preg_match('~/(?:iframe_api|player_api)(?:/|$)~',$path)) || ($fsm_hosts($s['host'],'spotify.com') && strpos($path,'/embed/iframe-api')===0)) return ''; return $m[0]; },$html); return is_string($out)?$out:$html; },99997); add_filter('the_content', static function ($html) use ($fsm_attrs,$fsm_active,$fsm_source,$fsm_convert,$fsm_name,$fsm_panel) { if (!$fsm_active() || !preg_match('~<(?:iframe|object|embed|video|audio)\b~i',$html)) return $html; /* Before output reaches browser. Code examples should be escaped HTML; actual active tags inside pre/code are still intercepted. */ $pattern='~(*SKIP)(*F)|<(script|style|textarea|xmp|title)\b'.$fsm_attrs.'>.*?(*SKIP)(*F)|<(object|video|audio)\b'.$fsm_attrs.'>.*?|(?:.*?)?|<(?:embed|object|video|audio)\b'.$fsm_attrs.'>~is'; $out=preg_replace_callback($pattern,static function($m) use($fsm_source,$fsm_convert,$fsm_name,$fsm_panel){ $raw=$m[0]; $t=new WP_HTML_Tag_Processor($raw); if(!$t->next_tag()) return $raw; $tag=$t->get_tag(); $native=in_array($tag,array('VIDEO','AUDIO'),true); $external=array(); $local=false; $invalid=false; $media=array(); $poster=''; $tracks=array(); $provider='external provider'; // srcdoc is arbitrary nested HTML, not safe to restore as an embed. if ($tag==='IFRAME' && $t->get_attribute('srcdoc')!==null) return $fsm_panel(array('provider'=>'embedded document')); do { $node=$t->get_tag(); $names=array(); if (in_array($node,array('IFRAME','EMBED','VIDEO','AUDIO','SOURCE','TRACK'),true)) $names=array('src','data-src','data-lazy-src','data-original','data-url','data-lazyload-src'); elseif($node==='OBJECT') $names=array('data','data-src','src'); elseif($node==='PARAM' && in_array(strtolower((string)$t->get_attribute('name')),array('movie','src'),true)) $names=array('value'); if ($native && $node==='VIDEO') $names[]='poster'; foreach($names as $attr){ $value=$t->get_attribute($attr); if($value===null || $value==='') continue; if (is_string($value) && in_array(strtolower(trim($value)),array('about:blank','about:srcdoc'),true)) continue; $s=$fsm_source($value); if(!$s){$invalid=true;continue;} if($s['local']) $local=true; else {$external[]=$s; $provider=$fsm_name($s['host']);} if ($native) { // HTTPS only for external resources; local paths are preserved. if (!$s['local'] && !$s['https'] && !preg_match('~(?:^|\.)apple\.com$~i',$s['host'])) continue; $u=preg_replace('~^http:~i','https:',$s['url']); if($attr==='poster') $poster=$u; elseif($node==='TRACK') $tracks[]=array('src'=>$u,'kind'=>(string)$t->get_attribute('kind'),'label'=>(string)$t->get_attribute('label'),'srclang'=>(string)$t->get_attribute('srclang')); elseif(in_array($node,array('VIDEO','AUDIO','SOURCE'),true)) $media[]=array('src'=>$u,'type'=>(string)$t->get_attribute('type')); } } } while($t->next_tag()); if (!$external && !$invalid && $local) return $raw; // Source-less native video/audio cannot request media and is left alone; // source-less frames and objects can be dynamically populated, so gate them. if (!$external && !$invalid && $native) return $raw; if ($native && $media && !$invalid) return $fsm_panel(array('provider'=>$provider,'kind'=>strtolower($tag),'sources'=>array_values(array_unique($media,SORT_REGULAR)),'poster'=>$poster,'tracks'=>$tracks,'watch'=>'')); if (!$native && !$invalid) foreach($external as $s){$v=$fsm_convert($s,$tag);if($v)return $fsm_panel($v);} return $fsm_panel(array('provider'=>$provider)); },$html); return is_string($out)?$out:$html; },99999); /* FSM external images and X posts v5. No original remote image markup is emitted for a gated image. Each gate owns its own payload and lifecycle. Scope remains the singular main-loop content, not feeds or global assets. */ $fsm_image_source = static function ($value) use ($fsm_source) { if (!is_string($value)) return null; $value=trim($value); // Inline raster images do not require a network connection. if (preg_match('~^data:image/(?:png|gif|jpe?g|webp|avif|bmp|x-icon|vnd\.microsoft\.icon);base64,[a-z0-9+/=\s]+$~iD',$value)) return array('local'=>true,'url'=>$value,'host'=>'','https'=>true); return $fsm_source($value); }; // Tokenize srcset URLs separately from their width/density descriptors. // A comma inside an URL (including data:) is not automatically a separator. $fsm_srcset_urls = static function ($value) { $urls=array(); while (is_string($value) && preg_match('~^[\s,]*([^\s]+)(.*)$~sD',$value,$m)) { $token=$m[1]; $value=$m[2]; $urls[]=rtrim($token,','); if (substr($token,-1)===',') continue; $comma=strpos($value,','); if ($comma===false) break; $value=substr($value,$comma+1); } return $urls; }; $fsm_img_attrs=array('src','srcset','data-src','data-srcset','data-lazy-src','data-lazy-srcset','data-original','data-original-src','data-original-srcset','data-lazyload-src','data-lazyload-srcset','data-url','data-litespeed-src','data-litespeed-srcset','data-ll-src','data-ll-srcset','data-echo','data-retina','data-hi-res-src'); $fsm_image_gate = static function ($raw,$no_js=false) use ($fsm_image_source,$fsm_srcset_urls,$fsm_img_attrs,$fsm_source) { $t=new WP_HTML_Tag_Processor($raw); $remote=array(); $preferred=array(); $invalid=false; $alt=''; $width=0; $height=0; $found=false; $link=''; $link_external=false; while ($t->next_tag()) { $tag=$t->get_tag(); if ($tag==='A' && !$found) { $href=$fsm_source($t->get_attribute('href')); if ($href) { $link=$href['url']; $link_external=!$href['local']; } } if (!in_array($tag,array('IMG','SOURCE','PICTURE'),true)) continue; if ($tag==='IMG') { if (!$found) { $alt=(string)$t->get_attribute('alt'); foreach (array('width','height') as $dim) { $val=$t->get_attribute($dim); if (is_string($val) && preg_match('~^[1-9][0-9]{0,4}$~D',$val)) $$dim=(int)$val; } } $found=true; } foreach ($fsm_img_attrs as $attr) { $v=$t->get_attribute($attr); if ($v===null || $v==='') continue; $urls=strpos($attr,'srcset')!==false ? $fsm_srcset_urls($v) : array($v); foreach ($urls as $u) { $s=$fsm_image_source($u); if (!$s) { $invalid=true; continue; } if (!$s['local']) { $remote[]=$s; if ($tag==='IMG' && strpos($attr,'srcset')===false) $preferred[]=$s; } } } // Review image-specific inline CSS. Do not replay remote backgrounds // or unknown CSS on the reconstructed image. Other CSS is unchanged. $style=$t->get_attribute('style'); if (is_string($style) && preg_match_all('~url\s*\(\s*(?:"([^"]*)"|\'([^\']*)\'|([^)]*))\s*\)~i',$style,$matches,PREG_SET_ORDER|PREG_UNMATCHED_AS_NULL)) { foreach ($matches as $m) { $s=$fsm_image_source(trim($m[1]??$m[2]??$m[3]??'')); if (!$s) $invalid=true; elseif (!$s['local']) $remote[]=$s; } } } if (!$remote && !$invalid) return $raw; // One explicit request, one image URL. Do not restore alternate srcset, // picture, arbitrary data attributes, styles, handlers or remote previews. $selected=null; foreach (array_merge($preferred,$remote) as $s) if ($s['https']) { $selected=$s; break; } $fallback=$selected ?? ($remote[0]??null); $url=$fallback['url']??''; $host=$fallback['host']??''; $fireplace=$url==='https://github.com/dolsup/cli-fireplace/raw/master/cli-fireplace-demo.gif?raw=true'; if ($fireplace && $alt==='') $alt='Animated Fireplace terminal demonstration'; $direct=$url?'Open original image ↗':''; $original_link=$link?'Open linked page ↗':''; if ($no_js) return 'External image not loaded. '.$direct.$original_link.''; $out='EXTERNAL IMAGE'.($host?' / '.esc_html(strtoupper($host)):'').'Image blocked for your privacy'; if ($alt!=='') $out.=''.esc_html($alt).''; if ($selected) { $cfg=array('kind'=>'image','url'=>$selected['url'],'alt'=>$alt,'width'=>$width,'height'=>$height); $out.='Loading connects to '.esc_html($host).' and may also contact redirect destinations. They receive connection data and may use cookies.'.($fireplace?' This animated GIF is approximately 20 MB.':'').''; } else $out.='No supported HTTPS image URL is available for in-page loading.'; return $out.$direct.$original_link.''; }; $fsm_images = static function ($html,$no_js=false) use ($fsm_attrs,$fsm_image_gate,&$fsm_images) { // Whole picture / image-only link / noscript fallback units are handled // before individual tags. Skip comments and text-only/raw-text elements. $picture='.*?'; $img=''; $pattern='~(*SKIP)(*F)|<(script|style|textarea|xmp|title)\b'.$fsm_attrs.'>.*?(*SKIP)(*F)|.*?|\s*(?:'.$picture.'|'.$img.')\s*|'.$picture.'|'.$img.'||(*SKIP)(*F)~is'; $out=preg_replace_callback($pattern,static function($m) use ($fsm_image_gate,$no_js,$fsm_attrs,&$fsm_images) { if (preg_match('~^(.*?)$~isD',$m[0],$inner)) { // The Tag Processor treats NOSCRIPT as raw text in some versions. // Examine its inner HTML separately, and retain local fallbacks. $clean=$fsm_images($inner[1],true); return $clean===$inner[1]?$m[0]:''; } // Standalone source tags belong to native video/audio too. Leave // src-only ones to v4; a stray responsive source is not needed. if (preg_match('~^next_tag()) return $m[0]; $responsive=false; foreach (array('srcset','data-srcset','data-lazy-srcset','data-lazyload-srcset','data-original-srcset') as $a) if ($t->get_attribute($a)!==null) $responsive=true; if (!$responsive) return $m[0]; $checked=$fsm_image_gate($m[0],true); return $checked===$m[0]?$m[0]:''; } return $fsm_image_gate($m[0],$no_js); },$html); // A regex engine failure must not expose the original active image HTML. // Rare error fallback: readable text, not a database change. return is_string($out)?$out:'

Some formatting and media could not be safely displayed.

'.esc_html(wp_strip_all_tags($html)).'

'; }; add_filter('the_content',static function($html) use ($fsm_active,$fsm_images) { if (!$fsm_active() || !preg_match('~<(?:img|picture|source|noscript)\b~i',$html)) return $html; return $fsm_images($html); },100000); $fsm_tweet_url=static function($value) use ($fsm_source) { $s=$fsm_source($value); if (!$s || $s['local']) return ''; if (!in_array($s['host'],array('twitter.com','www.twitter.com','mobile.twitter.com','x.com','www.x.com','mobile.x.com'),true)) return ''; $p=wp_parse_url($s['url']); if (isset($p['port'])) return ''; if (!preg_match('~^/(?:[A-Za-z0-9_]{1,15}/status|i/web/status)/([0-9]{1,25})/?$~D',$p['path']??'',$m)) return ''; return 'https://'.(($s['host']==='x.com'||str_ends_with($s['host'],'.x.com'))?'x.com':'twitter.com').rtrim($p['path'],'/'); }; add_filter('the_content',static function($html) use ($fsm_active,$fsm_attrs,$fsm_tweet_url) { if (!$fsm_active() || stripos($html,'twitter-')===false) return $html; $pattern='~(*SKIP)(*F)|<(script|style|textarea|xmp|title)\b'.$fsm_attrs.'>.*?(*SKIP)(*F)|.*?|(*SKIP)(*F)~is'; $out=preg_replace_callback($pattern,static function($m) use ($fsm_tweet_url) { $t=new WP_HTML_Tag_Processor($m[0]); if (!$t->next_tag()) return $m[0]; $classes=preg_split('~\s+~',trim((string)$t->get_attribute('class'))); if (!array_intersect($classes,array('twitter-tweet','twitter-video'))) return $m[0]; // Keep the original static quote and links, but remove auto-upgrade classes. $t->remove_class('twitter-tweet'); $t->remove_class('twitter-video'); $t->add_class('fsm-twitter-static'); $quote=$t->get_updated_html(); $url=''; $t=new WP_HTML_Tag_Processor($m[0]); while ($t->next_tag('A')) { $valid=$fsm_tweet_url($t->get_attribute('href')); if ($valid) $url=$valid; } if (!$url) return $quote; // No invented ID or remote lookup. $cfg=esc_attr(wp_json_encode(array('kind'=>'tweet','url'=>$url),JSON_UNESCAPED_SLASHES)); return $quote.'EXTERNAL POST / TWITTER (X)Live post blocked for your privacyLoading connects to X, which may receive connection data and use cookies or similar storage. The original quote remains above. Provider privacy information.View on X ↗'; },$html); return is_string($out)?$out:$html; },100001); add_action('wp_footer',static function(){ ?> "\']|"[^"]*"|\'[^\']*\')*'; $pattern = '~(*SKIP)(*F)|<(style|textarea|xmp|title)\b' . $attrs . '>.*?(*SKIP)(*F)|(.*?)~is'; $clean = preg_replace_callback($pattern, static function ($m) { /* Read actual attribute names, not quoted text in other attributes. */ preg_match_all('~([^\s=/<>"\']+)(?:\s*=\s*(?:"([^"]*)"|\'([^\']*)\'|([^\s>]+)))?~s', $m[2], $attributes, PREG_SET_ORDER | PREG_UNMATCHED_AS_NULL); foreach ($attributes as $attribute) { if (strtolower($attribute[1]) !== 'src') continue; $src = trim(html_entity_decode($attribute[2] ?? $attribute[3] ?? $attribute[4] ?? '', ENT_QUOTES | ENT_HTML5, 'UTF-8')); if (strpos($src, '//') === 0) $src = 'https:' . $src; $host = strtolower((string) wp_parse_url($src, PHP_URL_HOST)); if ($host === 'chitika.net' || str_ends_with($host, '.chitika.net') || $host === 'chitika.com' || str_ends_with($host, '.chitika.com')) return ''; return $m[0]; } /* Match the specific inline legacy ad configuration in FSM's export. */ $body = $m[3]; if (preg_match('~\bch_client\s*=\s*["\']murdamw["\']~i', $body) && preg_match('~\bch_type\s*=\s*["\']mpu["\']~i', $body) && preg_match('~\bch_width\s*=~i', $body) && preg_match('~\bch_height\s*=~i', $body) && preg_match('~\bch_queries\s*=~i', $body)) return ''; return $m[0]; }, $html); return is_string($clean) ? $clean : $html; }, 99998); } ?>
Posted inApps

TomTom iPhone App: Available in New Zealand’s AppStore

Waiting for the iPhone version of TomTom has an end. The navigation package is now available in four variants in New Zealand’s App Store: Western Europe (85 euros / $121), USA & Canada (60 euros / $100), New Zealand (60 euros / $100 ) and Australia (50 euros / $70).

When would it be available in the other appstores? We dont know, but FSMdotCOM will keep you updated. Stay tuned…

[via iFun.de ]
Support FSMdotCOM on Liberapay