capabilities properly added to plugin.
This commit is contained in:
parent
fdd6a154ad
commit
99bae4b6d5
|
@ -56,7 +56,9 @@ include( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-init-textdomain.php');
|
|||
|
||||
include( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-enable-svg.php');
|
||||
|
||||
|
||||
// disabled for now
|
||||
// include( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-delete-capabilities.php');
|
||||
// include_once( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-add-roles.php');
|
||||
|
||||
if ( is_admin() ) {
|
||||
|
|
|
@ -52,17 +52,15 @@
|
|||
// https://wordpress.stackexchange.com/questions/108338/capabilities-and-custom-post-types#108375
|
||||
// https://developer.wordpress.org/reference/functions/register_post_type/#capability_type
|
||||
$capabilities = array(
|
||||
'read' => 'read_archive_resource',
|
||||
'publish_posts' => 'publish_archive_resources',
|
||||
'edit_posts' => 'edit_archive_resources',
|
||||
'edit_published_posts' => 'edit_archive_published_resources',
|
||||
'edit_others_posts' => 'edit_other_archive_resources',
|
||||
'delete_posts' => 'delete_archive_resources',
|
||||
'delete_published_posts' => 'delete_archive_published_resources',
|
||||
'delete_others_posts' => 'delete_archive_others_resources',
|
||||
'delete_private_posts' => 'delete_archive_private_resources',
|
||||
'upload_files' => 'upload_media_files',
|
||||
'manage_categories' => 'manage_archive_resources_types',
|
||||
'read' => 'archive_read_resource',
|
||||
'publish_posts' => 'archive_publish_resources',
|
||||
'edit_posts' => 'archive_edit_resources',
|
||||
'edit_published_posts' => 'archive_edit_published_resources',
|
||||
'edit_others_posts' => 'archive_edit_other_resources',
|
||||
'delete_posts' => 'archive_delete_resources',
|
||||
'delete_published_posts' => 'archive_delete_published_resources',
|
||||
'delete_others_posts' => 'archive_delete_others_resources',
|
||||
// 'delete_private_posts' => 'archive_delete_private_resources',
|
||||
);
|
||||
$args = array(
|
||||
'label' => __( 'archive_resource', 'text_domain' ),
|
||||
|
@ -112,6 +110,7 @@ add_action( 'admin_init', 'archive_wpplugin_add_caps');
|
|||
* Start custom taxonomies
|
||||
* ----------------------------------------------------------------------------
|
||||
* https://developer.wordpress.org/plugins/taxonomies/working-with-custom-taxonomies/
|
||||
* https://developer.wordpress.org/reference/functions/register_taxonomy/
|
||||
*/
|
||||
|
||||
// Register Custom Taxonomy Category for Resources
|
||||
|
@ -137,15 +136,24 @@ add_action( 'admin_init', 'archive_wpplugin_add_caps');
|
|||
$rewrite = array(
|
||||
'slug' => 'resource-type',
|
||||
);
|
||||
$capabilities = array(
|
||||
'manage_terms' => 'archive_manage_resources_types',
|
||||
'edit_terms' => 'archive_edit_resources_types',
|
||||
'delete_terms' => 'archive_delete_resources_types',
|
||||
'assign_terms' => 'archive_assign_resources_types',
|
||||
);
|
||||
$args = array(
|
||||
'labels' => $labels,
|
||||
'hierarchical' => true,
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'show_admin_column' => true,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_tagcloud' => false,
|
||||
'rewrite' => $rewrite,
|
||||
'labels' => $labels,
|
||||
'hierarchical' => true,
|
||||
'public' => true,
|
||||
'show_ui' => true,
|
||||
'show_admin_column' => true,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_tagcloud' => false,
|
||||
'rewrite' => $rewrite,
|
||||
'capabilities' => $capabilities,
|
||||
'map_meta_cap' => true //neded to apply the new capabilities.
|
||||
|
||||
);
|
||||
register_taxonomy( 'archive_resource_category', array( 'archive_resource' ) , $args );
|
||||
}
|
||||
|
@ -177,6 +185,13 @@ add_action( 'admin_init', 'archive_wpplugin_add_caps');
|
|||
'slug' => 'resource-tag',
|
||||
// 'with_front' => false,
|
||||
);
|
||||
$capabilities = array(
|
||||
'manage_terms' => 'archive_manage_resources_tag',
|
||||
'edit_terms' => 'archive_edit_resources_tag',
|
||||
'delete_terms' => 'archive_delete_resources_tag',
|
||||
'assign_terms' => 'archive_assign_resources_tag',
|
||||
);
|
||||
|
||||
$args = array(
|
||||
'labels' => $labels,
|
||||
'hierarchical' => false,
|
||||
|
@ -186,6 +201,8 @@ add_action( 'admin_init', 'archive_wpplugin_add_caps');
|
|||
'show_in_nav_menus' => true,
|
||||
'show_tagcloud' => true,
|
||||
'rewrite' => $rewrite,
|
||||
'capabilities' => $capabilities,
|
||||
'map_meta_cap' => true //neded to apply the new capabilities.
|
||||
);
|
||||
register_taxonomy( 'archive_resource_tag', array( 'archive_resource' ) , $args );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue