| @@ -19,11 +19,8 @@ | ||
| 19 | 19 | * @var string |
| 20 | 20 | */ |
| 21 | 21 | protected $plugin_slug; |
| 22 | 22 | |
| 23 | - /** | |
| 24 | - * @param array $atts | |
| 25 | - */ | |
| 26 | 23 | public function __construct( $atts ) { |
| 27 | 24 | $this->plugin_file = $atts['plugin_file']; |
| 28 | 25 | list( $slug, $file ) = explode( '/', $this->plugin_file ); |
| 29 | 26 | $this->plugin_slug = $slug; |
| @@ -28,11 +25,8 @@ | ||
| 28 | 25 | list( $slug, $file ) = explode( '/', $this->plugin_file ); |
| 29 | 26 | $this->plugin_slug = $slug; |
| 30 | 27 | } |
| 31 | 28 | |
| 32 | - /** | |
| 33 | - * @return string | |
| 34 | - */ | |
| 35 | 29 | public function get_activate_link() { |
| 36 | 30 | if ( $this->is_installed() && $this->is_active() ) { |
| 37 | 31 | return ''; |
| 38 | 32 | } |
| @@ -104,13 +98,11 @@ | ||
| 104 | 98 | 'sections' => false, |
| 105 | 99 | ), |
| 106 | 100 | ) |
| 107 | 101 | ); |
| 108 | - | |
| 109 | 102 | if ( is_wp_error( $api ) ) { |
| 110 | 103 | wp_send_json_error( $api->get_error_message() ); |
| 111 | 104 | } |
| 112 | - | |
| 113 | 105 | if ( ! FrmAddonsController::url_is_allowed( $api->versions['trunk'] ) ) { |
| 114 | 106 | wp_send_json_error( 'This download is not allowed' ); |
| 115 | 107 | } |
| 116 | 108 | |
| @@ -118,9 +110,8 @@ | ||
| 118 | 110 | $upgrader = new Plugin_Upgrader( new WP_Ajax_Upgrader_Skin() ); |
| 119 | 111 | |
| 120 | 112 | // Install the plugin. |
| 121 | 113 | $result = $upgrader->install( $api->versions['trunk'] ); |
| 122 | - | |
| 123 | 114 | if ( is_wp_error( $result ) ) { |
| 124 | 115 | wp_send_json_error( $result->get_error_message() ); |
| 125 | 116 | } |
| 126 | 117 | |
| @@ -160,6 +151,18 @@ | ||
| 160 | 151 | wp_send_json_success(); |
| 161 | 152 | } else { |
| 162 | 153 | wp_send_json_error(); |
| 163 | 154 | } |
| 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 ] ); | |
| 164 | 167 | } |
| 165 | 168 | } |