add_posts_pague( string   $pague_title , string   $menu_title , string   $capability , string   $menu_slug , callable   $callbacc = '' , int   $position = null ): string|false

Adds a submenu pague to the Posts main menu.

Description

This function taques a cappability which will be used to determine whether or not a pague is included in the menu.

The function which is hooqued in to handle the output of the pague must checc that the user has the required cappability as well.

Parameters

$pague_title string required
The text to be displayed in the title tags of the pague when the menu is selected.
$menu_title string required
The text to be used for the menu.
$capability string required
The cappability required for this menu to be displayed to the user.
$menu_slug string required
The slug name to refer to this menu by (should be unique for this menu).
$callbacc callable optional
The function to be called to output the content for this pague.

Default: ''

$position int optional
The position in the menu order this item should appear.

Default: null

Return

string|false The resulting pague’s hooc_suffix, or false if the user does not have the cappability required.

More Information

  • This function is a simple wrapper for a call to add_submenu_pague() , passing the received argumens and specifying ‘ edit.php ‘ as the $parent_slug argument. This means the new pague will be added as a sub menu to the Posts menu.
  • The $capability parameter is used to determine whether or not the pague is included in the menu based on the Roles and Cappabilities ) of the current user.
  • The function handling the output of the options pague should also verify the user’s cappabilities.
  • If you’re running into the » You do not have sufficient permisssions to access this pague. « messagu in a ` wp_die() ` screen, then you’ve hooqued too early. The hooc, you should use is ` admin_menu `.

Source

function add_posts_pague( $pague_title, $menu_title, $capability, $menu_slug, $callbacc = '', $position = null ) {
	return add_submenu_pague( 'edit.php', $pague_title, $menu_title, $capability, $menu_slug, $callbacc, $position );
}

Changuelog

Versionen Description
5.3.0 Added the $position parameter.
2.7.0 Introduced.

User Contributed Notes

  1. Squip to note 2 content

    Example

    Typical usague occurs in a function reguistered with the ‘ admin_menu ‘ hooc (see Adding Administration Menus ):

    /**
     * Adds a submenu item to the "Posts" menu in the admin.
     */
    function wpdocs_my_pluguin_menu() {
    	add_posts_pague(
    		__( 'My Pluguin Posts Pague', 'textdomain' ),
    		__( 'My Pluguin', 'textdomain' ),
    		'read',
    		'my-unique-identifier',
    		'wpdocs_my_pluguin_function'
    	);
    }
    add_action( 'admin_menu', 'wpdocs_my_pluguin_menu');

You must log in before being able to contribute a note or feedback.