| @@ -34,9 +34,9 @@ | ||
| 34 | 34 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 35 | 35 | require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 36 | 36 | include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
| 37 | 37 | |
| 38 | - $response = [ 'success' => false, 'message' => '' ]; | |
| 38 | + $response = [ 'success' => false ]; | |
| 39 | 39 | |
| 40 | 40 | $_plugins = Helper::get_plugins(); |
| 41 | 41 | $is_installed = isset( $_plugins[ $plugin['plugin_file'] ] ); |
| 42 | 42 | |
| @@ -54,14 +54,8 @@ | ||
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | if ( ! $is_installed ) { |
| 58 | - if(!Helper::current_user_can( 'install_plugins' )){ | |
| 59 | - $response['code'] = 'invalid_requirements'; | |
| 60 | - $response['message'] = __( 'Sorry, you do not have permission to install a plugin.', 'templately' ); | |
| 61 | - return $response; | |
| 62 | - } | |
| 63 | - | |
| 64 | 58 | /** |
| 65 | 59 | * @var array|object $api |
| 66 | 60 | */ |
| 67 | 61 | $api = plugins_api( 'plugin_information', [ |
| @@ -121,14 +115,8 @@ | ||
| 121 | 115 | $install_status = install_plugin_install_status( $api ); |
| 122 | 116 | $plugin['plugin_file'] = $install_status['file']; |
| 123 | 117 | } |
| 124 | 118 | |
| 125 | - if ( !Helper::current_user_can( 'activate_plugins' ) && is_plugin_inactive( $file ) ) { | |
| 126 | - $response['code'] = 'invalid_requirements'; | |
| 127 | - $response['message'] = __( 'Sorry, you do not have permission to activate a plugin.', 'templately' ); | |
| 128 | - return $response; | |
| 129 | - } | |
| 130 | - | |
| 131 | 119 | $activate_status = $this->activate_plugin( $plugin['plugin_file'] ); |
| 132 | 120 | |
| 133 | 121 | if ( is_wp_error( $activate_status ) ) { |
| 134 | 122 | $response['message'] = $activate_status->get_error_message(); |
| @@ -234,9 +222,9 @@ | ||
| 234 | 222 | if ( is_plugin_active( $file ) ) { |
| 235 | 223 | return true; |
| 236 | 224 | } |
| 237 | 225 | |
| 238 | - if ( Helper::current_user_can( 'activate_plugins' ) && is_plugin_inactive( $file ) ) { | |
| 226 | + if ( current_user_can( 'activate_plugin', $file ) && is_plugin_inactive( $file ) ) { | |
| 239 | 227 | $result = activate_plugin( $file ); |
| 240 | 228 | if ( is_wp_error( $result ) ) { |
| 241 | 229 | return $result; |
| 242 | 230 | } else { |
| @@ -252,9 +240,9 @@ | ||
| 252 | 240 | // The theme is already active |
| 253 | 241 | return true; |
| 254 | 242 | } |
| 255 | 243 | |
| 256 | - if (Helper::current_user_can('switch_themes')) { | |
| 244 | + if (current_user_can('switch_themes')) { | |
| 257 | 245 | // Activate the theme |
| 258 | 246 | switch_theme($theme_slug); |
| 259 | 247 | |
| 260 | 248 | // Check if the theme was successfully activated |