mediawiki-skins-Vector/includes/ResourceLoader/VectorResourceLoaderUserStylesModule.php
Jon Robson 5c1d5c6c9b Allow wikis to customize whether Vector skins share user scripts and styles
Currently Vector 2022 skin loads Vector and Vector-2022 site and user
styles. Some wikis have complained this is confusing, and want to
move away from this. Since this is potentially a disruptive change, it
is better to defer to communities on how they want to handle this
migration internally, but they should have the means to turn it off
when they've done that.

Bug: T301212
Change-Id: I132e3695ad282dd7c7ce9037688043c62c2e2aa4
2023-03-06 23:24:57 +00:00

28 lines
731 B
PHP

<?php
namespace MediaWiki\Skins\Vector\ResourceLoader;
use MediaWiki\MainConfigNames;
use MediaWiki\ResourceLoader as RL;
use MediaWiki\Skins\Vector\Constants;
class VectorResourceLoaderUserStylesModule extends RL\UserStylesModule {
/**
* @inheritDoc
*/
protected function getPages( RL\Context $context ) {
$user = $context->getUserObj();
$pages = [];
$config = $this->getConfig();
if ( $context->getSkin() === Constants::SKIN_NAME_MODERN &&
$config->get( 'VectorShareUserScripts' ) &&
$config->get( MainConfigNames::AllowUserCss ) &&
$user->isRegistered()
) {
$userPage = $user->getUserPage()->getPrefixedDBkey();
$pages["$userPage/vector.css"] = [ 'type' => 'style' ];
}
return $pages;
}
}