24 GNU General Public License for more details. |
24 GNU General Public License for more details. |
25 ' |
25 ' |
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'); |
31 define('FDFEEDBURNER_TEXTDOMAIN', 'fdfeedburner'); |
32 |
32 |
33 if (function_exists('load_plugin_textdomain')) { |
33 if (function_exists('load_plugin_textdomain')) { |
34 load_plugin_textdomain(FDFEEDBURNER_TEXTDOMAIN, false, dirname(plugin_basename(__FILE__)).'/languages' ); |
34 load_plugin_textdomain(FDFEEDBURNER_TEXTDOMAIN, false, dirname(plugin_basename(__FILE__)).'/languages' ); |
38 |
38 |
39 function feedburner_config_page() { |
39 function feedburner_config_page() { |
40 global $wpdb; |
40 global $wpdb; |
41 if ( function_exists('add_submenu_page') ) |
41 if ( function_exists('add_submenu_page') ) |
42 add_submenu_page('options-general.php', |
42 add_submenu_page('options-general.php', |
43 __('Feedburner', FDFEEDBURNER_TEXTDOMAIN), |
43 __('Feedburner', FDFEEDBURNER_TEXTDOMAIN), |
44 __('Feedburner', FDFEEDBURNER_TEXTDOMAIN), |
44 __('Feedburner', FDFEEDBURNER_TEXTDOMAIN), |
45 'manage_options', __FILE__, 'feedburner_conf'); |
45 'manage_options', __FILE__, 'feedburner_conf'); |
46 } |
46 } |
47 |
47 |
48 function feedburner_fix_url($url) { |
48 function feedburner_fix_url($url) { |
49 $url = preg_replace('!^(http|https)://!i', '', $url); |
49 $url = preg_replace('!^(http|https)://!i', '', $url); |
50 $url = preg_replace('!^/!i', '', $url); |
50 $url = preg_replace('!^/!i', '', $url); |
58 if (!isset($options['feedburner_url'])) $options['feedburner_url'] = null; |
58 if (!isset($options['feedburner_url'])) $options['feedburner_url'] = null; |
59 if (!isset($options['feedburner_comment_url'])) $options['feedburner_comment_url'] = null; |
59 if (!isset($options['feedburner_comment_url'])) $options['feedburner_comment_url'] = null; |
60 if (!isset($options['feedburner_append_cats'])) $options['feedburner_append_cats'] = 0; |
60 if (!isset($options['feedburner_append_cats'])) $options['feedburner_append_cats'] = 0; |
61 if (!isset($options['feedburner_no_cats'])) $options['feedburner_no_cats'] = 0; |
61 if (!isset($options['feedburner_no_cats'])) $options['feedburner_no_cats'] = 0; |
62 if (!isset($options['feedburner_no_search'])) $options['feedburner_no_search'] = 0; |
62 if (!isset($options['feedburner_no_search'])) $options['feedburner_no_search'] = 0; |
63 |
63 if (!isset($options['feedburner_no_author'])) $options['feedburner_no_author'] = 0; |
|
64 |
64 $updated = false; |
65 $updated = false; |
65 if ( isset($_POST['submit']) ) { |
66 if ( isset($_POST['submit']) ) { |
66 check_admin_referer('fdfeedburner', 'fdfeedburner-admin'); |
67 check_admin_referer('fdfeedburner', 'fdfeedburner-admin'); |
67 |
68 |
68 if (isset($_POST['feedburner_url'])) { |
69 if (isset($_POST['feedburner_url'])) { |
69 $feedburner_url = $_POST['feedburner_url']; |
70 $feedburner_url = $_POST['feedburner_url']; |
70 if ($feedburner_url != null) $feedburner_url = feedburner_fix_url($feedburner_url); |
71 if ($feedburner_url != null) $feedburner_url = feedburner_fix_url($feedburner_url); |
71 } else { |
72 } else { |
72 $feedburner_url = null; |
73 $feedburner_url = null; |
73 } |
74 } |
74 |
75 |
75 if (isset($_POST['feedburner_comment_url'])) { |
76 if (isset($_POST['feedburner_comment_url'])) { |
76 $feedburner_comment_url = $_POST['feedburner_comment_url']; |
77 $feedburner_comment_url = $_POST['feedburner_comment_url']; |
77 if ($feedburner_comment_url != null) $feedburner_comment_url = feedburner_fix_url($feedburner_comment_url); |
78 if ($feedburner_comment_url != null) $feedburner_comment_url = feedburner_fix_url($feedburner_comment_url); |
78 } else { |
79 } else { |
79 $feedburner_comment_url = null; |
80 $feedburner_comment_url = null; |
80 } |
81 } |
81 |
82 |
82 if (isset($_POST['feedburner_append_cats'])) { |
83 if (isset($_POST['feedburner_append_cats'])) { |
83 $feedburner_append_cats = $_POST['feedburner_append_cats']; |
84 $feedburner_append_cats = $_POST['feedburner_append_cats']; |
84 } else { |
85 } else { |
85 $feedburner_append_cats = 0; |
86 $feedburner_append_cats = 0; |
86 } |
87 } |
87 |
88 |
88 if (isset($_POST['feedburner_no_cats'])) { |
89 if (isset($_POST['feedburner_no_cats'])) { |
89 $feedburner_no_cats = $_POST['feedburner_no_cats']; |
90 $feedburner_no_cats = $_POST['feedburner_no_cats']; |
90 } else { |
91 } else { |
91 $feedburner_no_cats = 0; |
92 $feedburner_no_cats = 0; |
92 } |
93 } |
93 |
94 |
94 if (isset($_POST['feedburner_no_search'])) { |
95 if (isset($_POST['feedburner_no_search'])) { |
95 $feedburner_no_search = $_POST['feedburner_no_search']; |
96 $feedburner_no_search = $_POST['feedburner_no_search']; |
96 } else { |
97 } else { |
97 $feedburner_no_search = 0; |
98 $feedburner_no_search = 0; |
98 } |
99 } |
99 |
100 |
|
101 if (isset($_POST['feedburner_no_author'])) { |
|
102 $feedburner_no_author = $_POST['feedburner_no_author']; |
|
103 } else { |
|
104 $feedburner_no_author = 0; |
|
105 } |
|
106 |
100 $options['feedburner_url'] = $feedburner_url; |
107 $options['feedburner_url'] = $feedburner_url; |
101 $options['feedburner_comment_url'] = $feedburner_comment_url; |
108 $options['feedburner_comment_url'] = $feedburner_comment_url; |
102 $options['feedburner_append_cats'] = $feedburner_append_cats; |
109 $options['feedburner_append_cats'] = $feedburner_append_cats; |
103 $options['feedburner_no_cats'] = $feedburner_no_cats; |
110 $options['feedburner_no_cats'] = $feedburner_no_cats; |
104 $options['feedburner_no_search'] = $feedburner_no_search; |
111 $options['feedburner_no_search'] = $feedburner_no_search; |
105 |
112 $options['feedburner_no_author'] = $feedburner_no_author; |
|
113 |
106 update_option('fd_feedburner', $options); |
114 update_option('fd_feedburner', $options); |
107 |
115 |
108 $updated = true; |
116 $updated = true; |
109 } |
117 } |
110 ?> |
118 ?> |
111 |
119 |
112 <div class="wrap"> |
120 <div class="wrap"> |
113 <?php |
121 <?php |
114 if ($updated) { |
122 if ($updated) { |
115 echo "<div id='message' class='updated fade'><p>"; |
123 echo "<div id='message' class='updated fade'><p>"; |
143 <p> |
151 <p> |
144 <input id="feedburner_no_search" name="feedburner_no_search" type="checkbox" value="1"<?php if ($options['feedburner_no_search']==1) echo ' checked'; ?> /> |
152 <input id="feedburner_no_search" name="feedburner_no_search" type="checkbox" value="1"<?php if ($options['feedburner_no_search']==1) echo ' checked'; ?> /> |
145 <label for="feedburner_no_search"><?php _e('Do not redirect search result feeds', FDFEEDBURNER_TEXTDOMAIN); ?></label> |
153 <label for="feedburner_no_search"><?php _e('Do not redirect search result feeds', FDFEEDBURNER_TEXTDOMAIN); ?></label> |
146 </p> |
154 </p> |
147 |
155 |
|
156 <p> |
|
157 <input id="feedburner_no_author" name="feedburner_no_author" type="checkbox" value="1"<?php if ($options['feedburner_no_author']==1) echo ' checked'; ?> /> |
|
158 <label for="feedburner_no_author"><?php _e('Do not redirect author feeds', FDFEEDBURNER_TEXTDOMAIN); ?></label> |
|
159 </p> |
|
160 |
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> |
161 <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> |
149 </form> |
162 </form> |
150 </div> |
163 </div> |
151 <?php |
164 <?php |
152 } |
165 } |
169 if (!isset($options['feedburner_url'])) $options['feedburner_url'] = null; |
182 if (!isset($options['feedburner_url'])) $options['feedburner_url'] = null; |
170 if (!isset($options['feedburner_comment_url'])) $options['feedburner_comment_url'] = null; |
183 if (!isset($options['feedburner_comment_url'])) $options['feedburner_comment_url'] = null; |
171 if (!isset($options['feedburner_append_cats'])) $options['feedburner_append_cats'] = 0; |
184 if (!isset($options['feedburner_append_cats'])) $options['feedburner_append_cats'] = 0; |
172 if (!isset($options['feedburner_no_cats'])) $options['feedburner_no_cats'] = 0; |
185 if (!isset($options['feedburner_no_cats'])) $options['feedburner_no_cats'] = 0; |
173 if (!isset($options['feedburner_no_search'])) $options['feedburner_no_search'] = 0; |
186 if (!isset($options['feedburner_no_search'])) $options['feedburner_no_search'] = 0; |
|
187 if (!isset($options['feedburner_no_author'])) $options['feedburner_no_author'] = 0; |
174 $feed_url = $options['feedburner_url']; |
188 $feed_url = $options['feedburner_url']; |
175 $comment_url = $options['feedburner_comment_url']; |
189 $comment_url = $options['feedburner_comment_url']; |
176 if ($feed_url == null && $comment_url == null) return; |
190 if ($feed_url == null && $comment_url == null) return; |
177 |
191 |
178 // Get category |
192 // Get category |
179 $cat = null; |
193 $cat = null; |
180 if ($wp->query_vars['category_name'] != null) { |
194 if ($wp->query_vars['category_name'] != null) { |
181 $cat = $wp->query_vars['category_name']; |
195 $cat = $wp->query_vars['category_name']; |
182 } |
196 } |
223 case 'atom': |
243 case 'atom': |
224 if (($cat || $tag) && $options['feedburner_no_cats'] == 1) { |
244 if (($cat || $tag) && $options['feedburner_no_cats'] == 1) { |
225 // If this is a category/tag feed and redirect is disabled, do nothing |
245 // If this is a category/tag feed and redirect is disabled, do nothing |
226 } else if ($search && $options['feedburner_no_search'] == 1) { |
246 } else if ($search && $options['feedburner_no_search'] == 1) { |
227 // If this is a search result feed and redirect is disabled, do nothing |
247 // If this is a search result feed and redirect is disabled, do nothing |
|
248 } else if ($author_name && $options['feedburner_no_author'] == 1) { |
|
249 // If this is an author feed and redirect is disabled, do nothing |
228 } else { |
250 } else { |
229 if ($feed_url != null) { |
251 if ($feed_url != null) { |
230 // Redirect the feed |
252 // Redirect the feed |
231 header("Location: ".$feed_url); |
253 header("Location: ".$feed_url); |
232 die; |
254 die; |