White label mode

One of the coolest Notification features is the white labeling. To put it in this mode you’ll need to call just one function:

if ( function_exists( 'notification_whitelabel' ) ) {
	notification_whitelabel();
}

Tip: it has to be called before init 50 action.

 

What it does is just removes all the default triggers. The fun part starts with the parameters you can use. See below:

notification_whitelabel( array(
	// admin page hook under which you want the Notifications to be displayed.
	'page_hook'       => 'edit.php?post_type=page',
	// if display extensions.
	'extensions'      => false,
	// if display settings.
	'settings'        => false,
	// control settings access, provided user IDs will have an access.
	// this works only if settings are enabled.
	'settings_access' => array( 123, 456 ),
) );

If Notifications page is moved to a submenu of another page, the settings and extensions are added as a separate submenu.

 

Adjusting Notification post type labels and capabilities

As easy as using two filters.

Labels

add_filter( 'notification/whitelabel/cpt/labels', function( $labels ) {

	// these are the defaults.
	return array(
		'name'                => __( 'Notifications', 'notification' ),
		'singular_name'       => __( 'Notification', 'notification' ),
		'add_new'             => _x( 'Add New Notification', 'notification', 'notification' ),
		'add_new_item'        => __( 'Add New Notification', 'notification' ),
		'edit_item'           => __( 'Edit Notification', 'notification' ),
		'new_item'            => __( 'New Notification', 'notification' ),
		'view_item'           => __( 'View Notification', 'notification' ),
		'search_items'        => __( 'Search Notifications', 'notification' ),
		'not_found'           => __( 'No Notifications found', 'notification' ),
		'not_found_in_trash'  => __( 'No Notifications found in Trash', 'notification' ),
		'parent_item_colon'   => __( 'Parent Notification:', 'notification' ),
		'menu_name'           => __( 'Notifications', 'notification' ),
	);

} );

 

Capabilities

add_filter( 'notification/post_type/capabilities', function( $capabilities ) {

	// these are the defaults.
	return array(
		'edit_post'          => 'manage_options',
		'read_post'          => 'manage_options',
		'delete_post'        => 'manage_options',
		'edit_posts'         => 'manage_options',
		'edit_others_posts'  => 'manage_options',
		'delete_posts'       => 'manage_options',
		'publish_posts'      => 'manage_options',
		'read_private_posts' => 'manage_options'
	);

} );
1 person considered this helpful