Extension:Edit Section Link Transform

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
OOjs UI icon advanced.svg
Edit Section Link Transform
Release status: stable
Implementation User interface
Description Changes "[edit]" edit section links in to an icon link.
Author(s) Tim Laquatalk
Latest version 1.0 (2007-08-05)
MediaWiki 1.5+
Database changes No
License No license specified
Download see below
  • $wgEditSectionIcon
Hooks used
Translate the Edit Section Link Transform extension if it is available at translatewiki.net
Check usage and version matrix.

The Edit Section Link Transform extension replaces the boring "[edit]" links with a pretty icon of your choice.


  1. Copy the source code (below) to a file named EditSectionLinkTransform.php
  2. Create a new folder (directory) in the following location:
  3. Copy EditSectionLinkTransform.php in to the new EditSectionLinkTransform folder
  4. Add the following code to your LocalSettings.php at the bottom
//Path to YOUR "[edit]" link icon!
$wgEditSectionIcon = "$wgScriptPath/extensions/EditSectionLinkTransform/EditSectionIcon.png"; 


Source Code[edit]

if ( !defined( 'MEDIAWIKI' ) ) {
        die( 'This file is a MediaWiki extension, it is not a valid entry point' );
$wgExtensionCredits['parserhook'][] = array(
    'name'=>'Edit Section Link Transform',
    'author'=>'Tim Laqua',
    'description'=>'Replaces the [edit] EditSection link in articles with an icon.',
$wgHooks['ParserAfterTidy'][]  = 'wfEditSectionLinkTransform'; 
function wfEditSectionLinkTransform(&$parser, &$text) {
    global $wgEditSectionIcon;
    $text = preg_replace("/<span class=\"editsection\">\[<a href=\"(.+)\" title=\"(.+)\">".
        wfMsg('editsection')."<\/a>\]<\/span>/i", "<span class=\"editsection\"><a href=\"\" title=\"\"><img src=\"".
        $wgEditSectionIcon."\" width=\"16px\" height=\"16px\" border=\"0\" alt=\"\"></a></span>",
    return true;


  1. Ensure that your $wgEditSectionIcon is a valid path to a valid image!