コード例 #1
0
    function form($instance)
    {
        $instance = $this->adinj_upgrade_widget_db($instance, $instance);
        $savedfieldname = $this->get_field_name('saved');
        $savedfieldvalue = $instance['saved'];
        ?>
		
		<input type='hidden' <?php 
        $this->add_name('db_version');
        ?>
 value='<?php 
        echo $defaults['db_version'];
        ?>
' />
		<input type='hidden' name="$savedfieldname" value='$savedfieldvalue' />
		
		<p>
			<b>Title:</b><br />
			<input id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" value="<?php 
        echo $instance['title'];
        ?>
" style="width:490px;" />
		<br />
			<span style="font-size:10px;">Make sure any title complies with your ad provider's TOS. More info for <a href="http://adsense.blogspot.com/2007/04/encouraging-clicks.html" target="_new">AdSense</a> users.</span>
		</p>

		<style type="text/css">
		.adinjtable td { vertical-align: top; }
		</style>
		
		<table border="0" width="490px" class="adinjtable">
		<?php 
        $total_ad_split = adinj_total_split('advert_', $instance);
        $this->add_row('advert_', 1, 'Ad code 1', 'ui_ad_1_show', $total_ad_split, $instance);
        ?>
		</table>
		
		<?php 
        if ($savedfieldvalue != 1) {
            echo '<b>The widget needs to be saved for first time to activate the other options.</b>';
            return;
        }
        ?>
		
		<br />
		<b> Exclude this widget from page types</b>
		<?php 
        $this->add_show_hide_section('ad_pagetypes_' . uniqid(''), 'ui_pagetypes_show', $instance);
        ?>
		<?php 
        $count_pages = wp_count_posts('page', 'readable');
        $count_posts = wp_count_posts('post', 'readable');
        ?>
		<?php 
        $this->add_checkbox('exclude_front', $instance);
        ?>
front - <?php 
        echo get_bloginfo('url');
        ?>
<br />
		<?php 
        $this->add_checkbox('exclude_home', $instance);
        ?>
home page (latest posts page - may or may not be same as front)<br />
		<?php 
        $this->add_checkbox('exclude_page', $instance);
        ?>
page - <?php 
        echo $count_pages->publish;
        ?>
 single page(s)<br />
		<?php 
        $this->add_checkbox('exclude_single', $instance);
        ?>
single - <?php 
        echo $count_posts->publish;
        ?>
 single post(s)<br />
		<?php 
        $this->add_checkbox('exclude_archive', $instance);
        ?>
archive - categories, tags, authors, dates<br />
		<?php 
        $this->add_checkbox('exclude_search', $instance);
        ?>
search<br />
		<?php 
        $this->add_checkbox('exclude_404', $instance);
        ?>
404<br />
		<span style="font-size:10px;"><b>Notes:</b> Your home page is the page displaying your latest posts. It may be different to your front page if you have configured your front page to be a static page.</span><br />
		<span style="font-size:10px;">If you have <a href='options-reading.php'>set your front page</a> to be a static 'page' rather than your latest posts, the 'page' tick box will also apply to the front page.</span>
		</div>
		
		<br />
		<b> Category, tag, author and id conditions</b>
		<?php 
        $this->add_show_hide_section('ad_restrictions_' . uniqid(''), 'ui_conditions_show', $instance);
        adinj_condition_table('widget_category', 'category slugs. e.g: cat1, cat2, cat3', 'category', $instance, $this->get_field_name('widget_category_condition_mode'), $this->get_field_name('widget_category_condition_entries'));
        adinj_condition_table('widget_tag', 'tag slugs. e.g: tag1, tag2, tag3', 'tag', $instance, $this->get_field_name('widget_tag_condition_mode'), $this->get_field_name('widget_tag_condition_entries'));
        adinj_condition_table('widget_author', 'author nicknames. e.g: john, paul', 'author', $instance, $this->get_field_name('widget_author_condition_mode'), $this->get_field_name('widget_author_condition_entries'));
        adinj_condition_table('widget_id', 'post/page ids. e.g: 7, 23, 276', 'id', $instance, $this->get_field_name('widget_id_condition_mode'), $this->get_field_name('widget_id_condition_entries'));
        echo '</div>';
        ?>
		
		<br />
		<b> Spacing and alignment options</b>
		<?php 
        $this->add_show_hide_section('ad_spacing_' . uniqid(''), 'ui_spacing_show', $instance);
        ?>
		<table border="0" width="490px" class="adinjtable">
		<tr><td>
			<?php 
        adinj_add_alignment_clear_options('widget_', $instance, $this->get_field_name('align'), $this->get_field_name('clear'));
        ?>
		</td><td>
			<?php 
        adinj_add_margin_top_bottom_options('widget_', $instance, $this->get_field_name('margin_top'), $this->get_field_name('margin_bottom'));
        ?>
		</td><td>
			<?php 
        adinj_add_padding_top_bottom_options('widget_', $instance, $this->get_field_name('padding_top'), $this->get_field_name('padding_bottom'));
        ?>
		</td></tr>
		</table>
		</div>
		
		<br />
		<b> Ad rotation pool</b>
		<?php 
        $this->add_show_hide_section('ad_pool_' . uniqid(''), 'ui_ad_pool_show', $instance);
        ?>
		<table border="0" width="490px" class="adinjtable">
		<?php 
        for ($i = 2; $i <= 10; ++$i) {
            $this->add_row('advert_', $i, 'Ad code ' . $i, 'ui_ad_' . $i . '_show', $total_ad_split, $instance);
        }
        ?>
		</table></div>
		
		<br />
		<b> Alt content pool</b>
		<?php 
        $this->add_show_hide_section('alt_pool_' . uniqid(''), 'ui_alt_pool_show', $instance);
        ?>
		<table border="0" cellspacing="5" width="490px" class="adinjtable">
		<?php 
        $total_alt_split = adinj_total_split('advert_alt_', $instance);
        for ($i = 1; $i <= 3; ++$i) {
            $this->add_row('advert_alt_', $i, 'Alt content ' . $i, 'ui_alt_' . $i . '_show', $total_alt_split, $instance);
        }
        ?>
		</table></div>
		
		<br />
		
		<p>Other options to define who sees these adverts (by page age, IP, referrer) are on the main <a href='options-general.php?page=ad-injection.php'>Ad Injection settings page</a>. You can also set a global <a href='options-general.php?page=ad-injection.php#global'>page type</a> restriction for the widgets.</p>
		
		<?php 
    }
