Manual:Hooks/EditFilter
From MediaWiki.org
| EditFilter | |
|---|---|
| Available from version 1.6.0 Perform checks on an edit |
|
*Define function: |
function fnMyHook( $editor, $text, $section, &$error, $summary ) { ... }
|
*Attach hook: |
$wgHooks['EditFilter'][] = 'fnMyHook'; |
| Called from: | EditPage.php |
*For more information about attaching hooks, see Manual:Hooks.
*For examples of extensions using this hook, see Category:EditFilter extensions.
[edit] 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
[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.