| 1 |
<?php |
| 2 |
|
| 3 |
add_action('template_redirect', 'register_feed_redirect'); |
| 4 |
|
| 5 |
add_action("plugins_loaded", "register_feed_head_manipulation"); |
| 6 |
|
| 7 |
add_filter('the_content', 'register_feed_ad_manipulation'); |
| 8 |
|
| 9 |
add_action("plugins_loaded", "register_email_feed_widget"); |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
// Creating the dynamic widget for the widgets page |
| 14 |
|
| 15 |
function register_email_feed_widget() { |
| 16 |
|
| 17 |
if(get_option('smart_feed_email_enabled')) { register_sidebar_widget(__('Feedburner : Subscribe via Email'), 'feed_email_subscribe_widget_create'); } |
| 18 |
|
| 19 |
if(get_option('smart_feed_subscribe_widget_enabled')) { register_sidebar_widget(__('Subscribe to Feed'), 'feed_subscribe_widget_create'); } |
| 20 |
|
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
function feed_subscribe_widget_create($args) { |
| 26 |
|
| 27 |
extract($args); |
| 28 |
|
| 29 |
echo $before_widget; |
| 30 |
|
| 31 |
if(get_option('smart_feed_subscribe_widget_header') != "") { |
| 32 |
|
| 33 |
echo $before_title.get_option('smart_feed_subscribe_widget_header').$after_title; |
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
if(get_option('smart_feed_feedburner_enabled')) { |
| 38 |
|
| 39 |
echo '<ul><li><a href="'.get_option('smart_feed_feedburner').'"><img src="'.get_bloginfo('url').'/wp-content/plugins/wp-insert/images/feed-icon-24x24.gif" /> Subscribe</a></li></ul>'; |
| 40 |
|
| 41 |
} else { |
| 42 |
|
| 43 |
echo '<ul><li><a href="'.get_bloginfo('rss2_url').'"><img src="'.get_bloginfo('url').'/wp-content/plugins/wp-insert/images/feed-icon-24x24.gif" /> Subscribe</a></li></ul>'; |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
echo $after_widget; |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
function feed_email_subscribe_widget_create($args) { |
| 54 |
|
| 55 |
extract($args); |
| 56 |
|
| 57 |
echo $before_widget; |
| 58 |
|
| 59 |
echo get_option('smart_feed_email'); |
| 60 |
|
| 61 |
echo $after_widget; |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
function register_feed_redirect() { |
| 68 |
|
| 69 |
if(get_option('smart_feed_feedburner_enabled')) { |
| 70 |
|
| 71 |
if (!is_feed()) { return; } |
| 72 |
|
| 73 |
else if (preg_match('/feedburner/', $_SERVER['HTTP_USER_AGENT'])) { return; } |
| 74 |
|
| 75 |
else { |
| 76 |
|
| 77 |
header("Location: ".get_option('smart_feed_feedburner')); |
| 78 |
|
| 79 |
} |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
else { return; } |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
function register_feed_ad_manipulation($content) { |
| 90 |
|
| 91 |
if(is_feed()) { |
| 92 |
|
| 93 |
$prefix = ''; |
| 94 |
|
| 95 |
$suffix = ''; |
| 96 |
|
| 97 |
if(get_option('smart_feed_ad_top_enabled')) { |
| 98 |
|
| 99 |
$prefix = get_option('smart_feed_ad_top'); |
| 100 |
|
| 101 |
} |
| 102 |
|
| 103 |
if(get_option('smart_feed_ad_bottom_enabled')) { |
| 104 |
|
| 105 |
$suffix = "<p>".get_option('smart_feed_ad_bottom')."</p>"; |
| 106 |
|
| 107 |
} |
| 108 |
|
| 109 |
return $prefix.$content.$suffix; |
| 110 |
|
| 111 |
} |
| 112 |
|
| 113 |
else { return $content; } |
| 114 |
|
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
function register_feed_head_manipulation() { |
| 120 |
|
| 121 |
if(get_option('smart_feed_head_enable')) { |
| 122 |
|
| 123 |
add_action('rss_head', 'smart_add_feedimage_rss'); |
| 124 |
|
| 125 |
add_action('rss2_head', 'smart_add_feedimage_rss'); |
| 126 |
|
| 127 |
} |
| 128 |
|
| 129 |
} |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
function smart_add_feedimage_rss() { |
| 134 |
|
| 135 |
echo "<image> |
| 136 |
|
| 137 |
<title>".get_bloginfo('name')."</title> |
| 138 |
|
| 139 |
<url>".get_option('smart_feed_head')."</url> |
| 140 |
|
| 141 |
<link>".get_bloginfo('url')."</link> |
| 142 |
|
| 143 |
<width>".get_option('smart_feed_head_width')."</width> |
| 144 |
|
| 145 |
<height>".get_option('smart_feed_head_height')."</height> |
| 146 |
|
| 147 |
<description>get_bloginfo('description')</description> |
| 148 |
|
| 149 |
</image>"; |
| 150 |
|
| 151 |
} |
| 152 |
|
| 153 |
// action function for adding the administrative page |
| 154 |
|
| 155 |
function smart_add_feedspage() { ?> |
| 156 |
|
| 157 |
<div class="wrap"> |
| 158 |
|
| 159 |
<h2>WP-INSERT : Manage Feeds</h2> |
| 160 |
|
| 161 |
<?php show_support_options(); ?> |
| 162 |
|
| 163 |
<form method="post" action="options.php"> |
| 164 |
|
| 165 |
<?php wp_nonce_field('update-options'); ?> |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
<table class="form-table"> |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
<tr valign="top"> |
| 174 |
|
| 175 |
<th scope="row"><b>Logo for your feed</b></th> |
| 176 |
|
| 177 |
<td><input id="smart_feed_head_enable" name="smart_feed_head_enable" type="checkbox" value="1" <?php if(get_option('smart_feed_head_enable')) echo 'checked="checked"'; ?> /> Enabled</td> |
| 178 |
|
| 179 |
</tr> |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
<tr valign="top"> |
| 184 |
|
| 185 |
<th scope="row">Logo URL</th> |
| 186 |
|
| 187 |
<td><input id="smart_feed_head" name="smart_feed_head" type="text" value="<?php echo get_option('smart_feed_head'); ?>" style="width:350px;" /><br/> |
| 188 |
|
| 189 |
<small>( Paste the URL of your logo image in the box above )</small></td> |
| 190 |
|
| 191 |
</tr> |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
<tr valign="top"> |
| 196 |
|
| 197 |
<th scope="row">Logo Width</th> |
| 198 |
|
| 199 |
<td><input id="smart_feed_head_width" name="smart_feed_head_width" type="text" value="<?php echo get_option('smart_feed_head_width'); ?>" style="width:350px;" /><br/> |
| 200 |
|
| 201 |
<small>( The width of your logo image )</small></td> |
| 202 |
|
| 203 |
</tr> |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
<tr valign="top"> |
| 208 |
|
| 209 |
<th scope="row">Logo Height</th> |
| 210 |
|
| 211 |
<td><input id="smart_feed_head_height" name="smart_feed_head_height" type="text" value="<?php echo get_option('smart_feed_head_height'); ?>" style="width:350px;" /><br/> |
| 212 |
|
| 213 |
<small>( The height of your logo image )</small></td> |
| 214 |
|
| 215 |
</tr> |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
<tr valign="top"> |
| 220 |
|
| 221 |
<th scope="row"><b>Insert ads into your feed</b></th> |
| 222 |
|
| 223 |
<td>The ads might not show up for already written posts!</td> |
| 224 |
|
| 225 |
</tr> |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
<tr valign="top"> |
| 230 |
|
| 231 |
<th scope="row">Ad code to insert<br/>( Above feed content )<br/> |
| 232 |
|
| 233 |
<br/><input id="smart_feed_ad_top_enabled" name="smart_feed_ad_top_enabled" type="checkbox" value="1"<?php if(get_option('smart_feed_ad_top_enabled')) echo ' checked="checked"'; ?>/> Enabled</th> |
| 234 |
|
| 235 |
<td><textarea id="smart_feed_ad_top" name="smart_feed_ad_top" style="width:350px;height:150px;"><?php echo get_option('smart_feed_ad_top'); ?></textarea><br/> |
| 236 |
|
| 237 |
<small>( Paste your ad-sense or similar code in the box above )</small></td> |
| 238 |
|
| 239 |
</tr> |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
<tr valign="top"> |
| 244 |
|
| 245 |
<th scope="row">Ad code to insert<br/>( Below feed content )<br/> |
| 246 |
|
| 247 |
<br/><input id="smart_feed_ad_bottom_enabled" name="smart_feed_ad_bottom_enabled" type="checkbox" value="1"<?php if(get_option('smart_feed_ad_bottom_enabled')) echo ' checked="checked"'; ?>/> Enabled</th> |
| 248 |
|
| 249 |
<td><textarea id="smart_feed_ad_bottom" name="smart_feed_ad_bottom" style="width:350px;height:150px;"><?php echo get_option('smart_feed_ad_bottom'); ?></textarea><br/> |
| 250 |
|
| 251 |
<small>( Paste your ad-sense or similar code in the box above )</small></td> |
| 252 |
|
| 253 |
</tr> |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
<tr valign="top"> |
| 258 |
|
| 259 |
<th scope="row"><b>Feedburner</b></th> |
| 260 |
|
| 261 |
<td></td> |
| 262 |
|
| 263 |
</tr> |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
<tr valign="top"> |
| 268 |
|
| 269 |
<th scope="row">Feedburner Feed URL<br/> |
| 270 |
|
| 271 |
<br/><input id="smart_feed_feedburner_enabled" name="smart_feed_feedburner_enabled" type="checkbox" value="1"<?php if(get_option('smart_feed_feedburner_enabled')) echo ' checked="checked"'; ?>/> Enabled</th> |
| 272 |
|
| 273 |
<td><input type="text" id="smart_feed_feedburner" name="smart_feed_feedburner" style="width:350px;" value="<?php echo get_option('smart_feed_feedburner'); ?>" /><br/> |
| 274 |
|
| 275 |
<small>( Paste your Feedburner feed URL in the box above )</small></td> |
| 276 |
|
| 277 |
</tr> |
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
<tr valign="top"> |
| 282 |
|
| 283 |
<th scope="row">Subscribe via E-mail Widget<br/> |
| 284 |
|
| 285 |
<br/><input id="smart_feed_email_enabled" name="smart_feed_email_enabled" type="checkbox" value="1"<?php if(get_option('smart_feed_email_enabled')) echo ' checked="checked"'; ?>/> Enabled</th> |
| 286 |
|
| 287 |
<td><textarea id="smart_feed_email" name="smart_feed_email" style="width:350px;height:150px;"><?php echo get_option('smart_feed_email'); ?></textarea><br/> |
| 288 |
|
| 289 |
<small>( Paste your Feedburner Subscribe via email code in the box above )</small></td> |
| 290 |
|
| 291 |
</tr> |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
<tr valign="top"> |
| 296 |
|
| 297 |
<th scope="row"><b>Subscribe Widget</b></th> |
| 298 |
|
| 299 |
<td></td> |
| 300 |
|
| 301 |
</tr> |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
<tr valign="top"> |
| 306 |
|
| 307 |
<th scope="row">Subscribe Widget Header<br/>( Optional ) <input id="smart_feed_subscribe_widget_enabled" name="smart_feed_subscribe_widget_enabled" type="checkbox" value="1"<?php if(get_option('smart_feed_subscribe_widget_enabled')) echo ' checked="checked"'; ?>/> Enabled</th> |
| 308 |
|
| 309 |
<td><input type="text" id="smart_feed_subscribe_widget_header" name="smart_feed_subscribe_widget_header" style="width:350px;" value="<?php echo get_option('smart_feed_subscribe_widget_header'); ?>" /><br/> |
| 310 |
|
| 311 |
<small>( Paste the header text for subscribe in the box above )</small></td> |
| 312 |
|
| 313 |
</tr> |
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
</table> |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
<input type="hidden" name="action" value="update" /> |
| 322 |
|
| 323 |
<input type="hidden" name="page_options" value="smart_feed_head_enable,smart_feed_head,smart_feed_head_width,smart_feed_head_height,smart_feed_ad_top_enabled,smart_feed_ad_top,smart_feed_ad_bottom_enabled,smart_feed_ad_bottom,smart_feed_feedburner_enabled,smart_feed_feedburner,smart_feed_email,smart_feed_email_enabled,smart_feed_subscribe_widget_enabled,smart_feed_subscribe_widget_header" /> |
| 324 |
|
| 325 |
<p class="submit"> |
| 326 |
|
| 327 |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> |
| 328 |
|
| 329 |
</p> |
| 330 |
|
| 331 |
</form> |
| 332 |
|
| 333 |
</div> |
| 334 |
|
| 335 |
<?php } ?> |