Created
February 29, 2024 05:48
-
-
Save jb510/9cd5f4c295b558dc49c989b6e990f934 to your computer and use it in GitHub Desktop.
Add "Manage Patterns" menu item under Pages
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 | |
/** | |
* Adds a menu item to the admin menu for managing patterns | |
*/ | |
function s9_add_manage_patterns_menu() { | |
// Check if the current user has the capability to edit pages | |
if (!current_user_can('edit_pages')) { | |
return; | |
} | |
// Use the add_submenu_page function to add the menu item under Appearance | |
add_submenu_page( | |
'edit.php?post_type=page', // The slug name for the parent menu (Pages) | |
'Manage Patterns', // The text to be displayed in the title tags of the page when the menu is selected | |
'Manage Patterns', // The text to be used for the menu | |
'edit_pages', // The capability required for this menu to be displayed to the user | |
'edit.php?post_type=wp_block' // The slug name to refer to this menu by; should be unique for this menu | |
); | |
} | |
add_action('admin_menu', 's9_add_manage_patterns_menu'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment