Extension:BetaFeatures/Hooks/GetBetaFeaturePreferences
Appearance
(Redirected from Manual:Hooks/GetBetaFeaturePreferences)
For more information about attaching hooks, see Manual:Hooks.
For examples of other extensions using this hook, see Category:GetBetaFeaturePreferences extensions.
Details
[edit]| Name | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
$user |
User whose preferences are being modified. | ||||||||||||||||||||||||||||||||||||
&$betaPrefs
|
Array of beta features. Each key is the identifier of the feature and the associated value is an array with the keys:
|
Example
[edit]In MyExtension/extension.json:
"Hooks": {
"GetBetaFeaturePreferences": "MediaWiki\\Extension\\MyExtension\\Hooks::onGetBetaFeaturePreferences"
},
In MyExtension/includes/Hooks.php:
namespace MediaWiki\Extension\MyExtension;
class Hooks {
static function onGetBetaFeaturePreferences( $user, &$prefs ) {
$extensionAssetsPath = MediaWikiServices::getInstance()
->getMainConfig()
->get( 'ExtensionAssetsPath' );
$prefs['my-awesome-feature'] = array(
// The first two are message keys
'label-message' => 'beta-feature-message',
'desc-message' => 'beta-feature-description',
// Paths to images that represent the feature.
'screenshot' => [
'ltr' => "$extensionAssetsPath/MyExtension/images/betafeature-ltr.png",
'rtl' => "$extensionAssetsPath/MyExtension/images/betafeature-rtl.png",
],
// Link to information on the feature - use subpages on mw.org, maybe?
'info-link' => 'https://mediawiki.org/wiki/Special:MyLanguage/Help:Extension:MyExtension',
// Link to discussion about the feature - talk pages might work
'discussion-link' => 'https://mediawiki.org/wiki/Help_talk:Extension:MyExtension',
);
}
}
// SpecialMyExtension.php
class SpecialMyExtension extends SpecialPage {
public function execute() {
if ( BetaFeatures::isFeatureEnabled( $this->getUser(), 'my-awesome-feature' ) ) {
// Implement the feature!
}
}
}