Extension:WimaAdvertising
リリースの状態: 安定 |
|
|---|---|
| 実装 | 外装, 自分のウィキ, フック |
| 説明 | LocalSettings.php で定義された広告バナー |
| 作者 | WikiMANNia (WikiForMenトーク) |
| 最新バージョン | 2.11.0 (2026-05-16) |
| 互換性の方針 | master が後方互換性を維持しています。 |
| MediaWiki | 1.35+ |
| PHP | 7.3.19+ |
| データベースの変更 | いいえ |
|
|
| ライセンス | GNU 一般公衆利用許諾書 2.0 以降 |
| ダウンロード | GitHub:
注: |
WimaAdvertising 拡張機能は、Citizen, Cologne Blue, Modern, Monaco, MonoBook, Timeless, Vector 外装に対して 4 つの追加の広告ブロックを提供します。 バナーはwikiの最上部と最下部に設定される。どちらもsidebar内にある。 Google Adsense もサポートされている。
使用
One ad block is located at the top of the "MediaWiki:Sitenotice", a second one below the article text and above the category bar and two more ad blocks in the サイドバー.
By entering * AD1 and * AD2 in the MediaWiki:Sidebar, these can be placed individually.
If Sitenotice is defined, the TopBanner will be displayed randomly alternating with the Sitenotice message.
インストール
最近のMediaWiki (1.35+) のバージョンでは、以下の手順となります。
git clone https://github.com/WikiMANNia/MediaWiki-Extension-WimaAdvertising.gitでソースを確認するして、ファイルをextensions/フォルダー内のWimaAdvertisingという名前のディレクトリ内に配置します。- 以下のコードを LocalSettings.php ファイルの末尾に追加します:
wfLoadExtension( 'WimaAdvertising' );
- 更新スクリプトを実行します。このスクリプトは、この拡張機能が必要とするデータベーステーブルを自動的に作成します。
完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
Installation for older versions of MediaWiki
For MediaWiki 1.23-1.34, replace the above-mentioned "git clone" command with the following:
git clone -b REL1_25 https://github.com/WikiMANNia/MediaWiki-Extension-WimaAdvertising.git
全般的な設定
広告を有効にする。デフォルトはfalse.
$wgWimaAdvertising = true;
ログインされたユーザー向けの広告を無効にする。
デフォルトはfalse。
$wgWimaAdvertisingAnonOnly = true;
Wima web slots
BannerType
バナータイプを設定
- 取りうる値: 'advertising', 'blank', 'eventnote', 'hint'
- 既定値: 'advertising'
blankに設定するとPortletはラベル表示されない。
$wgBannerTopType = "advertising";
$wgBannerBottomType = "blank";
$wgSidebarAd1Type = "eventnote";
$wgSidebarAd2Type = "hint";
BannerCode
Set a html snippet of the banner.
$wgBannerTopCode = '<a title="Uhren-Wiki" href="https://www.uhren-wiki.net"><img src="https://wikimannia.org/skins/werbung/Werbung - Oben.jpg" width="728" height="92" alt="Werbung" /></a>';
$wgBannerBottomCode = '
Your banner code here.
';
$wgSidebarAd1Code = '<a title="Schwarzbuch Wikipedia" href="https://de.wikimannia.org/Schwarzbuch_Wikipedia"><img src="https://wikimannia.org/werbung/images/130px-Schwarzbuch_Wikipedia.jpg" alt="Schwarzbuch_Wikipedia.jpg" /></a> <p><b>Schwarzbuch Wikipedia</b></p><p class="small">Mobbing, Diffamierung und Falschinformation in der Online-Enzyklopädie, und was jetzt dagegen getan werden muss.</p><p>Im Februar 2020 im <i>Zeitgeist-Verlag</i> erschienen.</p>';
$wgSidebarAd2Code = 'Your banner code here.';
Google AdSenseを設定することもできる。
$wgSidebarAd2Code = '<script type="text/javascript"><!--
google_ad_client = "9471398824076666"; // "pub-9471398824076666"
/* ID 007 */
google_ad_slot = "3512091103";
google_ad_width = 145;
google_ad_height = 260;
google_language = "en";
google_encoding = "utf8";
// -->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
BannerStyle
バナーのためのCSSスタイル仕様を設定する。
$wgBannerTopStyle = 'text-align:center;border:1px solid blue;';
$wgBannerBottomStyle = 'text-align:center;border:1px dotted red;';
$wgSidebarAd1Style = '';
$wgSidebarAd2Style = '';
Google Adsense
広告を有効にする
Default is false.
$wgGoogleAdSense = true;
Disable advertising for logged-in users.
Default is false.
$wgGoogleAdSenseAnonOnly = true;
The type of the banner here is fix 'advertising'.
Mandatory parameters
// Replace this with your own publisher ID (google_ad_client / data-ad-client)
$wgGoogleAdSenseClient = 'none'; // Client ID for your AdSense script
$wgGoogleAdSenseHost = 'none'; // Host ID for your AdSense script
(You can get your publisher ID and ad unit ID from the "Get code" page: Get and copy the ad code.)
Optional parameters
Add any of the optional settings below – if your settings deviate from the defaults:
// Source URL of the AdSense script. No need to change - it can't deviate from the defaults.
$wgGoogleAdSenseSrc = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
// AdSenseMode. Default is 'normal'.
$wgGoogleAdSenseMode = 'responsive'; (since 2.8.2)
// Text coding. Default is 'utf8'.
$wgGoogleAdSenseEncoding = "utf8"; (until 2.7.1)
// Advertising language. Default is $wgLanguageCode.
$wgGoogleAdSenseLanguage = "en"; (until 2.7.1)
// This can be anything you like. Default is 'none'.
$wgGoogleAdSenseID = 'none'; (until 2.7.1)
Ad units
Define up to four ad units:
$wgGoogleAdSense_AD1 = [ 'slotid 1', 145, 260 ];
$wgGoogleAdSense_AD2 = [ 'slotid 2', 145, 260 ];
$wgGoogleAdSense_Top = [ 'slotid 3', 145, 260 ];
$wgGoogleAdSense_Bottom = [ 'slotid 4', 145, 260 ];
$wgGoogleAdSense_AD1 = [ 'slotid 1', 145, 260, 'rectangle' ];
$wgGoogleAdSense_AD2 = [ 'slotid 2', 145, 260, 'horizontal' ];
$wgGoogleAdSense_Top = [ 'slotid 3', 145, 260, 'vertical' ];
$wgGoogleAdSense_Bottom = [ 'slotid 4', 145, 260, 'vertical, rectangle' ];
Replace the first value with your AdSense ad unit ID (google_ad_slot / data-ad-slot) for each ad unit.
The Slot ID for your AdSense script is for example 1234580893.
Also specify in the second and third value the width and the height of the AdSense unit, specified in your AdSense account (google_ad_width / data-ad-width, google_ad_height / data-ad-height).
Values such as 'auto', '100%', '60%' etc. are accepted.
The fourth variable for data-ad-format is optional.
例
This example is doing the same as the example above in chapter BannerCode:
$wgWimaAdvertising = false;
$wgGoogleAdSense = true;
$wgGoogleAdSenseClient = '9471398824076666';
$wgGoogleAdSense_AD1 = [ '3512091103', 145, 260 ];
$wgGoogleAdSenseSrc = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js;
Compatibility with more skins
$wgSidebarAd1Code and $wgSidebarAd2Code only work if the activated skin has a sidebar. $wgBannerBottomCode and $wgBannerTopCode should always work. Only a present sidebar may require additional css support, which handles the background color of the slot and similar stuff.You may avoid a PHP warning message by altering line 44 in file Hooks.php from
} else if ( $skinname !== 'fallback' ) {
into
} else if ( !in_array( $skinname, [ 'yourfavoriteskin', 'fallback' ] ) ) {
See also
- PCR GUI Inserts did something similar since REL 1.23, but not as sophisticated.
- ShoutWiki Ads
Remarks
- Branch REL1_25 for MediaWiki 1.23 up to 1.35.
- The branch REL1_25 was tested with the following MediaWiki versions: 1.23.17, 1.25.6, 1.31.16, 1.35.14
- Branch REL1_35 for MediaWiki 1.35+.
- The branch REL1_35 was tested with the following MediaWiki versions: 1.35.14, 1.39.17, 1.40.2, 1.41.2, 1.42.3, 1.43.8, 1.45.3
- Version 2.1 has added support for Skin
vector-2022. - Version 2.2 has added support for Skin
Timeless. - Version 2.3 has added Hook SkinAfterPortlet for supporting MediaWiki 1.35+.
- Version 2.4 has some Refactoring:
- Changed “configuration schema”, replaced manifest version 1 with version 2 and changed the prefix of the configuration variables from default to
wm. - Replaced class “WimaAdvertisingHooks” (extends “Hooks”) with class implements interfaces.
- Changed “configuration schema”, replaced manifest version 1 with version 2 and changed the prefix of the configuration variables from default to
- Version 2.4.1 contains a dirty hack for skin
Timeless. - Version 2.5 places JavaScript for GoogleAdSense in
<head>section. - Version 2.6 allows the labeling of Wima slots to be set as `blank`.
- Version 2.7 has added support for Skin
Monaco.- Note: To make the Ads in the Sidebar work is the use of a Fork of Skin Monaco needed!
- Version 2.8 has changed code for GoogleAdSense, see
- https_developers.google.com/adsense/host/adunits Ad Units and Code Generation
- https_developers.google.com/adsense/platforms/transparent/ad-tags Ad tags
- Version 2.8.5:
- Changed the prefix of the configuration variables back to
wg.
- Changed the prefix of the configuration variables back to
- Version 2.9 has added support for Skin
Citizen. - Version 2.10 supports REL1_45.
Version 3.0
- The version 3.0 (alpha) has a new approach, with click-away ads that are fixed and do not disappear when scrolling, and are (largely) independent of the skin.
- At the moment only tested with MediaWiki version
1.39.1. - Download on GitHub (alpha Version)
- Stable extensions/ja
- Skin extensions/ja
- Personalization extensions/ja
- Hook extensions/ja
- BeforePageDisplay extensions/ja
- SidebarBeforeOutput extensions/ja
- SiteNoticeAfter extensions/ja
- SkinAfterContent extensions/ja
- SkinAfterPortlet extensions/ja
- GPL licensed extensions/ja
- Extensions in GitHub version control/ja
- All extensions/ja
- Advertising extensions/ja