コード例 #2
0
function adinj_percentage_split($name_stem, $num, $ops, $total = NULL)
{
    // for old db -  TODO delete later
    if (adinj_db_version($ops) == 1) {
        if ($num == 1) {
            return '100%';
        }
        return '0%';
    }
    if ($total == NULL) {
        $total = adinj_total_split($name_stem, $ops);
    }
    $name = $name_stem . $num;
    $namesplit = $name . '_split';
    $percent = 0;
    if (!empty($ops[$name])) {
        if ($total == 0) {
            $percent = 0;
        } else {
            if (!empty($ops[$namesplit])) {
                $percent = $ops[$namesplit] / $total * 100;
            }
        }
    }
    $percent = number_format($percent, 1) . '%';
    return $percent;
}
コード例 #3
0
function adinj_tab_adrotation()
{
    $ops = adinj_options();
    echo <<<DOCS
\t<p><a href="#multiple_top">Top adverts</a> | <a href="#multiple_random">Random adverts</a> | <a href="#multiple_bottom">Bottom adverts</a> | <a href="#multiple_footer">Footer adverts</a> | <a href="#advanced">Advanced</a> | <a href="#docs_tags">Tag docs</a> | <a href="#testads">Test ads</a></p>
DOCS;
    $total_rand_split = adinj_total_split('ad_code_random_', $ops);
    $total_rand_alt_split = adinj_total_split('ad_code_random_alt_', $ops);
    $total_top_split = adinj_total_split('ad_code_top_', $ops);
    $total_top_alt_split = adinj_total_split('ad_code_top_alt_', $ops);
    $total_bottom_split = adinj_total_split('ad_code_bottom_', $ops);
    $total_bottom_alt_split = adinj_total_split('ad_code_bottom_alt_', $ops);
    $total_footer_split = adinj_total_split('ad_code_footer_', $ops);
    $total_footer_alt_split = adinj_total_split('ad_code_footer_alt_', $ops);
    ?>
	
	<style type="text/css">
	.adinjtable td { vertical-align: top; }
	</style>
	
	<?php 
    adinj_postbox_start(__("Ad rotation / alt content docs", 'adinj'), 'docs_adrotation');
    echo <<<DOCS
\t<p>Ad rotation / split testing and alternate content are advanced features. If you don't understand these features you probably don't need them and can therefore ignore this tab. In summary:</p>
\t<ul>
\t<li><b>Ad rotation / split testing:</b> You can define multiple adverts for the same ad space which are rotated according to the ratios you define. The percentage of views that each ad will be shows is displated beneath the ratio text box. For example if you define two ads and set both to have a ratio of '50' they will each be shown (roughly) 50% of the time. The numbers don't have to add up to 100 as the ratio is calculated based on the total. e.g. if you have two advert - one is set with a ratio of '1' and the other '3' the ratios will be 25% and 75%. Please remember this isn't strict ad rotation, it is random selection based on ratios so the ratios will be correct over a large sample of ad views, not a small sample.</li>
\t<li><b>Alternate content:</b> This is content that is displayed when ads are blocked for the user. You could use this alternate content to show other content, some kind of layout filler, or even a different type of ad. I've added support for rotation of alternate content as well.</li>
\t</ul>
DOCS;
    adinj_postbox_end();
    adinj_postbox_start(__("Top adverts", 'adinj'), 'multiple_top');
    echo '<table border="0" cellspacing="5" class="adinjtable">';
    for ($i = 1; $i <= 10; ++$i) {
        adinj_add_row_with_text_box('ad_code_top_', $i, 'Ad code', $total_top_split);
    }
    adinj_add_row_with_text_box('ad_code_top_alt_', 1, 'Alt content', $total_top_alt_split);
    adinj_add_row_with_text_box('ad_code_top_alt_', 2, 'Alt content', $total_top_alt_split);
    echo '</table>';
    adinj_postbox_end();
    adinj_postbox_start(__("Random adverts", 'adinj'), 'multiple_random');
    echo '<table border="0" cellspacing="5" class="adinjtable">';
    for ($i = 1; $i <= 10; ++$i) {
        adinj_add_row_with_text_box('ad_code_random_', $i, 'Ad code', $total_rand_split);
    }
    adinj_add_row_with_text_box('ad_code_random_alt_', 1, 'Alt content', $total_rand_alt_split);
    adinj_add_row_with_text_box('ad_code_random_alt_', 2, 'Alt content', $total_rand_alt_split);
    echo '</table>';
    adinj_postbox_end();
    adinj_postbox_start(__("Bottom adverts", 'adinj'), 'multiple_bottom');
    echo '<table border="0" cellspacing="5" class="adinjtable">';
    for ($i = 1; $i <= 10; ++$i) {
        adinj_add_row_with_text_box('ad_code_bottom_', $i, 'Ad code', $total_bottom_split);
    }
    adinj_add_row_with_text_box('ad_code_bottom_alt_', 1, 'Alt content', $total_bottom_alt_split);
    adinj_add_row_with_text_box('ad_code_bottom_alt_', 2, 'Alt content', $total_bottom_alt_split);
    echo '</table>';
    adinj_postbox_end();
    adinj_postbox_start(__("Footer adverts", 'adinj'), 'multiple_footer');
    echo '<table border="0" cellspacing="5" class="adinjtable">';
    for ($i = 1; $i <= 10; ++$i) {
        adinj_add_row_with_text_box('ad_code_footer_', $i, 'Ad code', $total_footer_split);
    }
    adinj_add_row_with_text_box('ad_code_footer_alt_', 1, 'Alt content', $total_footer_alt_split);
    adinj_add_row_with_text_box('ad_code_footer_alt_', 2, 'Alt content', $total_footer_alt_split);
    echo '</table>';
    adinj_postbox_end();
    adinj_advanced();
    adinj_docs_tags();
    adinj_testads();
}