| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace FL\Assistant\System\Integrations; |
| 5 |
|
| 6 |
|
| 7 |
/** |
| 8 |
* Class BeaverBuilder |
| 9 |
* |
| 10 |
* @package FL\Assistant\System\Integrations |
| 11 |
*/ |
| 12 |
class BeaverBuilder { |
| 13 |
|
| 14 |
|
| 15 |
/** |
| 16 |
* Checks to see if beaver builder is installed |
| 17 |
* @return bool |
| 18 |
*/ |
| 19 |
public function is_installed() { |
| 20 |
return class_exists( '\FLBuilderModel' ) && class_exists( '\FLBuilderUserAccess' ); |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Checks to see if Beaver Builder can be uses to edit a post. |
| 25 |
*/ |
| 26 |
public function can_edit_post( $post_id ) { |
| 27 |
$editable = false; |
| 28 |
$post = get_post( $post_id ); |
| 29 |
$post_types = \FLBuilderModel::get_post_types(); |
| 30 |
$user_can = current_user_can( 'edit_post', $post->ID ); |
| 31 |
$user_access = \FLBuilderUserAccess::current_user_can( 'builder_access' ); |
| 32 |
|
| 33 |
if ( in_array( $post->post_type, $post_types, true ) && $user_can && $user_access ) { |
| 34 |
$editable = true; |
| 35 |
} |
| 36 |
|
| 37 |
return (bool) apply_filters( 'fl_builder_is_post_editable', $editable ); |
| 38 |
} |
| 39 |
} |
| 40 |
|