Extension:Add Metas

From MediaWiki.org
Jump to: navigation, search

Other languages:
català • ‎Deutsch • ‎English • ‎español • ‎suomi • ‎français • ‎italiano • ‎日本語 • ‎polski • ‎português • ‎português do Brasil • ‎sicilianu • ‎中文
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
Add Metas

Release status:Extension status experimental

ImplementationTemplate:Extension#type Example
DescriptionTemplate:Extension#description This extension enables you to add meta tags on all the pages like meta keywords.
Author(s)Template:Extension#username Luis Diaz
Latest versionTemplate:Extension#version 0.1
MediaWikiTemplate:Extension#mediawiki Tested on 1.10.0
LicenseTemplate:Extension#license No license specified
Download buntulug.com.ar

Translate the Add Metas extension if it is available at translatewiki.net

Check usage and version matrix.

What can this extension do?[edit]

This extension enables you to add meta tags on all the pages, like meta keywords

It's based on the Extension:Emoticons and Extension:MetaKeywordsTag.

Usage[edit]

Just enable the require_once in LocalSettings.php.

Installation[edit]

Just look and edit the source, I'm not a PHP developer, feel free to make changes or suggestions.

Parameters[edit]

Changes to LocalSettings.php[edit]

require_once("$IP/extensions/AddMetas.php");

Code[edit]

<?php
if( !defined( 'MEDIAWIKI' ) ) {
    echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
    die( 1 );
}

$wgExtensionCredits['other'][] = array( 
    'name' => 'Add metas', 
    'status' => 'experimental',
    'author' => 'Luis Diaz',
    'version' => '0.1',
    'url' => 'http://www.buntulug.com.ar/wiki/Add_Metas',
    'description' => 'Add some custom metas to your wiki pages.',
);

$wgHooks['OutputPageBeforeHTML'][] = 'wfAddMetas';

function wfAddMetas( &$out, &$text ) {
  global $wgTitle, $wgParser, $wgRequest, $action;
  if(
          $action !== 'edit'
       && $action !== 'history'
       && $action !== 'delete'
       && $action !== 'watch'
       && strpos( $wgParser->mTitle->mPrefixedText, 'Special:' ) === false
       && $wgParser->mTitle->mNamespace !== 8
  )
  {
    $name = $wgTitle->getPrefixedDBKey();

    $out->addMeta( 'Description', 'you meta description');
    $out->addMeta( 'Keywords', $name.', your meta keywords' );
    //$out->addMeta( 'Author', 'the author');
    //$out->addMeta( 'Rating', 'General');
    //$out->addMeta( 'Revisit', '1 DAYS');
    //$out->addMeta( "revisit-after", "5 days");
  }
  return true;
}