Fandom

Wikia Developers Wiki

Code Style Guidelines

846pages on
this wiki
Add New Page
Talk0 Share

Please read Manual:Coding conventions on MediaWiki.org for general info about coding style within MediaWiki software and its extensions.

Below are some additional rules used within Wikia for convenience and consistency, along with examples and hints.

CSS

  • alphabetize the properties of a style

Useful hints

These aren't really useful and should be rewritten to state guideline, and not an example... But try to make use of them for now:
  • Add extension credits! How else are the users going to know what extensions are installed on the wiki?
  • PHP ending tag (?>) hasn't been used in MediaWiki code since r23531. Remove it if you see one.
  • Use $dbr = wfGetDB( DB_SLAVE ); instead of $dbr = &wfGetDB( DB_SLAVE ); — the ampersand there isn't needed and is a PHP4-ism.
  • Use 'single quoting' instead of "double quoting" where appropriate (for example, $wgSpecialPages, $wgExtensionMessagesFiles etc. do not need double quoting)
  • Extensions should remain self-contained as much as possible according to Brion Vibber, the head developer of MediaWiki software. Dependency on ExtensionFunctions.php is certainly not needed - see r26483 for info on how to avoid it. EasyTemplate is relatively Wikia-specific and you're advised against using it if possible.
  • } else { not }else{ or }else {
  • $wgHooks['myCoolHook'][] = 'wfMyCoolFunction';, not $wgHooks ['myCoolHook'][] = 'wfMyCoolFunction' ; or $wgHooks ['myCoolHook'][ ] = 'wfMyCoolFunction' ;
  • Right names should be lowercase instead of CamelCase for the sake of consistency — so 'privatedomains' is ok as a right name, but 'PrivateDomains' isn't
  • ©, not (C) or (c)
if ( !defined( 'MEDIAWIKI' ) ) {
	echo "This is a MediaWiki extension.\n";
	exit( 1 );
}

not

if (!defined('MEDIAWIKI'))
{
	echo "This is a MediaWiki extension.\n";
	exit(1);
}
  • @ package MediaWiki hasn't been used since r32112 and @ ingroup Extensions is now used in place of @ addtogroup Extensions

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.