PluginProbe
Wp-Insert / 1.7.6
Wp-Insert v1.7.6
trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.3.0 1.3.1 1.3.3 1.4 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 2.0 All 63 releases
wp-insert / includes / inpostads.php

inpostads.php in Wp-Insert 1.7.6, at includes/inpostads.php

269 lines 13.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 function wp_insert_filter_content_ads($content, $ad_ID) {
3 $output = '';
4 global $random;
5 $page_details = wp_insert_get_current_page_details();
6
7 if(get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_enable')) {
8 /*Finding a appropriate position near the middle of the content to insert the ad*/
9 $positions = array();
10 $endpos = -1;
11 $trigger = "<p";
12 if(strpos($content, "<p") === false)
13 $trigger = "<br";
14
15 while(strpos($content, $trigger, $endpos+1) !== false){
16 $endpos = strpos($content, $trigger, $endpos+1);
17 $positions[] = $endpos;
18 }
19 $middle = sizeof($positions);
20 while(sizeof($positions) > $middle)
21 array_pop($positions);
22 $triggerpoint = $positions[floor(sizeof($positions)/2)];
23 /*End of Finding a appropriate position near the middle of the content to insert the ad*/
24
25 if ($middle > 2) {
26 $ad_style = get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_style');
27 if($ad_style == '') { $ad_style = 'margin: 5px; padding: 0px;'; }
28 if(!get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_exclude_home') && ($page_details == 'HOME')) {
29 switch($random) {
30 case 0:
31 $content = substr_replace($content, '<div id="in_post_ad_middle_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content').'</div>'.$trigger, $triggerpoint, 2);
32 break;
33 case 1:
34 $content = substr_replace($content, '<div id="in_post_ad_middle_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_1').'</div>'.$trigger, $triggerpoint, 2);
35 break;
36 case 2:
37 $content = substr_replace($content, '<div id="in_post_ad_middle_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_2').'</div>'.$trigger, $triggerpoint, 2);
38 break;
39 }
40 }
41 else if(!get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_exclude_archives') && ($page_details == 'ARCHIVE')) {
42 switch($random) {
43 case 0:
44 $content = substr_replace($content, '<div id="in_post_ad_middle_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content').'</div>'.$trigger, $triggerpoint, 2);
45 break;
46 case 1:
47 $content = substr_replace($content, '<div id="in_post_ad_middle_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_1').'</div>'.$trigger, $triggerpoint, 2);
48 break;
49 case 2:
50 $content = substr_replace($content, '<div id="in_post_ad_middle_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_2').'</div>'.$trigger, $triggerpoint, 2);
51 break;
52 }
53 }
54 else {
55 if(is_singular()) {
56 $page_ids = explode(',', str_replace(" ", "", get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_exclude_ids')));
57 if(wp_insert_is_in_array($page_details, $page_ids) =='FALSE') {
58 switch($random) {
59 case 0:
60 $content = substr_replace($content, '<div id="in_post_ad_middle_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content').'</div>'.$trigger, $triggerpoint, 2);
61 break;
62 case 1:
63 $content = substr_replace($content, '<div id="in_post_ad_middle_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_1').'</div>'.$trigger, $triggerpoint, 2);
64 break;
65 case 2:
66 $content = substr_replace($content, '<div id="in_post_ad_middle_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_middle_'.$ad_ID.'_content_2').'</div>'.$trigger, $triggerpoint, 2);
67 break;
68 }
69 }
70 }
71 }
72 }
73 }
74 if(get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_enable')) {
75 $ad_style = get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_style');
76 if($ad_style == '') { $ad_style = 'margin: 5px; padding: 0px;'; }
77 if(!get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_exclude_home') && ($page_details == 'HOME')) {
78 switch($random) {
79 case 0:
80 $output .= '<div id="in_post_ad_top_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content').'</div>';
81 break;
82 case 1:
83 $output .= '<div id="in_post_ad_top_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_1').'</div>';
84 break;
85 case 2:
86 $output .= '<div id="in_post_ad_top_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_2').'</div>';
87 break;
88 }
89 }
90 else if(!get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_exclude_archives') && ($page_details == 'ARCHIVE')) {
91 switch($random) {
92 case 0:
93 $output .= '<div id="in_post_ad_top_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content').'</div>';
94 break;
95 case 1:
96 $output .= '<div id="in_post_ad_top_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_1').'</div>';
97 break;
98 case 2:
99 $output .= '<div id="in_post_ad_top_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_2').'</div>';
100 break;
101 }
102 }
103 else {
104 if(is_singular()) {
105 $page_ids = explode(',', str_replace(" ", "", get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_exclude_ids')));
106 if(wp_insert_is_in_array($page_details, $page_ids) =='FALSE') {
107 switch($random) {
108 case 0:
109 $output .= '<div id="in_post_ad_top_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content').'</div>';
110 break;
111 case 1:
112 $output .= '<div id="in_post_ad_top_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_1').'</div>';
113 break;
114 case 2:
115 $output .= '<div id="in_post_ad_top_'.$ad_ID.'" style="'.$ad_style.'">'.get_option('wp_insert_in_post_ad_top_'.$ad_ID.'_content_2').'</div>';
116 break;
117 }
118 }
119 }
120 }
121 }
122 if(get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_enable')) {
123 $ad_style = get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_style');
124 if($ad_style == '') { $ad_style = 'margin: 5px; padding: 0px;'; }
125 if(!get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_exclude_home') && ($page_details == 'HOME')) {
126 switch($random) {
127 case 0:
128 $output .= '<div id="in_post_ad_left_'.$ad_ID.'" style="float:left;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content').'</div>';
129 break;
130 case 1:
131 $output .= '<div id="in_post_ad_left_'.$ad_ID.'" style="float:left;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_1').'</div>';
132 break;
133 case 2:
134 $output .= '<div id="in_post_ad_left_'.$ad_ID.'" style="float:left;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_2').'</div>';
135 break;
136 }
137 }
138 else if(!get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_exclude_archives') && ($page_details == 'ARCHIVE')) {
139 switch($random) {
140 case 0:
141 $output .= '<div id="in_post_ad_left_'.$ad_ID.'" style="float:left;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content').'</div>';
142 break;
143 case 1:
144 $output .= '<div id="in_post_ad_left_'.$ad_ID.'" style="float:left;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_1').'</div>';
145 break;
146 case 2:
147 $output .= '<div id="in_post_ad_left_'.$ad_ID.'" style="float:left;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_2').'</div>';
148 break;
149 }
150 }
151 else {
152 if(is_singular()) {
153 $page_ids = explode(',', str_replace(" ", "", get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_exclude_ids')));
154 if(wp_insert_is_in_array($page_details, $page_ids) =='FALSE') {
155 switch($random) {
156 case 0:
157 $output .= '<div id="in_post_ad_left_'.$ad_ID.'" style="float:left;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content').'</div>';
158 break;
159 case 1:
160 $output .= '<div id="in_post_ad_left_'.$ad_ID.'" style="float:left;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_1').'</div>';
161 break;
162 case 2:
163 $output .= '<div id="in_post_ad_left_'.$ad_ID.'" style="float:left;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_left_'.$ad_ID.'_content_2').'</div>';
164 break;
165 }
166 }
167 }
168 }
169 }
170 if(get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_enable')) {
171 $ad_style = get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_style');
172 if($ad_style == '') { $ad_style = 'margin: 5px; padding: 0px;'; }
173 if(!get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_exclude_home') && ($page_details == 'HOME')) {
174 switch($random) {
175 case 0:
176 $output .= '<div id="in_post_ad_right_'.$ad_ID.'" style="float:right;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content').'</div>';
177 break;
178 case 1:
179 $output .= '<div id="in_post_ad_right_'.$ad_ID.'" style="float:right;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_1').'</div>';
180 break;
181 case 2:
182 $output .= '<div id="in_post_ad_right_'.$ad_ID.'" style="float:right;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_2').'</div>';
183 break;
184 }
185 }
186 else if(!get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_exclude_archives') && ($page_details == 'ARCHIVE')) {
187 switch($random) {
188 case 0:
189 $output .= '<div id="in_post_ad_right_'.$ad_ID.'" style="float:right;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content').'</div>';
190 break;
191 case 1:
192 $output .= '<div id="in_post_ad_right_'.$ad_ID.'" style="float:right;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_1').'</div>';
193 break;
194 case 2:
195 $output .= '<div id="in_post_ad_right_'.$ad_ID.'" style="float:right;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_2').'</div>';
196 break;
197 }
198 }
199 else {
200 if(is_singular()) {
201 $page_ids = explode(',', str_replace(" ", "", get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_exclude_ids')));
202 if(wp_insert_is_in_array($page_details, $page_ids) =='FALSE') {
203 switch($random) {
204 case 0:
205 $output .= '<div id="in_post_ad_right_'.$ad_ID.'" style="float:right;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content').'</div>';
206 break;
207 case 1:
208 $output .= '<div id="in_post_ad_right_'.$ad_ID.'" style="float:right;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_1').'</div>';
209 break;
210 case 2:
211 $output .= '<div id="in_post_ad_right_'.$ad_ID.'" style="float:right;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_right_'.$ad_ID.'_content_2').'</div>';
212 break;
213 }
214 }
215 }
216 }
217 }
218 if(get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_enable')) {
219 $ad_style = get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_style');
220 if($ad_style == '') { $ad_style = 'margin: 5px; padding: 0px;'; }
221 if(!get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_exclude_home') && ($page_details == 'HOME')) {
222 switch($random) {
223 case 0:
224 $content .= '<div id="in_post_ad_bottom_'.$ad_ID.'" style="clear:both;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content').'</div>';
225 break;
226 case 1:
227 $content .= '<div id="in_post_ad_bottom_'.$ad_ID.'" style="clear:both;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_1').'</div>';
228 break;
229 case 2:
230 $content .= '<div id="in_post_ad_bottom_'.$ad_ID.'" style="clear:both;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_2').'</div>';
231 break;
232 }
233 }
234 else if(!get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_exclude_archives') && ($page_details == 'ARCHIVE')) {
235 switch($random) {
236 case 0:
237 $content .= '<div id="in_post_ad_bottom_'.$ad_ID.'" style="clear:both;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content').'</div>';
238 break;
239 case 1:
240 $content .= '<div id="in_post_ad_bottom_'.$ad_ID.'" style="clear:both;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_1').'</div>';
241 break;
242 case 2:
243 $content .= '<div id="in_post_ad_bottom_'.$ad_ID.'" style="clear:both;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_2').'</div>';
244 break;
245 }
246 }
247 else {
248 if(is_singular()) {
249 $page_ids = explode(',', str_replace(" ", "", get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_exclude_ids')));
250 if(wp_insert_is_in_array($page_details, $page_ids) =='FALSE') {
251 switch($random) {
252 case 0:
253 $content .= '<div id="in_post_ad_bottom_'.$ad_ID.'" style="clear:both;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content').'</div>';
254 break;
255 case 1:
256 $content .= '<div id="in_post_ad_bottom_'.$ad_ID.'" style="clear:both;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_1').'</div>';
257 break;
258 case 2:
259 $content .= '<div id="in_post_ad_bottom_'.$ad_ID.'" style="clear:both;'.$ad_style.'">'.get_option('wp_insert_in_post_ad_bottom_'.$ad_ID.'_content_2').'</div>';
260 break;
261 }
262 }
263 }
264 }
265 }
266 $content = $output.$content."<div style='clear:both'></div>";
267 return $content;
268 }
269 ?>