| @@ -46,19 +46,35 @@ | ||
| 46 | 46 | array( 'os-variables', 'dashicons', 'os-files' ), |
| 47 | 47 | file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version |
| 48 | 48 | ); |
| 49 | 49 | |
| 50 | - $js_path = OPENSTATION_DIR . 'assets/js/my-wordpress' . $suffix . '.js'; | |
| 51 | - wp_register_script( | |
| 52 | - 'desktop-mode-my-wordpress', | |
| 53 | - OPENSTATION_URL . 'assets/js/my-wordpress' . $suffix . '.js', | |
| 54 | - array( 'wp-i18n' ), | |
| 55 | - file_exists( $js_path ) ? (string) filemtime( $js_path ) : $version, | |
| 56 | - true | |
| 57 | - ); | |
| 58 | - wp_set_script_translations( | |
| 59 | - 'desktop-mode-my-wordpress', | |
| 60 | - 'desktop-mode', | |
| 61 | - OPENSTATION_DIR . 'languages' | |
| 62 | - ); | |
| 50 | + // No script handle any more: the legacy window bundle is gone. The | |
| 51 | + // explorer's JS is the `my-wordpress` app's client view, registered | |
| 52 | + // by the App Framework host. | |
| 53 | + unset( $suffix ); | |
| 63 | 54 | } |
| 64 | 55 | add_action( 'init', 'openstation_my_wordpress_register_assets', 5 ); |
| 56 | + | |
| 57 | +/** | |
| 58 | + * Ride the explorer's shared stylesheet on the WP Explorer app. | |
| 59 | + * | |
| 60 | + * `my-wordpress.css` is shell infrastructure, not one window's skin: | |
| 61 | + * the hover card, the article slots, the footprint surface and the | |
| 62 | + * folder windows' preview pane all paint with its `os-my-wordpress__*` | |
| 63 | + * classes (desktop themes target them at palette level). The app | |
| 64 | + * renders those same surfaces, so the sheet travels with its window as | |
| 65 | + * a first-open companion — one stylesheet, every consumer. | |
| 66 | + * | |
| 67 | + * @param array $window_args Args passed to `openstation_register_window()`. | |
| 68 | + * @param string $app_id App id. | |
| 69 | + * @return array | |
| 70 | + */ | |
| 71 | +function openstation_my_wordpress_app_style( $window_args, $app_id ) { | |
| 72 | + if ( 'my-wordpress' !== (string) $app_id || ! is_array( $window_args ) ) { | |
| 73 | + return $window_args; | |
| 74 | + } | |
| 75 | + $styles = isset( $window_args['styles'] ) ? (array) $window_args['styles'] : array(); | |
| 76 | + $styles[] = 'desktop-mode-my-wordpress'; | |
| 77 | + $window_args['styles'] = $styles; | |
| 78 | + return $window_args; | |
| 79 | +} | |
| 80 | +add_filter( 'openstation_app_window_args', 'openstation_my_wordpress_app_style', 10, 2 ); | |