mirror of
https://ghproxy.net/https://github.com/abhijitb/helix.git
synced 2025-08-28 00:34:34 +08:00
lint fixes
This commit is contained in:
parent
d106c178ac
commit
01a7f967a4
7 changed files with 395 additions and 243 deletions
52
enqueue.php
52
enqueue.php
|
@ -1,17 +1,39 @@
|
|||
<?php
|
||||
add_action('admin_enqueue_scripts', function ($hook) {
|
||||
if ($hook !== 'toplevel_page_helix') return;
|
||||
/**
|
||||
* Enqueues Helix assets and exposes configuration to the frontend.
|
||||
*
|
||||
* @package Helix
|
||||
*/
|
||||
|
||||
wp_enqueue_script('helix-app', plugin_dir_url(__FILE__) . 'build/index.js', [], null, true);
|
||||
|
||||
// Get the original route that was redirected
|
||||
$original_route = isset($_GET['helix_route']) ? $_GET['helix_route'] : '/wp-admin/';
|
||||
|
||||
wp_localize_script('helix-app', 'helixData', [
|
||||
'restUrl' => esc_url_raw(rest_url('helix/v1/')),
|
||||
'nonce' => wp_create_nonce('wp_rest'),
|
||||
'user' => wp_get_current_user(),
|
||||
'originalRoute' => $original_route,
|
||||
'adminUrl' => admin_url(),
|
||||
]);
|
||||
});
|
||||
add_action(
|
||||
'admin_enqueue_scripts',
|
||||
function ( $hook ) {
|
||||
if ( 'toplevel_page_helix' !== $hook ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_script(
|
||||
'helix-app',
|
||||
plugin_dir_url( __FILE__ ) . 'build/index.js',
|
||||
array(),
|
||||
'0.1.0',
|
||||
array()
|
||||
);
|
||||
|
||||
// Get the original route that was redirected.
|
||||
$original_route = filter_input( INPUT_GET, 'helix_route', FILTER_SANITIZE_URL );
|
||||
$original_route = $original_route ? esc_url_raw( $original_route ) : '/wp-admin/';
|
||||
|
||||
wp_localize_script(
|
||||
'helix-app',
|
||||
'helixData',
|
||||
array(
|
||||
'restUrl' => esc_url_raw( rest_url( 'helix/v1/' ) ),
|
||||
'nonce' => wp_create_nonce( 'wp_rest' ),
|
||||
'user' => wp_get_current_user(),
|
||||
'originalRoute' => $original_route,
|
||||
'adminUrl' => admin_url(),
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue