'adinjwidget', 'description' => 'Insert Ad Injection adverts into your sidebars/widget areas.' ); $control_ops = array( 'width' => 400, 'height' => 300, 'id_base' => 'adinj' ); $this->WP_Widget( 'adinj', 'Ad Injection', $widget_ops, $control_ops ); } function widget( $args, $instance ) { if (adinj_ads_completely_disabled_from_page()) return; $options = adinj_options(); if ((is_home() && adinj_ticked('widget_exclude_home')) || (is_page() && adinj_ticked('widget_exclude_page')) || (is_single() && adinj_ticked('widget_exclude_single')) || (is_archive() && adinj_ticked('widget_exclude_archive'))){ return; } if ($options['ad_insertion_mode'] == 'direct_dynamic'){ if (adinj_show_adverts() !== true){ return; } } extract( $args ); $title = apply_filters('widget_title', $instance['title'] ); $advert = $instance['advert']; echo $before_widget; if ( $title ) { echo $before_title . $title . $after_title; } $adcode = ""; if ($options['ad_insertion_mode'] == 'mfunc'){ $adcode = adinj_get_mfunc_code($this->get_ad_file_name()); } else { $adcode = $advert; } $adcode = adinj_ad_code_eval($adcode); if ( $advert ){ echo $adcode; } echo $after_widget; } function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip tags (if needed) and update the widget settings. */ $instance['title'] = strip_tags( $new_instance['title'] ); $instance['advert'] = $new_instance['advert']; write_ad_to_file($instance['advert'], $this->get_ad_file_path()); return $instance; } function form( $instance ) { /* Set up some default widget settings. */ $defaults = array( 'title' => '', 'advert' => '' ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>
Make sure any label complies with your ad provider's TOS. More info for AdSense users.
The following dynamic options to define who sees these adverts are on the main Ad Injection settings page. The title will however always be displayed. If you want the title to be dynamic as well you should embed it in the ad code text box.
- Ads on pages older than...
- Ads for search engine visitors only.
- Block ads by IP.
You can also set which page types the widgets appear on.
get_ad_file_name(); } function get_ad_file_name(){ return 'ad_widget_'.$this->get_id().'.txt'; } function get_id(){ $field = $this->get_field_id('advert'); preg_match('/-(\d+)-/', $field, $matches); return $matches[1]; } } ?>