MenuBarにGoogle AdSenseをつける †当初、Google AdSenseは skin/pukiwiki.skin.php を直接書き換えて表示させていたのだけど、あまりスマートなものじゃないので、プラグイン化した。 ただし、このwikiページ専用のものなので、プラグインとして汎用性はない。 ソースコード †<?php define('PLUGIN_MENUBAR_GOOGLE_ADSENSE_USAGE', '#menubar_google_AdSense(google_ad_client, google_ad_slot)'); function plugin_menubar_google_AdSense_convert() { $google_ad_client = ''; if (func_num_args()) { $args = func_get_args(); if (!isset($args[0])) { return PLUGIN_MENUBAR_GOOGLE_ADSENSE_USAGE . '<br />'; } else { $google_ad_client = $args[0]; } $google_ad_slot = $args[1]; } $ret_string = '<script type="text/javascript"><!--' . "\n"; $ret_string .= 'google_ad_client = "' . $google_ad_client . '";' . "\n"; $ret_string .= '/* 160x600, 作成済み 08/04/29 */' . "\n"; $ret_string .= 'google_ad_slot = "' . $google_ad_slot . '";' . "\n"; $ret_string .= 'google_ad_width = 160;' . "\n"; $ret_string .= 'google_ad_height = 600;' . "\n"; $ret_string .= '//-->' . "\n"; $ret_string .= '</script>' . "\n"; $ret_string .= '<script type="text/javascript"' . "\n"; $ret_string .= 'src="http://pagead2.googlesyndication.com/pagead/show_ads.js">' . "\n"; $ret_string .= '</script>' . "\n"; return $ret_string; } ?> これを [PukiWiki-DIR]/plugin/menubar_google_adsense.inc.php として保存して、メニューバーの中で #menubar_google_AdSense(google_ad_client値,google_ad_slot値) とすると、 |