tag.
* @param String $text Incoming text - should always be null or empty (passed by value).
* @param Array $params Attributes specified for tag - must contain 'content' (passed by value).
* @param Parser $parser Reference to currently running parser (passed by reference).
* @return String Always empty.
*/
function renderMetaKeywordsTag( $input, array $args, Parser $parser, PPFrame $frame ) {
# Short-circuit with error message if content is not specified.
if ( !isset($input) ) {
return
('';
}
// Attach post-parser hook to extract metadata and alter headers
$wgHooks['OutputPageBeforeHTML'][] = 'insertMetaKeywords';
/**
* Adds the keywords to document head.
* Usage: $wgHooks['OutputPageBeforeHTML'][] = 'insertMetaKeywords';
* @param OutputPage $out Handle to an OutputPage object - presumably $wgOut (passed by reference).
* @param String $text Output text.
* @return Boolean Always true to allow other extensions to continue processing.
*/
function insertMetaKeywords( $out, $text ) {
# Extract meta keyword
if (preg_match_all(
'//m',
$text,
$matches)===false
) return true;
$data = $matches[1];
# Merge keyword data into OutputPage as meta tag
foreach ($data AS $item) {
$content = @base64_decode($item);
if ($content)
$out->addMeta( 'keywords', $content );
}
return true;
}