function wp_template_ad($instance) { global $wpInsertAdInstance; global $wpInsertGeoLocation; if ($instance <= 10) { $options = get_option('wp_insert_templateads_options'); } else { $options = get_option('wp_insert_more_templateads_options'); } if (wp_insert_get_ad_status($options['templateads-' . $instance])) { if ($options['templateads-' . $instance]['country_1'] != '' && $wpInsertGeoLocation != '' && in_array($wpInsertGeoLocation, split(',', $options['templateads-' . $instance]['country_1']))) { echo '<div class="wpInsert wpInsertTemplateTag"' . ($options['templateads-' . $instance]['styles'] != '' ? ' style="' . $options['templateads-' . $instance]['styles'] . '"' : '') . '>' . do_shortcode($options['templateads-' . $instance]['country_code_1']) . '</div>'; } else { echo '<div class="wpInsert wpInsertTemplateTag"' . ($options['templateads-' . $instance]['styles'] != '' ? ' style="' . $options['templateads-' . $instance]['styles'] . '"' : '') . '>' . do_shortcode($options['templateads-' . $instance]['ad_code_' . $wpInsertAdInstance]) . '</div>'; } } }
public function widget($args, $instance) { global $wpInsertAdInstance; global $wpInsertGeoLocation; extract($args); $title = apply_filters('widget_title', $instance['title']); if ($instance['instance'] <= 10) { $options = get_option('wp_insert_adwidgets_options'); } else { $options = get_option('wp_insert_more_adwidgets_options'); } if (wp_insert_get_ad_status($options['adwidgets-' . $instance['instance']])) { echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } if ($options['adwidgets-' . $instance['instance']]['country_1'] != '' && $wpInsertGeoLocation != '' && in_array($wpInsertGeoLocation, split(',', $options['adwidgets-' . $instance['instance']]['country_1']))) { echo '<div class="wpInsert wpInsertAdWidget"' . ($options['adwidgets-' . $instance['instance']]['styles'] != '' ? ' style="' . $options['adwidgets-' . $instance['instance']]['styles'] . '"' : '') . '>' . do_shortcode($options['adwidgets-' . $instance['instance']]['country_code_1']) . '</div>'; } else { echo '<div class="wpInsert wpInsertAdWidget"' . ($options['adwidgets-' . $instance['instance']]['styles'] != '' ? ' style="' . $options['adwidgets-' . $instance['instance']]['styles'] . '"' : '') . '>' . do_shortcode($options['adwidgets-' . $instance['instance']]['ad_code_' . $wpInsertAdInstance]) . '</div>'; } echo $after_widget; } }
function wp_insert_inpostads_filter_the_content($content) { global $wpInsertAdInstance; global $wpInsertGeoLocation; $options = get_option('wp_insert_inpostads_options'); if (wp_insert_get_ad_status($options['middle'])) { $paragraphs = explode('/p>', $content); $paragraphCount = 0; if (is_array($paragraphs)) { foreach ($paragraphs as $paragraph) { if (strlen($paragraph) > 1) { $paragraphCount++; } } } if ($paragraphCount > 1) { if ($options['middle']['minimum_character_count'] == 0 || $options['middle']['minimum_character_count'] == '') { if ($options['middle']['paragraph_buffer_count'] == 0 || $options['middle']['paragraph_buffer_count'] == '') { $position = wp_insert_inpostads_get_middle_position('/p>', $content, round($paragraphCount / 2)); } else { $position = wp_insert_inpostads_get_middle_position('/p>', $content, $options['middle']['paragraph_buffer_count']); } if ($position) { if ($options['middle']['country_1'] != '' && $wpInsertGeoLocation != '' && in_array($wpInsertGeoLocation, split(',', $options['middle']['country_1']))) { $content = substr_replace($content, '/p>' . '<div class="wpInsert wpInsertInPostAd wpInsertMiddle"' . ($options['middle']['styles'] != '' ? ' style="' . $options['middle']['styles'] . '"' : '') . '>' . do_shortcode($options['middle']['country_code_1']) . '</div>', $position, 3); } else { $content = substr_replace($content, '/p>' . '<div class="wpInsert wpInsertInPostAd wpInsertMiddle"' . ($options['middle']['styles'] != '' ? ' style="' . $options['middle']['styles'] . '"' : '') . '>' . do_shortcode($options['middle']['ad_code_' . $wpInsertAdInstance]) . '</div>', $position, 3); } } } else { if (strlen(strip_tags($content)) > $options['middle']['minimum_character_count']) { if ($options['middle']['paragraph_buffer_count'] == 0 || $options['middle']['paragraph_buffer_count'] == '') { $position = wp_insert_inpostads_get_middle_position('/p>', $content, round($paragraphCount / 2)); } else { $position = wp_insert_inpostads_get_middle_position('/p>', $content, $options['middle']['paragraph_buffer_count']); } if ($position) { if ($options['middle']['country_1'] != '' && $wpInsertGeoLocation != '' && in_array($wpInsertGeoLocation, split(',', $options['middle']['country_1']))) { $content = substr_replace($content, '/p>' . '<div class="wpInsert wpInsertInPostAd wpInsertMiddle"' . ($options['middle']['styles'] != '' ? ' style="' . $options['middle']['styles'] . '"' : '') . '>' . do_shortcode($options['middle']['country_code_1']) . '</div>', $position, 3); } else { $content = substr_replace($content, '/p>' . '<div class="wpInsert wpInsertInPostAd wpInsertMiddle"' . ($options['middle']['styles'] != '' ? ' style="' . $options['middle']['styles'] . '"' : '') . '>' . do_shortcode($options['middle']['ad_code_' . $wpInsertAdInstance]) . '</div>', $position, 3); } } } } } } if (wp_insert_get_ad_status($options['left'])) { if ($options['left']['country_1'] != '' && $wpInsertGeoLocation != '' && in_array($wpInsertGeoLocation, split(',', $options['left']['country_1']))) { $content = '<div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; ' . ($options['left']['styles'] != '' ? $options['left']['styles'] : '') . '">' . do_shortcode($options['left']['country_code_1']) . '</div>' . $content; } else { $content = '<div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; ' . ($options['left']['styles'] != '' ? $options['left']['styles'] : '') . '">' . do_shortcode($options['left']['ad_code_' . $wpInsertAdInstance]) . '</div>' . $content; } } if (wp_insert_get_ad_status($options['right'])) { if ($options['right']['country_1'] != '' && $wpInsertGeoLocation != '' && in_array($wpInsertGeoLocation, split(',', $options['right']['country_1']))) { $content = '<div class="wpInsert wpInsertInPostAd wpInsertRight" style="float: right; ' . ($options['right']['styles'] != '' ? $options['right']['styles'] : '') . '">' . do_shortcode($options['right']['country_code_1']) . '</div>' . $content; } else { $content = '<div class="wpInsert wpInsertInPostAd wpInsertRight" style="float: right; ' . ($options['right']['styles'] != '' ? $options['right']['styles'] : '') . '">' . do_shortcode($options['right']['ad_code_' . $wpInsertAdInstance]) . '</div>' . $content; } } if (wp_insert_get_ad_status($options['above'])) { if ($options['above']['country_1'] != '' && $wpInsertGeoLocation != '' && in_array($wpInsertGeoLocation, split(',', $options['above']['country_1']))) { $content = '<div class="wpInsert wpInsertInPostAd wpInsertAbove"' . ($options['above']['styles'] != '' ? ' style="' . $options['above']['styles'] . '"' : '') . '>' . do_shortcode($options['above']['country_code_1']) . '</div>' . $content; } else { $content = '<div class="wpInsert wpInsertInPostAd wpInsertAbove"' . ($options['above']['styles'] != '' ? ' style="' . $options['above']['styles'] . '"' : '') . '>' . do_shortcode($options['above']['ad_code_' . $wpInsertAdInstance]) . '</div>' . $content; } } if (wp_insert_get_ad_status($options['below'])) { if ($options['below']['country_1'] != '' && $wpInsertGeoLocation != '' && in_array($wpInsertGeoLocation, split(',', $options['below']['country_1']))) { $content = $content . '<div class="wpInsert wpInsertInPostAd wpInsertBelow"' . ($options['below']['styles'] != '' ? ' style="' . $options['below']['styles'] . '"' : '') . '>' . do_shortcode($options['below']['country_code_1']) . '</div>'; } else { $content = $content . '<div class="wpInsert wpInsertInPostAd wpInsertBelow"' . ($options['below']['styles'] != '' ? ' style="' . $options['below']['styles'] . '"' : '') . '>' . do_shortcode($options['below']['ad_code_' . $wpInsertAdInstance]) . '</div>'; } } return $content; }