| 1 |
<?php |
| 2 |
add_action('template_redirect', 'register_feed_redirect'); |
| 3 |
add_action("plugins_loaded", "register_feed_head_manipulation"); |
| 4 |
add_filter('the_content', 'register_feed_ad_manipulation'); |
| 5 |
add_action("plugins_loaded", "register_email_feed_widget"); |
| 6 |
|
| 7 |
// Creating the dynamic widget for the widgets page |
| 8 |
function register_email_feed_widget() { |
| 9 |
if(get_option('smart_feed_email_enabled')) { register_sidebar_widget(__('Feedburner : Subscribe via Email'), 'feed_email_subscribe_widget_create'); } |
| 10 |
if(get_option('smart_feed_subscribe_widget_enabled')) { register_sidebar_widget(__('Subscribe to Feed'), 'feed_subscribe_widget_create'); } |
| 11 |
} |
| 12 |
|
| 13 |
function feed_subscribe_widget_create($args) { |
| 14 |
extract($args); |
| 15 |
echo $before_widget; |
| 16 |
if(get_option('smart_feed_subscribe_widget_header') != "") { |
| 17 |
echo $before_title.get_option('smart_feed_subscribe_widget_header').$after_title; |
| 18 |
} |
| 19 |
if(get_option('smart_feed_feedburner_enabled')) { |
| 20 |
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>'; |
| 21 |
} else { |
| 22 |
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>'; |
| 23 |
} |
| 24 |
echo $after_widget; |
| 25 |
} |
| 26 |
|
| 27 |
function feed_email_subscribe_widget_create($args) { |
| 28 |
extract($args); |
| 29 |
echo $before_widget; |
| 30 |
echo get_option('smart_feed_email'); |
| 31 |
echo $after_widget; |
| 32 |
} |
| 33 |
|
| 34 |
function register_feed_redirect() { |
| 35 |
if(get_option('smart_feed_feedburner_enabled')) { |
| 36 |
if (!is_feed()) { return; } |
| 37 |
else if (preg_match('/feedburner/', $_SERVER['HTTP_USER_AGENT'])) { return; } |
| 38 |
else { |
| 39 |
header("Location: ".get_option('smart_feed_feedburner')); |
| 40 |
} |
| 41 |
} |
| 42 |
else { return; } |
| 43 |
} |
| 44 |
|
| 45 |
function register_feed_ad_manipulation($content) { |
| 46 |
if(is_feed()) { |
| 47 |
$prefix = ''; |
| 48 |
$suffix = ''; |
| 49 |
if(get_option('smart_feed_ad_top_enabled')) { |
| 50 |
$prefix = get_option('smart_feed_ad_top'); |
| 51 |
} |
| 52 |
if(get_option('smart_feed_ad_bottom_enabled')) { |
| 53 |
$suffix = "<p>".get_option('smart_feed_ad_bottom')."</p>"; |
| 54 |
} |
| 55 |
return $prefix.$content.$suffix; |
| 56 |
} |
| 57 |
else { return $content; } |
| 58 |
} |
| 59 |
|
| 60 |
function register_feed_head_manipulation() { |
| 61 |
if(get_option('smart_feed_head_enable')) { |
| 62 |
add_action('rss_head', 'smart_add_feedimage_rss'); |
| 63 |
add_action('rss2_head', 'smart_add_feedimage_rss'); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
function smart_add_feedimage_rss() { |
| 68 |
echo "<image> |
| 69 |
<title>".get_bloginfo('name')."</title> |
| 70 |
<url>".get_option('smart_feed_head')."</url> |
| 71 |
<link>".get_bloginfo('url')."</link> |
| 72 |
<width>".get_option('smart_feed_head_width')."</width> |
| 73 |
<height>".get_option('smart_feed_head_height')."</height> |
| 74 |
<description>get_bloginfo('description')</description> |
| 75 |
</image>"; |
| 76 |
} |
| 77 |
// action function for adding the administrative page |
| 78 |
function smart_add_feedspage() { ?> |
| 79 |
<div class="wrap"> |
| 80 |
<h2>WP-INSERT : Manage Feeds</h2> |
| 81 |
<?php show_support_options(); ?> |
| 82 |
<form method="post" action="options.php"> |
| 83 |
<?php wp_nonce_field('update-options'); ?> |
| 84 |
|
| 85 |
<table class="form-table"> |
| 86 |
|
| 87 |
<tr valign="top"> |
| 88 |
<th scope="row"><b>Logo for your feed</b></th> |
| 89 |
<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> |
| 90 |
</tr> |
| 91 |
|
| 92 |
<tr valign="top"> |
| 93 |
<th scope="row">Logo URL</th> |
| 94 |
<td><input id="smart_feed_head" name="smart_feed_head" type="text" value="<?php echo get_option('smart_feed_head'); ?>" style="width:350px;" /><br/> |
| 95 |
<small>( Paste the URL of your logo image in the box above )</small></td> |
| 96 |
</tr> |
| 97 |
|
| 98 |
<tr valign="top"> |
| 99 |
<th scope="row">Logo Width</th> |
| 100 |
<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/> |
| 101 |
<small>( The width of your logo image )</small></td> |
| 102 |
</tr> |
| 103 |
|
| 104 |
<tr valign="top"> |
| 105 |
<th scope="row">Logo Height</th> |
| 106 |
<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/> |
| 107 |
<small>( The height of your logo image )</small></td> |
| 108 |
</tr> |
| 109 |
|
| 110 |
<tr valign="top"> |
| 111 |
<th scope="row"><b>Insert ads into your feed</b></th> |
| 112 |
<td>The ads might not show up for already written posts!</td> |
| 113 |
</tr> |
| 114 |
|
| 115 |
<tr valign="top"> |
| 116 |
<th scope="row">Ad code to insert<br/>( Above feed content )<br/> |
| 117 |
<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> |
| 118 |
<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/> |
| 119 |
<small>( Paste your ad-sense or similar code in the box above )</small></td> |
| 120 |
</tr> |
| 121 |
|
| 122 |
<tr valign="top"> |
| 123 |
<th scope="row">Ad code to insert<br/>( Below feed content )<br/> |
| 124 |
<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> |
| 125 |
<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/> |
| 126 |
<small>( Paste your ad-sense or similar code in the box above )</small></td> |
| 127 |
</tr> |
| 128 |
|
| 129 |
<tr valign="top"> |
| 130 |
<th scope="row"><b>Feedburner</b></th> |
| 131 |
<td></td> |
| 132 |
</tr> |
| 133 |
|
| 134 |
<tr valign="top"> |
| 135 |
<th scope="row">Feedburner Feed URL<br/> |
| 136 |
<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> |
| 137 |
<td><input type="text" id="smart_feed_feedburner" name="smart_feed_feedburner" style="width:350px;" value="<?php echo get_option('smart_feed_feedburner'); ?>" /><br/> |
| 138 |
<small>( Paste your Feedburner feed URL in the box above )</small></td> |
| 139 |
</tr> |
| 140 |
|
| 141 |
<tr valign="top"> |
| 142 |
<th scope="row">Subscribe via E-mail Widget<br/> |
| 143 |
<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> |
| 144 |
<td><textarea id="smart_feed_email" name="smart_feed_email" style="width:350px;height:150px;"><?php echo get_option('smart_feed_email'); ?></textarea><br/> |
| 145 |
<small>( Paste your Feedburner Subscribe via email code in the box above )</small></td> |
| 146 |
</tr> |
| 147 |
|
| 148 |
<tr valign="top"> |
| 149 |
<th scope="row"><b>Subscribe Widget</b></th> |
| 150 |
<td></td> |
| 151 |
</tr> |
| 152 |
|
| 153 |
<tr valign="top"> |
| 154 |
<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> |
| 155 |
<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/> |
| 156 |
<small>( Paste the header text for subscribe in the box above )</small></td> |
| 157 |
</tr> |
| 158 |
|
| 159 |
</table> |
| 160 |
|
| 161 |
<input type="hidden" name="action" value="update" /> |
| 162 |
<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" /> |
| 163 |
<p class="submit"> |
| 164 |
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> |
| 165 |
</p> |
| 166 |
</form> |
| 167 |
</div> |
| 168 |
<?php } ?> |