PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.10
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.10
1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 All 34 releases
← All changes | includes/my-wordpress/assets.php +59 -25 0.9.01.1.10 View file →
@@ -1,14 +1,13 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — My WordPress: asset registration.
3 + * OpenStation — My WordPress: asset registration.
4 4 *
5 5 * Registers the bundle script + CSS handles. The bundle is lazy-loaded
6 6 * by the native-window sync the first time the My WordPress window
7 7 * opens, the same as the recycle-bin and posts-window modules.
8 8 *
9 - * @package WPDesktopMode
10 - * @since 0.8.0
9 + * @package OpenStation
11 10 */
12 11
13 12 defined( 'ABSPATH' ) || exit;
14 13
@@ -13,34 +12,69 @@
13 12 defined( 'ABSPATH' ) || exit;
14 13
15 14 /**
16 15 * Register My WordPress CSS and JS handles.
17 - *
18 - * @since 0.8.0
19 16 */
20 -function desktop_mode_my_wordpress_register_assets() {
21 - $version = DESKTOP_MODE_VERSION;
22 - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
17 +function openstation_my_wordpress_register_assets() {
18 + $version = OPENSTATION_VERSION;
19 + $suffix = openstation_asset_suffix();
23 20
24 - $css_path = DESKTOP_MODE_DIR . 'assets/css/my-wordpress.css';
21 + /*
22 + * `os-files` is a real dependency, not decoration. Every tile in
23 + * this window is an `<os-tile>` wearing the canonical
24 + * `.os-file-tile` chrome that `desktop-files.css` declares, and
25 + * this stylesheet overrides a handful of those declarations at
26 + * EQUAL specificity — most visibly `.os-my-wordpress__media-tile`,
27 + * which has to undo `position: absolute` + the fixed 88×104 box so
28 + * media thumbnails flow inside their CSS Grid.
29 + *
30 + * Equal specificity means source order decides, and source order is
31 + * not ours to assume: any handle depending on this one that is
32 + * enqueued before `openstation_enqueue_assets()` runs (the
33 + * WooCommerce integration enqueues its companion stylesheet at
34 + * `admin_enqueue_scripts` priority 5) pulls this file into
35 + * `WP_Dependencies::$to_do` ahead of `os-files`. The overrides then
36 + * lose, every media tile is absolutely positioned with no offsets,
37 + * and the whole grid stacks in one corner.
38 + *
39 + * Declaring the dependency makes the order a fact rather than a
40 + * coincidence. `Tests_OpenStation_TileStylesheetOrder` holds it.
41 + */
42 + $css_path = OPENSTATION_DIR . 'assets/css/my-wordpress.css';
25 43 wp_register_style(
26 44 'desktop-mode-my-wordpress',
27 - DESKTOP_MODE_URL . 'assets/css/my-wordpress.css',
28 - array( 'desktop-mode-variables', 'dashicons' ),
45 + OPENSTATION_URL . 'assets/css/my-wordpress.css',
46 + array( 'os-variables', 'dashicons', 'os-files' ),
29 47 file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version
30 48 );
31 49
32 - $js_path = DESKTOP_MODE_DIR . 'assets/js/my-wordpress' . $suffix . '.js';
33 - wp_register_script(
34 - 'desktop-mode-my-wordpress',
35 - DESKTOP_MODE_URL . 'assets/js/my-wordpress' . $suffix . '.js',
36 - array( 'wp-i18n' ),
37 - file_exists( $js_path ) ? (string) filemtime( $js_path ) : $version,
38 - true
39 - );
40 - wp_set_script_translations(
41 - 'desktop-mode-my-wordpress',
42 - 'desktop-mode',
43 - DESKTOP_MODE_DIR . 'languages'
44 - );
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 );
45 54 }
46 -add_action( 'init', 'desktop_mode_my_wordpress_register_assets', 5 );
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 );