| @@ -81,45 +81,40 @@ | ||
| 81 | 81 | |
| 82 | 82 | // Get posted data. |
| 83 | 83 | $plugin_slug = FrmAppHelper::get_post_param( 'plugin', '', 'sanitize_text_field' ); |
| 84 | 84 | |
| 85 | - if ( ! empty( get_plugins()[ $plugin_slug ] ) ) { | |
| 86 | - $activate = activate_plugin( $plugin_slug ); | |
| 87 | - } else { | |
| 88 | - // Include necessary files for plugin installation. | |
| 89 | - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; | |
| 90 | - require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; | |
| 85 | + // Include necessary files for plugin installation. | |
| 86 | + require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; | |
| 87 | + require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; | |
| 91 | 88 | |
| 92 | - // Get the plugin information. | |
| 93 | - $api = plugins_api( | |
| 94 | - 'plugin_information', | |
| 95 | - array( | |
| 96 | - 'slug' => $plugin_slug, | |
| 97 | - 'fields' => array( | |
| 98 | - 'sections' => false, | |
| 99 | - ), | |
| 100 | - ) | |
| 101 | - ); | |
| 102 | - if ( is_wp_error( $api ) ) { | |
| 103 | - wp_send_json_error( $api->get_error_message() ); | |
| 104 | - } | |
| 105 | - if ( ! FrmAddonsController::url_is_allowed( $api->versions['trunk'] ) ) { | |
| 106 | - wp_send_json_error( 'This download is not allowed' ); | |
| 107 | - } | |
| 89 | + // Get the plugin information. | |
| 90 | + $api = plugins_api( | |
| 91 | + 'plugin_information', | |
| 92 | + array( | |
| 93 | + 'slug' => $plugin_slug, | |
| 94 | + 'fields' => array( | |
| 95 | + 'sections' => false, | |
| 96 | + ), | |
| 97 | + ) | |
| 98 | + ); | |
| 99 | + if ( is_wp_error( $api ) ) { | |
| 100 | + wp_send_json_error( $api->get_error_message() ); | |
| 101 | + } | |
| 102 | + if ( ! FrmAddonsController::url_is_allowed( $api->versions['trunk'] ) ) { | |
| 103 | + wp_send_json_error( 'This download is not allowed' ); | |
| 104 | + } | |
| 108 | 105 | |
| 109 | - // Set up the Plugin Upgrader. | |
| 110 | - $upgrader = new Plugin_Upgrader( new WP_Ajax_Upgrader_Skin() ); | |
| 106 | + // Set up the Plugin Upgrader. | |
| 107 | + $upgrader = new Plugin_Upgrader( new WP_Ajax_Upgrader_Skin() ); | |
| 111 | 108 | |
| 112 | - // Install the plugin. | |
| 113 | - $result = $upgrader->install( $api->versions['trunk'] ); | |
| 114 | - if ( is_wp_error( $result ) ) { | |
| 115 | - wp_send_json_error( $result->get_error_message() ); | |
| 116 | - } | |
| 109 | + // Install the plugin. | |
| 110 | + $result = $upgrader->install( $api->versions['trunk'] ); | |
| 111 | + if ( is_wp_error( $result ) ) { | |
| 112 | + wp_send_json_error( $result->get_error_message() ); | |
| 113 | + } | |
| 117 | 114 | |
| 118 | - // Activate the plugin. | |
| 119 | - $activate = activate_plugin( $upgrader->plugin_info() ); | |
| 120 | - }//end if | |
| 121 | - | |
| 115 | + // Activate the plugin. | |
| 116 | + $activate = activate_plugin( $upgrader->plugin_info() ); | |
| 122 | 117 | if ( is_wp_error( $activate ) ) { |
| 123 | 118 | wp_send_json_error( $activate->get_error_message() ); |
| 124 | 119 | } |
| 125 | 120 | |
| @@ -151,18 +146,6 @@ | ||
| 151 | 146 | wp_send_json_success(); |
| 152 | 147 | } else { |
| 153 | 148 | wp_send_json_error(); |
| 154 | 149 | } |
| 155 | - } | |
| 156 | - | |
| 157 | - /** | |
| 158 | - * Check if a plugin is installed. | |
| 159 | - * | |
| 160 | - * @since 6.16 | |
| 161 | - * | |
| 162 | - * @param string $plugin_file | |
| 163 | - * @return bool | |
| 164 | - */ | |
| 165 | - private static function is_plugin_installed( $plugin_file ) { | |
| 166 | - return isset( get_plugins()[ $plugin_file ] ); | |
| 167 | 150 | } |
| 168 | 151 | } |