Example #1
0
function adinj_adverts_box($ops)
{
    adinj_postbox_start(__("Adverts", 'adinj'), 'adverts');
    ?>
	
	<h3><a name="topadcode"></a>Top ad (below post title - this is not a 'header' ad) [<a href="#topadplacement">placement</a>] <!--[<a href='?page=ad-injection&amp;tab=adrotation#multiple_top'>pool</a>]--></h3>
	<table border="0" class="adinjtable" width="98%">
	<tr><td>
	<textarea name="ad_code_top_1" rows="10" cols="<?php 
    adinj_table_width('ad');
    ?>
"><?php 
    echo adinj_process_text($ops['ad_code_top_1']);
    ?>
</textarea>
	<br />
	<p><span style="font-size:10px;"><b>Docs:</b> Try a <a href="#468x15">468x15</a> or <a href="#336x280">336x280</a> advert.</span></p>
	</td><td>
	<?php 
    adinj_add_alignment_options('top_');
    echo "<br /><b><a href='?page=ad-injection&amp;tab=adrotation#multiple_top'>Rotation:<br />" . adinj_percentage_split('ad_code_top_', 1, $ops) . "</a></b>";
    ?>
	</td></tr>
	</table>
	<p><span style="font-size:10px;">Be especially careful if you decide to use the 'float' layout options. Make sure that you don't have adverts floated over the top of other page elements, or vice-versa.</span></p>
	
	<h3><a name="randomadcode"></a>Random ad (inserted randomly between paragraphs) [<a href="#randomadplacement">placement</a>] <!--[<a href='?page=ad-injection&amp;tab=adrotation#multiple_random'>pool</a>]--></h3>
	<table border="0" class="adinjtable" width="98%">
	<tr><td>
	<textarea name="ad_code_random_1" rows="10" cols="<?php 
    adinj_table_width('ad');
    ?>
"><?php 
    echo adinj_process_text($ops['ad_code_random_1']);
    ?>
</textarea>
	<br />
	<p><span style="font-size:10px;"><b>Docs:</b> Try a <a href="#468x60">468x60</a> or <a href="#728x90">728x90</a> banner.</span></p>
	</td><td>
	<?php 
    adinj_add_alignment_options('rnd_');
    echo "<br /><b><a href='?page=ad-injection&amp;tab=adrotation#multiple_random'>Rotation:<br />" . adinj_percentage_split('ad_code_random_', 1, $ops) . "</a></b>";
    ?>
	</td></tr>
	</table>
	
	<h3><a name="bottomadcode"></a>Bottom ad (below the post content) [<a href="#bottomadplacement">placement</a>] <!--[<a href='?page=ad-injection&amp;tab=adrotation#multiple_bottom'>pool</a>]--></h3>
	<table border="0" class="adinjtable" width="98%">
	<tr><td>
	<textarea name="ad_code_bottom_1" rows="10" cols="<?php 
    adinj_table_width('ad');
    ?>
"><?php 
    echo adinj_process_text($ops['ad_code_bottom_1']);
    ?>
</textarea>
	<br />
	<p><span style="font-size:10px;"><b>Docs:</b> Try a <a href="#336x280">336x280</a> advert.</span></p>
	</td><td>
	<?php 
    adinj_add_alignment_options('bottom_');
    echo "<br /><b><a href='?page=ad-injection&amp;tab=adrotation#multiple_bottom'>Rotation:<br />" . adinj_percentage_split('ad_code_bottom_', 1, $ops) . "</a></b>";
    ?>
	</td></tr>
	</table>
	
	
	<h3><a name="footeradcode"></a>Footer ad (put into 'the_footer' hook - not supported by all themes) [<a href="#footeradplacement">placement</a>] <!--[<a href='?page=ad-injection&amp;tab=adrotation#multiple_footer'>pool</a>]--></h3>
	<table border="0" class="adinjtable" width="98%">
	<tr><td>
	<textarea name="ad_code_footer_1" rows="10" cols="<?php 
    adinj_table_width('ad');
    ?>
"><?php 
    echo adinj_process_text($ops['ad_code_footer_1']);
    ?>
</textarea>
	<br />
	Docs: footer ad information and troubleshooting
	<?php 
    adinj_add_show_hide_section('footer_docs_' . uniqid(''), 'ui_footer_docs_show', 'ui_footer_docs_show', $ops);
    ?>
	<blockquote>
	<p><span style="font-size:10px;">Try a <a href="#468x60">468x60</a> or <a href="#728x90">728x90</a> banner.</span></p>
	<p><span style="font-size:10px;">The footer ad will only work if your theme supports it.</span></p>
	<p><span style="font-size:10px;">Your theme must include 'the_footer' hook in the correct part of the page. If the footer ad is appearing in the wrong place, you could try manually editing your theme to move 'the_footer' hook.</span></p>
	</blockquote>
	</div>
	</td><td>
	<?php 
    adinj_add_alignment_options('footer_');
    echo "<br /><b><a href='?page=ad-injection&amp;tab=adrotation#multiple_footer'>Rotation:<br />" . adinj_percentage_split('ad_code_footer_', 1, $ops) . "</a></b>";
    ?>
	</td></tr>
	</table>
	
	<?php 
    adinj_postbox_end();
}
function adinj_options_page()
{
    adinj_save_options();
    $ops = adinj_options();
    if ($ops === false || adinj_options_need_upgrading($ops)) {
        // Upgraded via FTP without being deactivated/reactivated
        adinj_activate_hook();
    }
    $ops = adinj_options(1);
    if ($ops['ad_insertion_mode'] == 'mfunc') {
        if (!@file_exists(ADINJ_CONFIG_FILE)) {
            adinj_write_config_file();
        }
    }
    echo '<div class="wrap">';
    if (adinj_problem_with_wpminify_check()) {
        echo '<div id="ad-injection-warning" class="error"><p><strong>';
        echo adinj_get_problem_with_wpminify_message();
        echo '</strong></p></div>';
    }
    echo '<div id="icon-options-general" class="icon32"></div><h2>Ad Injection ' . adinj_get_version() . adinj_get_logo() . '</h2>';
    if (isset($_POST['adinj_action'])) {
        echo '<div id="message" class="updated below-h2"><p><strong>';
        echo 'All settings saved: ';
        if (is_plugin_active('wp-super-cache/wp-cache.php')) {
            echo "You might need to <a href='options-general.php?page=wpsupercache&amp;tab=tester'>clear your WP Super Cache cache</a> for the settings to take effect.";
        } else {
            echo "If you are using a caching plugin you might need to delete its cache for any changes to take effect.";
        }
        echo '</strong>';
        if ($ops['ad_insertion_mode'] == 'mfunc') {
            global $adinj_warning_msg_filewrite;
            if (!empty($adinj_warning_msg_filewrite)) {
                echo $adinj_warning_msg_filewrite;
                echo "<br />Workaround: If you are unable to fix these errors you will have to switch to a <a href='#restrictions'>direct insertion mode</a> (however dynamic features won't work if you are using a caching plugin).";
            }
        }
        global $adinj_warning_msg_chmod;
        if (!empty($adinj_warning_msg_chmod)) {
            echo '<br />Info: Some warnings were generated by chmod. See the <a href="#debugging">debugging</a> section for more info.';
        }
        if ($ops['ads_enabled'] != 'on') {
            echo '<br /><font color="red">Warning: Ads are not enabled. You need to turn the ads on for everyone to see them.</font>';
        }
        echo '</p></div>';
    } else {
        echo '<div id="message" class="updated below-h2"><p style="line-height:140%"><strong>';
        echo "24th December 2010: I'll be taking a break from updating Ad Injection over Christmas and the New Year. The next release will probably be on the 5th January. But please keep sending me any <a href='https://spreadsheets.google.com/viewform?formkey=dFUwZzBYcG1HNzNKMmJZdWFDdFhkY0E6MQ' target='_new'>feedback or bug reports</a>. I read and act on all feedback! Merry Christmas :)";
        echo '</strong></p></div>';
    }
    ?>
	
	
	
	<div style="width:258px; float:right;">
	<div class="postbox-container" style="width:258px;">
		<div class="metabox-holder">	
		<div class="meta-box-sortables" style="min-height:50px;">
		<div id="toc" class="postbox">
		<h3 class="hndle"><span><?php 
    echo adinj_get_logo();
    ?>
 Status</span></h3>
		<div class="inside" style="margin:5px;">
			<table border="0" cellpadding="2">
			<tr><td style="text-align:right; vertical-align:top">
			<b><a href="#global">Ads enabled</a></b>
			</td><td>
			<?php 
    $info = adinj_get_status('global');
    echo adinj_dot($info[0]) . ' ' . $info[1];
    if ($info[0] != 'red') {
        ?>
			<br />&nbsp;&nbsp;<?php 
        echo adinj_green_or_red_dot('exclude_home');
        ?>
 home
			<br />&nbsp;&nbsp;<?php 
        echo adinj_green_or_red_dot('exclude_page');
        ?>
 page
			<br />&nbsp;&nbsp;<?php 
        echo adinj_green_or_red_dot('exclude_single');
        ?>
 single
			<br />&nbsp;&nbsp;<?php 
        echo adinj_green_or_red_dot('exclude_archive');
        ?>
 archive
			</td></tr>
			<tr><td style="text-align:right; vertical-align:top">
			<b><a href="#random">Random ads</a></b>
			</td><td>
			<?php 
        $info = adinj_get_status('random');
        echo adinj_dot($info[0]) . ' ' . $info[1] . '<br />';
        $info = adinj_get_status('random_home');
        echo adinj_dot($info[0]) . ' ' . $info[1];
        ?>
			</td></tr>
			<tr><td style="text-align:right">
			<b><a href="#topad">Top ad</a></b>
			</td><td>
			<?php 
        $info = adinj_get_status('topad');
        echo adinj_dot($info[0]) . ' ' . $info[1];
        ?>
			</td></tr>
			<tr><td style="text-align:right">
			<b><a href="#bottomad">Bottom ad</a></b>
			</td><td>
			<?php 
        $info = adinj_get_status('bottomad');
        echo adinj_dot($info[0]) . ' ' . $info[1];
        ?>
			</td></tr>
			<tr><td style="text-align:right; vertical-align:top">
			<b><a href="#widgets">Widgets</a></b>
			</td><td>
			<?php 
        $info = adinj_get_status('widgets');
        echo adinj_dot($info[0]) . ' ' . $info[1];
        if ($info[0] != 'red') {
            ?>
			<br />&nbsp;&nbsp;<?php 
            echo adinj_green_or_red_dot('widget_exclude_home');
            ?>
 home
			<br />&nbsp;&nbsp;<?php 
            echo adinj_green_or_red_dot('widget_exclude_page');
            ?>
 page
			<br />&nbsp;&nbsp;<?php 
            echo adinj_green_or_red_dot('widget_exclude_single');
            ?>
 single
			<br />&nbsp;&nbsp;<?php 
            echo adinj_green_or_red_dot('widget_exclude_archive');
            ?>
 archive
			<?php 
        }
        ?>
			</td></tr>
			<tr><td style="text-align:right">
			<b><a href="#restrictions">Mode</a></b>
			</td><td>
			<?php 
        $info = adinj_get_status('mode');
        echo adinj_dot($info[0]) . ' ' . $info[1];
        ?>
			</td></tr>
			<tr><td style="text-align:right">
			<b><a href="#dynamic">Restrictions</a></b>
			</td><td>
			<?php 
        $info = adinj_get_status('restrictions');
        echo adinj_dot($info[0]) . ' ' . $info[1];
        ?>
			</td></tr>
			<tr><td style="text-align:right">
			<b><a href="#debugging">Debug mode</a></b>
			</td><td>
			<?php 
        $info = adinj_get_status('debugging');
        echo adinj_dot($info[0]) . ' ' . $info[1];
        ?>
			</td></tr>
			<tr><td>
			</td><td>
			</td></tr>
			<tr><td>
			</td><td>
			<?php 
    }
    ?>
			</td></tr>
			</table>
		</div>
		</div>	
		</div>
		</div>
	</div> 	
	
	<br />
	
	<div class="postbox-container" style="width:258px;">
		<div class="metabox-holder">	
		<div class="meta-box-sortables">
		<div id="toc" class="postbox">
		<h3 class="hndle"><span><?php 
    echo adinj_get_logo();
    ?>
 More info...</span></h3>
		<div class="inside" style="margin:5px;">
			<h4>More Ad Injection information</h4>
			<ul>
			<li><a href="http://www.reviewmylife.co.uk/blog/2010/12/06/ad-injection-plugin-wordpress/" target="_new">Ad Injection at reviewmylife</a></li>
			<li><a href="http://wordpress.org/extend/plugins/ad-injection/" target="_new">Ad Injection at WordPress</a></li>
			<li><b><a href="https://spreadsheets.google.com/viewform?formkey=dFUwZzBYcG1HNzNKMmJZdWFDdFhkY0E6MQ" target="_new">Report a bug / give feedback</a></b></li>
			</ul>
			<h4>Coming in 2011</h4>
			<ul>
			<li>More precise control over which categories and tags the ads are shown in.</li>
			<li>Extra places where adverts can be inserted.</li>
			</ul>
			
			<h4><font color="red">Important!</font></h4>
			<p>You are responsible for making sure the ad settings and positioning you define are in compliance with your ad provider's terms of service! Failure to do so could get you banned by them!</p>
		
			<h4><font color="red">Beta version</font></h4>
			<p>This plugin has only only recently been released. I'm actively listening to your feedback and fixing any problems, and adding new features that you request. Please let me know if you like the plugin too!</p>
			
			<h4>More by this author</h4>
			<ul>
			<li><a href="http://www.reviewmylife.co.uk/" target="_new">www.reviewmylife.co.uk</a></li>
			<li><a href="http://www.advancedhtml.co.uk/" target="_new">www.advancedhtml.co.uk</a></li>
			</ul>
		</div>
		</div>	
		</div>
		</div>
	</div> 
	</div>
		
	<script type="text/javascript">
	function adinj_addtext(element, value) {
		if (value.length == 0) return;
		separator = ', ';
		if (element.value.length == 0){
			separator = '';
		}
		element.value += (separator + value);
	}
	</script>
	
	<p><a href="#random">Random ads</a> | <a href="#topad">Top</a> | <a href="#bottomad">Bottom</a> | <a href="#widgets">Widgets</a> | <a href="#restrictions">Ad insert mode/dynamic restrictions</a> | <a href="#debugging">Debug</a> | <a href="#docs">Quick Start</a> | <a href="#testads">Test ads</a></p>
	
	<form name="adinjform" method="post" action="">
	<?php 
    wp_nonce_field('_adinj_form', '_adinj_nonce');
    ?>
	
	
	<?php 
    adinj_postbox_start(__("Global settings", 'adinj'), 'global');
    ?>
	
	<p>These settings apply to all ads (random, top, bottom, and widget). They will override all other settings.</p>
	
	<input type="radio" name="ads_enabled" value="on" <?php 
    if ($ops['ads_enabled'] == 'on') {
        echo 'checked="checked"';
    }
    ?>
 /> <b>On: <?php 
    _e('Ads enabled', 'adinj');
    ?>
</b><br />
	<input type="radio" name="ads_enabled" value="off" <?php 
    if ($ops['ads_enabled'] == 'off' || $ops['ads_enabled'] == '') {
        echo 'checked="checked"';
    }
    ?>
 /> <b>Off</b><br />
	<input type="radio" name="ads_enabled" value="test" <?php 
    if ($ops['ads_enabled'] == 'test') {
        echo 'checked="checked"';
    }
    ?>
 /> <b>Test mode</b> - Only show ads to admin.<br />
	<span style="font-size:10px;color:red;">Warning: Turn any caching plugin *off* before using test mode. If you leave them on the test adverts will be cached and shown to your real visitors.</span><br />

	<table border="0">
	<tr><td>
	<p><?php 
    _e("Only show ads on pages older than ", 'adinj');
    ?>
</p>
	</td><td>
	<p>
	<select name='ads_on_page_older_than'>
	<?php 
    $older_than_days = array(0, 1, 2, 3, 5, 7, 10, 14, 21, 28, 40, 50);
    for ($value = 0; $value < sizeof($older_than_days); ++$value) {
        echo "<option value=\"{$older_than_days[$value]}\" ";
        if ($ops['ads_on_page_older_than'] == $older_than_days[$value]) {
            echo 'selected="selected"';
        }
        echo ">{$older_than_days[$value]}</option>";
    }
    ?>
	</select><?php 
    _e(" (days)", 'adinj');
    ?>
 - only for single posts and pages</p>
	</td></tr>
	<tr><td style="vertical-align:top">
	Don't show ads on these page types:
	</td><td>
	<input type="checkbox" name="exclude_home" <?php 
    echo adinj_ticked('exclude_home');
    ?>
 />home - <?php 
    echo get_bloginfo('url');
    ?>
<br />
	<?php 
    $count_pages = wp_count_posts('page', 'readable');
    $count_posts = wp_count_posts('post', 'readable');
    ?>
	<input type="checkbox" name="exclude_page" <?php 
    echo adinj_ticked('exclude_page');
    ?>
 />page - <?php 
    echo $count_pages->publish;
    ?>
 page(s)<br />
	<input type="checkbox" name="exclude_single" <?php 
    echo adinj_ticked('exclude_single');
    ?>
 />single -<?php 
    echo $count_posts->publish;
    ?>
 individual blog post(s)<br />
	<input type="checkbox" name="exclude_archive" <?php 
    echo adinj_ticked('exclude_archive');
    ?>
 />archive - only <a href="#widgets">widgets</a> currently appear on archives<br />
	</td></tr>
	</table>
	
	<b>Category and tag conditions</b>
	
	<?php 
    adinj_condition_table('global_category', 'category slugs. e.g: cat1, cat2, cat3', 'category');
    ?>
	
	<?php 
    adinj_condition_table('global_tag', 'tag slugs. e.g: tag1, tag2, tag3', 'tag');
    ?>
	
	<?php 
    adinj_postbox_end();
    ?>
	
	
	
	
	<?php 
    adinj_postbox_start(__("Randomly Injected ad code", 'adinj'), 'random');
    ?>
	
	<table border="0" cellspacing="5">
	<tr><td style="vertical-align: top">
	<textarea name="ad_code_random_1" rows="10" cols="60"><?php 
    echo $ops['ad_code_random_1'];
    ?>
</textarea>
	</td><td style="vertical-align: top">
	<?php 
    adinj_add_alignment_options('rnd_');
    ?>
	</td></tr>
	<tr><td>
	<?php 
    _e("Always put the first ad after the first paragraph.", 'adinj');
    ?>
 <input type="checkbox" name="first_paragraph_ad" <?php 
    echo adinj_ticked('first_paragraph_ad');
    ?>
 />
	</td><td>
	</td></tr>
	</table>

	
	<p><span style="font-size:10px;"><b>Docs:</b> On individual posts or pages this advert is inserted between randomly selected paragraphs. On a multi-post page (e.g. home page), one ad is inserted into each post. Try a <a href="#468x60">468x60</a> or <a href="#728x90">728x90</a> banner.</span></p>
	<p><span style="font-size:10px;">Be especially careful if you decide to use the 'float' layout options. Make sure that you don't have adverts floated over the top of other page elements, or vice-versa.</span></p>
	</div>
	
	<input type="submit" style="float:right" name="adinj_action" value="<?php 
    _e('Save all settings', 'adinj');
    ?>
" />
	<h3><?php 
    _e("Single posts and pages: Randomly Injected ad settings", 'adinj');
    ?>
</h3>
	<div class="inside" style="margin:10px">
	<p>These random ad injection settings are specific to individual posts and pages.</p>
	
	<table border="0">
	
	<tr><td>
	<?php 
    _e("Allow multiple ads to be injected at the same positions.", 'adinj');
    ?>
	</td><td>
	<input type="checkbox" name="multiple_ads_at_same_position" <?php 
    echo adinj_ticked('multiple_ads_at_same_position');
    ?>
 /> (default is to inject ads at unique positions)
	</td></tr>

	
	<tr><td>
	<?php 
    _e("Maximum number of randomly injected ads: ", 'adinj');
    ?>
</td><td>
	<select name='max_num_of_ads'>
	<?php 
    for ($value = 0; $value <= 10; ++$value) {
        echo "<option value=\"{$value}\" ";
        if ($ops['max_num_of_ads'] == $value) {
            echo 'selected="selected"';
        }
        echo ">{$value}</option>";
    }
    ?>
	</select> <?php 
    echo adinj_getdefault('max_num_of_ads');
    ?>
<br />
	</td></tr>
	
	<tr><td>
	<?php 
    _e("No random ads if page shorter than: ", 'adinj');
    echo '</td><td>';
    adinj_selection_box("no_random_ads_if_shorter_than", array(ADINJ_RULE_DISABLED, 100, 200, 300, 500, 1000, 1500, 2000, 2500, 3000));
    echo adinj_getdefault('no_random_ads_if_shorter_than');
    ?>
	</td></tr>
	
	<tr><td>
	<?php 
    _e("Limit of 1 ad if page shorter than: ", 'adinj');
    echo '</td><td>';
    adinj_selection_box("one_ad_if_shorter_than", array(ADINJ_RULE_DISABLED, 100, 200, 300, 500, 1000, 1500, 2000, 2500, 3000));
    echo adinj_getdefault('one_ad_if_shorter_than');
    ?>
	</td></tr>
	
	<tr><td>
	<?php 
    _e("Limit of 2 ads if page shorter than: ", 'adinj');
    echo '</td><td>';
    adinj_selection_box("two_ads_if_shorter_than", array(ADINJ_RULE_DISABLED, 100, 200, 300, 500, 1000, 1500, 2000, 2500, 3000, 5000, 10000));
    echo adinj_getdefault('two_ads_if_shorter_than');
    ?>
	</td></tr>

	<tr><td>
	<?php 
    _e("Limit of 3 ads if page shorter than: ", 'adinj');
    echo '</td><td>';
    adinj_selection_box("three_ads_if_shorter_than", array(ADINJ_RULE_DISABLED, 100, 200, 300, 500, 1000, 1500, 2000, 2500, 3000, 5000, 10000, 20000));
    echo adinj_getdefault('three_ads_if_shorter_than');
    ?>
	</td></tr>
	</table>
	
	<br clear="all" />
	<p><span style="font-size:10px;"><b>Docs:</b> The above directives are processed in order from top to bottom.</span></p>
	

	<p></p>
	
	</div>
	
	<input type="submit" style="float:right" name="adinj_action" value="<?php 
    _e('Save all settings', 'adinj');
    ?>
" />
	<h3><a name="random_home"></a><?php 
    _e("Home page: Randomly Injected ad settings", 'adinj');
    ?>
 (<?php 
    echo get_bloginfo('url');
    ?>
)</h3>
	<div class="inside" style="margin:10px">
	<p>These random ad injection settings are specific to your home page.</p>
	
	<?php 
    _e("Maximum number of injected ads: ", 'adinj');
    ?>
	<select name='max_num_of_ads_home_page'>
	<?php 
    for ($value = 0; $value <= 10; ++$value) {
        echo "<option value=\"{$value}\" ";
        if ($ops['max_num_of_ads_home_page'] == $value) {
            echo 'selected="selected"';
        }
        echo ">{$value}</option>";
    }
    ?>
	</select> <?php 
    echo adinj_getdefault('max_num_of_ads_home_page');
    ?>
<br />
	
	<p><span style="font-size:10px;"><b>Docs:</b> On a multi-post home page, one randomly positioned advert will be inserted into each post, up to the maximum number specified here.</span></p>
	
	<?php 
    adinj_postbox_end();
    ?>
	
	
	
	<?php 
    adinj_postbox_start(__("Optional top advert (single posts and pages only)", 'adinj'), 'topad');
    ?>
	
	<?php 
    _e("Only show top ad on pages longer than: ", 'adinj');
    adinj_selection_box("top_ad_if_longer_than", array(ADINJ_RULE_DISABLED, 100, 200, 300, 500, 1000, 1500, 2000, 2500, 3000, 5000, 10000, 20000, ADINJ_ALWAYS_SHOW));
    ?>

	<br clear="all" />
	
	<table border="0">
	<tr><td>
	<textarea name="ad_code_top_1" rows="10" cols="60"><?php 
    echo $ops['ad_code_top_1'];
    ?>
</textarea>
	</td><td style="vertical-align: top">
	<?php 
    adinj_add_alignment_options('top_');
    ?>
	</td></tr>
	</table>
	<span style="font-size:10px;">The top ad is in addition to the quantity of other ads selected.</span>
	
	<p><span style="font-size:10px;"><b>Docs:</b> The top ad will only appear on single posts and pages. It will not appear on multi-post pages. Try a <a href="#468x15">468x15</a> or <a href="#336x280">336x280</a> advert.</span></p>
	
	<?php 
    adinj_postbox_end();
    ?>
	
	
	<?php 
    adinj_postbox_start(__("Optional bottom advert (single posts and pages only)", 'adinj'), 'bottomad');
    ?>
	
	<?php 
    _e("Only show bottom ad on pages longer than: ", 'adinj');
    adinj_selection_box("bottom_ad_if_longer_than", array(ADINJ_RULE_DISABLED, 100, 200, 300, 500, 1000, 1500, 2000, 2500, 3000, 5000, 10000, 20000, ADINJ_ALWAYS_SHOW));
    ?>
	
	<br clear="all"/>
	
	<table border="0">
	<tr><td>
	<textarea name="ad_code_bottom_1" rows="10" cols="60"><?php 
    echo $ops['ad_code_bottom_1'];
    ?>
</textarea>
	</td><td style="vertical-align: top">
	<?php 
    adinj_add_alignment_options('bottom_');
    ?>
	</td></tr>
	</table>
	<span style="font-size:10px;">The top ad is in addition to the quantity of other ads selected.</span>
	
	<p><span style="font-size:10px;"><b>Docs:</b> The bottom ad will only appear on single posts and pages. It will not appear on multi-post pages. Try a <a href="#336x280">336x280</a> advert.</span></p>
	
	
	<?php 
    adinj_postbox_end();
    ?>
	
	
	<?php 
    adinj_postbox_start(__("Widget settings (sidebar ads)", 'adinj'), 'widgets');
    ?>
	
	<p>You must configure your individual widgets from the <a href="widgets.php">widgets control panel</a>. However these settings are global to all widgets. Also note that the main set of <a href="#global">global settings</a> will override these ones.</p>

	<table border="0">
	
	<tr><td>
	<p>Don't show widget ads on these page types:</p>
	</td><td>
	<input type="checkbox" name="widget_exclude_home" <?php 
    echo adinj_ticked('widget_exclude_home');
    ?>
 />home - <?php 
    echo get_bloginfo('url');
    ?>
<br />
	<input type="checkbox" name="widget_exclude_page" <?php 
    echo adinj_ticked('widget_exclude_page');
    ?>
 />page - <?php 
    echo $count_pages->publish;
    ?>
 page(s)<br />
	<input type="checkbox" name="widget_exclude_single" <?php 
    echo adinj_ticked('widget_exclude_single');
    ?>
 />single - <?php 
    echo $count_posts->publish;
    ?>
 individual blog post(s)<br />
	<input type="checkbox" name="widget_exclude_archive" <?php 
    echo adinj_ticked('widget_exclude_archive');
    ?>
 />archive - includes category, tag, author, and date pages types<br />
	</td></tr>
	
	</table>
	
	
	<?php 
    adinj_postbox_end();
    ?>
	
	
	<?php 
    adinj_postbox_start(__("Ad insertion mode and dynamic ad display restrictions", 'adinj'), 'restrictions');
    ?>
	
	<h4>Ad insertion mode</h4>
	
	<blockquote>
	<p><input type="radio" name="ad_insertion_mode" value="mfunc" <?php 
    if ($ops['ad_insertion_mode'] == 'mfunc') {
        echo 'checked="checked"';
    }
    ?>
 /> <b>Use mfunc tags for dynamic features</b> - Dynamic features will work with WP Super Cache in legacy mode (or with a caching program that is compatible with WP Super Cache's mfunc tags). Dynamic features will also work if you don't use a caching program, although if you don't use a caching program 'direct' insertion will be more efficient.</p>
	<p><input type="radio" name="ad_insertion_mode" value="direct_dynamic" <?php 
    if ($ops['ad_insertion_mode'] == 'direct_dynamic') {
        echo 'checked="checked"';
    }
    ?>
 /> <b>Direct ad insertion with dynamic features</b> - Dynamic features will work if no caching is used. Only select this if you are not using any caching plugin.</p>
	<p><input type="radio" name="ad_insertion_mode" value="direct_static" <?php 
    if ($ops['ad_insertion_mode'] == 'direct_static') {
        echo 'checked="checked"';
    }
    ?>
 /> <b>Direct static ad insertion</b> - No dynamic feature support. Select this if you are using a caching plugin which is not compatible with WP Super Cache's mfunc tags.</p>
	</blockquote>
	</div>
	<p></p>
	
	<script type="text/javascript">
	jQuery(document).ready(function(){
	jQuery('input[name=ad_insertion_mode]:radio').change(function() {
		if (jQuery('input[name=ad_insertion_mode]:checked').val() == "direct_static"){
			jQuery('.dynamic_features').slideUp(1000);
			jQuery('.dynamic_features_msg').slideDown(1000);
		} else {
			jQuery('.dynamic_features_msg').slideUp(1000);
			jQuery('.dynamic_features').slideDown(1000);
		}
		return true;
		});
	});
	</script>
	
	<?php 
    if ($ops['ad_insertion_mode'] == 'direct_static') {
        ?>
	<div class="dynamic_features_msg">
	<?php 
    } else {
        ?>
	<div class="dynamic_features_msg" style="display:none">
	<?php 
    }
    ?>
	<div class="inside" style="margin:10px">
	<b><span style="font-size:10px;color:red;">Note: Dynamic features (restricting ad views by referrer and IP address) are only available in the mfunc, or direct dynamic modes.</span></b>
	</div>
	</div>
	
	<?php 
    if ($ops['ad_insertion_mode'] == 'direct_static') {
        ?>
	<script type="text/javascript">
	document.write('<style type="text/css" media="screen">#dynamic_features { display: none; }</style>');
	</script>
	<?php 
    }
    ?>
	<div id="dynamic_features" class="dynamic_features">
	
	<div class="inside" style="margin:10px">

	<h4><a name="dynamic"></a>Show ads only to search engine visitors (dynamic feature)</h4>
	
	<blockquote>
	<input type="checkbox" name="sevisitors_only" <?php 
    echo adinj_ticked('sevisitors_only');
    ?>
 /><?php 
    _e("Only show ads to search engine visitors (customise search engine referrers below if necessary).", 'adinj');
    ?>
<br />
	<textarea name="ad_referrers" rows="2" cols="70"><?php 
    echo $ops['ad_referrers'];
    ?>
</textarea>
	<p>Comma separated list e.g.: <br /><code>.google., .bing., .yahoo., .ask., search?, search., /search/</code></p>
	</blockquote>
	
	<h4>Blocked IP addresses (dynamic feature)</h4>
	
	<blockquote>
	<textarea name="blocked_ips" rows="4" cols="70"><?php 
    echo $ops['blocked_ips'];
    ?>
</textarea>
	<p>Comma separated list e.g.: <br /><code>0.0.0.1, 0.0.0.2</code></p>
	<p>Or you can list one IP per line with optional comments e.g.</p>
	<code style="padding:0px 0px">192.168.0.1<br />0.0.0.2<br /><?php 
    echo $_SERVER['REMOTE_ADDR'];
    ?>
 //my ip<br />0.0.0.3</code>
	
	<p>For reference your current IP address is <code><?php 
    echo $_SERVER['REMOTE_ADDR'];
    ?>
</code></p>
	</blockquote>
	</div>
	
	
	<h3>Recommended WP Super Cache settings:</h3>
	<div class="inside" style="margin:10px">

	<blockquote>
		<ul>
		<li>Cache hits to this website for quick access.</li>
		<li>Legacy page caching.</li>
		<li>Compress pages so they&#x2019;re served more quickly to visitors.</li>
		<li>Expire time: 36000 (10 hours). Or 3600 (1 hour) for very busy site.</li>
		</ul>
	</blockquote>
	
	<p>
	<?php 
    if (is_plugin_active('wp-super-cache/wp-cache.php')) {
        echo "Go to the WP Super Cache <a href='options-general.php?page=wpsupercache&amp;tab=settings'>advanced settings page</a> (where you can set the caching mode to Legacy).";
    } else {
        echo "Note: WP Super Cache does not appear to be active.";
    }
    ?>
	</p>
	</div>
	
	</div>
	
	<?php 
    adinj_postbox_end();
    ?>
	
	
	<?php 
    adinj_postbox_start(__("Debugging", 'adinj'), 'debugging');
    ?>
	
	<input type="checkbox" name="debug_mode" <?php 
    echo adinj_ticked('debug_mode');
    ?>
 />Enable debug mode
	
	<p>If you are not sure why ads aren't appearing, or why they are appearing, enable debug mode and look at the debug information (search for 'ADINJ DEBUG') in the HTML of your content pages.</p>
	
	<?php 
    if (adinj_problem_with_wpminify_check()) {
        echo adinj_get_problem_with_wpminify_message();
    }
    adinj_debug_information();
    ?>
	
	<p></p>
	
	<p>If you want to restore all settings (excluding the ad contents) to their default values use this button.</p>
	
	<input type="submit" name="adinj_action" value="<?php 
    _e('Reset to Default', 'adinj');
    ?>
" />
	
	<p>You can delete the database settings if you are going to uninstall Ad Injection.</p>
	
	<input type="submit" name="adinj_action" value="<?php 
    _e('Delete settings from DB', 'adinj');
    ?>
" />
	
	<?php 
    adinj_postbox_end();
    ?>


	<br clear="all" />
	
	<?php 
    adinj_docs();
    echo '</form>';
    echo '</div> <!--wrap-->';
}