MediaWiki: activate Visual Editor for all NameSpaces by default

mediawikimediawiki-extensions

I would like to activate the extension VisualEditor by default to all available and future Namespaces by default in MediaWiki. In particular see section Changing active namespaces of the VisualEditor extension page mentioned above.

This means that I would like to (if possible):

  • avoid having to modify LocalSettings.php after having added a Namespace;
  • avoid having to modify source code in MediaWiki itself;
  • avoid having to modify source code in MediaWiki Extensions (namely VisualEditor).

I saw that there has already been attempts in doing this here but it didn't work when I tried the suggested modification and it violated my rule of wanting to avoid modifying any source code (see bullet points above).

I was thinking about something like this in LocalSettings.php (based on section Changing active namespaces mentioned above):

$wgVisualEditorAvailableNamespaces = [
    * => true
];

Any ideas/suggestions?

Best Answer

The idea is to use the namespace id in your LocalSettings.php. As a consequence, you can configure your future namespaces in advance. When you will create your next namespace, it will be already configured. Please find below an example:

for ($x = 3000; $x <= 4000; $x++) {
    $egApprovedRevsEnabledNamespaces[$x] = true;
    $wgVisualEditorAvailableNamespaces[$x] = true;
}

I have tested and it worked. See you soon Pit ;)