| @@ -60,23 +60,18 @@ | ||
| 60 | 60 | $response['message'] = __( 'Sorry, you do not have permission to install a plugin.', 'templately' ); |
| 61 | 61 | return $response; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $plugins_api_args = [ | |
| 64 | + /** | |
| 65 | + * @var array|object $api | |
| 66 | + */ | |
| 67 | + $api = plugins_api( 'plugin_information', [ | |
| 65 | 68 | 'slug' => sanitize_key( wp_unslash( $plugin['slug'] ) ), |
| 66 | 69 | 'fields' => [ |
| 67 | 70 | 'sections' => false, |
| 68 | 71 | ], |
| 69 | - ]; | |
| 70 | - if(isset($plugin['has_license']) && $plugin['has_license']){ | |
| 71 | - $plugins_api_args['has_license'] = $plugin['has_license']; | |
| 72 | - } | |
| 73 | - /** | |
| 74 | - * @var array|object $api | |
| 75 | - */ | |
| 76 | - $api = plugins_api( 'plugin_information', $plugins_api_args); | |
| 72 | + ] ); | |
| 77 | 73 | |
| 78 | - | |
| 79 | 74 | if ( is_wp_error( $api ) ) { |
| 80 | 75 | $response['message'] = $api->get_error_message(); |
| 81 | 76 | |
| 82 | 77 | return $response; |
| @@ -126,14 +121,9 @@ | ||
| 126 | 121 | $install_status = install_plugin_install_status( $api ); |
| 127 | 122 | $plugin['plugin_file'] = $install_status['file']; |
| 128 | 123 | } |
| 129 | 124 | |
| 130 | - // `$file` was never defined here — the plugin path lives in | |
| 131 | - // $plugin['plugin_file'], and it is reassigned above when a fresh install | |
| 132 | - // resolves a different one. The undefined name made is_plugin_inactive() | |
| 133 | - // see null, which is never "active", so the guard silently collapsed to a | |
| 134 | - // bare capability test. It failed closed, but it was not the check written. | |
| 135 | - if ( !Helper::current_user_can( 'activate_plugins' ) && is_plugin_inactive( $plugin['plugin_file'] ) ) { | |
| 125 | + if ( !Helper::current_user_can( 'activate_plugins' ) && is_plugin_inactive( $file ) ) { | |
| 136 | 126 | $response['code'] = 'invalid_requirements'; |
| 137 | 127 | $response['message'] = __( 'Sorry, you do not have permission to activate a plugin.', 'templately' ); |
| 138 | 128 | return $response; |
| 139 | 129 | } |