< Manual:Hooks
EditFilter
Available from version 1.6.0
Perform checks on an edit
Define function:
public static function onEditFilter( $editor, $text, $section, &$error, $summary ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"EditFilter": "MyExtensionHooks::onEditFilter"
	}
}
Called from: File(s): EditPage.php
Interface: EditFilterHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:EditFilter extensions.

Details

  • $editor: EditPage instance (object)
  • $text: Contents of the edit box
  • $section: Section being edited
  • &$error: Error message to return
  • $summary: edit summary provided for edit

Notes

  • You have two options for filtering edits:
    • Return false to halt editing. You'll need to handle error messages, etc. yourself.
    • Return true and modify $error (set to a value other than ''). This will cause the page to stay in edit mode and will cause the contents of $error to be displayed above the edit box. Note: $error should be wikitext.
  • $text is the wikitext submitted by the editor. If only a section of the article was being edited, $text only contains that section. If your processing needs to take into account the entire article, use EditFilterMerged instead.

See also

This article is issued from Mediawiki. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.