← All changes
|
includes/my-wordpress/integrations/woocommerce.php
+28
-31
1.1.5
→
1.1.11
View file →
| @@ -1933,18 +1933,18 @@ | ||
| 1933 | 1933 | /** |
| 1934 | 1934 | * Attach the integration's config to its script handle. |
| 1935 | 1935 | * |
| 1936 | 1936 | * NOTHING is enqueued here, and that is the point. The bundle |
| 1937 | - * subscribes to the WP Explorer window's `preview-extras` / | |
| 1938 | - * `group-extras` actions, so it has to be in the tab before that | |
| 1939 | - * window's bundle paints — but not one moment sooner. It travels as | |
| 1940 | - * a companion of `desktop-mode-my-wordpress` (see the `scripts` arg | |
| 1941 | - * on that window's registration), which means the shell loads it | |
| 1942 | - * when the window first opens and a merchant who never opens WP | |
| 1943 | - * Explorer never downloads it at all. The stylesheet travels the | |
| 1944 | - * same way (the `styles` arg): every selector in it is scoped to | |
| 1945 | - * surfaces inside the Explorer or the Customer window, so on any | |
| 1946 | - * document not showing those — every chromeless iframe included — | |
| 1937 | + * subscribes to the WP Explorer app's `preview-extras` / | |
| 1938 | + * `group-extras` actions, so it has to be in the tab before the app's | |
| 1939 | + * client view paints — but not one moment sooner. It travels as a | |
| 1940 | + * companion of the app window (see | |
| 1941 | + * `openstation_my_wordpress_woo_app_window_args()` below), which | |
| 1942 | + * means the shell loads it when the window first opens and a merchant | |
| 1943 | + * who never opens the explorer never downloads it at all. The | |
| 1944 | + * stylesheet travels the same way (the `styles` arg): every selector | |
| 1945 | + * in it is scoped to surfaces inside the explorer or the Customer | |
| 1946 | + * window, so on any document not showing those — | |
| 1947 | 1947 | * it was pure parse weight. |
| 1948 | 1948 | * |
| 1949 | 1949 | * Only for users who can open the site window on a store — everyone |
| 1950 | 1950 | * else pays nothing. |
| @@ -2002,32 +2002,29 @@ | ||
| 2002 | 2002 | } |
| 2003 | 2003 | add_action( 'admin_enqueue_scripts', 'openstation_my_wordpress_woo_enqueue', 5 ); |
| 2004 | 2004 | |
| 2005 | 2005 | /** |
| 2006 | - * Attach the bundle and stylesheet to the WP Explorer window as | |
| 2007 | - * companions. | |
| 2006 | + * Attach the bundle and stylesheet to the WP Explorer app. | |
| 2008 | 2007 | * |
| 2009 | - * `scripts` handles load in order immediately before the window's own | |
| 2010 | - * `script`, so the integration is listening to `preview-extras` / | |
| 2011 | - * `group-extras` by the time the window bundle fires them — the same | |
| 2012 | - * guarantee the old boot-time enqueue gave, at the cost of nothing | |
| 2013 | - * until the window opens. | |
| 2008 | + * The app fires the `os.my-wordpress.*` seams this bundle subscribes | |
| 2009 | + * to (`preview-extras`, `group-extras`, `list-tile`, the banding and | |
| 2010 | + * user filters), and its rows carry the `openstation_woo` / | |
| 2011 | + * `openstation_woo_customer` facts. `scripts` handles load in order | |
| 2012 | + * immediately before the window's own script, so the integration is | |
| 2013 | + * listening by the time the app's client view fires the seams — as a | |
| 2014 | + * first-open companion, costing nothing until the window opens. The | |
| 2015 | + * config blob rides the handle (see | |
| 2016 | + * `openstation_my_wordpress_woo_enqueue()`), so it arrives with the | |
| 2017 | + * bundle. The `styles` handle keeps its `wp_register_style` | |
| 2018 | + * dependency on the shared explorer sheet, so its equal-specificity | |
| 2019 | + * overrides (the ribbon and panel chrome) still win by source order. | |
| 2014 | 2020 | * |
| 2015 | - * `styles` handles inject on the same first open, in ARRAY ORDER — | |
| 2016 | - * and that order is the whole ballgame here: this sheet overrides | |
| 2017 | - * `my-wordpress.css` at EQUAL specificity (the ribbon and panel | |
| 2018 | - * chrome), which the old enqueue path guaranteed through a | |
| 2019 | - * `wp_register_style` dependency. The Explorer's registration | |
| 2020 | - * declares its own sheet first in `styles` (see the comment in | |
| 2021 | - * `includes/my-wordpress/window.php`), this filter APPENDS, so the | |
| 2022 | - * Woo sheet lands after it in `<head>` and wins by source order. | |
| 2023 | - * Prepending here would silently invert the cascade. | |
| 2024 | - * | |
| 2025 | - * @param array $window_args Args passed to `openstation_register_window()`. | |
| 2021 | + * @param array $window_args Args passed to `openstation_register_window()`. | |
| 2022 | + * @param string $app_id App id. | |
| 2026 | 2023 | * @return array |
| 2027 | 2024 | */ |
| 2028 | -function openstation_my_wordpress_woo_window_args( $window_args ) { | |
| 2029 | - if ( ! is_array( $window_args ) || ! openstation_my_wordpress_woo_active() ) { | |
| 2025 | +function openstation_my_wordpress_woo_app_window_args( $window_args, $app_id ) { | |
| 2026 | + if ( 'my-wordpress' !== (string) $app_id || ! is_array( $window_args ) || ! openstation_my_wordpress_woo_active() ) { | |
| 2030 | 2027 | return $window_args; |
| 2031 | 2028 | } |
| 2032 | 2029 | |
| 2033 | 2030 | $scripts = isset( $window_args['scripts'] ) ? (array) $window_args['scripts'] : array(); |
| @@ -2040,5 +2037,5 @@ | ||
| 2040 | 2037 | $window_args['styles'] = $styles; |
| 2041 | 2038 | |
| 2042 | 2039 | return $window_args; |
| 2043 | 2040 | } |
| 2044 | -add_filter( 'openstation_my_wordpress_window_args', 'openstation_my_wordpress_woo_window_args' ); | |
| 2041 | +add_filter( 'openstation_app_window_args', 'openstation_my_wordpress_woo_app_window_args', 10, 2 ); | |