BackwardsCompatibility.class.php
4 years ago
Blocks.class.php
4 years ago
CustomPostTypes.class.php
4 years ago
Dashboard.class.php
4 years ago
DeactivationSurvey.class.php
4 years ago
InstallationWalkthrough.class.php
4 years ago
Permissions.class.php
4 years ago
ReviewAsk.class.php
4 years ago
Settings.class.php
4 years ago
Widgets.class.php
4 years ago
WooCommerceIntegration.class.php
4 years ago
template-functions.php
4 years ago
Permissions.class.php
65 lines
| 1 | <?php |
| 2 | if ( !defined( 'ABSPATH' ) ) exit; |
| 3 | |
| 4 | if ( !class_exists( 'ewdusPermissions' ) ) { |
| 5 | /** |
| 6 | * Class to handle plugin permissions for Ultimate Slider |
| 7 | * |
| 8 | * @since 2.0.0 |
| 9 | */ |
| 10 | class ewdusPermissions { |
| 11 | |
| 12 | private $plugin_permissions; |
| 13 | private $permission_level; |
| 14 | |
| 15 | public function __construct() { |
| 16 | |
| 17 | $this->plugin_permissions = array( |
| 18 | 'styling' => 2, |
| 19 | 'woocommerce' => 2, |
| 20 | 'youtube' => 2, |
| 21 | 'premium' => 2, |
| 22 | 'controls' => 2 |
| 23 | ); |
| 24 | } |
| 25 | |
| 26 | public function set_permissions() { |
| 27 | global $ewd_us_controller; |
| 28 | |
| 29 | if ( is_array( get_option( 'ewd-us-permission-level' ) ) ) { return; } |
| 30 | |
| 31 | if ( ! empty( get_option( 'ewd-us-permission-level' ) ) ) { |
| 32 | |
| 33 | update_option( 'ewd-us-permission-level', array( get_option( 'ewd-us-permission-level' ) ) ); |
| 34 | |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | $this->permission_level = get_option( 'EWD_US_Full_Version' ) == 'Yes' ? 2 : 1; |
| 39 | |
| 40 | update_option( 'ewd-us-permission-level', array( $this->permission_level ) ); |
| 41 | } |
| 42 | |
| 43 | public function get_permission_level() { |
| 44 | |
| 45 | if ( ! is_array( get_option( 'ewd-us-permission-level' ) ) ) { $this->set_permissions(); } |
| 46 | |
| 47 | $permissions_array = get_option( 'ewd-us-permission-level' ); |
| 48 | |
| 49 | $this->permission_level = is_array( $permissions_array ) ? reset( $permissions_array ) : $permissions_array; |
| 50 | } |
| 51 | |
| 52 | public function check_permission( $permission_type = '' ) { |
| 53 | |
| 54 | if ( ! $this->permission_level ) { $this->get_permission_level(); } |
| 55 | |
| 56 | return ( array_key_exists( $permission_type, $this->plugin_permissions ) ? ( $this->permission_level >= $this->plugin_permissions[$permission_type] ? true : false ) : false ); |
| 57 | } |
| 58 | |
| 59 | public function update_permissions() { |
| 60 | |
| 61 | $this->permission_level = get_option( 'ewd-us-permission-level' ); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | } |