| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation — My WordPress: asset registration. |
| 4 |
* |
| 5 |
* Registers the bundle script + CSS handles. The bundle is lazy-loaded |
| 6 |
* by the native-window sync the first time the My WordPress window |
| 7 |
* opens, the same as the recycle-bin and posts-window modules. |
| 8 |
* |
| 9 |
* @package OpenStation |
| 10 |
*/ |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
|
| 14 |
/** |
| 15 |
* Register My WordPress CSS and JS handles. |
| 16 |
*/ |
| 17 |
function openstation_my_wordpress_register_assets() { |
| 18 |
$version = OPENSTATION_VERSION; |
| 19 |
$suffix = openstation_asset_suffix(); |
| 20 |
|
| 21 |
$css_path = OPENSTATION_DIR . 'assets/css/my-wordpress.css'; |
| 22 |
wp_register_style( |
| 23 |
'desktop-mode-my-wordpress', |
| 24 |
OPENSTATION_URL . 'assets/css/my-wordpress.css', |
| 25 |
array( 'os-variables', 'dashicons' ), |
| 26 |
file_exists( $css_path ) ? (string) filemtime( $css_path ) : $version |
| 27 |
); |
| 28 |
|
| 29 |
$js_path = OPENSTATION_DIR . 'assets/js/my-wordpress' . $suffix . '.js'; |
| 30 |
wp_register_script( |
| 31 |
'desktop-mode-my-wordpress', |
| 32 |
OPENSTATION_URL . 'assets/js/my-wordpress' . $suffix . '.js', |
| 33 |
array( 'wp-i18n' ), |
| 34 |
file_exists( $js_path ) ? (string) filemtime( $js_path ) : $version, |
| 35 |
true |
| 36 |
); |
| 37 |
wp_set_script_translations( |
| 38 |
'desktop-mode-my-wordpress', |
| 39 |
'desktop-mode', |
| 40 |
OPENSTATION_DIR . 'languages' |
| 41 |
); |
| 42 |
} |
| 43 |
add_action( 'init', 'openstation_my_wordpress_register_assets', 5 ); |
| 44 |
|