WordPress的功能总是让我感到困惑,因为您不能允许某些角色对某些功能进行细粒度的访问。(来自Drupal背景)
我安装了WordPress Carousel插件,我希望允许“编辑器”访问以管理Carousel,这似乎是一个合理的选择。但从插件内部看,他们对“manage\\u options”功能设置了权限。但我不希望编辑器访问与站点相关的选项(例如缓存和其他可能被破坏的选项)。下面是注册post类型的插件的代码。
允许编辑权限添加/编辑/删除旋转木马帖子的最佳方式是什么?
public function wp_carousel_post_type() {
if ( post_type_exists( \'sp_wp_carousel\' ) ) {
return;
}
// Set the WordPress carousel post type labels.
$labels = apply_filters(
\'sp_wp_carousel_post_type_labels\',
array(
\'name\' => esc_html_x( \'All Carousels\', \'wp-carousel-free\' ),
\'singular_name\' => esc_html_x( \'WP Carousel\', \'wp-carousel-free\' ),
\'add_new\' => esc_html__( \'Add New\', \'wp-carousel-free\' ),
\'add_new_item\' => esc_html__( \'Add New Carousel\', \'wp-carousel-free\' ),
\'edit_item\' => esc_html__( \'Edit Carousel\', \'wp-carousel-free\' ),
\'new_item\' => esc_html__( \'New Carousel\', \'wp-carousel-free\' ),
\'view_item\' => esc_html__( \'View Carousel\', \'wp-carousel-free\' ),
\'search_items\' => esc_html__( \'Search Carousels\', \'wp-carousel-free\' ),
\'not_found\' => esc_html__( \'No Carousels found.\', \'wp-carousel-free\' ),
\'not_found_in_trash\' => esc_html__( \'No Carousels found in trash.\', \'wp-carousel-free\' ),
\'parent_item_colon\' => esc_html__( \'Parent Item:\', \'wp-carousel-free\' ),
\'menu_name\' => esc_html__( \'WP Carousel\', \'wp-carousel-free\' ),
\'all_items\' => esc_html__( \'All Carousels\', \'wp-carousel-free\' ),
)
);
// Set the WordPress carousel post type arguments.
$args = apply_filters(
\'sp_wp_carousel_post_type_args\',
array(
\'labels\' => $labels,
\'public\' => false,
\'hierarchical\' => false,
\'exclude_from_search\' => true,
\'show_ui\' => current_user_can( \'manage_options\' ) ? true : false,
\'show_in_admin_bar\' => false,
\'menu_position\' => apply_filters( \'sp_wp_carousel_menu_position\', 120 ),
\'menu_icon\' => WPCAROUSELF_URL . \'/admin/js/wp-carousel-icon.svg\',
\'rewrite\' => false,
\'query_var\' => false,
\'supports\' => array(
\'title\',
),
)
);
register_post_type( \'sp_wp_carousel\', $args );
}