| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation — Content Graph: asset registration. |
| 4 |
* |
| 5 |
* Mirrors the my-wordpress / recycle-bin / posts-window modules: the |
| 6 |
* bundle script + CSS handles are registered on `init` priority 5, and |
| 7 |
* the native-window sync lazy-loads the script the first time the |
| 8 |
* Content Graph window opens. The CSS is enqueued eagerly in admin |
| 9 |
* context (cheap, ~3KB) so the empty-state spinner has its layout the |
| 10 |
* moment the window mounts. |
| 11 |
* |
| 12 |
* @package OpenStation |
| 13 |
*/ |
| 14 |
|
| 15 |
defined( 'ABSPATH' ) || exit; |
| 16 |
|
| 17 |
/** |
| 18 |
* Register Content Graph CSS and JS handles. |
| 19 |
*/ |
| 20 |
function openstation_content_graph_register_assets() { |
| 21 |
$version = OPENSTATION_VERSION; |
| 22 |
$suffix = openstation_asset_suffix(); |
| 23 |
|
| 24 |
$css_path = OPENSTATION_DIR . 'assets/css/content-graph.css'; |
| 25 |
wp_register_style( |
| 26 |
'desktop-mode-content-graph', |
| 27 |
OPENSTATION_URL . 'assets/css/content-graph.css', |
| 28 |
array( 'os-variables', 'dashicons' ), |
| 29 |
file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version |
| 30 |
); |
| 31 |
|
| 32 |
$js_path = OPENSTATION_DIR . 'assets/js/content-graph' . $suffix . '.js'; |
| 33 |
wp_register_script( |
| 34 |
'desktop-mode-content-graph', |
| 35 |
OPENSTATION_URL . 'assets/js/content-graph' . $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-content-graph', |
| 42 |
'desktop-mode', |
| 43 |
OPENSTATION_DIR . 'languages' |
| 44 |
); |
| 45 |
} |
| 46 |
add_action( 'init', 'openstation_content_graph_register_assets', 5 ); |
| 47 |
|