mediawiki-extensions-Confir.../Turnstile/includes/Hooks.php
Reedy 8d3afbd390 Turnstile: Minor cleanup
Bug: T319068
Follows-Up: I0d5a74655619975f0bf61b5b672159afe5f4fb00
Change-Id: I15c26957158f22a0b6d6abb9def0e84e73c63ddc
2024-01-15 20:04:49 +00:00

28 lines
754 B
PHP

<?php
namespace MediaWiki\Extension\ConfirmEdit\Turnstile;
use MediaWiki\Config\Config;
use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
class Hooks implements ResourceLoaderGetConfigVarsHook {
/**
* Adds extra variables to the global config
*
* @param array &$vars Global variables object
* @param string $skin
* @param Config $config
*/
public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
global $wgTurnstileSiteKey;
global $wgCaptchaClass;
if ( $wgCaptchaClass === Turnstile::class ) {
$vars['wgConfirmEditConfig'] = [
'turnstileSiteKey' => $wgTurnstileSiteKey,
'turnstileScriptURL' => 'https://challenges.cloudflare.com/turnstile/v0/api.js'
];
}
}
}