Last active
February 4, 2022 06:10
-
-
Save Asikur22/f8ae8328ecf8cf342266132b09f8dc4d to your computer and use it in GitHub Desktop.
WP Add Admin Page
This file contains hidden or 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
/* | |
* Add Admin Hidden Page. | |
*/ | |
add_action( 'admin_menu', function () { | |
add_submenu_page( | |
'', | |
__( 'Trade License Image', 'text-domain' ), | |
__( 'Trade License Image', 'text-domain' ), | |
'manage_options', | |
'trade-license-image', | |
function () { | |
isset( $_GET['image'] ) or wp_die( '<div class="wrap"><h1>Nothing to Show on this page</h1></div>' ); | |
$image = sanitize_file_name( $_GET['image'] ); | |
?> | |
<div class="wrap"> | |
<h1><?php _e( 'Welcome to my custom admin page.', 'text-domain' ); ?></h1> | |
</div> | |
<?php | |
} | |
); | |
} ); |
This file contains hidden or 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
/** | |
Dashboard: ‘index.php’ | |
Posts: ‘edit.php’ | |
Media: ‘upload.php’ | |
Pages: ‘edit.php?post_type=page’ | |
Comments: ‘edit-comments.php’ | |
Custom Post Types: ‘edit.php?post_type=your_post_type’ | |
Appearance: ‘themes.php’ | |
Plugins: ‘plugins.php’ | |
Users: ‘users.php’ | |
Tools: ‘tools.php’ | |
Settings: ‘options-general.php’ | |
Network Settings: ‘settings.php’ | |
*/ | |
add_action( 'admin_menu', function () { | |
add_submenu_page( | |
'users.php', | |
__( 'Trade License Image', 'text-domain' ), | |
__( 'Trade License Image', 'text-domain' ), | |
'manage_options', | |
'trade-license-image', | |
function () { | |
isset( $_GET['image'] ) or wp_die( '<div class="wrap"><h1>Nothing to Show on this page</h1></div>' ); | |
$image = sanitize_file_name( $_GET['image'] ); | |
?> | |
<div class="wrap"> | |
<h1><?php _e( 'Welcome to my custom admin page.', 'text-domain' ); ?></h1> | |
</div> | |
<?php | |
} | |
); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment