Commit 6e8b5a80 by Amiya Committed by Scott

Responsive adsense

parent b011cd3a
...@@ -41,6 +41,7 @@ class qa_basic_adsense ...@@ -41,6 +41,7 @@ class qa_basic_adsense
if (qa_clicked('adsense_save_button')) { if (qa_clicked('adsense_save_button')) {
$trimchars="=;\"\' \t\r\n"; // prevent common errors by copying and pasting from Javascript $trimchars="=;\"\' \t\r\n"; // prevent common errors by copying and pasting from Javascript
qa_opt('adsense_publisher_id', trim(qa_post_text('adsense_publisher_id_field'), $trimchars)); qa_opt('adsense_publisher_id', trim(qa_post_text('adsense_publisher_id_field'), $trimchars));
qa_opt('adsense_adunit_id', trim(qa_post_text('adsense_adunit_id_field'), $trimchars));
$saved=true; $saved=true;
} }
...@@ -54,6 +55,12 @@ class qa_basic_adsense ...@@ -54,6 +55,12 @@ class qa_basic_adsense
'tags' => 'name="adsense_publisher_id_field"', 'tags' => 'name="adsense_publisher_id_field"',
'note' => 'Example: <i>pub-1234567890123456</i>', 'note' => 'Example: <i>pub-1234567890123456</i>',
), ),
array(
'label' => 'AdSense Ad Unit ID:',
'value' => qa_html(qa_opt('adsense_adunit_id')),
'tags' => 'name="adsense_adunit_id_field"',
'note' => 'Example: <i>8XXXXX1</i>',
),
), ),
'buttons' => array( 'buttons' => array(
...@@ -68,38 +75,30 @@ class qa_basic_adsense ...@@ -68,38 +75,30 @@ class qa_basic_adsense
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content) public function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
{ {
$divstyle=''; $format = 'auto';
switch ($region) { switch ($region) {
case 'full': // Leaderboard case 'full':
$divstyle='width:728px; margin:0 auto;'; case 'main':
// fall-through $format='horizontal';
case 'main': // Leaderboard
$width=728;
$height=90;
$format='728x90_as';
break; break;
case 'side': // Wide skyscraper case 'side':
$width=160; $format='vertical';
$height=600;
$format='160x600_as';
break; break;
} }
?> ?>
<div style="<?php echo $divstyle?>"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script type="text/javascript"> <ins class="adsbygoogle <?php echo qa_html($region) ?>"
google_ad_client = <?php echo qa_js(qa_opt('adsense_publisher_id'))?>; style="display:block; margin:.5em auto"
google_ad_width = <?php echo qa_js($width)?>; data-ad-client="<?php echo qa_html(qa_opt('adsense_publisher_id')) ?>"
google_ad_height = <?php echo qa_js($height)?>; data-ad-slot="<?php echo qa_html(qa_opt('adsense_adunit_id')) ?>"
google_ad_format = <?php echo qa_js($format)?>; data-ad-format="<?php echo qa_html($format) ?>">
google_ad_type = "text_image"; </ins>
google_ad_channel = ""; <script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script> </script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> <?php
</div>
<?php
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment