PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.0
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
← All changes | app/Http/Controllers/SettingController.php +58 -9 2.8.02.10.0 View file →
@@ -190,8 +190,17 @@
190 190 'settings_url' => Helper::baseUrl('chat'),
191 191 'action_text' => $this->isPluginInstalled('fluent-messaging/fluent-messaging.php') ? __('Active FluentCommunity Chat', 'fluent-community') : __('Install FluentCommunity Chat', 'fluent-community'),
192 192 'description' => __('FluentCommunity Chat is a real-time chat plugin for WordPress. It allows you to create a chat room for your community members.', 'fluent-community')
193 193 ],
194 + 'fluent-notify' => [
195 + 'is_repo' => false,
196 + 'title' => __('FluentNotify', 'fluent-community'),
197 + 'logo' => Helper::assetUrl('images/brands/fluent-notify.svg'),
198 + 'is_installed' => defined('FLUENT_NOTIFY_PLUGIN_VERSION'),
199 + 'learn_more_url' => 'https://fluentnotify.com',
200 + 'action_text' => $this->isPluginInstalled('fluent-notify/fluent-notify.php') ? __('Active FluentNotify', 'fluent-community') : __('Install FluentNotify', 'fluent-community'),
201 + 'description' => __('Send browser push notifications to your community members for comments, replies and mentions.', 'fluent-community')
202 + ],
194 203 'fluent-player' => [
195 204 'is_repo' => false,
196 205 'title' => __('FluentPlayer', 'fluent-community'),
197 206 'logo' => Helper::assetUrl('images/brands/fluent-player.svg'),
@@ -274,14 +283,8 @@
274 283 }
275 284
276 285 public function installPlugin(Request $request)
277 286 {
278 - if (!current_user_can('install_plugins')) {
279 - return $this->sendError([
280 - 'message' => __('You do not have permission to install plugins', 'fluent-community')
281 - ]);
282 - }
283 -
284 287 $pluginSlug = $request->get('plugin');
285 288
286 289 $addons = $this->getAddons();
287 290
@@ -290,8 +293,39 @@
290 293 }
291 294
292 295 $details = $addons[$pluginSlug];
293 296
297 + $pluginFile = $pluginSlug . '/' . $pluginSlug . '.php';
298 +
299 + // Already on disk but deactivated: that is an activation, so it answers to
300 + // activate_plugins and needs no download.
301 + if (!$details['is_repo'] && $this->isPluginInstalled($pluginFile)) {
302 + if (!current_user_can('activate_plugins')) {
303 + return $this->sendError(['message' => __('You do not have permission to activate plugins', 'fluent-community')]);
304 + }
305 +
306 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
307 +
308 + if (!is_plugin_active($pluginFile)) {
309 + $activated = activate_plugin($pluginFile);
310 +
311 + if (is_wp_error($activated)) {
312 + return $this->sendError(['message' => wp_kses_post($activated->get_error_message())]);
313 + }
314 + }
315 +
316 + return [
317 + 'message' => __('Plugin has been activated Successfully', 'fluent-community'),
318 + 'is_installed' => true
319 + ];
320 + }
321 +
322 + if (!current_user_can('install_plugins')) {
323 + return $this->sendError([
324 + 'message' => __('You do not have permission to install plugins', 'fluent-community')
325 + ]);
326 + }
327 +
294 328 if ($details['is_repo']) {
295 329 $plugin = [
296 330 'name' => $details['title'],
297 331 'repo-slug' => $pluginSlug,
@@ -302,20 +336,35 @@
302 336 } catch (\Exception $e) {
303 337 return $this->sendError(['message' => $e->getMessage()]);
304 338 }
305 339 } else {
340 + $installHook = '';
341 +
306 342 if ($pluginSlug == 'fluent-messaging') {
307 343 if (!defined('FLUENT_COMMUNITY_PRO')) {
308 344 return $this->sendError(['message' => __('FluentMessaging is a Pro Plugin. Please install FluentCommunity Pro first.', 'fluent-community')]);
309 345 }
310 - do_action('fluent_community/install_messaging_plugin');
346 + $installHook = 'fluent_community/install_messaging_plugin';
311 347 } else if ($pluginSlug == 'fluent-player') {
312 348
313 349 if (!defined('FLUENT_COMMUNITY_PRO')) {
314 - return $this->sendError(['message' => __('FluentPlayer is required pro version of FluentCommunity. Please install FluentCommunity Pro first.', 'fluent-community')]);
350 + return $this->sendError(['message' => __('FluentPlayer requires the pro version of FluentCommunity. Please install FluentCommunity Pro first.', 'fluent-community')]);
315 351 }
316 352
317 - do_action('fluent_community/install_fluent_player_plugin');
353 + $installHook = 'fluent_community/install_fluent_player_plugin';
354 + } else if ($pluginSlug == 'fluent-notify') {
355 + $installHook = 'fluent_community/install_fluent_notify_plugin';
356 + }
357 +
358 + if (!$installHook || !has_action($installHook)) {
359 + return $this->sendError(['message' => __('This plugin can not be installed from here. Please install it manually.', 'fluent-community')]);
360 + }
361 +
362 + try {
363 + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- every assigned value is a literal fluent_community/ prefixed hook, guarded above
364 + do_action($installHook);
365 + } catch (\Exception $e) {
366 + return $this->sendError(['message' => $e->getMessage()]);
318 367 }
319 368 }
320 369
321 370 return [