PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.01
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.01
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 +59 -9 2.7.72.10.01 View file →
@@ -48,8 +48,9 @@
48 48 'user_badge' => 'sanitize_text_field',
49 49 'has_crm_sync' => 'sanitize_text_field',
50 50 'followers_module' => 'sanitize_text_field',
51 51 'custom_profile_fields' => 'sanitize_text_field',
52 + 'pwa_module' => 'sanitize_text_field',
52 53 ]);
53 54
54 55 $prevConfig = Utility::getFeaturesConfig();
55 56
@@ -189,8 +190,17 @@
189 190 'settings_url' => Helper::baseUrl('chat'),
190 191 'action_text' => $this->isPluginInstalled('fluent-messaging/fluent-messaging.php') ? __('Active FluentCommunity Chat', 'fluent-community') : __('Install FluentCommunity Chat', 'fluent-community'),
191 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')
192 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 + ],
193 203 'fluent-player' => [
194 204 'is_repo' => false,
195 205 'title' => __('FluentPlayer', 'fluent-community'),
196 206 'logo' => Helper::assetUrl('images/brands/fluent-player.svg'),
@@ -273,14 +283,8 @@
273 283 }
274 284
275 285 public function installPlugin(Request $request)
276 286 {
277 - if (!current_user_can('install_plugins')) {
278 - return $this->sendError([
279 - 'message' => __('You do not have permission to install plugins', 'fluent-community')
280 - ]);
281 - }
282 -
283 287 $pluginSlug = $request->get('plugin');
284 288
285 289 $addons = $this->getAddons();
286 290
@@ -289,8 +293,39 @@
289 293 }
290 294
291 295 $details = $addons[$pluginSlug];
292 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 +
293 328 if ($details['is_repo']) {
294 329 $plugin = [
295 330 'name' => $details['title'],
296 331 'repo-slug' => $pluginSlug,
@@ -301,20 +336,35 @@
301 336 } catch (\Exception $e) {
302 337 return $this->sendError(['message' => $e->getMessage()]);
303 338 }
304 339 } else {
340 + $installHook = '';
341 +
305 342 if ($pluginSlug == 'fluent-messaging') {
306 343 if (!defined('FLUENT_COMMUNITY_PRO')) {
307 344 return $this->sendError(['message' => __('FluentMessaging is a Pro Plugin. Please install FluentCommunity Pro first.', 'fluent-community')]);
308 345 }
309 - do_action('fluent_community/install_messaging_plugin');
346 + $installHook = 'fluent_community/install_messaging_plugin';
310 347 } else if ($pluginSlug == 'fluent-player') {
311 348
312 349 if (!defined('FLUENT_COMMUNITY_PRO')) {
313 - 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')]);
314 351 }
315 352
316 - 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()]);
317 367 }
318 368 }
319 369
320 370 return [