<?php
define('PLUGIN_GOOGLE_ADSENSE_USAGE', '#google_AdSense(data_ad_client, data_ad_slot)');
define('PLUGIN_GOOGLE_ADSENSE_LOGIN', 'ログイン中');

function plugin_google_AdSense_convert()
{
	$google_ad_client = '';
	global $auth_user;

	if (func_num_args()) {
		$args = func_get_args();

		if (!isset($args[0])) {
			return PLUGIN_GOOGLE_ADSENSE_USAGE . '<br>';
		} else {
			$data_ad_client = $args[0];
		}

		$data_ad_slot = $args[1];
	}

	if ($auth_user) {
		$ret_string = PLUGIN_GOOGLE_ADSENSE_LOGIN . '<br>';
	} else {
		$ret_string  = '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>' . "\n";
		$ret_string .= '<!-- ディスプレイ広告 -->' . "\n";
		$ret_string .= '<ins class="adsbygoogle"' . "\n";
		$ret_string .= '     style="display:block"' . "\n";
		$ret_string .= '     data-ad-client="' . $data_ad_client . '"' . "\n";
		$ret_string .= '     data-ad-slot="' . $data_ad_slot . '"' . "\n";
		$ret_string .= '     data-ad-format="auto"' . "\n";
		$ret_string .= '     data-full-width-responsive="true"></ins>' . "\n";
		$ret_string .= '<script>' . "\n";
		$ret_string .= '     (adsbygoogle = window.adsbygoogle || []).push({});' . "\n";
		$ret_string .= '</script>' . "\n";
	}

	return $ret_string;
}
?>
