PluginProbe
Wp-Insert / 1.0
Wp-Insert v1.0
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
← All changes | ads/insert-ads.php +176 -176 1.21.0 View file →
@@ -1,177 +1,177 @@
1 -<?php
2 -// Hook for adding admin menus
3 -add_action("plugins_loaded", "register_ad_widgets");
4 -
5 -// Creating the dynamic widget for the widgets page
6 -function register_ad_widgets() {
7 -if(get_option('ad_widget_1_enable')) { register_sidebar_widget(__('Ad Widget : 1'), 'ad_widget_1_create'); }
8 -if(get_option('ad_widget_2_enable')) { register_sidebar_widget(__('Ad Widget : 2'), 'ad_widget_2_create'); }
9 -if(get_option('ad_widget_3_enable')) { register_sidebar_widget(__('Ad Widget : 3'), 'ad_widget_3_create'); }
10 -if(get_option('ad_widget_4_enable')) { register_sidebar_widget(__('Ad Widget : 4'), 'ad_widget_4_create'); }
11 -if(get_option('ad_widget_5_enable')) { register_sidebar_widget(__('Ad Widget : 5'), 'ad_widget_5_create'); }
12 -}
13 -
14 -function ad_widget_1_create($args) {
15 -extract($args);
16 -echo $before_widget;
17 -echo get_option('ad_widget_1');
18 -echo $after_widget;
19 -}
20 -
21 -function ad_widget_2_create($args) {
22 -extract($args);
23 -echo $before_widget;
24 -echo get_option('ad_widget_2');
25 -echo $after_widget;
26 -}
27 -
28 -function ad_widget_3_create($args) {
29 -extract($args);
30 -echo $before_widget;
31 -echo get_option('ad_widget_3');
32 -echo $after_widget;
33 -}
34 -
35 -function ad_widget_4_create($args) {
36 -extract($args);
37 -echo $before_widget;
38 -echo get_option('ad_widget_4');
39 -echo $after_widget;
40 -}
41 -
42 -function ad_widget_5_create($args) {
43 -extract($args);
44 -echo $before_widget;
45 -echo get_option('ad_widget_5');
46 -echo $after_widget;
47 -}
48 -
49 -// action function for adding the administrative page
50 -function smart_add_adspage() { ?>
51 -<div class="wrap">
52 -<h2>WP-INSERT : Manage Ads</h2>
53 -<?php show_support_options(); ?>
54 -<form method="post" action="options.php">
55 -<?php wp_nonce_field('update-options'); ?>
56 -
57 -<table class="form-table">
58 -
59 -<tr valign="top">
60 -<th scope="row"><b>In post ads</b></th>
61 -<td>Paste your ads below to make them appear automatically in your posts.</td>
62 -</tr>
63 -
64 -<tr valign="top">
65 -<th scope="row">Ad code to insert<br/><b>( Above the post )</b><br/>
66 -<br/><input id="ad_top_enable" name="ad_top_enable" type="checkbox" value="1"<?php if(get_option('ad_top_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
67 -<td><textarea id="ad_top" name="ad_top" style="width:350px;height:150px;"><?php echo get_option('ad_top'); ?></textarea><br/>
68 -<small>( Paste your ad-sense or similar code in the box above )</small></td>
69 -</tr>
70 -
71 -<tr valign="top">
72 -<th scope="row">Ad code to insert<br/><b>( Below the post )</b><br/>
73 -<br/><input id="ad_bottom_enable" name="ad_bottom_enable" type="checkbox" value="1"<?php if(get_option('ad_bottom_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
74 -<td><textarea id="ad_bottom" name="ad_bottom" style="width:350px;height:150px;"><?php echo get_option('ad_bottom'); ?></textarea><br/>
75 -<small>( Paste your ad-sense or similar code in the box above )</small></td>
76 -</tr>
77 -
78 -<tr valign="top">
79 -<th scope="row">Ad code to insert<br/><b>( Left of the post )</b><br/>
80 -<br/><input id="ad_left_enable" name="ad_left_enable" type="checkbox" value="1"<?php if(get_option('ad_left_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
81 -<td><textarea id="ad_left" name="ad_left" style="width:350px;height:150px;"><?php echo get_option('ad_left'); ?></textarea><br/>
82 -<small>( Paste your ad-sense or similar code in the box above )</small></td>
83 -</tr>
84 -
85 -<tr valign="top">
86 -<th scope="row">Ad code to insert<br/><b>( Right of the post )</b><br/>
87 -<br/><input id="ad_right_enable" name="ad_right_enable" type="checkbox" value="1"<?php if(get_option('ad_right_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
88 -<td><textarea id="ad_right" name="ad_right" style="width:350px;height:150px;"><?php echo get_option('ad_right'); ?></textarea><br/>
89 -<small>( Paste your ad-sense or similar code in the box above )</small></td>
90 -</tr>
91 -
92 -<tr valign="top">
93 -<th scope="row"></th>
94 -<td><input id="ad_enable_single" name="ad_enable_single" type="checkbox" value="1"<?php if(get_option('ad_enable_single')) echo ' checked="checked"'; ?>/> Show Ads only on single posts and pages<br/></td>
95 -</tr>
96 -
97 -<tr valign="top">
98 -<th scope="row"><b>Ad Widgets</b></th>
99 -<td>Paste your ads below and use the widgets section to insert the ads into your sidebar.</td>
100 -</tr>
101 -
102 -<tr valign="top">
103 -<th scope="row">Ad code to insert<br/><b>( Ad widget : 1 )</b><br/>
104 -<br/><input id="ad_widget_1_enable" name="ad_widget_1_enable" type="checkbox" value="1"<?php if(get_option('ad_widget_1_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
105 -<td><textarea id="ad_widget_1" name="ad_widget_1" style="width:350px;height:150px;"><?php echo get_option('ad_widget_1'); ?></textarea><br/>
106 -<small>( Paste your ad-sense or similar code in the box above )</small></td>
107 -</tr>
108 -
109 -<tr valign="top">
110 -<th scope="row">Ad code to insert<br/><b>( Ad widget : 2 )</b><br/>
111 -<br/><input id="ad_widget_2_enable" name="ad_widget_2_enable" type="checkbox" value="1"<?php if(get_option('ad_widget_2_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
112 -<td><textarea id="ad_widget_2" name="ad_widget_2" style="width:350px;height:150px;"><?php echo get_option('ad_widget_2'); ?></textarea><br/>
113 -<small>( Paste your ad-sense or similar code in the box above )</small></td>
114 -</tr>
115 -
116 -<tr valign="top">
117 -<th scope="row">Ad code to insert<br/><b>( Ad widget : 3 )</b><br/>
118 -<br/><input id="ad_widget_3_enable" name="ad_widget_3_enable" type="checkbox" value="1"<?php if(get_option('ad_widget_3_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
119 -<td><textarea id="ad_widget_3" name="ad_widget_3" style="width:350px;height:150px;"><?php echo get_option('ad_widget_3'); ?></textarea><br/>
120 -<small>( Paste your ad-sense or similar code in the box above )</small></td>
121 -</tr>
122 -
123 -<tr valign="top">
124 -<th scope="row">Ad code to insert<br/><b>( Ad widget : 4 )</b><br/>
125 -<br/><input id="ad_widget_4_enable" name="ad_widget_4_enable" type="checkbox" value="1"<?php if(get_option('ad_widget_4_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
126 -<td><textarea id="ad_widget_4" name="ad_widget_4" style="width:350px;height:150px;"><?php echo get_option('ad_widget_4'); ?></textarea><br/>
127 -<small>( Paste your ad-sense or similar code in the box above )</small></td>
128 -</tr>
129 -
130 -<tr valign="top">
131 -<th scope="row">Ad code to insert<br/><b>( Ad widget : 5 )</b><br/>
132 -<br/><input id="ad_widget_5_enable" name="ad_widget_5_enable" type="checkbox" value="1"<?php if(get_option('ad_widget_5_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
133 -<td><textarea id="ad_widget_5" name="ad_widget_5" style="width:350px;height:150px;"><?php echo get_option('ad_widget_5'); ?></textarea><br/>
134 -<small>( Paste your ad-sense or similar code in the box above )</small></td>
135 -</tr>
136 -
137 -</table>
138 -
139 -<input type="hidden" name="action" value="update" />
140 -<input type="hidden" name="page_options" value="ad_top,ad_top_enable,ad_bottom,ad_bottom_enable,ad_left,ad_left_enable,ad_right,ad_right_enable,ad_enable_single,ad_widget_5_enable,ad_widget_4_enable,ad_widget_3_enable,ad_widget_2_enable,ad_widget_1_enable,ad_widget_5,ad_widget_4,ad_widget_3,ad_widget_2,ad_widget_1" />
141 -<p class="submit">
142 -<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
143 -</p>
144 -</form>
145 -</div>
146 -<?php }
147 -//Actual insertion of ads into content takes place here.
148 -add_filter('the_content', 'insert_into_content');
149 -
150 -function insert_into_content($content) {
151 -if(!is_singular() && get_option('ad_enable_single')) { return $content; }
152 -else {
153 - $output = '<table><tr>';
154 - if(get_option('ad_left_enable') && get_option('ad_right_enable')) {$cellspan=' colspan="3"';} else if(get_option('ad_left_enable') || get_option('ad_right_enable')) {$cellspan=' colspan="2"';} else {$cellspan='';}
155 -
156 - if(get_option('ad_top_enable')) {
157 -
158 - $output .= '<td'.$cellspan.' align="center">'.get_option('ad_top').'</td></tr><tr>';
159 - }
160 - if(get_option('ad_left_enable')) {
161 - $output .= '<td valign="top">'.get_option('ad_left').'</td>';
162 - }
163 -
164 - $output .= '<td>'.$content.'</td>';
165 -
166 - if(get_option('ad_right_enable')) {
167 - $output .= '<td valign="top">'.get_option('ad_right').'</td>';
168 - }
169 - if(get_option('ad_bottom_enable')) {
170 - $output .= '</tr><tr><td'.$cellspan.' align="center">'.get_option('ad_bottom').'</td>';
171 - }
172 -
173 - $output .= '</tr></table>';
174 - return $output;
175 -}
176 -}
1 +<?php
2 +// Hook for adding admin menus
3 +add_action("plugins_loaded", "register_ad_widgets");
4 +
5 +// Creating the dynamic widget for the widgets page
6 +function register_ad_widgets() {
7 +if(get_option('ad_widget_1_enable')) { register_sidebar_widget(__('Ad Widget : 1'), 'ad_widget_1_create'); }
8 +if(get_option('ad_widget_2_enable')) { register_sidebar_widget(__('Ad Widget : 2'), 'ad_widget_2_create'); }
9 +if(get_option('ad_widget_3_enable')) { register_sidebar_widget(__('Ad Widget : 3'), 'ad_widget_3_create'); }
10 +if(get_option('ad_widget_4_enable')) { register_sidebar_widget(__('Ad Widget : 4'), 'ad_widget_4_create'); }
11 +if(get_option('ad_widget_5_enable')) { register_sidebar_widget(__('Ad Widget : 5'), 'ad_widget_5_create'); }
12 +}
13 +
14 +function ad_widget_1_create($args) {
15 +extract($args);
16 +echo $before_widget;
17 +echo get_option('ad_widget_1');
18 +echo $after_widget;
19 +}
20 +
21 +function ad_widget_2_create($args) {
22 +extract($args);
23 +echo $before_widget;
24 +echo get_option('ad_widget_2');
25 +echo $after_widget;
26 +}
27 +
28 +function ad_widget_3_create($args) {
29 +extract($args);
30 +echo $before_widget;
31 +echo get_option('ad_widget_3');
32 +echo $after_widget;
33 +}
34 +
35 +function ad_widget_4_create($args) {
36 +extract($args);
37 +echo $before_widget;
38 +echo get_option('ad_widget_4');
39 +echo $after_widget;
40 +}
41 +
42 +function ad_widget_5_create($args) {
43 +extract($args);
44 +echo $before_widget;
45 +echo get_option('ad_widget_5');
46 +echo $after_widget;
47 +}
48 +
49 +// action function for adding the administrative page
50 +function smart_add_adspage() { ?>
51 +<div class="wrap">
52 +<h2>WP-INSERT : Manage Ads</h2>
53 +<?php show_support_options(); ?>
54 +<form method="post" action="options.php">
55 +<?php wp_nonce_field('update-options'); ?>
56 +
57 +<table class="form-table">
58 +
59 +<tr valign="top">
60 +<th scope="row"><b>In post ads</b></th>
61 +<td>Paste your ads below to make them appear automatically in your posts.</td>
62 +</tr>
63 +
64 +<tr valign="top">
65 +<th scope="row">Ad code to insert<br/><b>( Above the post )</b><br/>
66 +<br/><input id="ad_top_enable" name="ad_top_enable" type="checkbox" value="1"<?php if(get_option('ad_top_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
67 +<td><textarea id="ad_top" name="ad_top" style="width:350px;height:150px;"><?php echo get_option('ad_top'); ?></textarea><br/>
68 +<small>( Paste your ad-sense or similar code in the box above )</small></td>
69 +</tr>
70 +
71 +<tr valign="top">
72 +<th scope="row">Ad code to insert<br/><b>( Below the post )</b><br/>
73 +<br/><input id="ad_bottom_enable" name="ad_bottom_enable" type="checkbox" value="1"<?php if(get_option('ad_bottom_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
74 +<td><textarea id="ad_bottom" name="ad_bottom" style="width:350px;height:150px;"><?php echo get_option('ad_bottom'); ?></textarea><br/>
75 +<small>( Paste your ad-sense or similar code in the box above )</small></td>
76 +</tr>
77 +
78 +<tr valign="top">
79 +<th scope="row">Ad code to insert<br/><b>( Left of the post )</b><br/>
80 +<br/><input id="ad_left_enable" name="ad_left_enable" type="checkbox" value="1"<?php if(get_option('ad_left_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
81 +<td><textarea id="ad_left" name="ad_left" style="width:350px;height:150px;"><?php echo get_option('ad_left'); ?></textarea><br/>
82 +<small>( Paste your ad-sense or similar code in the box above )</small></td>
83 +</tr>
84 +
85 +<tr valign="top">
86 +<th scope="row">Ad code to insert<br/><b>( Right of the post )</b><br/>
87 +<br/><input id="ad_right_enable" name="ad_right_enable" type="checkbox" value="1"<?php if(get_option('ad_right_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
88 +<td><textarea id="ad_right" name="ad_right" style="width:350px;height:150px;"><?php echo get_option('ad_right'); ?></textarea><br/>
89 +<small>( Paste your ad-sense or similar code in the box above )</small></td>
90 +</tr>
91 +
92 +<tr valign="top">
93 +<th scope="row"></th>
94 +<td><input id="ad_enable_single" name="ad_enable_single" type="checkbox" value="1"<?php if(get_option('ad_enable_single')) echo ' checked="checked"'; ?>/> Show Ads only on single posts and pages<br/></td>
95 +</tr>
96 +
97 +<tr valign="top">
98 +<th scope="row"><b>Ad Widgets</b></th>
99 +<td>Paste your ads below and use the widgets section to insert the ads into your sidebar.</td>
100 +</tr>
101 +
102 +<tr valign="top">
103 +<th scope="row">Ad code to insert<br/><b>( Ad widget : 1 )</b><br/>
104 +<br/><input id="ad_widget_1_enable" name="ad_widget_1_enable" type="checkbox" value="1"<?php if(get_option('ad_widget_1_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
105 +<td><textarea id="ad_widget_1" name="ad_widget_1" style="width:350px;height:150px;"><?php echo get_option('ad_widget_1'); ?></textarea><br/>
106 +<small>( Paste your ad-sense or similar code in the box above )</small></td>
107 +</tr>
108 +
109 +<tr valign="top">
110 +<th scope="row">Ad code to insert<br/><b>( Ad widget : 2 )</b><br/>
111 +<br/><input id="ad_widget_2_enable" name="ad_widget_2_enable" type="checkbox" value="1"<?php if(get_option('ad_widget_2_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
112 +<td><textarea id="ad_widget_2" name="ad_widget_2" style="width:350px;height:150px;"><?php echo get_option('ad_widget_2'); ?></textarea><br/>
113 +<small>( Paste your ad-sense or similar code in the box above )</small></td>
114 +</tr>
115 +
116 +<tr valign="top">
117 +<th scope="row">Ad code to insert<br/><b>( Ad widget : 3 )</b><br/>
118 +<br/><input id="ad_widget_3_enable" name="ad_widget_3_enable" type="checkbox" value="1"<?php if(get_option('ad_widget_3_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
119 +<td><textarea id="ad_widget_3" name="ad_widget_3" style="width:350px;height:150px;"><?php echo get_option('ad_widget_3'); ?></textarea><br/>
120 +<small>( Paste your ad-sense or similar code in the box above )</small></td>
121 +</tr>
122 +
123 +<tr valign="top">
124 +<th scope="row">Ad code to insert<br/><b>( Ad widget : 4 )</b><br/>
125 +<br/><input id="ad_widget_4_enable" name="ad_widget_4_enable" type="checkbox" value="1"<?php if(get_option('ad_widget_4_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
126 +<td><textarea id="ad_widget_4" name="ad_widget_4" style="width:350px;height:150px;"><?php echo get_option('ad_widget_4'); ?></textarea><br/>
127 +<small>( Paste your ad-sense or similar code in the box above )</small></td>
128 +</tr>
129 +
130 +<tr valign="top">
131 +<th scope="row">Ad code to insert<br/><b>( Ad widget : 5 )</b><br/>
132 +<br/><input id="ad_widget_5_enable" name="ad_widget_5_enable" type="checkbox" value="1"<?php if(get_option('ad_widget_5_enable')) echo ' checked="checked"'; ?>/> Enabled</th>
133 +<td><textarea id="ad_widget_5" name="ad_widget_5" style="width:350px;height:150px;"><?php echo get_option('ad_widget_5'); ?></textarea><br/>
134 +<small>( Paste your ad-sense or similar code in the box above )</small></td>
135 +</tr>
136 +
137 +</table>
138 +
139 +<input type="hidden" name="action" value="update" />
140 +<input type="hidden" name="page_options" value="ad_top,ad_top_enable,ad_bottom,ad_bottom_enable,ad_left,ad_left_enable,ad_right,ad_right_enable,ad_enable_single,ad_widget_5_enable,ad_widget_4_enable,ad_widget_3_enable,ad_widget_2_enable,ad_widget_1_enable,ad_widget_5,ad_widget_4,ad_widget_3,ad_widget_2,ad_widget_1" />
141 +<p class="submit">
142 +<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
143 +</p>
144 +</form>
145 +</div>
146 +<?php }
147 +//Actual insertion of ads into content takes place here.
148 +add_filter('the_content', 'insert_into_content');
149 +
150 +function insert_into_content($content) {
151 +if(!is_singular() && get_option('ad_enable_single')) { return $content; }
152 +else {
153 + $output = '<table><tr>';
154 + if(get_option('ad_left_enable') && get_option('ad_right_enable')) {$cellspan=' colspan="3"';} else if(get_option('ad_left_enable') || get_option('ad_right_enable')) {$cellspan=' colspan="2"';} else {$cellspan='';}
155 +
156 + if(get_option('ad_top_enable')) {
157 +
158 + $output .= '<td'.$cellspan.' align="center">'.get_option('ad_top').'</td></tr><tr>';
159 + }
160 + if(get_option('ad_left_enable')) {
161 + $output .= '<td valign="top">'.get_option('ad_left').'</td>';
162 + }
163 +
164 + $output .= '<td>'.$content.'</td>';
165 +
166 + if(get_option('ad_right_enable')) {
167 + $output .= '<td valign="top">'.get_option('ad_right').'</td>';
168 + }
169 + if(get_option('ad_bottom_enable')) {
170 + $output .= '</tr><tr><td'.$cellspan.' align="center">'.get_option('ad_bottom').'</td>';
171 + }
172 +
173 + $output .= '</tr></table>';
174 + return $output;
175 +}
176 +}
177 177 ?>