$value){ if (isset($_POST[$key])){ $ops[$key] = $_POST[$key]; } } extract_text_args('ad_code_random_', $ops, 1, 10, ADINJ_AD_PATH.'/ad_random_'); extract_text_args('ad_code_top_', $ops, 1, 10, ADINJ_AD_PATH.'/ad_top_'); extract_text_args('ad_code_bottom_', $ops, 1, 10, ADINJ_AD_PATH.'/ad_bottom_'); extract_text_args('ad_code_random_alt_', $ops, 1, 2, ADINJ_AD_PATH.'/ad_random_alt_'); extract_text_args('ad_code_top_alt_', $ops, 1, 2, ADINJ_AD_PATH.'/ad_top_alt_'); extract_text_args('ad_code_bottom_alt_', $ops, 1, 2, ADINJ_AD_PATH.'/ad_bottom_alt_'); extract_text_args('ad_referrers', $ops); extract_text_args('blocked_ips', $ops); adinj_update_options($ops); if ($ops['ad_insertion_mode'] == 'mfunc') { adinj_write_config_file(); } break; case 'Reset to Default': adinj_checkNonce(); adinj_update_options(adinj_default_options()); break; case 'Delete settings from DB': adinj_checkNonce(); delete_option('adinj_options'); adinj_install_db(); adinj_options(1); break; case 'Delete widget settings from DB': adinj_checkNonce(); delete_option('widget_adinj'); // TODO add option to delete ads files as well break; } } function extract_text_args($name, &$ops, $start=NULL, $end=NULL, $save_path_stem=NULL){ if ($start === NULL){ if (isset($_POST[$name])){ $ops[$name] = stripslashes($_POST[$name]); if ($save_path_stem != NULL){ write_ad_to_file($ops[$name], $save_path_stem.'1.txt'); } } } else { for ($i = $start; $i<=$end; ++$i){ if (isset($_POST[$name.$i])){ $ops[$name.$i] = stripslashes($_POST[$name.$i]); if ($save_path_stem != NULL){ write_ad_to_file($ops[$name.$i], $save_path_stem.$i.'.txt'); } } } } } // Test reminder: These generated functions won't exist until the first save // so be careful if adding any new ones - they might not exist yet, but could // still be referenced by adshow. function adinj_write_config_file(){ $ops = adinj_options(); if ($ops['ad_insertion_mode'] != 'mfunc') return; $sevisitors_only = adinj_ticked('sevisitors_only')?'true':'false'; $referrer_list = adinj_quote_list('ad_referrers'); $block_ips = adinj_ticked('block_ips')?'true':'false'; $ip_list = adinj_quote_list('blocked_ips'); // TODO $block_keywords = adinj_ticked('block_keywords')?'true':'false'; $keyword_list = adinj_quote_list('blocked_keywords'); $debug_mode = adinj_ticked('debug_mode')?'true':'false'; // TODO remove these from config file later... $legacy_funcs = ' function adinj_config_add_tags_rnd($ad) { return ""; } function adinj_config_add_tags_top($ad) { return ""; } function adinj_config_add_tags_bottom($ad) { return ""; } '; $config = << CONFIG; adinj_write_file(ADINJ_CONFIG_FILE, $config, 0640); } function adinj_write_file($path, $content, $permission){ $ops = adinj_options(); global $adinj_warning_msg_filewrite; $dir = dirname($path); if (!@file_exists($dir)){ if (!@mkdir($dir, 0750)){ @mkdir($dir, 0755) or $adinj_warning_msg_filewrite .= "
Warning: could not create dir: ".$dir.". Please create it manually and try again."; } } $handle = @fopen($path, "w"); if (strlen($content) > 0){ @fwrite($handle, $content) or $adinj_warning_msg_filewrite .= "
Warning: could not write to file: $path"; } @fclose($handle); if (@file_exists($path)){ adinj_chmod($path, $permission); } } function adinj_chmod($path, $permission){ global $adinj_warning_msg_chmod; $oldperm = substr(decoct(@fileperms($path)), -3); $newperm = decoct($permission); if ($newperm == $oldperm) return; @chmod($path, $permission) or $adinj_warning_msg_chmod .= "
Warning: chmod $permission " . "on $path failed. Current permissions: $oldperm
Try manually updating the permission if problems occur."; } function adinj_get_logo(){ return 'reviewmylife'; } // only for Ad Injection admin pages function adinj_admin_print_scripts_main(){ adinj_admin_print_scripts_widgets(); } // only for widgets.php function adinj_admin_print_scripts_widgets(){ echo ""; adinj_javascript_addtext(); echo << function adinj_toggle_click(show_setting_id, toggle_button_id, toggle_box_id){ jQuery('#'+show_setting_id).val(jQuery('#'+toggle_box_id).is(":hidden")); adinj_button_update(show_setting_id, toggle_button_id); jQuery('#'+toggle_box_id).slideToggle(300); } function adinj_button_update(show_setting_id, toggle_button_id){ if (jQuery('#'+show_setting_id).val() == 'true'){ jQuery('#'+toggle_button_id).text('-'); } else { jQuery('#'+toggle_button_id).text('+'); } } HTML; } function adinj_options_page(){ if (isset($_POST['adinj_action'])){ adinj_save_options(); } adinj_upgrade_db_if_necessary(); $ops = adinj_options(); echo '
'; if (adinj_problem_with_wpminify_check()){ echo '

