Changeset 3797104
- Timestamp:
- 11/11/2026 09:17:24 PM (less than one hour ago)
- Location:
- simple-digital-clock
- Files:
-
- 2 added
- 8 edited
- 1 copied
-
tags/1.1.5 (copied) (copied from simple-digital-clock/trunk )
-
tags/1.1.5/includes/simple-digital-clock-assets.php (modified) (5 diffs)
-
tags/1.1.5/includes/simple-digital-clock-output.php (added)
-
tags/1.1.5/languages/simple-digital-clock.pot (modified) (1 diff)
-
tags/1.1.5/readme.txt (modified) (4 diffs)
-
tags/1.1.5/widget_init.php (modified) (2 diffs)
-
trunk/includes/simple-digital-clock-assets.php (modified) (5 diffs)
-
trunk/includes/simple-digital-clock-output.php (added)
-
trunk/languages/simple-digital-clock.pot (modified) (1 diff)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/widget_init.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-digital-clock/tags/1.1.5/includes/simple-digital-clock-assets.php
r3796553 r3797104 5 5 } 6 6 7 /** Register stable handles only when rendering or previewing an owned clock. */7 /** Register stable handles without sending frontend resources. */ 8 8 function SDCW_register_assets() { 9 9 if (!wp_script_is('simple-digital-clock', 'registered')) { … … 17 17 } 18 18 if (!wp_style_is('simple-digital-clock-block-style', 'registered')) { 19 // A source-free handle prints only this host-layout rule, without a request. 20 wp_register_style('simple-digital-clock-block-style', false, array(), '1.1.4'); 19 wp_register_style('simple-digital-clock-block-style', false, array(), '1.1.5'); 21 20 wp_add_inline_style( 22 21 'simple-digital-clock-block-style', … … 25 24 } 26 25 } 26 add_action('init', 'SDCW_register_assets', 9); 27 27 28 /** WordPress deduplicates each stable handle within the current document. */28 /** Editors enqueue normally; frontend runtime delivery follows actual HTML. */ 29 29 function SDCW_enqueue_scripts() { 30 30 SDCW_register_assets(); 31 wp_enqueue_script('simple-digital-clock'); 31 if (is_admin()) { 32 wp_enqueue_script('simple-digital-clock'); 33 } 32 34 wp_enqueue_style('simple-digital-clock-block-style'); 33 35 if (!is_admin()) { 34 // Content and footer sidebars can enqueue the inline rule after wp_head.35 36 add_action('wp_footer', 'SDCW_print_clock_styles', 19); 36 37 if (did_action('wp_print_footer_scripts')) { 37 // Explicit late rendering still uses Core's filters and done lists.38 38 SDCW_print_clock_styles(); 39 if (!wp_script_is('simple-digital-clock', 'done')) {40 wp_print_scripts(array('simple-digital-clock'));41 }42 39 } 43 40 } 44 41 } 45 42 46 /** 47 * Only the owned block's render event automatically enqueues frontend assets. 48 * No page, content, sidebar option or response stream is inspected. 49 */ 43 /** Preserve the owned block's layout policy without leaking frontend scripts. */ 50 44 function SDCW_enqueue_rendered_clock_assets($block_content) { 51 45 if ('' !== trim($block_content) && !is_admin() && !is_feed() && !is_robots() && … … 57 51 add_filter('render_block_simple-digital-clock-block/widget-block', 'SDCW_enqueue_rendered_clock_assets'); 58 52 59 /** Print only a pending owned inline rule; Core deduplicates head/footer output. */53 /** Inline layout may remain after a later filter discards an owned block. */ 60 54 function SDCW_print_clock_styles() { 61 55 if (wp_style_is('simple-digital-clock-block-style', 'enqueued') && … … 65 59 } 66 60 67 /** Empty editors still need preview assets, including their iframe canvas. */ 61 require_once SDCW_PATH . 'includes/simple-digital-clock-output.php'; 62 63 /** Only ordinary HTML may receive generated script tags. */ 64 function SDCW_is_frontend_html() { 65 foreach (headers_list() as $header) { 66 if (0 === stripos($header, 'Content-Type:') && !preg_match('~^Content-Type:\s*text/html(?:\s*;|\s*$)~i', $header)) { 67 return false; 68 } 69 } 70 return true; 71 } 72 73 /** Insertion changes response length; never retain a stale fixed length. */ 74 function SDCW_prepare_frontend_length() { 75 foreach (headers_list() as $header) { 76 if (0 === stripos($header, 'Content-Length:')) { 77 if (headers_sent()) { 78 $GLOBALS['SDCW_frontend_output_blocker'] = 'content_length_already_sent'; 79 return false; 80 } 81 header_remove('Content-Length'); 82 break; 83 } 84 } 85 return true; 86 } 87 88 /** Observe delivered chunks; cleaned writes never change lexical history. */ 89 function SDCW_filter_frontend_output($html, $phase) { 90 if (($phase & PHP_OUTPUT_HANDLER_CLEAN) || !empty($GLOBALS['SDCW_frontend_assets_delivered'])) { 91 return $html; 92 } 93 if (!SDCW_is_frontend_html() || !SDCW_prepare_frontend_length()) { 94 return $html; 95 } 96 $ready = isset($GLOBALS['SDCW_frontend_asset_markup']); 97 $position = $GLOBALS['SDCW_frontend_observer']->feed($html, $ready); 98 if ($ready && null !== $position) { 99 $GLOBALS['SDCW_frontend_assets_delivered'] = true; 100 return substr($html, 0, $position) . $GLOBALS['SDCW_frontend_asset_markup'] . substr($html, $position); 101 } 102 return $html; 103 } 104 105 function SDCW_start_frontend_output() { 106 if (is_admin() || is_feed() || is_robots() || is_trackback() || wp_is_json_request() || 107 isset($GLOBALS['SDCW_frontend_observer']) || !SDCW_is_frontend_html()) { 108 return; 109 } 110 if (!SDCW_prepare_frontend_length()) { 111 return; 112 } 113 $GLOBALS['SDCW_frontend_observer'] = new SDCW_Clock_Output_Observer(); 114 ob_start('SDCW_filter_frontend_output', 1); 115 add_action('wp_footer', 'SDCW_capture_frontend_assets', 19); 116 } 117 add_action('template_redirect', 'SDCW_start_frontend_output', PHP_INT_MAX); 118 119 /** Capture only Core-generated runtime tags, not page content or layout CSS. */ 120 function SDCW_capture_frontend_assets() { 121 if (isset($GLOBALS['SDCW_frontend_asset_markup']) || !SDCW_is_frontend_html() || 122 !SDCW_prepare_frontend_length()) { 123 return; 124 } 125 SDCW_register_assets(); 126 ob_start(); 127 wp_scripts()->do_items(array('simple-digital-clock'), 1); 128 $GLOBALS['SDCW_frontend_asset_markup'] = ob_get_clean(); 129 // A late owned render must still print its layout after footer priority 19. 130 add_action('wp_footer', 'SDCW_print_clock_styles', PHP_INT_MAX); 131 echo '<!-- -->'; 132 } 133 68 134 function SDCW_enqueue_editor_clock_assets() { 69 135 $screen = function_exists('get_current_screen') ? get_current_screen() : null; -
simple-digital-clock/tags/1.1.5/languages/simple-digital-clock.pot
r3796553 r3797104 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Simple Digital Clock 🕒 1.1. 4\n"5 "Project-Id-Version: Simple Digital Clock 🕒 1.1.5\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/simple-digital-clock\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -
simple-digital-clock/tags/1.1.5/readme.txt
r3796553 r3797104 6 6 Requires at least: 6.3 7 7 Requires PHP: 7.0 8 Stable tag: 1.1. 48 Stable tag: 1.1.5 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 74 74 75 75 = Is it fast? = 76 Yes. The bundled clock widget is about 12.2 KiB gzip and is served locally without a runtime JavaScript CDN dependency. Frontend JavaScript and the inline layout rule are queued when WordPress renders the Simple Digital Clock block, including block-based widget areas. The plugin does not scan or buffer page HTML. Custom templates, shortcodes or raw HTML integrations must call SDCW_enqueue_scripts() when they output a clock. If another plugin removes an already rendered clock later, its queued assets may remain. Multiple clocks share one runtime script and one inline layout rule per page; no external plugin stylesheet is loaded.76 Yes. The bundled clock widget is about 12.2 KiB gzip and is served locally without a runtime JavaScript CDN dependency. On the frontend, the runtime is delivered only when a clock is present in the server-rendered page HTML; clock-free pages receive no plugin script or browser loader. Multiple clocks share one runtime script. The inline layout rule remains scoped to rendered Simple Digital Clock blocks and explicit integrations; raw HTML keeps its existing layout. No external plugin stylesheet is loaded. Server-side HTML observation adds PHP work, including on clock-free pages. 77 77 78 = What about clocks created later by custom JavaScript? = 79 Automatic delivery detects server-rendered clocks. An integration that creates its first clock only after page load must load the widget runtime itself. Calling SDCW_enqueue_scripts() without rendering a clock on the server does not bypass the zero-script rule. 80 81 = What if my site caches complete HTML pages? = 82 Regenerate full-page caches after updating so visitors receive the corrected HTML. Cached pages served without WordPress running are not rewritten by the plugin. 78 83 == Screenshots == 79 84 … … 102 107 103 108 == Changelog == 109 110 = 1.1.5 = 111 * Restore automatic clock rendering in existing raw HTML, Custom HTML/Text widgets, templates and shortcode integrations after updating from 1.1.2 or 1.1.4. 112 * Load the runtime only for actual server-rendered clocks, including raw HTML and cached fragments, while preserving raw HTML layout. 113 * Retain the Gutenberg, legacy metadata and localization fixes from 1.1.4 without changing stored content. 104 114 105 115 = 1.1.4 = … … 182 192 🕒 Sync Time: [UTC](https://utctime.info/) 183 193 🗓️ Today's Date: [TodaysDateNow](https://todaysdatenow.com/) 194 195 == Upgrade Notice == 196 197 = 1.1.5 = 198 Restores clocks in existing HTML, widget and template integrations. No content migration is required. -
simple-digital-clock/tags/1.1.5/widget_init.php
r3796553 r3797104 2 2 3 3 /** 4 * @version 1.1. 44 * @version 1.1.5 5 5 */ 6 6 … … 9 9 Plugin URI: https://utctime.info/ 10 10 Description: It is 🪄 a magical and easy-to-use digital clock with a beautiful UI, supporting multiple languages, locales, dates, captions, and time zones. 11 Version: 1.1. 411 Version: 1.1.5 12 12 Requires at least: 6.3 13 13 Requires PHP: 7.0 -
simple-digital-clock/trunk/includes/simple-digital-clock-assets.php
r3796553 r3797104 5 5 } 6 6 7 /** Register stable handles only when rendering or previewing an owned clock. */7 /** Register stable handles without sending frontend resources. */ 8 8 function SDCW_register_assets() { 9 9 if (!wp_script_is('simple-digital-clock', 'registered')) { … … 17 17 } 18 18 if (!wp_style_is('simple-digital-clock-block-style', 'registered')) { 19 // A source-free handle prints only this host-layout rule, without a request. 20 wp_register_style('simple-digital-clock-block-style', false, array(), '1.1.4'); 19 wp_register_style('simple-digital-clock-block-style', false, array(), '1.1.5'); 21 20 wp_add_inline_style( 22 21 'simple-digital-clock-block-style', … … 25 24 } 26 25 } 26 add_action('init', 'SDCW_register_assets', 9); 27 27 28 /** WordPress deduplicates each stable handle within the current document. */28 /** Editors enqueue normally; frontend runtime delivery follows actual HTML. */ 29 29 function SDCW_enqueue_scripts() { 30 30 SDCW_register_assets(); 31 wp_enqueue_script('simple-digital-clock'); 31 if (is_admin()) { 32 wp_enqueue_script('simple-digital-clock'); 33 } 32 34 wp_enqueue_style('simple-digital-clock-block-style'); 33 35 if (!is_admin()) { 34 // Content and footer sidebars can enqueue the inline rule after wp_head.35 36 add_action('wp_footer', 'SDCW_print_clock_styles', 19); 36 37 if (did_action('wp_print_footer_scripts')) { 37 // Explicit late rendering still uses Core's filters and done lists.38 38 SDCW_print_clock_styles(); 39 if (!wp_script_is('simple-digital-clock', 'done')) {40 wp_print_scripts(array('simple-digital-clock'));41 }42 39 } 43 40 } 44 41 } 45 42 46 /** 47 * Only the owned block's render event automatically enqueues frontend assets. 48 * No page, content, sidebar option or response stream is inspected. 49 */ 43 /** Preserve the owned block's layout policy without leaking frontend scripts. */ 50 44 function SDCW_enqueue_rendered_clock_assets($block_content) { 51 45 if ('' !== trim($block_content) && !is_admin() && !is_feed() && !is_robots() && … … 57 51 add_filter('render_block_simple-digital-clock-block/widget-block', 'SDCW_enqueue_rendered_clock_assets'); 58 52 59 /** Print only a pending owned inline rule; Core deduplicates head/footer output. */53 /** Inline layout may remain after a later filter discards an owned block. */ 60 54 function SDCW_print_clock_styles() { 61 55 if (wp_style_is('simple-digital-clock-block-style', 'enqueued') && … … 65 59 } 66 60 67 /** Empty editors still need preview assets, including their iframe canvas. */ 61 require_once SDCW_PATH . 'includes/simple-digital-clock-output.php'; 62 63 /** Only ordinary HTML may receive generated script tags. */ 64 function SDCW_is_frontend_html() { 65 foreach (headers_list() as $header) { 66 if (0 === stripos($header, 'Content-Type:') && !preg_match('~^Content-Type:\s*text/html(?:\s*;|\s*$)~i', $header)) { 67 return false; 68 } 69 } 70 return true; 71 } 72 73 /** Insertion changes response length; never retain a stale fixed length. */ 74 function SDCW_prepare_frontend_length() { 75 foreach (headers_list() as $header) { 76 if (0 === stripos($header, 'Content-Length:')) { 77 if (headers_sent()) { 78 $GLOBALS['SDCW_frontend_output_blocker'] = 'content_length_already_sent'; 79 return false; 80 } 81 header_remove('Content-Length'); 82 break; 83 } 84 } 85 return true; 86 } 87 88 /** Observe delivered chunks; cleaned writes never change lexical history. */ 89 function SDCW_filter_frontend_output($html, $phase) { 90 if (($phase & PHP_OUTPUT_HANDLER_CLEAN) || !empty($GLOBALS['SDCW_frontend_assets_delivered'])) { 91 return $html; 92 } 93 if (!SDCW_is_frontend_html() || !SDCW_prepare_frontend_length()) { 94 return $html; 95 } 96 $ready = isset($GLOBALS['SDCW_frontend_asset_markup']); 97 $position = $GLOBALS['SDCW_frontend_observer']->feed($html, $ready); 98 if ($ready && null !== $position) { 99 $GLOBALS['SDCW_frontend_assets_delivered'] = true; 100 return substr($html, 0, $position) . $GLOBALS['SDCW_frontend_asset_markup'] . substr($html, $position); 101 } 102 return $html; 103 } 104 105 function SDCW_start_frontend_output() { 106 if (is_admin() || is_feed() || is_robots() || is_trackback() || wp_is_json_request() || 107 isset($GLOBALS['SDCW_frontend_observer']) || !SDCW_is_frontend_html()) { 108 return; 109 } 110 if (!SDCW_prepare_frontend_length()) { 111 return; 112 } 113 $GLOBALS['SDCW_frontend_observer'] = new SDCW_Clock_Output_Observer(); 114 ob_start('SDCW_filter_frontend_output', 1); 115 add_action('wp_footer', 'SDCW_capture_frontend_assets', 19); 116 } 117 add_action('template_redirect', 'SDCW_start_frontend_output', PHP_INT_MAX); 118 119 /** Capture only Core-generated runtime tags, not page content or layout CSS. */ 120 function SDCW_capture_frontend_assets() { 121 if (isset($GLOBALS['SDCW_frontend_asset_markup']) || !SDCW_is_frontend_html() || 122 !SDCW_prepare_frontend_length()) { 123 return; 124 } 125 SDCW_register_assets(); 126 ob_start(); 127 wp_scripts()->do_items(array('simple-digital-clock'), 1); 128 $GLOBALS['SDCW_frontend_asset_markup'] = ob_get_clean(); 129 // A late owned render must still print its layout after footer priority 19. 130 add_action('wp_footer', 'SDCW_print_clock_styles', PHP_INT_MAX); 131 echo '<!-- -->'; 132 } 133 68 134 function SDCW_enqueue_editor_clock_assets() { 69 135 $screen = function_exists('get_current_screen') ? get_current_screen() : null; -
simple-digital-clock/trunk/languages/simple-digital-clock.pot
r3796553 r3797104 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Simple Digital Clock 🕒 1.1. 4\n"5 "Project-Id-Version: Simple Digital Clock 🕒 1.1.5\n" 6 6 "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/simple-digital-clock\n" 7 7 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -
simple-digital-clock/trunk/readme.txt
r3796553 r3797104 6 6 Requires at least: 6.3 7 7 Requires PHP: 7.0 8 Stable tag: 1.1. 48 Stable tag: 1.1.5 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 74 74 75 75 = Is it fast? = 76 Yes. The bundled clock widget is about 12.2 KiB gzip and is served locally without a runtime JavaScript CDN dependency. Frontend JavaScript and the inline layout rule are queued when WordPress renders the Simple Digital Clock block, including block-based widget areas. The plugin does not scan or buffer page HTML. Custom templates, shortcodes or raw HTML integrations must call SDCW_enqueue_scripts() when they output a clock. If another plugin removes an already rendered clock later, its queued assets may remain. Multiple clocks share one runtime script and one inline layout rule per page; no external plugin stylesheet is loaded.76 Yes. The bundled clock widget is about 12.2 KiB gzip and is served locally without a runtime JavaScript CDN dependency. On the frontend, the runtime is delivered only when a clock is present in the server-rendered page HTML; clock-free pages receive no plugin script or browser loader. Multiple clocks share one runtime script. The inline layout rule remains scoped to rendered Simple Digital Clock blocks and explicit integrations; raw HTML keeps its existing layout. No external plugin stylesheet is loaded. Server-side HTML observation adds PHP work, including on clock-free pages. 77 77 78 = What about clocks created later by custom JavaScript? = 79 Automatic delivery detects server-rendered clocks. An integration that creates its first clock only after page load must load the widget runtime itself. Calling SDCW_enqueue_scripts() without rendering a clock on the server does not bypass the zero-script rule. 80 81 = What if my site caches complete HTML pages? = 82 Regenerate full-page caches after updating so visitors receive the corrected HTML. Cached pages served without WordPress running are not rewritten by the plugin. 78 83 == Screenshots == 79 84 … … 102 107 103 108 == Changelog == 109 110 = 1.1.5 = 111 * Restore automatic clock rendering in existing raw HTML, Custom HTML/Text widgets, templates and shortcode integrations after updating from 1.1.2 or 1.1.4. 112 * Load the runtime only for actual server-rendered clocks, including raw HTML and cached fragments, while preserving raw HTML layout. 113 * Retain the Gutenberg, legacy metadata and localization fixes from 1.1.4 without changing stored content. 104 114 105 115 = 1.1.4 = … … 182 192 🕒 Sync Time: [UTC](https://utctime.info/) 183 193 🗓️ Today's Date: [TodaysDateNow](https://todaysdatenow.com/) 194 195 == Upgrade Notice == 196 197 = 1.1.5 = 198 Restores clocks in existing HTML, widget and template integrations. No content migration is required. -
simple-digital-clock/trunk/widget_init.php
r3796553 r3797104 2 2 3 3 /** 4 * @version 1.1. 44 * @version 1.1.5 5 5 */ 6 6 … … 9 9 Plugin URI: https://utctime.info/ 10 10 Description: It is 🪄 a magical and easy-to-use digital clock with a beautiful UI, supporting multiple languages, locales, dates, captions, and time zones. 11 Version: 1.1. 411 Version: 1.1.5 12 12 Requires at least: 6.3 13 13 Requires PHP: 7.0
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)