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');
|
include( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-enable-svg.php');
|
||||||
|
|
||||||
|
|
||||||
// disabled for now
|
// disabled for now
|
||||||
|
// include( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-delete-capabilities.php');
|
||||||
// include_once( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-add-roles.php');
|
// include_once( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-add-roles.php');
|
||||||
|
|
||||||
if ( is_admin() ) {
|
if ( is_admin() ) {
|
||||||
|
|
|
@ -52,17 +52,15 @@
|
||||||
// https://wordpress.stackexchange.com/questions/108338/capabilities-and-custom-post-types#108375
|
// https://wordpress.stackexchange.com/questions/108338/capabilities-and-custom-post-types#108375
|
||||||
// https://developer.wordpress.org/reference/functions/register_post_type/#capability_type
|
// https://developer.wordpress.org/reference/functions/register_post_type/#capability_type
|
||||||
$capabilities = array(
|
$capabilities = array(
|
||||||
'read' => 'read_archive_resource',
|
'read' => 'archive_read_resource',
|
||||||
'publish_posts' => 'publish_archive_resources',
|
'publish_posts' => 'archive_publish_resources',
|
||||||
'edit_posts' => 'edit_archive_resources',
|
'edit_posts' => 'archive_edit_resources',
|
||||||
'edit_published_posts' => 'edit_archive_published_resources',
|
'edit_published_posts' => 'archive_edit_published_resources',
|
||||||
'edit_others_posts' => 'edit_other_archive_resources',
|
'edit_others_posts' => 'archive_edit_other_resources',
|
||||||
'delete_posts' => 'delete_archive_resources',
|
'delete_posts' => 'archive_delete_resources',
|
||||||
'delete_published_posts' => 'delete_archive_published_resources',
|
'delete_published_posts' => 'archive_delete_published_resources',
|
||||||
'delete_others_posts' => 'delete_archive_others_resources',
|
'delete_others_posts' => 'archive_delete_others_resources',
|
||||||
'delete_private_posts' => 'delete_archive_private_resources',
|
// 'delete_private_posts' => 'archive_delete_private_resources',
|
||||||
'upload_files' => 'upload_media_files',
|
|
||||||
'manage_categories' => 'manage_archive_resources_types',
|
|
||||||
);
|
);
|
||||||
$args = array(
|
$args = array(
|
||||||
'label' => __( 'archive_resource', 'text_domain' ),
|
'label' => __( 'archive_resource', 'text_domain' ),
|
||||||
|
@ -112,6 +110,7 @@ add_action( 'admin_init', 'archive_wpplugin_add_caps');
|
||||||
* Start custom taxonomies
|
* Start custom taxonomies
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
* https://developer.wordpress.org/plugins/taxonomies/working-with-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
|
// Register Custom Taxonomy Category for Resources
|
||||||
|
@ -137,6 +136,12 @@ add_action( 'admin_init', 'archive_wpplugin_add_caps');
|
||||||
$rewrite = array(
|
$rewrite = array(
|
||||||
'slug' => 'resource-type',
|
'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(
|
$args = array(
|
||||||
'labels' => $labels,
|
'labels' => $labels,
|
||||||
'hierarchical' => true,
|
'hierarchical' => true,
|
||||||
|
@ -146,6 +151,9 @@ add_action( 'admin_init', 'archive_wpplugin_add_caps');
|
||||||
'show_in_nav_menus' => true,
|
'show_in_nav_menus' => true,
|
||||||
'show_tagcloud' => false,
|
'show_tagcloud' => false,
|
||||||
'rewrite' => $rewrite,
|
'rewrite' => $rewrite,
|
||||||
|
'capabilities' => $capabilities,
|
||||||
|
'map_meta_cap' => true //neded to apply the new capabilities.
|
||||||
|
|
||||||
);
|
);
|
||||||
register_taxonomy( 'archive_resource_category', array( 'archive_resource' ) , $args );
|
register_taxonomy( 'archive_resource_category', array( 'archive_resource' ) , $args );
|
||||||
}
|
}
|
||||||
|
@ -177,6 +185,13 @@ add_action( 'admin_init', 'archive_wpplugin_add_caps');
|
||||||
'slug' => 'resource-tag',
|
'slug' => 'resource-tag',
|
||||||
// 'with_front' => false,
|
// '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(
|
$args = array(
|
||||||
'labels' => $labels,
|
'labels' => $labels,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
|
@ -186,6 +201,8 @@ add_action( 'admin_init', 'archive_wpplugin_add_caps');
|
||||||
'show_in_nav_menus' => true,
|
'show_in_nav_menus' => true,
|
||||||
'show_tagcloud' => true,
|
'show_tagcloud' => true,
|
||||||
'rewrite' => $rewrite,
|
'rewrite' => $rewrite,
|
||||||
|
'capabilities' => $capabilities,
|
||||||
|
'map_meta_cap' => true //neded to apply the new capabilities.
|
||||||
);
|
);
|
||||||
register_taxonomy( 'archive_resource_tag', array( 'archive_resource' ) , $args );
|
register_taxonomy( 'archive_resource_tag', array( 'archive_resource' ) , $args );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue