public static function is_current_user_can_edit($post_id = 0)
{
if (empty($post_id)) {
$post_id = get_the_ID();
}
if (!Utils::is_post_type_support($post_id)) {
return false;
}
if ('trash' === get_post_status($post_id)) {
return false;
}
$post_type_object = get_post_type_object(get_post_type($post_id));
if (empty($post_type_object)) {
return false;
}
if (!isset($post_type_object->cap->edit_post)) {
return false;
}
$edit_cap = $post_type_object->cap->edit_post;
if (!current_user_can($edit_cap, $post_id)) {
return false;
}
$user = wp_get_current_user();
$exclude_roles = get_option('elementor_exclude_user_roles', []);
$compare_roles = array_intersect($user->roles, $exclude_roles);
if (!empty($compare_roles)) {
return false;
}
return true;
}