PluginProbe
FeedWordPress / 2009.0612
FeedWordPress v2009.0612
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | syndication-options.php +159 -168 0.9912009.0612 View file →
@@ -1,7 +1,9 @@
1 1 <?php
2 +require_once(dirname(__FILE__) . '/admin-ui.php');
3 +
2 4 function fwp_syndication_options_page () {
3 - global $wpdb, $wp_db_version;
5 + global $wpdb, $wp_db_version, $fwp_path;
4 6
5 7 if (FeedWordPress::needs_upgrade()) :
6 8 fwp_upgrade_page();
7 9 return;
@@ -6,80 +8,59 @@
6 8 fwp_upgrade_page();
7 9 return;
8 10 endif;
9 11
10 - $caption = 'Save Changes';
11 - if (isset($_POST['action']) and $_POST['action']==$caption):
12 - check_admin_referer();
12 + // If this is a POST, validate source and user credentials
13 + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_options', /*capability=*/ 'manage_options');
13 14
14 - if (!current_user_can('manage_options')):
15 - die (__("Cheatin' uh ?"));
16 - else:
17 - update_option('feedwordpress_cat_id', $_REQUEST['syndication_category']);
18 - update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
19 - update_option('feedwordpress_update_logging', $_REQUEST['update_logging']);
20 - update_option('feedwordpress_unfamiliar_author', $_REQUEST['unfamiliar_author']);
21 - update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']);
22 - update_option('feedwordpress_syndicated_post_status', $_REQUEST['post_status']);
23 - update_option('feedwordpress_automatic_updates', ($_POST['automatic_updates']=='yes'));
24 - update_option('feedwordpress_freshness', ($_POST['freshness_interval']*60));
15 + if (isset($_POST['create_index'])) :
16 + FeedWordPress::create_guid_index();
17 +?>
18 +<div class="updated">
19 +<p><?php _e('Index created on database table.')?></p>
20 +</div>
21 +<?php
22 + endif;
25 23
26 - // Categories
27 - $cats = array();
28 - if (isset($_POST['post_category'])) :
29 - $cats = array();
30 - foreach ($_POST['post_category'] as $cat_id) :
31 - $cats[] = '{#'.$cat_id.'}';
32 - endforeach;
33 - endif;
24 + if (isset($_POST['submit']) or isset($_POST['create_index'])) :
25 + update_option('feedwordpress_cat_id', $_REQUEST['syndication_category']);
26 + update_option('feedwordpress_update_logging', $_REQUEST['update_logging']);
27 + update_option('feedwordpress_debug', $_POST['feedwordpress_debug']);
28 + update_option('feedwordpress_automatic_updates', ($_POST['automatic_updates']=='yes'));
29 + update_option('feedwordpress_update_time_limit', ($_POST['update_time_limit']=='yes')?(int) $_POST['time_limit_seconds']:0);
34 30
35 - if (!empty($cats)) :
36 - update_option('feedwordpress_syndication_cats', implode("\n", $cats));
37 - else :
38 - delete_option('feedwordpress_syndication_cats');
39 - endif;
31 + $freshness_interval = (isset($_POST['freshness_interval']) ? (int) $_POST['freshness_interval'] : 10);
32 + update_option('feedworidpress_freshness', $freshness_interval*60);
40 33
41 - if (isset($_REQUEST['comment_status']) and ($_REQUEST['comment_status'] == 'open')) :
42 - update_option('feedwordpress_syndicated_comment_status', 'open');
43 - else :
44 - update_option('feedwordpress_syndicated_comment_status', 'closed');
45 - endif;
34 + if (isset($_REQUEST['hardcode_name']) and ($_REQUEST['hardcode_name'] == 'no')) :
35 + update_option('feedwordpress_hardcode_name', 'no');
36 + else :
37 + update_option('feedwordpress_hardcode_name', 'yes');
38 + endif;
39 +
40 + if (isset($_REQUEST['hardcode_description']) and ($_REQUEST['hardcode_description'] == 'no')) :
41 + update_option('feedwordpress_hardcode_description', 'no');
42 + else :
43 + update_option('feedwordpress_hardcode_description', 'yes');
44 + endif;
46 45
47 - if (isset($_REQUEST['ping_status']) and ($_REQUEST['ping_status'] == 'open')) :
48 - update_option('feedwordpress_syndicated_ping_status', 'open');
49 - else :
50 - update_option('feedwordpress_syndicated_ping_status', 'closed');
51 - endif;
52 -
53 - if (isset($_REQUEST['hardcode_name']) and ($_REQUEST['hardcode_name'] == 'no')) :
54 - update_option('feedwordpress_hardcode_name', 'no');
55 - else :
56 - update_option('feedwordpress_hardcode_name', 'yes');
57 - endif;
58 -
59 - if (isset($_REQUEST['hardcode_description']) and ($_REQUEST['hardcode_description'] == 'no')) :
60 - update_option('feedwordpress_hardcode_description', 'no');
61 - else :
62 - update_option('feedwordpress_hardcode_description', 'yes');
63 - endif;
64 -
65 - if (isset($_REQUEST['hardcode_url']) and ($_REQUEST['hardcode_url'] == 'no')) :
66 - update_option('feedwordpress_hardcode_url', 'no');
67 - else :
68 - update_option('feedwordpress_hardcode_url', 'yes');
69 - endif;
46 + if (isset($_REQUEST['hardcode_url']) and ($_REQUEST['hardcode_url'] == 'no')) :
47 + update_option('feedwordpress_hardcode_url', 'no');
48 + else :
49 + update_option('feedwordpress_hardcode_url', 'yes');
50 + endif;
70 51 ?>
71 52 <div class="updated">
72 53 <p><?php _e('Options saved.')?></p>
73 54 </div>
74 55 <?php
75 - endif;
76 56 endif;
77 57
78 58 $cat_id = FeedWordPress::link_category_id();
79 - $munge_permalink = get_option('feedwordpress_munge_permalink');
80 59 $update_logging = get_option('feedwordpress_update_logging');
60 + $feedwordpress_debug = (get_option('feedwordpress_debug')=='yes');
81 61
62 + $update_time_limit = (int) get_option('feedwordpress_update_time_limit');
82 63 $automatic_updates = get_option('feedwordpress_automatic_updates');
83 64
84 65 $freshness_interval = get_option('feedwordpress_freshness');
85 66 if (false === $freshness_interval) :
@@ -89,26 +70,14 @@
89 70
90 71 $hardcode_name = get_option('feedwordpress_hardcode_name');
91 72 $hardcode_description = get_option('feedwordpress_hardcode_description');
92 73 $hardcode_url = get_option('feedwordpress_hardcode_url');
93 -
94 - $post_status = get_option("feedwordpress_syndicated_post_status"); // default="publish"
95 - $comment_status = get_option("feedwordpress_syndicated_comment_status"); // default="closed"
96 - $ping_status = get_option("feedwordpress_syndicated_ping_status"); // default="closed"
97 -
98 - $unfamiliar_author = array ('create' => '','default' => '','filter' => '');
99 - $ua = FeedWordPress::on_unfamiliar('author');
100 - if (is_string($ua) and array_key_exists($ua, $unfamiliar_author)) :
101 - $unfamiliar_author[$ua] = ' checked="checked"';
102 - endif;
103 - $unfamiliar_category = array ('create'=>'','default'=>'','filter'=>'');
104 - $uc = FeedWordPress::on_unfamiliar('category');
105 - if (is_string($uc) and array_key_exists($uc, $unfamiliar_category)) :
106 - $unfamiliar_category[$uc] = ' checked="checked"';
107 - endif;
108 74
109 75 if (isset($wp_db_version) and $wp_db_version >= 4772) :
110 - $results = get_categories('type=link');
76 + $results = get_categories(array(
77 + "type" => 'link',
78 + "hide_empty" => false,
79 + ));
111 80
112 81 // Guarantee that the Contributors category will be in the drop-down chooser, even if it is empty.
113 82 $found_link_category_id = false;
114 83 foreach ($results as $row) :
@@ -119,61 +88,101 @@
119 88 else :
120 89 $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
121 90 endif;
122 91
123 - $cats = get_option('feedwordpress_syndication_cats');
124 - $dogs = get_nested_categories(-1, 0);
125 - $cats = array_map('strtolower',
126 - array_map('trim',
127 - preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, $cats)
128 - ));
92 + $cats = array_map('trim',
93 + preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_cats'))
94 + );
95 + $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL);
96 +
97 + $tags = array_map('trim',
98 + preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_tags'))
99 + );
129 100
130 - foreach ($dogs as $tag => $dog) :
131 - $found_by_name = in_array(strtolower(trim($dog['cat_name'])), $cats);
132 - if (isset($dog['cat_ID'])) : $dog['cat_id'] = $dog['cat_ID']; endif;
133 - $found_by_id = in_array('{#'.trim($dog['cat_id']).'}', $cats);
101 + if (fwp_test_wp_version(FWP_SCHEMA_27)) :
102 + $icon = '<div class="icon32"><img src="'.htmlspecialchars(WP_PLUGIN_URL.'/'.$fwp_path.'/feedwordpress.png').'" alt="" /></div>';
103 + else :
104 + $icon = '';
105 + endif;
134 106
135 - if ($found_by_name or $found_by_id) :
136 - $dogs[$tag]['checked'] = true;
137 - endif;
138 - endforeach;
107 + if (fwp_test_wp_version(FWP_SCHEMA_26)) :
108 + $options = __('Settings');
109 + else :
110 + $options = __('Options');
111 + endif;
112 +?>
113 +<script type="text/javascript">
114 + function contextual_appearance (item, appear, disappear, value, checkbox) {
115 + var rollup=document.getElementById(item);
116 + var newuser=document.getElementById(appear);
117 + var sitewide=document.getElementById(disappear);
118 + if (rollup) {
119 + if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) {
120 + if (newuser) newuser.style.display='block';
121 + if (sitewide) sitewide.style.display='none';
122 + } else {
123 + if (newuser) newuser.style.display='none';
124 + if (sitewide) sitewide.style.display='block';
125 + }
126 + }
127 + }
128 +</script>
139 129
140 -?>
141 130 <div class="wrap">
142 -<h2>Syndication Options</h2>
131 +<?php print $icon; ?>
132 +<h2>Syndication <?php print $options; ?></h2>
133 +<div id="poststuff">
143 134 <form action="" method="post">
144 -<fieldset class="options">
145 -<legend>Syndicated Feeds</legend>
135 +<?php
136 + FeedWordPressCompatibility::stamp_nonce('feedwordpress_options');
137 + fwp_linkedit_single_submit();
138 +?>
139 +<div id="post-body">
140 +<?php fwp_option_box_opener('Syndicated Feeds', 'syndicatedfeedsdiv'); ?>
146 141 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
147 142 <tr>
148 143 <th width="33%" scope="row">Syndicated Link category:</th>
149 144 <td width="67%"><?php
150 - echo "\n<select name=\"syndication_category\" size=\"1\">";
151 - foreach ($results as $row) {
152 - if (!isset($row->cat_id)) { $row->cat_id = $row->cat_ID; }
153 -
154 - echo "\n\t<option value=\"$row->cat_id\"";
155 - if ($row->cat_id == $cat_id)
156 - echo " selected='selected'";
157 - echo ">$row->cat_id: ".wp_specialchars($row->cat_name);
158 - if ('Y' == $row->auto_toggle)
159 - echo ' (auto toggle)';
160 - echo "</option>\n";
161 - }
162 - echo "\n</select>\n";
145 + echo "\n<select name=\"syndication_category\" size=\"1\">";
146 + foreach ($results as $row) :
147 + if (!isset($row->cat_id)) : $row->cat_id = $row->cat_ID; endif;
148 +
149 + echo "\n\t<option value=\"$row->cat_id\"";
150 + if ($row->cat_id == $cat_id) :
151 + echo " selected='selected'";
152 + endif;
153 + echo ">$row->cat_id: ".wp_specialchars($row->cat_name);
154 + if ('Y' == $row->auto_toggle) :
155 + echo ' (auto toggle)';
156 + endif;
157 + echo "</option>\n";
158 + endforeach;
159 + echo "\n</select>\n";
163 160 ?></td>
164 161 </tr>
165 162
166 -<tr>
167 -<th width="33%" scope="row">Check for new posts:</th>
168 -<td width="67%"><select name="automatic_updates" size="1" onchange="if (this.value=='yes') { disp = 'inline'; } else { disp = 'none'; }; el=document.getElementById('automatic-update-interval-span'); if (el) el.style.display=disp;">
163 +<tr style="vertical-align: top">
164 +<th width="33%" scope="row">Check for updates:</th>
165 +<td width="67%"><select name="automatic_updates" size="1">
169 166 <option value="yes"<?php echo ($automatic_updates)?' selected="selected"':''; ?>>automatically</option>
170 167 <option value="no"<?php echo (!$automatic_updates)?' selected="selected"':''; ?>>only when I request</option>
171 168 </select>
172 -<span id="automatic-update-interval-span" style="display: <?php echo $automatic_updates?'inline':'none';?>"><label for="automatic-update-interval">every</label> <input id="automatic-update-interval" name="freshness_interval" value="<?php echo $freshness_interval; ?>" size="4" /> minutes.</span>
173 169 </td>
174 170 </tr>
175 171
172 +<tr style="vertical-align: top">
173 +<th width="33%" scope="row"><?php print __('Time limit on updates'); ?>:</th>
174 +<td width="67%"><select id="time-limit" name="update_time_limit" size="1" onchange="contextual_appearance('time-limit', 'time-limit-box', null, 'yes');">
175 +<option value="no"<?php echo ($update_time_limit>0)?'':' selected="selected"'; ?>>no time limit on updates</option>
176 +<option value="yes"<?php echo ($update_time_limit>0)?' selected="selected"':''; ?>>limit updates to no more than...</option>
177 +</select>
178 +<span id="time-limit-box"><label><input type="text" name="time_limit_seconds" value="<?php print $update_time_limit; ?>" size="5" /> seconds</label></span>
179 +</tr>
180 +
181 +<script type="text/javascript">
182 + contextual_appearance('time-limit', 'time-limit-box', null, 'yes');
183 +</script>
184 +
176 185 <tr><th width="33%" scope="row" style="vertical-align:top">Feed information:</th>
177 186 <td width="67%"><ul style="margin:0;padding:0;list-style:none">
178 187 <li><input type="checkbox" name="hardcode_name" value="no"<?php echo (($hardcode_name=='yes')?'':' checked="checked"');?>/> Update the contributor title when the feed title changes</li>
179 188 <li><input type="checkbox" name="hardcode_description" value="no"<?php echo (($hardcode_description=='yes')?'':' checked="checked"');?>/> Update when contributor description if the feed tagline changes</li>
@@ -179,74 +188,56 @@
179 188 <li><input type="checkbox" name="hardcode_description" value="no"<?php echo (($hardcode_description=='yes')?'':' checked="checked"');?>/> Update when contributor description if the feed tagline changes</li>
180 189 <li><input type="checkbox" name="hardcode_url" value="no"<?php echo (($hardcode_url=='yes')?'':' checked="checked"');?>/> Update the contributor homepage when the feed link changes</li>
181 190 </ul></td></tr>
182 191 </table>
183 -<div class="submit"><input type="submit" name="action" value="<?php echo $caption; ?>" /></div>
184 -</fieldset>
192 +<?php fwp_linkedit_periodic_submit(); ?>
193 +<?php fwp_option_box_closer(); ?>
185 194
186 -<fieldset class="options">
187 -<legend>Syndicated Posts</legend>
188 -
189 -<?php fwp_category_box($dogs, '<em>all syndicated posts</em>'); ?>
190 -
191 -<table class="editform" width="75%" cellspacing="2" cellpadding="5">
192 -<tr style="vertical-align: top"><th width="44%" scope="row">Publication:</th>
193 -<td width="56%"><ul style="margin: 0; padding: 0; list-style:none">
194 -<li><label><input type="radio" name="post_status" value="publish"<?php echo (!$post_status or $post_status=='publish')?' checked="checked"':''; ?> /> Publish syndicated posts immediately</label></li>
195 -<li><label><input type="radio" name="post_status" value="draft"<?php echo ($post_status=='draft')?' checked="checked"':''; ?> /> Hold syndicated posts as drafts</label></li>
196 -<li><label><input type="radio" name="post_status" value="private"<?php echo ($post_status=='private')?' checked="checked"':''; ?> /> Hold syndicated posts as private posts</label></li>
197 -</ul></td></tr>
198 -
199 -<tr style="vertical-align: top"><th width="44%" scope="row">Comments:</th>
200 -<td width="56%"><ul style="margin: 0; padding: 0; list-style:none">
201 -<li><label><input type="radio" name="comment_status" value="open"<?php echo ($comment_status=='open')?' checked="checked"':''; ?> /> Allow comments on syndicated posts</label></li>
202 -<li><label><input type="radio" name="comment_status" value="closed"<?php echo ($comment_status!='open')?' checked="checked"':''; ?> /> Don't allow comments on syndicated posts</label></li>
203 -</ul></td></tr>
204 -
205 -<tr style="vertical-align: top"><th width="44%" scope="row">Trackback and Pingback:</th>
206 -<td width="56%"><ul style="margin:0; padding: 0; list-style:none">
207 -<li><label><input type="radio" name="ping_status" value="open"<?php echo ($ping_status=='open')?' checked="checked"':''; ?> /> Accept pings on syndicated posts</label></li>
208 -<li><label><input type="radio" name="ping_status" value="closed"<?php echo ($ping_status!='open')?' checked="checked"':''; ?> /> Don't accept pings on syndicated posts</label></li>
209 -</ul></td></tr>
210 -
211 -<tr style="vertical-align: top"><th width="44%" scope="row" style="vertical-align:top">Unfamiliar authors:</th>
212 -<td width="56%"><ul style="margin: 0; padding: 0; list-style:none">
213 -<li><label><input type="radio" name="unfamiliar_author" value="create"<?php echo $unfamiliar_author['create']; ?>/> create a new author account</label></li>
214 -<li><label><input type="radio" name="unfamiliar_author" value="default"<?php echo $unfamiliar_author['default']; ?> /> attribute the post to the default author</label></li>
215 -<li><label><input type="radio" name="unfamiliar_author" value="filter"<?php echo $unfamiliar_author['filter']; ?> /> don't syndicate the post</label></li>
216 -</ul></td></tr>
217 -
218 -<tr style="vertical-align: top"><th width="44%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
219 -<td width="56%"><ul style="margin: 0; padding:0; list-style:none">
220 -<li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar_category['create']; ?>/> create any categories the post is in</label></li>
221 -<li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar_category['default']; ?>/> don't create new categories</li>
222 -<li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar_category['filter']; ?>/> don't create new categories and don't syndicate posts unless they match at least one familiar category</label></li>
223 -</ul></td></tr>
224 -
225 -<tr style="vertical-align: top"><th width="44%" scope="row">Permalinks point to:</th>
226 -<td width="56%"><select name="munge_permalink" size="1">
227 -<option value="yes"<?php echo ($munge_permalink=='yes')?' selected="selected"':''; ?>>original website</option>
228 -<option value="no"<?php echo ($munge_permalink=='no')?' selected="selected"':''; ?>>this website</option>
229 -</select></td></tr>
230 -</table>
231 -<div class="submit"><input type="submit" name="action" value="<?php echo $caption; ?>" /></div>
232 -</fieldset>
233 -
234 -<fieldset class="options">
235 -<legend>Back-end Options</legend>
195 +<?php
196 + FeedWordPressSettingsUI::instead_of_posts_box();
197 + FeedWordPressSettingsUI::instead_of_authors_box();
198 + FeedWordPressSettingsUI::instead_of_categories_box();
199 +
200 + fwp_option_box_opener('Back End', 'backenddiv', 'postbox');
201 +?>
236 202 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
237 -<th width="33%" scope="row">Write update notices to PHP logs:</th>
203 +<tr style="vertical-align: top">
204 +<th width="33%" scope="row">Update notices:</th>
238 205 <td width="67%"><select name="update_logging" size="1">
239 -<option value="yes"<?php echo (($update_logging=='yes')?' selected="selected"':''); ?>>yes</option>
240 -<option value="no"<?php echo (($update_logging!='yes')?' selected="selected"':''); ?>>no</option>
206 +<option value="yes"<?php echo (($update_logging=='yes')?' selected="selected"':''); ?>>write to PHP logs</option>
207 +<option value="no"<?php echo (($update_logging!='yes')?' selected="selected"':''); ?>>don't write to PHP logs</option>
241 208 </select></td>
242 209 </tr>
210 +<tr style="vertical-align: top">
211 +<th width="33%" scope="row">Debugging mode:</th>
212 +<td width="67%"><select name="feedwordpress_debug" size="1">
213 +<option value="yes"<?php echo ($feedwordpress_debug ? ' selected="selected"' : ''); ?>>on</option>
214 +<option value="no"<?php echo ($feedwordpress_debug ? '' : ' selected="selected"'); ?>>off</option>
215 +</select>
216 +<p>When debugging mode is <strong>ON</strong>, FeedWordPress displays many diagnostic error messages,
217 +warnings, and notices that are ordinarily suppressed, and turns off all caching of feeds. Use with
218 +caution: this setting is absolutely inappropriate for a production server.</p>
219 +</td>
220 +</tr>
221 +
222 +<tr style="vertical-align: top">
223 +<th width="33%" scope="row">Guid index:</th>
224 +<td width="67%"><input class="button" type="submit" name="create_index" value="Create index on guid column in posts database table" />
225 +<p>Creating this index may significantly improve performance on some large
226 +FeedWordPress installations.</p></td>
227 +</tr>
243 228 </table>
244 -<div class="submit"><input type="submit" name="action" value="<?php echo $caption; ?>" /></div>
245 -</fieldset>
229 +<?php
230 + fwp_option_box_closer();
231 + fwp_linkedit_periodic_submit();
232 + fwp_linkedit_single_submit_closer();
233 +?>
234 +</div>
246 235 </form>
247 -</div>
236 +
237 +</div> <!-- id="poststuff" -->
238 +</div> <!-- class="wrap" -->
248 239 <?php
249 240 }
250 241
251 242 fwp_syndication_options_page();
252 -?>
243 +