From 49f4343c5330c709ed3e039b6c44bfe2a8a6577f Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 4 Nov 2026 10:53:58 +0000 Subject: [PATCH 1/2] Fix Timeline line filling on tablet and mobile (#3306) The iOS polyfill matched any user agent containing Safari/, including Chrome, Edge, and Android. Narrow detection to iPhone, iPad, and real Safari so the line fills on scroll again. Quality-gated: risk=low; ship=ready. Co-authored-by: Benjamin Intal --- readme.txt | 1 + src/block/timeline/index.php | 33 +++++++- tests/phpunit/TimelineIosPolyfillTest.php | 92 +++++++++++++++++++++++ 3 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 tests/phpunit/TimelineIosPolyfillTest.php diff --git a/readme.txt b/readme.txt index 97b6b689d0..7c2b064887 100644 --- a/readme.txt +++ b/readme.txt @@ -317,6 +317,7 @@ Nope. Stackable only works with Gutenberg, the new WordPress editor. * Fixed: Hero block - content alignment now applies to the whole block #3739 * Fixed: Design Library - opens when Show Template is enabled #3737 * Fixed: Timeline block - text alignment works on tablet and mobile #3738 +* Fixed: Timeline block - line now fills on scroll on tablet and mobile #3306 = 3.20.2 = diff --git a/src/block/timeline/index.php b/src/block/timeline/index.php index 862192d1e4..d1a476f84f 100644 --- a/src/block/timeline/index.php +++ b/src/block/timeline/index.php @@ -9,6 +9,34 @@ exit; } +if ( ! function_exists( 'stackable_is_timeline_ios_polyfill_user_agent' ) ) { + /** + * Whether the Timeline iOS line-fill workaround should run for this visitor. + * + * Chrome, Edge, and Android browsers include "Safari/" in their user agent. + * Real Safari also includes "Version/" and does not include "Chrome/". + * Keep iPhone, iPad, and Safari so iPadOS Safari (which can report the same + * user agent as macOS Safari) still gets the workaround. + * See https://developer.apple.com/forums/thread/119186 + * + * @param string $user_agent + * @return bool + */ + function stackable_is_timeline_ios_polyfill_user_agent( $user_agent ) { + if ( empty( $user_agent ) ) { + return false; + } + + if ( stripos( $user_agent, 'iPhone' ) !== false || stripos( $user_agent, 'iPad' ) !== false ) { + return true; + } + + return stripos( $user_agent, 'Safari/' ) !== false && + stripos( $user_agent, 'Version/' ) !== false && + stripos( $user_agent, 'Chrome/' ) === false; + } +} + if ( ! function_exists( 'stackable_load_timeline_ios_frontend_polyfill' ) ) { function stackable_load_timeline_ios_frontend_polyfill( $block_content, $block ) { // Add class stk-block-timeline__ios-polyfill to $block_content @@ -16,10 +44,7 @@ function stackable_load_timeline_ios_frontend_polyfill( $block_content, $block ) } $user_agent = ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; - // Add polyfill if device is iPhone/iPad - // Include Safari because by default the User Agent in Safari on iPadOS is same on MacOS - // Reference: https://developer.apple.com/forums/thread/119186 - if ( ! empty( $user_agent ) && ( stripos( $user_agent, 'iPhone' ) !== false || stripos( $user_agent, 'iPad' ) !== false || stripos( $user_agent, 'Safari/' ) !== false ) ) { + if ( stackable_is_timeline_ios_polyfill_user_agent( $user_agent ) ) { add_filter( 'render_block_stackable/timeline', 'stackable_load_timeline_ios_frontend_polyfill', 10, 2 ); } } diff --git a/tests/phpunit/TimelineIosPolyfillTest.php b/tests/phpunit/TimelineIosPolyfillTest.php new file mode 100644 index 0000000000..6bd6558abd --- /dev/null +++ b/tests/phpunit/TimelineIosPolyfillTest.php @@ -0,0 +1,92 @@ +require_plugin_file( 'src/block/timeline/index.php' ); + } + + /** + * Known-good user agents. Chrome, Edge, and Android include "Safari/" + * for compatibility, but they are not Safari. + * + * @return array + */ + public function user_agent_provider() { + return array( + 'empty' => array( + '', + false, + ), + 'chrome desktop' => array( + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', + false, + ), + 'chrome android' => array( + 'Mozilla/5.0 (Linux; Android 13; Redmi 10C) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.6045.193 Mobile Safari/537.36', + false, + ), + 'edge desktop' => array( + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0', + false, + ), + 'android webview' => array( + 'Mozilla/5.0 (Linux; Android 10; Redmi 10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/119.0.6045.193 Mobile Safari/537.36', + false, + ), + 'firefox desktop' => array( + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0', + false, + ), + 'safari macos' => array( + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15', + true, + ), + 'safari ipados desktop ua' => array( + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15', + true, + ), + 'iphone safari' => array( + 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1', + true, + ), + 'iphone chrome' => array( + 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/120.0.6099.119 Mobile/15E148 Safari/604.1', + true, + ), + 'ipad safari' => array( + 'Mozilla/5.0 (iPad; CPU OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1', + true, + ), + ); + } + + /** + * @dataProvider user_agent_provider + * + * @param string $user_agent + * @param bool $expected + */ + public function test_ios_polyfill_user_agent_detection( $user_agent, $expected ) { + $this->assertSame( + $expected, + stackable_is_timeline_ios_polyfill_user_agent( $user_agent ) + ); + } + + public function test_polyfill_adds_class_at_render_time() { + $html = '
'; + $out = stackable_load_timeline_ios_frontend_polyfill( $html, array() ); + + $this->assertSame( + '
', + $out + ); + } +} From 03f1fea589a32431fb26e9f9f2eab6c7b201a798 Mon Sep 17 00:00:00 2001 From: Benjamin Intal Date: Thu, 12 Nov 2026 17:39:09 +0800 Subject: [PATCH 2/2] Apply suggestion from @bfintal --- readme.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/readme.txt b/readme.txt index 7c2b064887..97b6b689d0 100644 --- a/readme.txt +++ b/readme.txt @@ -317,7 +317,6 @@ Nope. Stackable only works with Gutenberg, the new WordPress editor. * Fixed: Hero block - content alignment now applies to the whole block #3739 * Fixed: Design Library - opens when Show Template is enabled #3737 * Fixed: Timeline block - text alignment works on tablet and mobile #3738 -* Fixed: Timeline block - line now fills on scroll on tablet and mobile #3306 = 3.20.2 =