Skip to content

Commit

Permalink
Merge pull request #2181 from CityOfPhiladelphia/custom-capabilities-…
Browse files Browse the repository at this point in the history
…cherrypick

added custom capabilities for custom taxonomies
  • Loading branch information
RitikaDesai98 authored Sep 25, 2024
2 parents c12f070 + d90f4fa commit 2226f9e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ function change_admin_post_label(){

// Add Menus as a Department Site submenu and program pages
add_menu_page('Owners', 'Owners', 'manage_categories', 'edit-tags.php?taxonomy=category', '', 'dashicons-admin-users');
add_menu_page('Audiences', 'Audiences', 'manage_categories','edit-tags.php?taxonomy=audience', '', 'dashicons-groups');
add_menu_page('Categories', 'Categories', 'manage_categories', 'edit-tags.php?taxonomy=service_type&post_type=service_page',);
add_menu_page('Tags', 'Tags', 'manage_categories', 'edit-tags.php?taxonomy=post_tag', '', 'dashicons-tag');
add_menu_page('Audiences', 'Audiences', 'manage_audiences','edit-tags.php?taxonomy=audience', '', 'dashicons-groups');
add_menu_page('Categories', 'Categories', 'manage_service-types', 'edit-tags.php?taxonomy=service_type&post_type=service_page',);
add_menu_page('Tags', 'Tags', 'manage_tags', 'edit-tags.php?taxonomy=post_tag', '', 'dashicons-tag');

add_submenu_page('edit.php', 'Announcements', 'Announcements', 'edit_posts', 'edit.php?post_type=announcement');
add_submenu_page('edit.php', 'Announcements', 'Announcements', ' edit_announcements', 'edit.php?post_type=announcement');
add_submenu_page('edit.php?post_type=service_page', 'Add Service Page', 'Add service page', 'publish_service_pages', 'post-new.php?post_type=service_page');
add_submenu_page('edit.php?post_type=programs', 'Add Program Page', 'Add program page', 'publish_programss', 'post-new.php?post_type=programs');
add_submenu_page('edit.php?post_type=programs', 'Nav Menu', 'Navigation menus', 'publish_programss', 'nav-menus.php');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ function service_type() {
'slug' => 'service-types',
'with_front' => false,
),
'capabilities' => array(
'manage_terms' => 'manage_service-types',
'edit_terms' => 'edit_service-types',
'delete_terms' => 'delete_service-types',
'assign_terms' => 'assign_service-types',
),
));
}

Expand Down Expand Up @@ -81,6 +87,12 @@ function audiences() {
'slug' => 'audiences',
'with_front' => false,
),
'capabilities' => array(
'manage_terms' => 'manage_audiences',
'edit_terms' => 'edit_audiences',
'delete_terms' => 'delete_audiences',
'assign_terms' => 'assign_audiences',
),
));
}

Expand Down Expand Up @@ -204,6 +216,12 @@ function hierarchical_tags() {
'show_ui' => true,
'show_admin_column' => true,
'_builtin' => true,
'capabilities' => array(
'manage_terms' => 'manage_tags',
'edit_terms' => 'edit_tags',
'delete_terms' => 'delete_tags',
'assign_terms' => 'assign_tags',
),
) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@ function phila_roles_and_capabilities(){
// add the custom capability to other qualified roles
get_role( 'administrator' )->add_cap( PHILA_ADMIN );
get_role( 'editor' )->add_cap( PHILA_ADMIN );
get_role( 'administrator' )->add_cap("manage_service-types");
get_role( 'administrator' )->add_cap("edit_service-types");
get_role( 'administrator' )->add_cap("delete_service-types");
get_role( 'administrator' )->add_cap("assign_service-types");
get_role( 'administrator' )->add_cap("manage_audiences");
get_role( 'administrator' )->add_cap("edit_audiences");
get_role( 'administrator' )->add_cap("delete_audiences");
get_role( 'administrator' )->add_cap("assign_audiences");
get_role( 'administrator' )->add_cap("manage_tags");
get_role( 'administrator' )->add_cap("edit_tags");
get_role( 'administrator' )->add_cap("delete_tags");
get_role( 'administrator' )->add_cap("assign_tags");

}

0 comments on commit 2226f9e

Please sign in to comment.