3 Plugin Name: FD Feedburner Plugin |
3 Plugin Name: FD Feedburner Plugin |
4 Plugin URI: http://flagrantdisregard.com/feedburner/ |
4 Plugin URI: http://flagrantdisregard.com/feedburner/ |
5 Description: Redirects all feeds to a Feedburner feed |
5 Description: Redirects all feeds to a Feedburner feed |
6 Author: John Watson |
6 Author: John Watson |
7 Author URI: http://flagrantdisregard.com/ |
7 Author URI: http://flagrantdisregard.com/ |
8 Version: 1.41 |
8 Version: 1.45 |
9 |
9 |
10 Copyright (C) Sat Feb 18 2006 John Watson |
10 Copyright (C) Sat Feb 18 2006 John Watson |
11 john@flagrantdisregard.com |
11 john@flagrantdisregard.com |
12 http://flagrantdisregard.com/ |
12 http://flagrantdisregard.com/ |
13 |
13 |
26 You should have received a copy of the GNU General Public License |
26 You should have received a copy of the GNU General Public License |
27 along with this program; if not, write to the Free Software |
27 along with this program; if not, write to the Free Software |
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 */ |
29 */ |
30 |
30 |
|
31 define('FDFEEDBURNER_TEXTDOMAIN', 'fdfeedburner'); |
|
32 |
|
33 if (function_exists('load_plugin_textdomain')) { |
|
34 load_plugin_textdomain(FDFEEDBURNER_TEXTDOMAIN, false, dirname(plugin_basename(__FILE__)).'/languages' ); |
|
35 } |
|
36 |
31 add_action('admin_menu', 'feedburner_config_page'); |
37 add_action('admin_menu', 'feedburner_config_page'); |
32 |
38 |
33 function feedburner_config_page() { |
39 function feedburner_config_page() { |
34 global $wpdb; |
40 global $wpdb; |
35 if ( function_exists('add_submenu_page') ) |
41 if ( function_exists('add_submenu_page') ) |
36 add_submenu_page('plugins.php', __('Feedburner Configuration'), __('Feedburner Configuration'), 8, __FILE__, 'feedburner_conf'); |
42 add_submenu_page('options-general.php', |
|
43 __('Feedburner', FDFEEDBURNER_TEXTDOMAIN), |
|
44 __('Feedburner', FDFEEDBURNER_TEXTDOMAIN), |
|
45 'manage_options', __FILE__, 'feedburner_conf'); |
37 } |
46 } |
38 |
47 |
39 function feedburner_fix_url($url) { |
48 function feedburner_fix_url($url) { |
40 $url = preg_replace('!^(http|https)://!i', '', $url); |
49 $url = preg_replace('!^(http|https)://!i', '', $url); |
41 $url = preg_replace('!^/!i', '', $url); |
50 $url = preg_replace('!^/!i', '', $url); |
52 if (!isset($options['feedburner_no_cats'])) $options['feedburner_no_cats'] = 0; |
61 if (!isset($options['feedburner_no_cats'])) $options['feedburner_no_cats'] = 0; |
53 if (!isset($options['feedburner_no_search'])) $options['feedburner_no_search'] = 0; |
62 if (!isset($options['feedburner_no_search'])) $options['feedburner_no_search'] = 0; |
54 |
63 |
55 $updated = false; |
64 $updated = false; |
56 if ( isset($_POST['submit']) ) { |
65 if ( isset($_POST['submit']) ) { |
57 check_admin_referer(); |
66 check_admin_referer('fdfeedburner', 'fdfeedburner-admin'); |
58 |
67 |
59 if (isset($_POST['feedburner_url'])) { |
68 if (isset($_POST['feedburner_url'])) { |
60 $feedburner_url = $_POST['feedburner_url']; |
69 $feedburner_url = $_POST['feedburner_url']; |
61 if ($feedburner_url != null) $feedburner_url = feedburner_fix_url($feedburner_url); |
70 if ($feedburner_url != null) $feedburner_url = feedburner_fix_url($feedburner_url); |
62 } else { |
71 } else { |
102 |
111 |
103 <div class="wrap"> |
112 <div class="wrap"> |
104 <?php |
113 <?php |
105 if ($updated) { |
114 if ($updated) { |
106 echo "<div id='message' class='updated fade'><p>"; |
115 echo "<div id='message' class='updated fade'><p>"; |
107 _e('Configuration updated.'); |
116 _e('Configuration updated.', FDFEEDBURNER_TEXTDOMAIN); |
108 echo "</p></div>"; |
117 echo "</p></div>"; |
109 } |
118 } |
110 ?> |
119 ?> |
111 <h2><?php _e('Feedburner Configuration'); ?></h2> |
120 <h2><?php _e('Feedburner Configuration', FDFEEDBURNER_TEXTDOMAIN); ?></h2> |
112 <div style="float: right; width: 350px"> |
121 <div style="float: right; width: 350px"> |
113 <h3>How does this work?</h3> |
122 <h3><?php _e('How does this work?', FDFEEDBURNER_TEXTDOMAIN); ?></h3> |
114 <p><?php _e('This plugin automatically redirects all of your existing feeds to Feedburner (including category and tag feeds).')?></p> |
123 <p><?php _e('This plugin automatically redirects all of your existing feeds to Feedburner (including category and tag feeds).', FDFEEDBURNER_TEXTDOMAIN)?></p> |
115 <p><?php _e('First go to <a href="http://feedburner.com">Feedburner.com</a> and burn your feed. Enter the URL Feedburner created for you. You may optionally redirect your comments feed using the same procedure. To disable redirection, disable the plugin or erase the URLs.'); |
124 <p><?php _e('First go to <a href="http://feedburner.com">Feedburner.com</a> and burn your feed. Enter the URL Feedburner created for you. You may optionally redirect your comments feed using the same procedure. To disable redirection, disable the plugin or erase the URLs.', FDFEEDBURNER_TEXTDOMAIN);?></p> |
116 ?></p> |
125 <p><?php _e('Once you enter URLs your feeds will be redirected automatically and you do not need to take any further action.') ?> <em><?php _e('Note that your feeds may not appear to redirect to Feedburner until you add a new post.', FDFEEDBURNER_TEXTDOMAIN); ?></em></p> |
117 <p><?php _e('Once you enter URLs your feeds will be redirected automatically and you do not need to take any further action.') ?> <em><?php _e('Note that your feeds may not appear to redirect to Feedburner until you add a new post.'); ?></em> |
|
118 </p> |
|
119 </div> |
126 </div> |
120 <form action="" method="post" id="feedburner-conf"> |
127 <form action="" method="post" id="feedburner-conf"> |
121 <h3><label for="feedburner_url"><?php _e('Redirect my feeds here:'); ?></label></h3> |
128 <h3><label for="feedburner_url"><?php _e('Redirect my feeds here:', FDFEEDBURNER_TEXTDOMAIN); ?></label></h3> |
122 <p><input id="feedburner_url" name="feedburner_url" type="text" size="65" maxlength="200" value="<?php echo $options['feedburner_url']; ?>" /></p> |
129 <p><input id="feedburner_url" name="feedburner_url" type="text" maxlength="200" value="<?php echo $options['feedburner_url']; ?>" /></p> |
123 |
130 |
124 <h3><label for="feedburner_comment_url"><?php _e('Redirect my comments feed here:'); ?></label></h3> |
131 <h3><label for="feedburner_comment_url"><?php _e('Redirect my comments feed here:', FDFEEDBURNER_TEXTDOMAIN); ?></label></h3> |
125 <p><input id="feedburner_comment_url" name="feedburner_comment_url" type="text" size="65" maxlength="200" value="<?php echo $options['feedburner_comment_url']; ?>" /></p> |
132 <p><input id="feedburner_comment_url" name="feedburner_comment_url" type="text" maxlength="200" value="<?php echo $options['feedburner_comment_url']; ?>" /></p> |
126 |
133 |
127 <h3>Advanced Options</h3> |
134 <h3><?php _e('Advanced Options', FDFEEDBURNER_TEXTDOMAIN); ?></h3> |
128 <p> |
135 <p> |
129 <input id="feedburner_no_cats" name="feedburner_no_cats" type="checkbox" value="1"<?php if ($options['feedburner_no_cats']==1) echo ' checked'; ?> /> |
136 <input id="feedburner_no_cats" name="feedburner_no_cats" type="checkbox" value="1"<?php if ($options['feedburner_no_cats']==1) echo ' checked'; ?> /> |
130 <label for="feedburner_no_cats"><?php _e('Do not redirect category or tag feeds'); ?></label> |
137 <label for="feedburner_no_cats"><?php _e('Do not redirect category or tag feeds', FDFEEDBURNER_TEXTDOMAIN); ?></label> |
131 </p> |
138 </p> |
132 <p> |
139 <p> |
133 <input id="feedburner_append_cats" name="feedburner_append_cats" type="checkbox" value="1"<?php if ($options['feedburner_append_cats']==1) echo ' checked'; ?> /> |
140 <input id="feedburner_append_cats" name="feedburner_append_cats" type="checkbox" value="1"<?php if ($options['feedburner_append_cats']==1) echo ' checked'; ?> /> |
134 <label for="feedburner_append_cats"><?php _e('Append category/tag to URL for category/tag feeds'); ?> (<i>http://url<b>_category</b></i>)</label> |
141 <label for="feedburner_append_cats"><?php _e('Append category/tag to URL for category/tag feeds', FDFEEDBURNER_TEXTDOMAIN); ?> (<i>http://url<b>_category</b></i>)</label> |
135 </p> |
142 </p> |
136 <p> |
143 <p> |
137 <input id="feedburner_no_search" name="feedburner_no_search" type="checkbox" value="1"<?php if ($options['feedburner_no_search']==1) echo ' checked'; ?> /> |
144 <input id="feedburner_no_search" name="feedburner_no_search" type="checkbox" value="1"<?php if ($options['feedburner_no_search']==1) echo ' checked'; ?> /> |
138 <label for="feedburner_no_search"><?php _e('Do not redirect search result feeds'); ?></label> |
145 <label for="feedburner_no_search"><?php _e('Do not redirect search result feeds', FDFEEDBURNER_TEXTDOMAIN); ?></label> |
139 </p> |
146 </p> |
140 |
147 |
141 <p class="submit" style="text-align: left"><input type="submit" name="submit" value="<?php _e('Save »'); ?>" /></p> |
148 <p class="submit" style="text-align: left"><?php wp_nonce_field('fdfeedburner', 'fdfeedburner-admin'); ?><input type="submit" name="submit" value="<?php _e('Save', FDFEEDBURNER_TEXTDOMAIN); ?> »" /></p> |
142 </form> |
149 </form> |
143 </div> |
150 </div> |
144 <?php |
151 <?php |
145 } |
152 } |
146 |
153 |
150 // Do nothing if not a feed |
157 // Do nothing if not a feed |
151 if (!is_feed()) return; |
158 if (!is_feed()) return; |
152 |
159 |
153 // Do nothing if feedburner is the user-agent |
160 // Do nothing if feedburner is the user-agent |
154 if (preg_match('/feedburner/i', $_SERVER['HTTP_USER_AGENT'])) return; |
161 if (preg_match('/feedburner/i', $_SERVER['HTTP_USER_AGENT'])) return; |
|
162 |
|
163 // Avoid redirecting Googlebot to avoid sitemap feeds issues |
|
164 // http://www.google.com/support/feedburner/bin/answer.py?hl=en&answer=97090 |
|
165 if (preg_match('/googlebot/i', $_SERVER['HTTP_USER_AGENT'])) return; |
155 |
166 |
156 // Do nothing if not configured |
167 // Do nothing if not configured |
157 $options = get_option('fd_feedburner'); |
168 $options = get_option('fd_feedburner'); |
158 if (!isset($options['feedburner_url'])) $options['feedburner_url'] = null; |
169 if (!isset($options['feedburner_url'])) $options['feedburner_url'] = null; |
159 if (!isset($options['feedburner_comment_url'])) $options['feedburner_comment_url'] = null; |
170 if (!isset($options['feedburner_comment_url'])) $options['feedburner_comment_url'] = null; |