| 1 |
<?php |
| 2 |
/** |
| 3 |
* Progressive Web App |
| 4 |
* |
| 5 |
* @package gutenberg |
| 6 |
*/ |
| 7 |
|
| 8 |
add_filter( |
| 9 |
'admin_head', |
| 10 |
function() { |
| 11 |
$l10n = array( |
| 12 |
'logo' => file_get_contents( ABSPATH . 'wp-admin/images/wordpress-logo-white.svg' ), |
| 13 |
'siteTitle' => get_bloginfo( 'name' ), |
| 14 |
'adminUrl' => admin_url(), |
| 15 |
); |
| 16 |
wp_enqueue_script( 'wp-admin-manifest' ); |
| 17 |
wp_localize_script( 'wp-admin-manifest', 'wpAdminManifestL10n', $l10n ); |
| 18 |
} |
| 19 |
); |
| 20 |
|
| 21 |
add_filter( |
| 22 |
'load-index.php', |
| 23 |
function() { |
| 24 |
if ( ! isset( $_GET['service-worker'] ) ) { |
| 25 |
return; |
| 26 |
} |
| 27 |
|
| 28 |
header( 'Content-Type: text/javascript' ); |
| 29 |
// Must be at the admin root so the scope is correct. Move to the |
| 30 |
// wp-admin folder when merging with core. |
| 31 |
echo file_get_contents( __DIR__ . '/service-worker.js' ); |
| 32 |
exit; |
| 33 |
} |
| 34 |
); |
| 35 |
|