Skip to content

Commit

Permalink
Hello world react app in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidurbanski committed Nov 20, 2024
1 parent 2f3e888 commit e279c1d
Show file tree
Hide file tree
Showing 8 changed files with 18,127 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
build
19 changes: 19 additions & 0 deletions includes/admin-menu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace TodoApp;

add_action('admin_menu', __NAMESPACE__ . '\\menu');

function menu() {
add_menu_page(
'Todo App',
'Todo App',
'manage_options',
'todoapp',
__NAMESPACE__ . '\\admin_page',
);
}

function admin_page() {
echo '<div id="todo-app"></div>';
}
23 changes: 23 additions & 0 deletions includes/admin-scripts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace TodoApp;

add_action('admin_enqueue_scripts', __NAMESPACE__ . '\\scripts');

function scripts() {
$screen = get_current_screen();

if ($screen->id !== 'toplevel_page_todoapp') {
return;
}

$admin_deps = require_once TODOAPP_PLUGIN_DIR_PATH . '/build/index.asset.php';

wp_enqueue_script(
'todoapp',
TODOAPP_PLUGIN_DIR_URL . 'build/index.js',
$admin_deps['dependencies'],
$admin_deps['version'],
true
);
}
Loading

0 comments on commit e279c1d

Please sign in to comment.