twork / admin
Easy WordPress admin modifications.
Installs: 12
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^7.1
Requires (Dev)
- phpunit/phpunit: 7.*
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-10-29 05:53:59 UTC
README
Example usage:
Create an admin menu and submenu.
<?php namespace Twork\App\Admin\MenuPages; use Twork\Admin\Menu; class Example extends Menu { protected $menuTitle = 'Example'; /** * Display for the menu item page. */ public function view(): void { ?> <h1>Example</h1> <form method="POST" action=""> <input type="hidden" name="twork_example" value="<?= wp_create_nonce('twork_example') ?>"> <input type="text" name="t_example"> <button type="submit" class="button action">Submit</button> </form> <?php } /** * Actions to run on on admin_init. */ public function actions() { if (isset($_POST['t_example'])) { wp_verify_nonce($_POST['twork_example'], 'twork_example'); // Do some stuff } } public function submenus() { $this->addSubmenu('A Submenu', [$this, 'submenuView']); } public function submenuView() { echo '<h1>Example Submenu</h1>'; } }