2023-10-02 22:42:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\ConfirmEdit\Turnstile;
|
|
|
|
|
2024-01-15 20:04:46 +00:00
|
|
|
use MediaWiki\Config\Config;
|
2023-10-02 22:42:57 +00:00
|
|
|
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 {
|
2024-04-26 20:40:13 +00:00
|
|
|
if ( $config->get( 'CaptchaClass' ) === Turnstile::class ) {
|
2023-10-02 22:42:57 +00:00
|
|
|
$vars['wgConfirmEditConfig'] = [
|
2024-04-26 20:40:13 +00:00
|
|
|
'turnstileSiteKey' => $config->get( 'TurnstileSiteKey' ),
|
2023-10-02 22:42:57 +00:00
|
|
|
'turnstileScriptURL' => 'https://challenges.cloudflare.com/turnstile/v0/api.js'
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|