$slug, 'fields' => [ 'sections' => false, 'language_packs' => true, ], ] ); $skin = new \WP_Ajax_Upgrader_Skin(); $upgrader = new \Plugin_Upgrader($skin); $upgrader->install($api->download_link); $file = $upgrader->plugin_info(); // Install the language pack if available. $currentLocale = get_locale(); foreach ($api->language_packs as $pack) { if ($pack['language'] === $currentLocale) { $languageUpgrader = new \Language_Pack_Upgrader($skin); $languageUpgrader->upgrade((object) $pack); break; } } // Activate the plugin. return activate_plugin($file ? $file : $fallbackPath); } }