Last active
December 3, 2022 07:25
-
-
Save kingjmaningo/2c546a3eae52e6bf9aa5757e50cd78aa to your computer and use it in GitHub Desktop.
Create sample page on the admin dashboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'admin_menu', 'my_admin_menu' ); | |
function my_admin_menu() { | |
add_menu_page( | |
__( 'My page name', 'my-textdomain' ), | |
__( 'My menu name', 'my-textdomain' ), | |
'manage_options', | |
'sample-page', | |
'my_admin_page_contents', | |
'dashicons-schedule', | |
3 | |
); | |
} | |
function my_admin_page_content() { ?> | |
<div class="wrap"> | |
<h1>My Settings page</h1> | |
// Notice sample | |
<div id="setting-error-settings_updated" class="notice notice-success settings-error is-dismissible"> | |
<p><strong>Form updated.</strong></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button> | |
</div> | |
// Form | |
<form name="form" action="" method="post"> | |
<input type="text" name="sample_field" value=""> | |
<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Save"></p> | |
</form> | |
</div> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment