| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation — Content Graph: asset registration. |
| 4 |
* |
| 5 |
* Mirrors the my-wordpress / posts-window modules: the bundle script |
| 6 |
* + CSS handles are registered on `init` priority 5, and the |
| 7 |
* native-window sync lazy-loads BOTH the first time the Content Graph |
| 8 |
* window opens — the script via the registration's `script` arg, the |
| 9 |
* CSS as a `styles` companion (see the registration in `window.php`). |
| 10 |
* Nothing is enqueued eagerly; a session that never opens the |
| 11 |
* Corkboard downloads neither. |
| 12 |
* |
| 13 |
* @package OpenStation |
| 14 |
*/ |
| 15 |
|
| 16 |
defined( 'ABSPATH' ) || exit; |
| 17 |
|
| 18 |
/** |
| 19 |
* Register Content Graph CSS and JS handles. |
| 20 |
*/ |
| 21 |
function openstation_content_graph_register_assets() { |
| 22 |
$version = OPENSTATION_VERSION; |
| 23 |
$suffix = openstation_asset_suffix(); |
| 24 |
|
| 25 |
$css_path = OPENSTATION_DIR . 'assets/css/content-graph.css'; |
| 26 |
wp_register_style( |
| 27 |
'desktop-mode-content-graph', |
| 28 |
OPENSTATION_URL . 'assets/css/content-graph.css', |
| 29 |
array( 'os-variables', 'dashicons' ), |
| 30 |
file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version |
| 31 |
); |
| 32 |
|
| 33 |
$js_path = OPENSTATION_DIR . 'assets/js/content-graph' . $suffix . '.js'; |
| 34 |
wp_register_script( |
| 35 |
'desktop-mode-content-graph', |
| 36 |
OPENSTATION_URL . 'assets/js/content-graph' . $suffix . '.js', |
| 37 |
array( 'wp-i18n' ), |
| 38 |
file_exists( $js_path ) ? (string) filemtime( $js_path ) : $version, |
| 39 |
true |
| 40 |
); |
| 41 |
wp_set_script_translations( |
| 42 |
'desktop-mode-content-graph', |
| 43 |
'desktop-mode', |
| 44 |
OPENSTATION_DIR . 'languages' |
| 45 |
); |
| 46 |
} |
| 47 |
add_action( 'init', 'openstation_content_graph_register_assets', 5 ); |
| 48 |
|