| @@ -39,8 +39,39 @@ | ||
| 39 | 39 | |
| 40 | 40 | wp_set_script_translations( $handle, 'hello-plus' ); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | + public function enqueue_whats_new_onboarding_scripts() { | |
| 44 | + $screen = get_current_screen(); | |
| 45 | + | |
| 46 | + if ( 'plugins' !== $screen->id ) { | |
| 47 | + return; | |
| 48 | + } | |
| 49 | + | |
| 50 | + $handle = 'helloplus-whats-new'; | |
| 51 | + $asset_path = HELLOPLUS_SCRIPTS_PATH . $handle . '.asset.php'; | |
| 52 | + $asset_url = HELLOPLUS_SCRIPTS_URL; | |
| 53 | + | |
| 54 | + if ( ! file_exists( $asset_path ) ) { | |
| 55 | + throw new \Exception( 'You need to run `npm run build` for the "hello-plus" first.' ); | |
| 56 | + } | |
| 57 | + | |
| 58 | + $script_asset = require $asset_path; | |
| 59 | + | |
| 60 | + $script_asset['dependencies'][] = 'wp-util'; | |
| 61 | + | |
| 62 | + wp_enqueue_script( | |
| 63 | + $handle, | |
| 64 | + HELLOPLUS_SCRIPTS_URL . "$handle.js", | |
| 65 | + $script_asset['dependencies'], | |
| 66 | + $script_asset['version'], | |
| 67 | + true | |
| 68 | + ); | |
| 69 | + | |
| 70 | + wp_set_script_translations( $handle, 'hello-plus' ); | |
| 71 | + } | |
| 72 | + | |
| 43 | 73 | public function __construct() { |
| 44 | 74 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_hello_plus_onboarding_scripts' ] ); |
| 75 | + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_whats_new_onboarding_scripts' ] ); | |
| 45 | 76 | } |
| 46 | 77 | } |