| @@ -5,15 +5,15 @@ | ||
| 5 | 5 | class SetupModule |
| 6 | 6 | { |
| 7 | 7 | public function installPlugin($repoSlug) |
| 8 | 8 | { |
| 9 | - if(!current_user_can('install_plugins')) { | |
| 9 | + if (!current_user_can('install_plugins')) { | |
| 10 | 10 | wp_send_json([ |
| 11 | - 'message' => __('Sorry! you do not have permission to install plugin', 'fluentform') | |
| 11 | + 'message' => __('Sorry! you do not have permission to install plugin', 'fluentform'), | |
| 12 | 12 | ], 423); |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - if($repoSlug == 'fluent-smtp') { | |
| 15 | + if ('fluent-smtp' == $repoSlug) { | |
| 16 | 16 | $info = $this->installFluentSMTP(); |
| 17 | 17 | wp_send_json($info); |
| 18 | 18 | } |
| 19 | 19 | } |
| @@ -28,11 +28,11 @@ | ||
| 28 | 28 | ]; |
| 29 | 29 | $this->backgroundInstaller($plugin, $plugin_id); |
| 30 | 30 | |
| 31 | 31 | return [ |
| 32 | - 'is_installed' => defined('FLUENTMAIL'), | |
| 33 | - 'config_url' => admin_url('options-general.php?page=fluent-mail#/'), | |
| 34 | - 'message' => __('FluentSMTP plugin has been installed and activated successfully', 'fluent-crm') | |
| 32 | + 'is_installed' => defined('FLUENTMAIL'), | |
| 33 | + 'config_url' => admin_url('options-general.php?page=fluent-mail#/'), | |
| 34 | + 'message' => __('FluentSMTP plugin has been installed and activated successfully', 'fluentform'), | |
| 35 | 35 | ]; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | private function backgroundInstaller($plugin_to_install, $plugin_id) |
| @@ -46,9 +46,9 @@ | ||
| 46 | 46 | WP_Filesystem(); |
| 47 | 47 | |
| 48 | 48 | $skin = new \Automatic_Upgrader_Skin(); |
| 49 | 49 | $upgrader = new \WP_Upgrader($skin); |
| 50 | - $installed_plugins = array_reduce(array_keys(\get_plugins()), array($this, 'associate_plugin_file'), array()); | |
| 50 | + $installed_plugins = array_reduce(array_keys(\get_plugins()), [$this, 'associate_plugin_file'], []); | |
| 51 | 51 | $plugin_slug = $plugin_to_install['repo-slug']; |
| 52 | 52 | $plugin_file = isset($plugin_to_install['file']) ? $plugin_to_install['file'] : $plugin_slug . '.php'; |
| 53 | 53 | $installed = false; |
| 54 | 54 | $activate = false; |
| @@ -66,11 +66,11 @@ | ||
| 66 | 66 | |
| 67 | 67 | try { |
| 68 | 68 | $plugin_information = plugins_api( |
| 69 | 69 | 'plugin_information', |
| 70 | - array( | |
| 70 | + [ | |
| 71 | 71 | 'slug' => $plugin_slug, |
| 72 | - 'fields' => array( | |
| 72 | + 'fields' => [ | |
| 73 | 73 | 'short_description' => false, |
| 74 | 74 | 'sections' => false, |
| 75 | 75 | 'requires' => false, |
| 76 | 76 | 'rating' => false, |
| @@ -82,10 +82,10 @@ | ||
| 82 | 82 | 'homepage' => false, |
| 83 | 83 | 'donate_link' => false, |
| 84 | 84 | 'author_profile' => false, |
| 85 | 85 | 'author' => false, |
| 86 | - ), | |
| 87 | - ) | |
| 86 | + ], | |
| 87 | + ] | |
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | 90 | if (is_wp_error($plugin_information)) { |
| 91 | 91 | throw new \Exception($plugin_information->get_error_message()); |
| @@ -104,19 +104,19 @@ | ||
| 104 | 104 | throw new \Exception($working_dir->get_error_message()); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | $result = $upgrader->install_package( |
| 108 | - array( | |
| 108 | + [ | |
| 109 | 109 | 'source' => $working_dir, |
| 110 | 110 | 'destination' => WP_PLUGIN_DIR, |
| 111 | 111 | 'clear_destination' => false, |
| 112 | 112 | 'abort_if_destination_exists' => false, |
| 113 | 113 | 'clear_working' => true, |
| 114 | - 'hook_extra' => array( | |
| 114 | + 'hook_extra' => [ | |
| 115 | 115 | 'type' => 'plugin', |
| 116 | 116 | 'action' => 'install', |
| 117 | - ), | |
| 118 | - ) | |
| 117 | + ], | |
| 118 | + ] | |
| 119 | 119 | ); |
| 120 | 120 | |
| 121 | 121 | if (is_wp_error($result)) { |
| 122 | 122 | throw new \Exception($result->get_error_message()); |
| @@ -122,9 +122,8 @@ | ||
| 122 | 122 | throw new \Exception($result->get_error_message()); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $activate = true; |
| 126 | - | |
| 127 | 126 | } catch (\Exception $e) { |
| 128 | 127 | } |
| 129 | 128 | |
| 130 | 129 | // Discard feedback. |
| @@ -153,5 +152,5 @@ | ||
| 153 | 152 | $filename = end($path); |
| 154 | 153 | $plugins[$filename] = $key; |
| 155 | 154 | return $plugins; |
| 156 | 155 | } |
| 157 | -} | |
| 156 | +} | |