'; echo adinj_get_problem_with_wpminify_message(); echo '

'; } echo '

Ad Injection ' . adinj_get_version() . adinj_get_logo() . '

'; adinj_top_message_box(); adinj_admin_tabs(); echo '
'; wp_nonce_field('_adinj_form'); echo '
'; switch( $_GET[ 'tab' ] ) { case "adrotation": require_once(ADINJ_PATH . '/ui-tab-adrotation.php'); adinj_side_info_box(); echo '
'; adinj_tab_adrotation(); break; case "debug": require_once(ADINJ_PATH . '/ui-tab-debug.php'); adinj_side_info_box(); echo '
'; adinj_tab_debug(); break; case "main": default: require_once(ADINJ_PATH . '/ui-tab-main.php'); adinj_side_status_box(); adinj_side_info_box(); echo ''; adinj_tab_main(); break; } echo ''; echo ' '; } function adinj_top_message_box(){ $ops = adinj_options(); if (isset($_POST['adinj_action'])) { echo '

'; echo 'All settings saved: '; if (is_plugin_active('wp-super-cache/wp-cache.php')){ echo "You might need to clear your WP Super Cache cache for the settings to take effect."; } else if (is_plugin_active('w3-total-cache/w3-total-cache.php')){ echo "You might need to clear your W3 Total Cache cache for the settings to take effect."; } else if (is_plugin_active('wp-cache/wp-cache.php')){ echo "You might need to clear your WP Cache cache 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 ''; if ($ops['debug_mode']=='on' && $ops['ads_enabled'] == 'on'){ echo "
Recommendation: Turn debug mode off once you have got your ads working."; } if ($ops['ad_insertion_mode']=='mfunc'){ if (!is_supported_caching_plugin_active()){ echo "
Recommendation: It looks like you don't have a supported caching plugin (WP Super Cache, W3 Total Cache or WP Cache) active. Therefore one of the direct insertion modes might be better for you."; } global $adinj_warning_msg_filewrite; if (!empty($adinj_warning_msg_filewrite)){ echo $adinj_warning_msg_filewrite; echo "
Workaround: If you are unable to fix these errors you will have to switch to a direct insertion mode (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 '
Info: Some warnings were generated by chmod. See the debugging section for more info.'; } if ($ops['ads_enabled'] != 'on'){ echo '
Warning: Ads are not enabled. You need to turn the ads on for everyone to see them.'; } echo '

'; } else { echo '

'; echo "1st March 2011: If you are one of the people whose top/bottom ads have dissapeared with the 0.9.7.x release I'm very sorry - I hope this release will fix it. If it doesn't please email me a link via the quick feedback form to one of your affected pages. There are a some other bugs I've found whilst fixing this, I'll hopefully get them fixed this week/next week.
Archives and home ads now fully supported - you can add top/random/bottom ads to them. Big UI updates to support this. And fixes for when/where widget ads appear. I'd recommend you re-check that your ads appear where you expect them to. Please contact me ASAP if you spot any bugs, or odd behaviour via the ".'quick feedback form.'; echo '

'; } } function adinj_side_info_box(){ ?>

Info

More Ad Injection information

Important!

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!

In developement

This plugin is only a few months old. 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!

More by this author

'; echo ''; } // From WP Super cache function adinj_admin_tabs( $current = 0 ) { global $wp_db_version; if ( $current == 0 ) { if ( isset( $_GET[ 'tab' ] ) ) { $current = $_GET[ 'tab' ]; } else { $current = 'main'; } } $tabs = array( 'main' => __( 'Main', 'ad-injection' ), 'adrotation' => __( 'Ad codes / rotation / misc', 'ad-injection' ), 'debug' => __( 'Debug' ) ); $links = array(); foreach( $tabs as $tab => $name ) { if ( $current == $tab ) { $links[] = "$name"; } else { $links[] = "$name"; } } echo ''; } // TODO replace with new Javascript function adinj_postbox_start($title, $anchor, $width='650px'){ $ops = adinj_options(); ?>
HTML; ?>

'; } function adinj_get_status($name){ $ops = adinj_options(); $status[] = 'black'; $status[] = 'Error...'; if ($name == 'global'){ if ($ops['exclude_front'] == 'on' && $ops['exclude_home'] == 'on' && $ops['exclude_page'] == 'on' && $ops['exclude_single'] == 'on' && $ops['exclude_archive'] == 'on' && $ops['exclude_search'] == 'on' && $ops['exclude_404'] == 'on'){ $status[0] = 'red'; $status[1] = 'excluded from all'; return $status; } $val = $ops['ads_enabled']; if ($val == 'on'){ $status[0] = 'green'; $status[1] = $val; } else if ($val == 'off' || $val == ''){ $status[0] = 'red'; $status[1] = $val; } else if ($val == 'test'){ $status[0] = 'orange'; $status[1] = 'test mode'; } } else if ($name == 'mode'){ $status[0] = 'green'; if ($ops['ad_insertion_mode'] == 'direct_static') $status[0] = 'orange'; $status[1] = $ops['ad_insertion_mode']; } else if ($name == 'restrictions'){ $status[0] = 'green'; $status[1] = ""; if ($ops['sevisitors_only'] == 'on'){ $status[1] .= 'referrer'; } if ($ops['block_ips'] == 'on' && !empty($ops['blocked_ips'])){ $status[1] .= ' ip'; } } else if ($name == 'adsettings'){ $status[0] = 'green'; } else if ($name == 'adverts'){ if (adinj_count_live_ads('top', $ops) > 0 || adinj_count_live_ads('random', $ops) || adinj_count_live_ads('bottom', $ops)){ $status[0] = 'green'; } else { $status[0] = 'red'; } } else if ($name == 'debugging'){ $val = $ops['debug_mode']; if ($val == 'on'){ $status[0] = 'green'; $status[1] = 'on'; } else { $status[0] = 'red'; $status[1] = 'off'; } } return $status; } // This is for 'exclude' options so 'on' is red. function adinj_green_or_red_dot($option){ $ops = adinj_options(); if ($ops[$option] == 'on'){ return adinj_dot('red'); } else { return adinj_dot('green'); } } function adinj_print_ad_dot($adtype, $pagetype){ if (adinj_max_num_ads($adtype, $pagetype) > 0){ echo adinj_dot('green'); } else { echo adinj_dot('red'); } } function adinj_dot($colour){ return ''; } function adinj_max_num_ads($adtype, $pagetype){ $ops = adinj_options(); if (adinj_ticked('exclude_'.$pagetype)) return 0; if ($adtype == 'widget'){ if (adinj_ticked('widget_exclude_'.$pagetype)) return 0; } if ($adtype == 'top' || $adtype == 'random' || $adtype == 'bottom'){ if (adinj_count_live_ads($adtype, $ops) == 0) return 0; } if ($adtype == 'top' || $adtype == 'bottom'){ if ($pagetype == "single" || $pagetype == "page"){ if (!adinj_disabled($ops[$adtype.'_ad_if_longer_than'])) return 1; } else if ($pagetype == 'home' || $pagetype == 'archive'){ if (!adinj_disabled($ops[$pagetype.'_'.$adtype.'_ad_if_longer_than'])) return $ops[$pagetype.'_max_num_'.$adtype.'_ads_per_page']; } else if ($pagetype == "excerpt"){ //TODO } } else if ($adtype == "random"){ if ($pagetype == "single" || $pagetype == "page"){ return $ops['max_num_of_ads']; } else if ($pagetype == 'home' || $pagetype == 'archive'){ if ($ops[$pagetype.'_max_num_random_ads_per_post'] > 0) return $ops[$pagetype.'_max_num_random_ads_per_page']; } else if ($pagetype == "excerpt"){ //TODO } } if ($adtype == 'widget'){ return 1; } return 0; } function adinj_selection_box($name, $values, $type="", $selected_value=NULL){ $associative = false; if (!array_key_exists(0, $values)){ // Very naive test but works for me. $associative = true; } if ($selected_value == NULL){ $ops = adinj_options(); $selected_value = $ops[$name]; } echo ""; } function adinj_javascript_addtext(){ ?>
HTML; if ($show_value == 'false'){ echo "
"; } else { echo "
"; } } function adinj_condition_tables($prefix, $show_setting){ $ops = adinj_options(); ?> Category tag, and author conditions '; } function adinj_condition_table($name, $description, $type, $ops, $dropdown_fieldname=NULL, $textarea_fieldname=NULL){ $style = ""; if ($dropdown_fieldname == NULL){ $dropdown_fieldname = $name."_condition_mode"; // Only for the main screen - now for widgets screen. $style = "style='width:280px'"; } if ($textarea_fieldname == NULL){ $textarea_fieldname = $name."_condition_entries"; } ?>

Comma separated list of
get_results( "SELECT user_login, display_name from $wpdb->users" ); return $authors; } function adinj_add_alignment_options($prefix){ _e("Alignment", 'adinj'); echo "
"; adinj_selection_box($prefix.'align', array('d', 'left', 'center', 'right', 'float left', 'float right', 'rand lcr', 'rand float lr', 'rand all')); echo "
"; _e("Clear (CSS)", 'adinj'); echo "
"; adinj_selection_box($prefix.'clear', array('d', 'left', 'right', 'both')); echo "
"; adinj_add_padding_top_bottom_options($prefix); echo "
"; adinj_add_margin_top_bottom_options($prefix); } function adinj_add_margin_top_bottom_options($prefix, $options=NULL, $topname=NULL, $bottomname=NULL){ $tname = $prefix.'margin_top'; $bname = $prefix.'margin_bottom'; $tdefault = NULL; $bdefault = NULL; if ($topname != NULL){ $tname = $topname; $tdefault = "margin_top"; } if ($bottomname != NULL){ $bname = $bottomname; $bdefault = "margin_bottom"; } _e("Margin top", 'adinj'); echo "
"; $margin_settings = array('d',0,1,2,3,4,5,7,10,15,20,30); adinj_selection_box($tname, $margin_settings, "(px)", $options[$tdefault]); echo "
"; _e("Margin bottom", 'adinj'); echo "
"; adinj_selection_box($bname, $margin_settings, "(px)", $options[$bdefault]); } function adinj_add_padding_top_bottom_options($prefix, $options=NULL, $topname=NULL, $bottomname=NULL){ $tname = $prefix.'padding_top'; $bname = $prefix.'padding_bottom'; $tdefault = NULL; $bdefault = NULL; if ($topname != NULL){ $tname = $topname; $tdefault = "padding_top"; } if ($bottomname != NULL){ $bname = $bottomname; $bdefault = "padding_bottom"; } _e("Padding top", 'adinj'); echo "
"; $padding_settings = array('d',0,1,2,3,4,5,7,10,15,20,30); adinj_selection_box($tname, $padding_settings, "(px)", $options[$tdefault]); echo "
"; _e("Padding bottom", 'adinj'); echo "
"; adinj_selection_box($bname, $padding_settings, "(px)", $options[$bdefault]); } function adinj_get_version(){ $plugin_data=get_plugin_data(ADINJ_PATH . '/ad-injection.php'); return $plugin_data['Version']; } function adinj_problem_with_wpminify_check(){ if (!is_plugin_active('wp-minify/wp-minify.php')) return false; $wpm_options = get_option('wp_minify'); $ops = adinj_options(); if ($wpm_options['enable_html'] == true && $ops['ad_insertion_mode'] == 'mfunc'){ return true; } return false; } function adinj_get_problem_with_wpminify_message(){ return 'Problem: Ad Injection will not work if WP Minify is set to minify HTML whilst mfunc mode is enabled.
Solution: Go to the WP Minify settings page and untick "Enable HTML Minification".'; } function adinj_init_warning() { if (stripos($_SERVER["PHP_SELF"], 'plugins.php') !== false){ echo '

Ad Injection needs configuring: Go to the settings page to configure and enable your ads.

'; } // TODO add option to disable message without having to go to settings. } function adinj_compatibility_checks() { if (stripos($_SERVER["PHP_SELF"], 'ad-injection') !== false){ $wpm_options = get_option('wp_minify'); if ($wpm_options['enable_html'] == true){ echo '

'; echo adinj_get_problem_with_wpminify_message(); echo '

'; } } } function is_supported_caching_plugin_active(){ if (!is_plugin_active('wp-super-cache/wp-cache.php') && !is_plugin_active('w3-total-cache/w3-total-cache.php') && !is_plugin_active('wp-cache/wp-cache.php')){ return false; } return true; } ////////////////////////////////////////////////////////////////////////////// function adinj_testads(){ adinj_postbox_start(__("Test Adverts", 'adinj'), "testads", '95%'); ?>

You can copy and paste these adverts into the boxes above to test your ad setup before switching to your real ads.

468x60 banner

TEST ADVERT 468x60 - www.reviewmylife.co.uk

728x90 banner

160x90 link unit

468x15 link unit

TEST ADVERT 468x15 reviewmylife.co.uk

336x280 large rectangle

TEST ADVERT 336x280 - www.reviewmylife.co.uk

468x60 banner with dynamic PHP

The PHP will execute if you use a mfunc compatible caching plugin which is correctly configured, or if you don't use any caching plugin at all.

TEST ADVERT 468x60 with date() and rand()

www.advancedhtml.co.uk

0){ $total += $ops[$split]; } } return $total; } function adinj_count_live_ads($adtype, $ops){ $name_stem = adinj_ad_name_stem($adtype); $total = 0; for ($i=1; $i<=10; ++$i){ $split = $name_stem.$i.'_split'; if (!empty($ops[$name_stem.$i]) && is_numeric($ops[$split]) && $ops[$split] > 0){ $total += 1; } } return $total; } function adinj_ad_name_stem($adtype){ if ($adtype == 'top') return 'ad_code_top_'; if ($adtype == 'random') return 'ad_code_random_'; if ($adtype == 'bottom') return 'ad_code_bottom_'; if ($adtype == 'top_alt') return 'ad_code_top_alt_'; if ($adtype == 'random_alt') return 'ad_code_random_alt_'; if ($adtype == 'bottom_alt') return 'ad_code_bottom_alt_'; // TODO widget? return 'Error: adinj_ad_name_stem:'.$adtype; } ////////////////////////////////////////////////////////////////////////////// // Hopefully run on install and upgrade function adinj_activate_hook(){ $ops = adinj_options(); if(empty($ops)){ // 1st Install. adinj_install_db(); } else { // Upgrade check. adinj_upgrade_db_if_necessary(); } } function adinj_install_db(){ $new_options = adinj_default_options(); // Dynamic defaults. if (!is_supported_caching_plugin_active()){ $new_options['ad_insertion_mode'] = 'direct_dynamic'; } adinj_update_options($new_options); if ($new_options['ad_insertion_mode'] == 'mfunc'){ // Create config file. adinj_write_config_file(); } } function adinj_upgrade_db(){ $stored_options = adinj_options(); $new_options = adinj_default_options(); $stored_dbversion = adinj_db_version($stored_options); $new_dbversion = adinj_db_version($new_options); // 1. Copy existing options to new array. Use default as a baseline, // and then overwrite default with the saved ones. foreach ($new_options as $key => $value){ if (array_key_exists($key, $stored_options)){ $new_options[$key] = $stored_options[$key]; } } // 2. Upgrade options if necessary. if ($stored_dbversion == 1){ // Copy this to new setting if (adinj_ticked('first_paragraph_ad')){ $new_options['start_from_paragraph'] = 1; } // This previously wan't configured correctly $new_options['block_ips'] = 'on'; } if ($stored_dbversion < 4){ // Maintain previous behaviour for users who upgrade $new_options['content_length_unit'] = 'all'; } if ($stored_dbversion < 5){ // Maintain previous behaviour for users who upgrade $new_options['exclude_search'] = 'on'; $new_options['exclude_404'] = 'on'; $new_options['widget_exclude_search'] = 'on'; $new_options['widget_exclude_404'] = 'on'; } if ($stored_dbversion < 6){ $new_options['home_max_num_random_ads_per_page'] = $stored_options['max_num_of_ads_home_page']; } // 3. Bump up db version number. $new_options['db_version'] = $new_dbversion; // 4. Save upgraded options. adinj_update_options($new_options); // 5. Update config file. if ($new_options['ad_insertion_mode'] == 'mfunc'){ // Update config file adinj_write_config_file(); } } // All these stored in a single DB option row function adinj_default_options(){ return array( // Global settings 'ads_enabled' => 'off', 'ads_on_page_older_than' => '0', 'exclude_front' => '', 'exclude_home' => '', 'exclude_page' => '', 'exclude_single' => '', 'exclude_archive' => '', 'exclude_search' => 'on', 'exclude_404' => 'on', 'global_category_condition_mode' => 'o', 'global_category_condition_entries' => '', 'global_tag_condition_mode' => 'o', 'global_tag_condition_entries' => '', 'global_author_condition_mode' => 'o', 'global_author_condition_entries' => '', 'content_length_unit' => 'words', // Random ads 'ad_code_random_1' => '', 'ad_code_random_2' => '', 'ad_code_random_3' => '', 'ad_code_random_4' => '', 'ad_code_random_5' => '', 'ad_code_random_6' => '', 'ad_code_random_7' => '', 'ad_code_random_8' => '', 'ad_code_random_9' => '', 'ad_code_random_10' => '', 'ad_code_random_1_split' => '100', 'ad_code_random_2_split' => '100', 'ad_code_random_3_split' => '100', 'ad_code_random_4_split' => '100', 'ad_code_random_5_split' => '100', 'ad_code_random_6_split' => '100', 'ad_code_random_7_split' => '100', 'ad_code_random_8_split' => '100', 'ad_code_random_9_split' => '100', 'ad_code_random_10_split' => '100', 'ad_code_random_alt_1' => '', 'ad_code_random_alt_2' => '', 'ad_code_random_alt_1_split' => '100', 'ad_code_random_alt_2_split' => '100', 'rnd_align' => 'd', 'rnd_clear' => 'd', 'rnd_margin_top' => 'd', 'rnd_margin_bottom' => 'd', 'rnd_padding_top' => 'd', 'rnd_padding_bottom' => 'd', 'start_from_paragraph' => 'd', 'multiple_ads_at_same_position' => '', 'random_category_condition_mode' => 'o', 'random_category_condition_entries' => '', 'random_tag_condition_mode' => 'o', 'random_tag_condition_entries' => '', 'random_author_condition_mode' => 'o', 'random_author_condition_entries' => '', // single posts and pages 'top_ad_if_longer_than' => 'd', 'max_num_of_ads' => '2', // random ads 'no_random_ads_if_shorter_than' => '100', 'one_ad_if_shorter_than' => '500', 'two_ads_if_shorter_than' => '1000', 'three_ads_if_shorter_than' => 'd', 'bottom_ad_if_longer_than' => 'd', // Home page ads 'home_top_ad_if_longer_than' => 'd', 'home_max_num_top_ads_per_page' => '1', 'home_max_num_random_ads_per_post' => '1', 'home_max_num_random_ads_per_page' => '3', 'home_no_random_ads_if_shorter_than' => '100', 'home_one_ad_if_shorter_than' => '500', 'home_two_ads_if_shorter_than' => '1000', 'home_three_ads_if_shorter_than' => 'd', 'home_bottom_ad_if_longer_than' => 'd', 'home_max_num_bottom_ads_per_page' => '1', // Archive ads 'archive_top_ad_if_longer_than' => 'd', 'archive_max_num_top_ads_per_page' => '1', 'archive_max_num_random_ads_per_post' => '1', 'archive_max_num_random_ads_per_page' => '3', 'archive_no_random_ads_if_shorter_than' => '100', 'archive_one_ad_if_shorter_than' => '500', 'archive_two_ads_if_shorter_than' => '1000', 'archive_three_ads_if_shorter_than' => 'd', 'archive_bottom_ad_if_longer_than' => 'd', 'archive_max_num_bottom_ads_per_page' => '1', // Top ads 'ad_code_top_1' => '', 'ad_code_top_2' => '', 'ad_code_top_3' => '', 'ad_code_top_4' => '', 'ad_code_top_5' => '', 'ad_code_top_6' => '', 'ad_code_top_7' => '', 'ad_code_top_8' => '', 'ad_code_top_9' => '', 'ad_code_top_10' => '', 'ad_code_top_1_split' => '100', 'ad_code_top_2_split' => '100', 'ad_code_top_3_split' => '100', 'ad_code_top_4_split' => '100', 'ad_code_top_5_split' => '100', 'ad_code_top_6_split' => '100', 'ad_code_top_7_split' => '100', 'ad_code_top_8_split' => '100', 'ad_code_top_9_split' => '100', 'ad_code_top_10_split' => '100', 'ad_code_top_alt_1' => '', 'ad_code_top_alt_2' => '', 'ad_code_top_alt_1_split' => '100', 'ad_code_top_alt_2_split' => '100', 'top_align' => 'd', 'top_clear' => 'd', 'top_margin_top' => 'd', 'top_margin_bottom' => 'd', 'top_padding_top' => 'd', 'top_padding_bottom' => 'd', 'top_category_condition_mode' => 'o', 'top_category_condition_entries' => '', 'top_tag_condition_mode' => 'o', 'top_tag_condition_entries' => '', 'top_author_condition_mode' => 'o', 'top_author_condition_entries' => '', // Bottom ads 'ad_code_bottom_1' => '', 'ad_code_bottom_2' => '', 'ad_code_bottom_3' => '', 'ad_code_bottom_4' => '', 'ad_code_bottom_5' => '', 'ad_code_bottom_6' => '', 'ad_code_bottom_7' => '', 'ad_code_bottom_8' => '', 'ad_code_bottom_9' => '', 'ad_code_bottom_10' => '', 'ad_code_bottom_1_split' => '100', 'ad_code_bottom_2_split' => '100', 'ad_code_bottom_3_split' => '100', 'ad_code_bottom_4_split' => '100', 'ad_code_bottom_5_split' => '100', 'ad_code_bottom_6_split' => '100', 'ad_code_bottom_7_split' => '100', 'ad_code_bottom_8_split' => '100', 'ad_code_bottom_9_split' => '100', 'ad_code_bottom_10_split' => '100', 'ad_code_bottom_alt_1' => '', 'ad_code_bottom_alt_2' => '', 'ad_code_bottom_alt_1_split' => '100', 'ad_code_bottom_alt_2_split' => '100', 'bottom_align' => 'd', 'bottom_clear' => 'd', 'bottom_margin_top' => 'd', 'bottom_margin_bottom' => 'd', 'bottom_padding_top' => 'd', 'bottom_padding_bottom' => 'd', 'bottom_category_condition_mode' => 'o', 'bottom_category_condition_entries' => '', 'bottom_tag_condition_mode' => 'o', 'bottom_tag_condition_entries' => '', 'bottom_author_condition_mode' => 'o', 'bottom_author_condition_entries' => '', // widgets 'widget_exclude_front' => '', 'widget_exclude_home' => '', 'widget_exclude_page' => '', 'widget_exclude_single' => '', 'widget_exclude_archive' => '', 'widget_exclude_search' => '', 'widget_exclude_404' => '', // dynamic features 'ad_insertion_mode' => 'mfunc', 'sevisitors_only' => 'off', 'ad_referrers' => '.google., .bing., .yahoo., .ask., search?, search., /search/', 'block_keywords' => 'off', //TODO change to blocked referrers? 'blocked_keywords' => '', //TODO 'block_ips' => 'off', 'blocked_ips' => '', // ui main tab 'ui_global_hide' => 'false', 'ui_adsettings_hide' => 'false', 'ui_adverts_hide' => 'false', 'ui_restrictions_hide' => 'false', 'ui_docsquickstart_hide' => 'false', 'ui_testads_hide' => 'false', 'ui_conditions_show' => 'false', 'ui_top_conditions_show' => 'false', 'ui_random_conditions_show' => 'false', 'ui_bottom_conditions_show' => 'false', // ui ad rotation tab 'ui_docs_adrotation_hide' => 'false', 'ui_multiple_top_hide' => 'false', 'ui_multiple_random_hide' => 'false', 'ui_multiple_bottom_hide' => 'false', 'ui_misc_hide' => 'true', 'ui_docs_tags_hide' => 'true', // ui debug tab 'ui_debugging_hide' => 'false', // debug 'debug_mode' => '', // version 'db_version' => ADINJ_DB_VERSION ); } function adinj_getdefault($option){ $default_options = adinj_default_options(); return "(default: " . $default_options[$option] . ")"; } function write_ad_to_file($ad, $ad_path){ adinj_write_file($ad_path, $ad, 0640); } function adinj_init_hook() { $ops = adinj_options(); if ($ops['ads_enabled'] != 'on') { add_action('admin_notices', 'adinj_init_warning'); } } // init add_action('init', 'adinj_init_hook'); // Config links add_action('admin_menu', 'adinj_admin_menu_hook'); add_filter('plugin_action_links', 'adinj_options_link_hook', 10, 2); // digits = priority, num args ?>