| There is no RationalWiki without you. We are a small non-profit with no staff – we are hundreds of volunteers who document pseudoscience and crankery around the world every day. We will never allow ads because we must remain independent. We cannot rely on big donors with corresponding big agendas. We are not the largest website around, but we believe we play an important role in defending truth and objectivity. If everyone who saw this today donated $5, we would meet our goal for 2019. |
Fighting pseudoscience isn't free. We are 100% user-supported! Help and donate $5, $20 or whatever you can today with |
User:Nx/Extensions/pagecss/pagecss.php
From RationalWiki
< User:Nx | Extensions
<?php
// Extension credits that show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
'name' => '<css> tag',
'author' => '[http://rationalwiki.com/wiki/User:Nx Nx]',
'url' => 'http://rationalwiki.com/',
'description' => 'Embed css into a page using the css tag.'
);
//Avoid unstubbing $wgParser on setHook() too early on modern (1.12+) MW versions, as per r35980
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
$wgHooks['ParserFirstCallInit'][] = 'pagecssinit';
} else { // Otherwise do things the old fashioned way
$wgExtensionFunctions[] = 'pagecssinit';
}
$wgHooks['OutputPageParserOutput'][] = 'efPageCss_ParserOutput';
function pagecssinit() {
global $wgParser;
$wgParser->setHook('css','cssrender');
return true;
}
function cssrender($input, $args, $parser)
{
/* global $wgRequest;
$nopagecss = $wgRequest->getVal( 'nopagecss', false);
if (!$nopagecss) {*/
$parser->mOutput->setProperty('pagecss', $parser->mOutput->getProperty('pagecss') . htmlspecialchars( Sanitizer::checkCss($input) ) );
/* } */
return "";
}
function efPageCss_ParserOutput( &$out, $parseroutput )
{
$cssentry = '<style type="text/css">/*<![CDATA[*/ ' . $parseroutput->getProperty('pagecss') . ' /*]]>*/</style>';
$out->addScript($cssentry);
return true;
}