Skip to content

Instantly share code, notes, and snippets.

@Asikur22
Last active February 4, 2022 06:10
Show Gist options
  • Save Asikur22/f8ae8328ecf8cf342266132b09f8dc4d to your computer and use it in GitHub Desktop.
Save Asikur22/f8ae8328ecf8cf342266132b09f8dc4d to your computer and use it in GitHub Desktop.
WP Add Admin Page
/*
* 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
}
);
} );
/**
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