FeedWordPress - Version 2022.0222

Version Description

  • ADDITIONAL CODE CLEANUP: This version does some additional code clean-up to remove some obsolete methods of generating output, and to do a better job of sanitizing input and escaping output in the FeedWordPress administrative dashboard.
Download this release

Release Info

Developer radgeek
Plugin Icon wp plugin FeedWordPress
Version 2022.0222
Comparing to
See all releases

Code changes from version 2022.0208 to 2022.0222

admin-ui.php CHANGED
@@ -1,72 +1,158 @@
1
  <?php
2
  /**
3
- * admin-ui.php: This is kind of a junk pile of utility functions mostly created to smooth
4
- * out interactions to make things show up, or behave correctly, within the WordPress admin
5
- * settings interface. Major chunks of this code that deal with making it easy for FWP,
6
- * add-on modules, etc. to create new settings panels have since been hived off into class
7
- * FeedWordPressAdminPage. Many of the functions that remain here were created to handle
8
- * compatibility across multiple, sometimes very old, versions of WordPress, many of which
9
- * are no longer supported anymore. It's likely that some of these functions will be
10
- * re-evaluated, re-organized, deprecated, or clipped out in the next few versions.
 
11
  * -cj 2017-10-27
 
 
12
  */
13
 
14
- $dir = dirname(__FILE__);
15
- require_once("${dir}/feedwordpressadminpage.class.php");
16
- require_once("${dir}/feedwordpresssettingsui.class.php");
17
 
18
- function fwp_form_class_attr( $className ) {
 
 
 
 
 
 
 
 
 
 
19
 
20
- if ( is_string($className) ) :
21
- if (strlen($className) > 0 ) :
22
- $sClassName = sanitize_html_class( $className );
23
- print sprintf( 'class="%s"', esc_attr( $sClassName ) );
24
  endif;
25
  endif;
 
26
  } /* fwp_form_class_attr() */
27
 
28
- function fwp_selected_flag( /* mixed */ $arg = null, $key = null, $flag = "selected" ) {
29
-
30
- $bIsOn = false;
31
-
32
- $theArg = $arg;
33
- if (is_array($arg) and !is_null($key)) :
34
- if (array_key_exists($key, $arg)) :
35
- $theArg = $arg[$key];
 
 
 
 
 
 
 
 
 
 
 
 
36
  else :
37
- $theArg = false;
38
  endif;
39
  endif;
40
-
41
- if (is_string($theArg)) :
42
- $bIsOn = (strlen($theArg) > 0);
43
  else :
44
- $bIsOn = !!($theArg);
45
  endif;
46
-
47
- if ( $bIsOn ) :
48
- print sprintf( '%s="%s"', esc_attr($flag), esc_attr($flag) );
49
  endif;
50
  } /* fwp_selected_flag() */
51
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  function fwp_checked_flag( /* mixed */ $arg = null, $key = null ) {
53
- fwp_selected_flag( $arg, $key, "checked" );
54
  } /* fwp_checked_flag() */
55
 
56
- function fwp_update_set_results_message ($delta, $joiner = ';') {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  $mesg = array();
58
- if (isset($delta['new'])) : $mesg[] = ' '.$delta['new'].' new posts were syndicated'; endif;
59
- if (isset($delta['updated']) and ($delta['updated'] != 0)) : $mesg[] = ' '.$delta['updated'].' existing posts were updated'; endif;
60
- if (isset($delta['stored']) and ($delta['stored'] != 0)) : $mesg[] = ' '.$delta['stored'].' alternate versions of existing posts were stored for reference'; endif;
61
 
62
- if (!is_null($joiner)) :
63
- $mesg = implode($joiner, $mesg);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  endif;
65
  return $mesg;
66
  } /* function fwp_update_set_results_message () */
67
 
68
- function fwp_authors_single_submit ($link = NULL) {
69
- ?>
 
 
 
 
 
70
  <div class="submitbox" id="submitlink">
71
  <div id="previewview">
72
  </div>
@@ -74,239 +160,318 @@ function fwp_authors_single_submit ($link = NULL) {
74
  </div>
75
 
76
  <p class="submit">
77
- <input type="submit" name="save" value="<?php _e('Save') ?>" />
78
  </p>
79
  </div>
80
- <?php
81
  }
82
 
83
- function fwp_tags_box ($tags, $object, $params = array()) {
84
- $params = wp_parse_args($params, array( // Default values
85
- 'taxonomy' => 'post_tag',
86
- 'textarea_name' => NULL,
87
- 'textarea_id' => NULL,
88
- 'input_id' => NULL,
89
- 'input_name' => NULL,
90
- 'id' => NULL,
91
- 'box_title' => __('Post Tags'),
92
- ));
93
-
94
- if (!is_array($tags)) : $tags = array(); endif;
95
-
96
- $tax_name = $params['taxonomy'];
97
-
98
- $oTax = get_taxonomy($params['taxonomy']);
99
- $oTaxLabels = get_taxonomy_labels($oTax);
100
-
101
- $disabled = (!current_user_can($oTax->cap->assign_terms) ? 'disabled="disabled"' : '');
102
-
103
- $desc = "<p style=\"font-size:smaller;font-style:bold;margin:0\">Tag $object as...</p>";
104
-
105
- if (is_null($params['textarea_name'])) :
 
 
 
 
 
 
 
 
106
  $params['textarea_name'] = "tax_input[$tax_name]";
107
  endif;
108
- if (is_null($params['textarea_id'])) :
109
  $params['textarea_id'] = "tax-input-${tax_name}";
110
  endif;
111
- if (is_null($params['input_id'])) :
112
  $params['input_id'] = "new-tag-${tax_name}";
113
  endif;
114
- if (is_null($params['input_name'])) :
115
  $params['input_name'] = "newtag[$tax_name]";
116
  endif;
117
 
118
- if (is_null($params['id'])) :
119
  $params['id'] = $tax_name;
120
  endif;
121
 
122
- print $desc;
123
- $helps = __('Separate tags with commas.');
124
- $box['title'] = __('Tags');
125
  ?>
126
  <div class="tagsdiv" id="<?php echo esc_attr( $params['id'] ); ?>">
127
  <div class="jaxtag">
128
  <div class="nojs-tags hide-if-js">
129
- <p><?php echo esc_html( $oTaxLabels->add_or_remove_items ); ?></p>
130
- <textarea name="<?php echo esc_attr( $params['textarea_name'] ); ?>" class="the-tags" id="<?php echo esc_attr( $params['textarea_id'] ); ?>"><?php echo esc_attr(implode(",", $tags)); ?></textarea></div>
131
 
132
- <?php if ( current_user_can($oTax->cap->assign_terms) ) :?>
133
  <div class="ajaxtag hide-if-no-js">
134
  <label class="screen-reader-text" for="<?php echo esc_attr( $params['input_id'] ); ?>"><?php echo esc_html( $params['box_title'] ); ?></label>
135
- <div class="taghint"><?php echo esc_html( $oTaxLabels->add_new_item ); ?></div>
136
  <p><input type="text" id="<?php print esc_attr( $params['input_id'] ); ?>" name="<?php print esc_attr( $params['input_name'] ); ?>" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
137
- <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" /></p>
138
  </div>
139
- <p class="howto"><?php echo esc_attr( $oTaxLabels->separate_items_with_commas ); ?></p>
140
  <?php endif; ?>
141
  </div>
142
 
143
  <div class="tagchecklist"></div>
144
  </div>
145
- <?php if ( current_user_can($oTax->cap->assign_terms) ) : ?>
146
- <p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo esc_attr( $tax_name ); ?>"><?php echo esc_html( $oTaxLabels->choose_from_most_used ); ?></a></p>
147
- <?php endif;
 
 
 
148
 
149
  }
150
 
151
- function fwp_category_box ($checked, $object, $tags = array(), $params = array()) {
 
 
 
 
 
 
 
 
152
  global $wp_db_version;
153
 
154
- if (is_string($params)) :
155
- $prefix = $params;
156
  $taxonomy = 'category';
157
- elseif (is_array($params)) :
158
- $prefix = (isset($params['prefix']) ? $params['prefix'] : '');
159
- $taxonomy = (isset($params['taxonomy']) ? $params['taxonomy'] : 'category');
 
 
 
 
 
 
 
 
160
  endif;
161
-
162
- $oTax = get_taxonomy($taxonomy);
163
- $oTaxLabels = get_taxonomy_labels($oTax);
164
-
165
- if (strlen($prefix) > 0) :
166
- $idPrefix = $prefix.'-';
167
- $idSuffix = "-".$prefix;
168
- $namePrefix = $prefix . '_';
169
- else :
170
- $idPrefix = 'feedwordpress-';
171
- $idSuffix = "-feedwordpress";
172
- $namePrefix = 'feedwordpress_';
173
  endif;
174
 
175
- $boxDivId = sanitize_html_class( $idPrefix . 'taxonomy-' . $taxonomy );
176
- $tabsUlId = sanitize_html_class( $idPrefix . $taxonomy . '-tabs' );
177
- $allTabId = sanitize_html_class( $idPrefix . $taxonomy . '-all' );
178
- $chkLstId = sanitize_html_class( $idPrefix . $taxonomy . 'checklist' );
179
- $addTaxId = sanitize_html_class( $idPrefix . $taxonomy . '-adder' );
180
- $addTogId = sanitize_html_class( $idPrefix . $taxonomy . '-add-toggle' );
181
- $addCatId = sanitize_html_class( $idPrefix . $taxonomy . '-add' );
182
- $newTaxId = sanitize_html_class( $idPrefix . 'new' . $taxonomy );
183
- $taxIdAddSubmit = sanitize_html_class( $idPrefix . $taxonomy . '-add-sumbit' );
184
- ?>
185
- <div id="<?php print esc_attr( $boxDivId ); ?>" class="feedwordpress-category-div">
186
- <ul id="<?php print esc_attr( $tabsUlId ); ?>" class="category-tabs">
187
- <li class="ui-tabs-selected tabs"><a href="#<?php print esc_attr( $allTabId ); ?>" tabindex="3"><?php _e( 'All posts' ); ?></a>
188
- <p style="font-size:smaller;font-style:bold;margin:0">Give <?php print esc_html( $object ); ?> these <?php print esc_html( $oTaxLabels->name ); ?></p>
189
- </li>
190
- </ul>
191
-
192
- <div id="<?php print esc_attr( $allTabId); ?>" class="tabs-panel">
193
- <input type="hidden" value="0" name="tax_input[<?php print esc_attr( $taxonomy ); ?>][]" />
194
- <ul id="<?php print esc_attr($chkLstId); ?>" class="list:<?php print esc_attr( $taxonomy ); ?> categorychecklist form-no-clear">
195
- <?php fwp_category_checklist(null, false, $checked, $params) ?>
196
- </ul>
 
 
 
 
 
197
  </div>
198
 
199
- <div id="<?php print esc_attr( $addTaxId ); ?>" class="<?php print esc_attr( $taxonomy ); ?>-adder wp-hidden-children">
200
- <h4><a id="<?php print esc_attr( $addTogId ); ?>" class="category-add-toggle" href="#<?php print esc_attr( $addCatId ); ?>" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
201
- <p id="<?php print esc_attr($addCatId); ?>" class="category-add wp-hidden-child">
202
- <?php
203
  $newcat = 'new' . $taxonomy;
204
- ?>
205
- <label class="screen-reader-text" for="<?php print esc_attr($newTaxId); ?>"><?php _e('Add New Category'); ?></label>
206
- <input
207
- id="<?php print esc_attr($newTaxId); ?>"
208
- class="<?php print esc_attr( $newcat ); ?> form-required form-input-tip"
209
- aria-required="true"
210
- tabindex="3"
211
- type="text" name="<?php print esc_attr( $newcat ); ?>"
212
- value="<?php _e( 'New category name' ); ?>"
213
- />
214
- <label class="screen-reader-text" for="<?php print esc_attr( $newTaxId ); ?>-parent"><?php _e('Parent Category:'); ?></label>
215
- <?php wp_dropdown_categories( array(
216
- 'taxonomy' => $taxonomy,
217
- 'hide_empty' => 0,
218
- 'id' => $newTaxId . '-parent',
219
- 'class' => $newcat . '-parent',
220
- 'name' => $newcat . '_parent',
221
- 'orderby' => 'name',
222
- 'hierarchical' => 1,
223
- 'show_option_none' => __('Parent category'),
224
- 'tab_index' => 3,
225
- ) ); ?>
226
- <input type="button" id="<?php print esc_attr( $taxIdAddSubmit ); ?>" class="add:<?php print esc_attr( $idPrefix . $taxonomy ); ?>checklist:<?php print esc_attr( $idPrefix . $taxonomy ); ?>-add add-categorychecklist-category-add button category-add-submit" value="<?php _e( 'Add' ); ?>" tabindex="3" />
 
 
 
 
 
 
227
  <?php /* wp_nonce_field currently doesn't let us set an id different from name, but we need a non-unique name and a unique id */ ?>
228
- <input type="hidden" id="_ajax_nonce<?php print esc_html($idSuffix); ?>" name="_ajax_nonce" value="<?php print wp_create_nonce('add-'.$taxonomy); ?>" />
229
- <input type="hidden" id="_ajax_nonce-add-<?php print esc_attr( $taxonomy . $idSuffix ); ?>" name="_ajax_nonce-add-<?php print esc_attr( $taxonomy ); ?>" value="<?php print wp_create_nonce('add-'.$taxonomy); ?>" />
230
- <span id="<?php print esc_attr( $idPrefix . $taxonomy ); ?>-ajax-response" class="<?php print esc_attr( $taxonomy ); ?>-ajax-response"></span>
231
- </p>
232
  </div>
233
 
234
  </div>
235
- <?php
236
  }
237
 
238
- function update_feeds_mention ($feed) {
239
- echo "<li>Updating <cite>".$feed['link/name']."</cite> from &lt;<a href=\""
240
- .$feed['link/uri']."\">".$feed['link/uri']."</a>&gt; ...";
 
 
 
 
 
 
 
 
 
241
  flush();
242
  }
243
- function update_feeds_finish ($feed, $added, $dt) {
244
- if (is_wp_error($added)) :
 
 
 
 
 
 
 
 
245
  $mesgs = $added->get_error_messages();
246
- foreach ($mesgs as $mesg) :
247
- echo "<br/><strong>Feed error:</strong> <code>$mesg</code>";
248
  endforeach;
249
  echo "</li>\n";
250
  else :
251
- echo " completed in $dt second".(($dt==1)?'':'s')."</li>\n";
252
  endif;
253
  flush();
254
  }
255
 
256
- function fwp_author_list () {
 
 
 
 
 
257
  global $wpdb;
258
  $ret = array();
259
 
260
  $users = get_users();
261
- if (is_array($users)) :
262
- foreach ($users as $user) :
263
- $id = (int) $user->ID;
264
- $ret[$id] = $user->display_name;
265
- if (strlen(trim($ret[$id])) == 0) :
266
- $ret[$id] = $user->user_login;
 
267
  endif;
268
  endforeach;
269
  endif;
270
  return $ret;
271
  }
272
 
273
- function fwp_insert_new_user ($newuser_name) {
 
 
 
 
 
 
274
  global $wpdb;
275
 
276
  $ret = null;
277
- if (strlen($newuser_name) > 0) :
278
- $userdata = array();
279
- $userdata['ID'] = NULL;
280
- $userdata['user_login'] = apply_filters('pre_user_login', sanitize_user($newuser_name));
281
- $userdata['user_nicename'] = apply_filters('pre_user_nicename', sanitize_title($newuser_name));
282
- $userdata['display_name'] = $newuser_name;
283
- $userdata['user_pass'] = substr(md5(uniqid(microtime())), 0, 6); // just something random to lock it up
284
-
285
- $blahUrl = get_bloginfo('url'); $url = parse_url($blahUrl);
286
- $userdata['user_email'] = substr(md5(uniqid(microtime())), 0, 6).'@'.$url['host'];
287
-
288
- $newuser_id = wp_insert_user($userdata);
289
- $ret = $newuser_id; // Either a numeric ID or a WP_Error object
 
 
 
 
290
  else :
291
- // TODO: Add some error reporting
 
 
292
  endif;
293
  return $ret;
294
- } /* fwp_insert_new_user () */
295
 
296
- function fwp_syndication_manage_page_links_table_rows ($links, $page, $visible = 'Y') {
 
 
 
 
 
 
 
297
 
298
- $fwp_syndicated_sources_columns = array(__('Name'), __('Feed'), __('Updated'));
299
-
300
- $subscribed = ('Y' == strtoupper($visible));
301
- if ($subscribed or (count($links) > 0)) :
302
- ?>
303
- <table class="widefat<?php if (!$subscribed) : ?> unsubscribed<?php endif; ?>">
 
 
 
 
 
304
  <thead>
305
  <tr>
306
  <th class="check-column" scope="col"><input type="checkbox" /></th>
307
- <?php
308
- foreach ($fwp_syndicated_sources_columns as $col) :
309
- print "\t<th scope='col'>${col}</th>\n";
310
  endforeach;
311
  print "</tr>\n";
312
  print "</thead>\n";
@@ -314,154 +479,268 @@ function fwp_syndication_manage_page_links_table_rows ($links, $page, $visible =
314
  print "<tbody>\n";
315
 
316
  $alt_row = true;
317
- if (count($links) > 0):
318
- foreach ($links as $link):
319
- $trClass = array();
320
-
321
- // Prep: Get last updated timestamp
322
- $sLink = new SyndicatedLink($link->link_id);
323
- if (!is_null($sLink->setting('update/last'))) :
324
- $lastUpdated = 'Last checked '. fwp_time_elapsed($sLink->setting('update/last'));
325
- else :
326
- $lastUpdated = __('None yet');
327
- endif;
328
 
329
- // Prep: get last error timestamp, if any
330
- $fileSizeLines = array();
331
- $feed_type = $sLink->get_feed_type();
332
- if (is_null($sLink->setting('update/error'))) :
333
- $errorsSince = '';
334
- if (!is_null($sLink->setting('link/item count'))) :
335
- $N = $sLink->setting('link/item count');
336
- $fileSizeLines[] = sprintf((($N==1) ? __('%d item') : __('%d items')), $N) . ", " . $feed_type;
337
- endif;
338
-
339
- if (!is_null($sLink->setting('link/filesize'))) :
340
- $fileSizeLines[] = size_format($sLink->setting('link/filesize')). ' total';
341
- endif;
342
- else :
343
- $trClass[] = 'feed-error';
344
-
345
- $theError = unserialize($sLink->setting('update/error'));
346
-
347
- $errorsSince = "<div class=\"returning-errors\">"
348
- ."<p><strong>Returning errors</strong> since "
349
- .fwp_time_elapsed($theError['since'])
350
- ."</p>"
351
- ."<p>Most recent ("
352
- .fwp_time_elapsed($theError['ts'])
353
- ."):<br/><code>"
354
- .implode("</code><br/><code>", $theError['object']->get_error_messages())
355
- ."</code></p>"
356
- ."</div>\n";
357
- endif;
358
 
359
- $nextUpdate = "<div style='max-width: 30.0em; font-size: 0.9em;'><div style='font-style:italic;'>";
360
-
361
- $ttl = $sLink->setting('update/ttl');
362
- if (is_numeric($ttl)) :
363
- $next = $sLink->setting('update/last') + $sLink->setting('update/fudge') + ((int) $ttl * 60);
364
- if ('automatically'==$sLink->setting('update/timed')) :
365
- if ($next < time()) :
366
- $nextUpdate .= 'Ready and waiting to be updated since ';
367
- else :
368
- $nextUpdate .= 'Scheduled for next update ';
369
- endif;
370
- $nextUpdate .= fwp_time_elapsed($next);
371
- if (FEEDWORDPRESS_DEBUG) : $nextUpdate .= " [".(($next-time())/60)." minutes]"; endif;
372
- else :
373
- $lastUpdated .= " &middot; Next ";
374
- if ($next < time()) :
375
- $lastUpdated .= 'ASAP';
376
- elseif ($next - time() < 60) :
377
- $lastUpdated .= fwp_time_elapsed($next);
378
- elseif ($next - time() < 60*60*24) :
379
- $lastUpdated .= gmdate('g:ia', $next + (get_option('gmt_offset') * 3600));
380
- else :
381
- $lastUpdated .= gmdate('F j', $next + (get_option('gmt_offset') * 3600));
382
- endif;
383
-
384
- $nextUpdate .= "Scheduled to be checked for updates every ".$ttl." minute".(($ttl!=1)?"s":"")."</div><div style='size:0.9em; margin-top: 0.5em'> This update schedule was requested by the feed provider";
385
- if ($sLink->setting('update/xml')) :
386
- $nextUpdate .= " using a standard <code style=\"font-size: inherit; padding: 0; background: transparent\">&lt;".$sLink->setting('update/xml')."&gt;</code> element";
387
- endif;
388
- $nextUpdate .= ".";
389
- endif;
390
- else:
391
- $nextUpdate .= "Scheduled for update as soon as possible";
392
- endif;
393
- $nextUpdate .= "</div></div>";
394
 
395
- $fileSize = '';
396
- if (count($fileSizeLines) > 0) :
397
- $fileSize = '<div>'.implode(" / ", $fileSizeLines)."</div>";
398
  endif;
399
 
400
- unset($sLink);
401
 
402
- $alt_row = !$alt_row;
403
 
404
- if ($alt_row) :
405
- $trClass[] = 'alternate';
406
  endif;
407
  ?>
408
- <tr<?php echo ((count($trClass) > 0) ? ' class="'.implode(" ", $trClass).'"':''); ?>>
409
  <th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo esc_attr( $link->link_id ); ?>" /></th>
410
  <?php
411
  $caption = (
412
- (strlen($link->link_rss) > 0)
413
- ? __('Switch Feed')
414
- : $caption=__('Find Feed')
415
  );
416
  ?>
417
  <td>
418
- <strong><a href="<?php print esc_url( $page->admin_page_href('feeds-page.php', array(), $link) ); ?>"><?php print esc_html($link->link_name); ?></a></strong>
419
- <div class="row-actions"><?php if ($subscribed) :
420
- $page->display_feed_settings_page_links(array(
421
- 'before' => '<div><strong>Settings &gt;</strong> ',
422
- 'after' => '</div>',
423
- 'subscription' => $link,
424
- ));
425
- endif; ?>
 
 
 
 
 
426
 
427
  <div><strong>Actions &gt;</strong>
428
- <?php if ($subscribed) : ?>
429
- <a href="<?php print esc_url( $page->admin_page_href('syndication.php', array('action' => 'feedfinder'), $link) ); ?>"><?php echo esc_html( $caption ); ?></a>
430
- <?php else : ?>
431
- <a href="<?php print esc_url( $page->admin_page_href('syndication.php', array('action' => FWP_RESUB_CHECKED), $link) ); ?>"><?php _e('Re-subscribe'); ?></a>
432
- <?php endif; ?>
433
- | <a href="<?php print esc_url( $page->admin_page_href( 'syndication.php', array('action' => 'Unsubscribe'), $link ) ); ?>"><?php _e( ( $subscribed ? 'Unsubscribe' : 'Delete permanently' ) ); ?></a>
434
- | <a href="<?php print esc_url( $link->link_url ); ?>"><?php _e('View')?></a></div>
 
 
 
 
 
 
 
 
435
  </div>
436
  </td>
437
- <?php if (strlen($link->link_rss) > 0): ?>
438
- <td><div><a href="<?php echo esc_html($link->link_rss); ?>"><?php echo esc_html(feedwordpress_display_url($link->link_rss, 32)); ?></a></div></td>
439
- <?php else: ?>
440
  <td class="feed-missing"><p><strong>no feed assigned</strong></p></td>
441
  <?php endif; ?>
442
 
443
  <td><div style="float: right; padding-left: 10px">
444
- <input type="submit" class="button" name="update_uri[<?php print esc_html($link->link_rss); ?>]" value="<?php _e('Update Now'); ?>" />
445
  </div>
446
- <?php
447
- print $lastUpdated;
448
- print $fileSize;
449
- print $errorsSince;
450
- print $nextUpdate;
451
- ?>
452
  </td>
453
  </tr>
454
- <?php
 
 
455
  endforeach;
456
  else :
457
- ?>
458
  <tr><td colspan="4"><p>There are no websites currently listed for syndication.</p></td></tr>
459
- <?php
 
460
  endif;
461
- ?>
 
 
462
  </tbody>
463
  </table>
464
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
465
  endif;
466
- } /* function fwp_syndication_manage_page_links_table_rows () */
467
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
+ * Admin UI Compatibility (admin-ui.php): This is kind of a junk pile of utility functions
4
+ * mostly created to smooth out interactions to make things show up, or behave correctly,
5
+ * within the WordPress admin settings interface. Major chunks of this code that deal with
6
+ * making it easy for FWP, add-on modules, etc. to create new settings panels have since
7
+ * been hived off into class FeedWordPressAdminPage. Many of the functions that remain here
8
+ * were created to handle compatibility across multiple, sometimes very old, versions of
9
+ * WordPress, many of which are no longer supported anymore. It's likely that some of these
10
+ * functions will be re-evaluated, re-organized, deprecated, or clipped out in the next few
11
+ * versions.
12
  * -cj 2017-10-27
13
+ *
14
+ * @package FeedWordPress
15
  */
16
 
17
+ $dir = dirname( __FILE__ );
18
+ require_once "${dir}/feedwordpressadminpage.class.php";
19
+ require_once "${dir}/feedwordpresssettingsui.class.php";
20
 
21
+ /**
22
+ * Prints the class="..." attribute (if any) for an HTML form element
23
+ *
24
+ * If there is at least one class to add to the element, escape it for attribute contet and print;
25
+ * if not, omit the attribute entirely.
26
+ *
27
+ * @param string $class_name The name(s) of the HTML class or classes to apply.
28
+ * @param string $before Separator prefix string to print just before class="..." attribute, when printed (usually whitespace).
29
+ * @param string $after Separator suffix string to print just after class="..." attribute, when printed (usually blank).
30
+ */
31
+ function fwp_form_class_attr( $class_name, $before = ' ', $after = '' ) {
32
 
33
+ if ( is_string( $class_name ) ) :
34
+ if ( strlen( $class_name ) > 0 ) :
35
+ $s_class_name = sanitize_html_class( $class_name );
36
+ printf( '%sclass="%s"%s', esc_html( $before ), esc_attr( $s_class_name ), esc_html( $after ) );
37
  endif;
38
  endif;
39
+
40
  } /* fwp_form_class_attr() */
41
 
42
+ /**
43
+ * Prints a flag attribute for selected UI elements (selected="selected" or checked="checked", etc.) when appropriate
44
+ *
45
+ * In HTML form output templates, this allows conditional output of the selected="selected"
46
+ * (or checked="checked", etc.) attribute on input or option controls when appropriate, and
47
+ * omits the element when not appropriate, as measured by a flag that is monitored and updated
48
+ * by the caller.
49
+ *
50
+ * @param mixed $arg Flag monitoring variable.
51
+ * @param mixed $key When $arg is an array, $key provides the index within the array to check for the flag.
52
+ * @param string $flag The name of the flag attribute to output when appropriate; default, "selected".
53
+ */
54
+ function fwp_selected_flag( /* mixed */ $arg = null, $key = null, $flag = 'selected' ) {
55
+
56
+ $is_on = false;
57
+
58
+ $s_arg = $arg;
59
+ if ( is_array( $arg ) && ! is_null( $key ) ) :
60
+ if ( array_key_exists( $key, $arg ) ) :
61
+ $s_arg = $arg[ $key ];
62
  else :
63
+ $s_arg = false;
64
  endif;
65
  endif;
66
+
67
+ if ( is_string( $s_arg ) ) :
68
+ $is_on = ( strlen( $s_arg ) > 0 );
69
  else :
70
+ $is_on = (bool) ( $s_arg );
71
  endif;
72
+
73
+ if ( $is_on ) :
74
+ print sprintf( '%s="%s"', esc_attr( $flag ), esc_attr( $flag ) );
75
  endif;
76
  } /* fwp_selected_flag() */
77
 
78
+ /**
79
+ * Outputs a flag attribute for checked UI elements (checked="checked") when appropriate
80
+ *
81
+ * In HTML form output templates, this allows conditional output of the check="checked"
82
+ * attribute on input controls (e.g. checkbox, radio) when appropriate, and omits when
83
+ * inappropriate (unchecked), as determined by a flag monitored and updated by caller.
84
+ *
85
+ * @param mixed $arg Flag monitoring variable.
86
+ * @param mixed $key When $arg is an array, $key provides index within the array to check for flag value.
87
+ *
88
+ * @uses fwp_selected_flag()
89
+ */
90
  function fwp_checked_flag( /* mixed */ $arg = null, $key = null ) {
91
+ fwp_selected_flag( $arg, $key, 'checked' );
92
  } /* fwp_checked_flag() */
93
 
94
+ /**
95
+ * Retrieves a plural or singular form of a string based on the supplied number.
96
+ *
97
+ * Used when you want to use the appropriate form of a string based on whether
98
+ * a number is singular or plural. Very similar to WordPress l10n.php _n(),
99
+ * but designed for a nice short form in the
100
+ * default case (provide "s" when plural, "" otherwise).
101
+ *
102
+ * @param int $n The counter to determine singular or plural form.
103
+ * @param string $plural The text to use if the counter is plural.
104
+ * @param string $singular The text to use if the counter is singular.
105
+ *
106
+ * @return string The text of the singular or plural form.
107
+ */
108
+ function _s( $n = 0, $plural = 's', $singular = '' ) {
109
+ $is_singular = ( is_numeric( $n ) && intval( $n ) === 1 );
110
+ return ( $is_singular ? $singular : $plural );
111
+ }
112
+
113
+ /**
114
+ * Outputs a status message for the aggregate results of polling a set of feeds.
115
+ *
116
+ * This will always output the number of new syndicated posts added, even if this is 0.
117
+ * Posts updated and alternate versions stored will be added to the message iff > 0.
118
+ *
119
+ * @param array $delta Counters indicating results in "new", "updated" and "stored".
120
+ * @param string $joiner Default ';'. Delimiter used to separate messages about new, updated and stored posts.
121
+ */
122
+ function fwp_update_set_results_message( $delta, $joiner = ';' ) {
123
+
124
  $mesg = array();
 
 
 
125
 
126
+ $delta = wp_parse_args(
127
+ $delta,
128
+ array(
129
+ 'new' => 0,
130
+ 'updated' => 0,
131
+ 'stored' => 0,
132
+ )
133
+ );
134
+
135
+ $mesg[] = sprintf( ' %d new post%s syndicated', intval( $delta['new'] ), _s( $delta['new'], 's were', ' was' ) );
136
+ if ( $delta['updated'] > 0 ) :
137
+ $mesg[] = sprintf( ' %d existing post%s updated', intval( $delta['updated'] ), _s( $delta['updated'], 's were', ' was' ) );
138
+ endif;
139
+ if ( $delta['stored'] > 0 ) :
140
+ $mesg[] = sprintf( ' %d alternate version%s of existing post%s stored for reference', intval( $delta['stored'] ), _s( $delta['stored'] ), _s( $delta['stored'], 's were', ' was' ) );
141
+ endif;
142
+
143
+ if ( ! is_null( $joiner ) ) :
144
+ $mesg = implode( $joiner, $mesg );
145
  endif;
146
  return $mesg;
147
  } /* function fwp_update_set_results_message () */
148
 
149
+ /**
150
+ * Outputs the HTML template for a "Submit" button on FWP admin pages.
151
+ *
152
+ * @param mixed $link The syndicated link, if any, that we are viewing settings for.
153
+ */
154
+ function fwp_authors_single_submit( $link = null ) {
155
+ ?>
156
  <div class="submitbox" id="submitlink">
157
  <div id="previewview">
158
  </div>
160
  </div>
161
 
162
  <p class="submit">
163
+ <input type="submit" name="save" value="<?php esc_html_e( 'Save' ); ?>" />
164
  </p>
165
  </div>
166
+ <?php
167
  }
168
 
169
+ /**
170
+ * Outputs the HTML template for a Tags (or similar taxonomy) add / remove box in FeedWordPress admin UI pages.
171
+ *
172
+ * @param array $tags An array of tags already applied to the object.
173
+ * @param string $object The human-readable description of the objects to be tagged ("post", "posts from this feed", etc.).
174
+ * @param array $params An array of optional parameters.
175
+ */
176
+ function fwp_tags_box( $tags, $object, $params = array() ) {
177
+ $params = wp_parse_args(
178
+ $params,
179
+ array( // Default values.
180
+ 'taxonomy' => 'post_tag',
181
+ 'textarea_name' => null,
182
+ 'textarea_id' => null,
183
+ 'input_id' => null,
184
+ 'input_name' => null,
185
+ 'id' => null,
186
+ 'box_title' => __( 'Post Tags' ),
187
+ )
188
+ );
189
+
190
+ if ( ! is_array( $tags ) ) :
191
+ $tags = array();
192
+ endif;
193
+
194
+ $tax_name = $params['taxonomy'];
195
+ $o_tax = get_taxonomy( $params['taxonomy'] );
196
+ $o_tax_labels = get_taxonomy_labels( $o_tax );
197
+ $is_enabled = current_user_can( $o_tax->cap->assign_terms );
198
+
199
+ if ( is_null( $params['textarea_name'] ) ) :
200
  $params['textarea_name'] = "tax_input[$tax_name]";
201
  endif;
202
+ if ( is_null( $params['textarea_id'] ) ) :
203
  $params['textarea_id'] = "tax-input-${tax_name}";
204
  endif;
205
+ if ( is_null( $params['input_id'] ) ) :
206
  $params['input_id'] = "new-tag-${tax_name}";
207
  endif;
208
+ if ( is_null( $params['input_name'] ) ) :
209
  $params['input_name'] = "newtag[$tax_name]";
210
  endif;
211
 
212
+ if ( is_null( $params['id'] ) ) :
213
  $params['id'] = $tax_name;
214
  endif;
215
 
216
+ printf( /* $desc = */ '<p style="font-size:smaller;font-style:bold;margin:0\">Tag %s as...</p>', esc_html( $object ) );
217
+ $helps = __( 'Separate tags with commas.' );
218
+ $box['title'] = __( 'Tags' );
219
  ?>
220
  <div class="tagsdiv" id="<?php echo esc_attr( $params['id'] ); ?>">
221
  <div class="jaxtag">
222
  <div class="nojs-tags hide-if-js">
223
+ <p><?php echo esc_html( $o_tax_labels->add_or_remove_items ); ?></p>
224
+ <textarea name="<?php echo esc_attr( $params['textarea_name'] ); ?>" class="the-tags" id="<?php echo esc_attr( $params['textarea_id'] ); ?>"><?php echo esc_attr( implode( ',', $tags ) ); ?></textarea></div>
225
 
226
+ <?php if ( $is_enabled ) : ?>
227
  <div class="ajaxtag hide-if-no-js">
228
  <label class="screen-reader-text" for="<?php echo esc_attr( $params['input_id'] ); ?>"><?php echo esc_html( $params['box_title'] ); ?></label>
229
+ <div class="taghint"><?php echo esc_html( $o_tax_labels->add_new_item ); ?></div>
230
  <p><input type="text" id="<?php print esc_attr( $params['input_id'] ); ?>" name="<?php print esc_attr( $params['input_name'] ); ?>" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
231
+ <input type="button" class="button tagadd" value="<?php esc_attr_e( 'Add' ); ?>" tabindex="3" /></p>
232
  </div>
233
+ <p class="howto"><?php echo esc_attr( $o_tax_labels->separate_items_with_commas ); ?></p>
234
  <?php endif; ?>
235
  </div>
236
 
237
  <div class="tagchecklist"></div>
238
  </div>
239
+ <?php
240
+ if ( $is_enabled ) :
241
+ ?>
242
+ <p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo esc_attr( $tax_name ); ?>"><?php echo esc_html( $o_tax_labels->choose_from_most_used ); ?></a></p>
243
+ <?php
244
+ endif;
245
 
246
  }
247
 
248
+ /**
249
+ * Outputs the HTML template for a Category (or similar taxonomy) add / remove box in FeedWordPress admin UI pages.
250
+ *
251
+ * @param array $checked An array of cats already applied to the object.
252
+ * @param string $object The human-readable description of the objects to be tagged ("post", "posts from this feed", etc.).
253
+ * @param array $tags Not used.
254
+ * @param array $params An array of optional parameters.
255
+ */
256
+ function fwp_category_box( $checked, $object, $tags = array(), $params = array() ) {
257
  global $wp_db_version;
258
 
259
+ if ( is_string( $params ) ) :
260
+ $prefix = $params;
261
  $taxonomy = 'category';
262
+ elseif ( is_array( $params ) ) :
263
+ $params = wp_parse_args(
264
+ $params,
265
+ array(
266
+ 'prefix' => '',
267
+ 'taxonomy' => 'category',
268
+ )
269
+ );
270
+
271
+ $prefix = $params['prefix'];
272
+ $taxonomy = $params['taxonomy'];
273
  endif;
274
+
275
+ $o_tax = get_taxonomy( $taxonomy );
276
+ $o_tax_labels = get_taxonomy_labels( $o_tax );
277
+
278
+ if ( strlen( $prefix ) === 0 ) :
279
+ $prefix = 'feedwordpress';
 
 
 
 
 
 
280
  endif;
281
 
282
+ $id_prefix = $prefix . '-';
283
+ $id_suffix = '-' . $prefix;
284
+ $name_prefix = $prefix . '_';
285
+
286
+ $box_div_id = sanitize_html_class( $id_prefix . 'taxonomy-' . $taxonomy );
287
+ $tabs_ul_id = sanitize_html_class( $id_prefix . $taxonomy . '-tabs' );
288
+ $all_tab_id = sanitize_html_class( $id_prefix . $taxonomy . '-all' );
289
+ $chk_lst_id = sanitize_html_class( $id_prefix . $taxonomy . 'checklist' );
290
+ $add_tax_id = sanitize_html_class( $id_prefix . $taxonomy . '-adder' );
291
+ $add_tog_id = sanitize_html_class( $id_prefix . $taxonomy . '-add-toggle' );
292
+ $add_cat_id = sanitize_html_class( $id_prefix . $taxonomy . '-add' );
293
+ $new_tax_id = sanitize_html_class( $id_prefix . 'new' . $taxonomy );
294
+
295
+ $tax_id_add_submit = sanitize_html_class( $id_prefix . $taxonomy . '-add-sumbit' );
296
+ ?>
297
+ <div id="<?php print esc_attr( $box_div_id ); ?>" class="feedwordpress-category-div">
298
+ <ul id="<?php print esc_attr( $tabs_ul_id ); ?>" class="category-tabs">
299
+ <li class="ui-tabs-selected tabs"><a href="#<?php print esc_attr( $all_tab_id ); ?>" tabindex="3"><?php esc_html_e( 'All posts' ); ?></a>
300
+ <p style="font-size:smaller;font-style:bold;margin:0">Give <?php print esc_html( $object ); ?> these <?php print esc_html( $o_tax_labels->name ); ?></p>
301
+ </li>
302
+ </ul>
303
+
304
+ <div id="<?php print esc_attr( $all_tab_id ); ?>" class="tabs-panel">
305
+ <input type="hidden" value="0" name="tax_input[<?php print esc_attr( $taxonomy ); ?>][]" />
306
+ <ul id="<?php print esc_attr( $chk_lst_id ); ?>" class="list:<?php print esc_attr( $taxonomy ); ?> categorychecklist form-no-clear">
307
+ <?php fwp_category_checklist( null, false, $checked, $params ); ?>
308
+ </ul>
309
  </div>
310
 
311
+ <div id="<?php print esc_attr( $add_tax_id ); ?>" class="<?php print esc_attr( $taxonomy ); ?>-adder wp-hidden-children">
312
+ <h4><a id="<?php print esc_attr( $add_tog_id ); ?>" class="category-add-toggle" href="#<?php print esc_attr( $add_cat_id ); ?>" class="hide-if-no-js" tabindex="3"><?php esc_html_e( '+ Add New Category' ); ?></a></h4>.
313
+ <p id="<?php print esc_attr( $add_cat_id ); ?>" class="category-add wp-hidden-child">
314
+ <?php
315
  $newcat = 'new' . $taxonomy;
316
+ ?>
317
+ <label class="screen-reader-text" for="<?php print esc_attr( $new_tax_id ); ?>"><?php esc_html_e( 'Add New Category' ); ?></label>
318
+ <input
319
+ id="<?php print esc_attr( $new_tax_id ); ?>"
320
+ class="<?php print esc_attr( $newcat ); ?> form-required form-input-tip"
321
+ aria-required="true"
322
+ tabindex="3"
323
+ type="text" name="<?php print esc_attr( $newcat ); ?>"
324
+ value="<?php esc_attr_e( 'New category name' ); ?>"
325
+ />
326
+ <label class="screen-reader-text" for="<?php print esc_attr( $new_tax_id ); ?>-parent"><?php esc_html_e( 'Parent Category:' ); ?></label>
327
+ <?php
328
+ wp_dropdown_categories(
329
+ array(
330
+ 'taxonomy' => $taxonomy,
331
+ 'hide_empty' => 0,
332
+ 'id' => $new_tax_id . '-parent',
333
+ 'class' => $newcat . '-parent',
334
+ 'name' => $newcat . '_parent',
335
+ 'orderby' => 'name',
336
+ 'hierarchical' => 1,
337
+ 'show_option_none' => __( 'Parent category' ),
338
+ 'tab_index' => 3,
339
+ )
340
+ );
341
+
342
+ $nonce_code = ( 'add-' . $taxonomy );
343
+ ?>
344
+ <input type="button" id="<?php print esc_attr( $tax_id_add_submit ); ?>" class="add:<?php print esc_attr( $id_prefix . $taxonomy ); ?>checklist:<?php print esc_attr( $id_prefix . $taxonomy ); ?>-add add-categorychecklist-category-add button category-add-submit" value="<?php esc_attr_e( 'Add' ); ?>" tabindex="3" />
345
  <?php /* wp_nonce_field currently doesn't let us set an id different from name, but we need a non-unique name and a unique id */ ?>
346
+ <input type="hidden" id="_ajax_nonce<?php print esc_html( $id_suffix ); ?>" name="_ajax_nonce" value="<?php print esc_attr( wp_create_nonce( $nonce_code ) ); ?>" />
347
+ <input type="hidden" id="_ajax_nonce-add-<?php print esc_attr( $taxonomy . $id_suffix ); ?>" name="_ajax_nonce-add-<?php print esc_attr( $taxonomy ); ?>" value="<?php print esc_attr( wp_create_nonce( $nonce_code ) ); ?>" />
348
+ <span id="<?php print esc_attr( $id_prefix . $taxonomy ); ?>-ajax-response" class="<?php print esc_attr( $taxonomy ); ?>-ajax-response"></span>
349
+ </p>
350
  </div>
351
 
352
  </div>
353
+ <?php
354
  }
355
 
356
+ /**
357
+ * Outputs a text/html status message indicating that FWP has started polling a feed.
358
+ *
359
+ * @param array $feed An associative array containing meta-data about the feed being polled.
360
+ */
361
+ function update_feeds_mention( $feed ) {
362
+ printf(
363
+ '<li>Updating <cite>%s</cite> from &lt;<a href="%s">%s</a>&gt; ...',
364
+ esc_html( $feed['link/name'] ),
365
+ esc_url( $feed['link/uri'] ),
366
+ esc_html( $feed['link/uri'] )
367
+ );
368
  flush();
369
  }
370
+
371
+ /**
372
+ * Outputs a text/html status message indicating that FWP has completed polling a feed.
373
+ *
374
+ * @param array $feed An associative array containing meta-data about the feed being polled.
375
+ * @param mixed $added a WP_Error object with error codes and messages, if there was an error in polling.
376
+ * @param int $dt seconds it took to complete the poll.
377
+ */
378
+ function update_feeds_finish( $feed, $added, $dt ) {
379
+ if ( is_wp_error( $added ) ) :
380
  $mesgs = $added->get_error_messages();
381
+ foreach ( $mesgs as $mesg ) :
382
+ printf( '<br/><strong>Feed error:</strong> <code>%s</code>', esc_html( $mesg ) );
383
  endforeach;
384
  echo "</li>\n";
385
  else :
386
+ printf( " completed in %d second%s</li>\n", esc_html( $dt ), esc_html( _s( $dt ) ) );
387
  endif;
388
  flush();
389
  }
390
 
391
+ /**
392
+ * Retrieves a list of users via the WordPress API.
393
+ *
394
+ * @return array List of users, by numeric ID => display_name
395
+ */
396
+ function fwp_author_list() {
397
  global $wpdb;
398
  $ret = array();
399
 
400
  $users = get_users();
401
+ if ( is_array( $users ) ) :
402
+ foreach ( $users as $user ) :
403
+ $id = (int) $user->ID;
404
+ $ret[ $id ] = $user->display_name;
405
+
406
+ if ( strlen( trim( $ret[ $id ] ) ) === 0 ) :
407
+ $ret[ $id ] = $user->user_login;
408
  endif;
409
  endforeach;
410
  endif;
411
  return $ret;
412
  }
413
 
414
+ /**
415
+ * Insert a new user into the WordPress database, with some FeedWordPress-specific default behaviors.
416
+ *
417
+ * @param string $newuser_name The "Display Name" for the new user; user logins and the like will be determined by a formula.
418
+ * @return mixed Either a numeric ID or a WP_Error object.
419
+ */
420
+ function fwp_insert_new_user( $newuser_name ) {
421
  global $wpdb;
422
 
423
  $ret = null;
424
+ if ( strlen( $newuser_name ) > 0 ) :
425
+ $userdata = array();
426
+ $userdata['ID'] = null;
427
+ $userdata['user_login'] = apply_filters( 'pre_user_login', sanitize_user( $newuser_name ) );
428
+ $userdata['user_nicename'] = apply_filters( 'pre_user_nicename', sanitize_title( $newuser_name ) );
429
+ $userdata['display_name'] = $newuser_name;
430
+ $userdata['user_pass'] = substr( md5( uniqid( microtime() ) ), 0, 6 ); // just something random to lock it up.
431
+
432
+ $blah_url = get_bloginfo( 'url' );
433
+ $url = wp_parse_url( $blah_url );
434
+
435
+ $userdata['user_email'] = substr( md5( uniqid( microtime() ) ), 0, 6 ) . '@' . $url['host'];
436
+
437
+ $newuser_id = wp_insert_user( $userdata );
438
+
439
+ $ret = $newuser_id; // Either a numeric ID or a WP_Error object.
440
+
441
  else :
442
+
443
+ $ret = new WP_Error( 'empty_username', 'Provide a non-empty string for the Display Name to fwp_insert_new_user' );
444
+
445
  endif;
446
  return $ret;
447
+ } /* fwp_insert_new_user ( ) */
448
 
449
+ /**
450
+ * Output HTML for table row in FeedWordPress Syndicated Sources list.
451
+ *
452
+ * @param array $links array of WordPress link objects.
453
+ * @param object $page FeedWordPress admin page object.
454
+ * @param string $visible 'Y' or 'N', whether to display syndicated sources marked as visible or as hidden.
455
+ */
456
+ function fwp_syndication_manage_page_links_table_rows( $links, $page, $visible = 'Y' ) {
457
 
458
+ $fwp_syndicated_sources_columns = array( __( 'Name' ), __( 'Feed' ), __( 'Updated' ) );
459
+
460
+ $subscribed = ( 'Y' === strtoupper( $visible ) );
461
+ if ( $subscribed || ( count( $links ) > 0 ) ) :
462
+ $table_classes = array( 'widefat' );
463
+ if ( ! $subscribed ) :
464
+ $table_classes[] = 'unsubscribed';
465
+ endif;
466
+ $table_classes = implode( ' ', $table_classes );
467
+ ?>
468
+ <table class="<?php print esc_attr( $table_classes ); ?>">
469
  <thead>
470
  <tr>
471
  <th class="check-column" scope="col"><input type="checkbox" /></th>
472
+ <?php
473
+ foreach ( $fwp_syndicated_sources_columns as $col ) :
474
+ printf( "\t<th scope='col'>%s</th>\n", esc_html( $col ) );
475
  endforeach;
476
  print "</tr>\n";
477
  print "</thead>\n";
479
  print "<tbody>\n";
480
 
481
  $alt_row = true;
482
+ if ( count( $links ) > 0 ) :
483
+ foreach ( $links as $link ) :
484
+ $tr_class = array();
 
 
 
 
 
 
 
 
485
 
486
+ $o_s_link = new SyndicatedLink( $link->link_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
 
488
+ if ( is_null( $o_s_link->setting( 'update/error' ) ) ) :
489
+
490
+ $the_error = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
 
492
+ else :
493
+ $tr_class[] = 'feed-error';
494
+ $the_error = unserialize( $o_s_link->setting( 'update/error' ) );
495
  endif;
496
 
497
+ $ttl = $o_s_link->setting( 'update/ttl' );
498
 
499
+ $alt_row = ! $alt_row;
500
 
501
+ if ( $alt_row ) :
502
+ $tr_class[] = 'alternate';
503
  endif;
504
  ?>
505
+ <tr<?php fwp_form_class_attr( implode( ' ', $tr_class ) ); ?>>
506
  <th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo esc_attr( $link->link_id ); ?>" /></th>
507
  <?php
508
  $caption = (
509
+ ( strlen( $link->link_rss ) > 0 )
510
+ ? __( 'Switch Feed' )
511
+ : __( 'Find Feed' )
512
  );
513
  ?>
514
  <td>
515
+ <strong><a href="<?php print esc_url( $page->admin_page_href( 'feeds-page.php', array(), $link ) ); ?>"><?php print esc_html( $link->link_name ); ?></a></strong>
516
+ <div class="row-actions">
517
+ <?php
518
+ if ( $subscribed ) :
519
+ $page->display_feed_settings_page_links(
520
+ array(
521
+ 'before' => '<div><strong>Settings &gt;</strong> ',
522
+ 'after' => '</div>',
523
+ 'subscription' => $link,
524
+ )
525
+ );
526
+ endif;
527
+ ?>
528
 
529
  <div><strong>Actions &gt;</strong>
530
+ <?php if ( $subscribed ) : ?>
531
+ <a href="<?php print esc_url( $page->admin_page_href( 'syndication.php', array( 'action' => 'feedfinder' ), $link ) ); ?>"><?php echo esc_html( $caption ); ?></a>
532
+ <?php else : ?>
533
+ <a href="<?php print esc_url( $page->admin_page_href( 'syndication.php', array( 'action' => FWP_RESUB_CHECKED ), $link ) ); ?>"><?php esc_html_e( 'Re-subscribe' ); ?></a>
534
+ <?php endif; ?>
535
+ | <a href="<?php print esc_url( $page->admin_page_href( 'syndication.php', array( 'action' => 'Unsubscribe' ), $link ) ); ?>">
536
+ <?php
537
+ if ( $subscribed ) :
538
+ esc_html_e( 'Unsubscribe' );
539
+ else :
540
+ esc_html_e( 'Delete permanently' );
541
+ endif;
542
+ ?>
543
+ </a>
544
+ | <a href="<?php print esc_url( $link->link_url ); ?>"><?php esc_html_e( 'View' ); ?></a></div>
545
  </div>
546
  </td>
547
+ <?php if ( strlen( $link->link_rss ) > 0 ) : ?>
548
+ <td><div><a href="<?php echo esc_html( $link->link_rss ); ?>"><?php echo esc_html( feedwordpress_display_url( $link->link_rss, 32 ) ); ?></a></div></td>
549
+ <?php else : ?>
550
  <td class="feed-missing"><p><strong>no feed assigned</strong></p></td>
551
  <?php endif; ?>
552
 
553
  <td><div style="float: right; padding-left: 10px">
554
+ <input type="submit" class="button" name="update_uri[<?php print esc_html( $link->link_rss ); ?>]" value="<?php esc_html_e( 'Update Now' ); ?>" />
555
  </div>
556
+ <?php
557
+ fwp_links_table_rows_last_updated( $o_s_link );
558
+ fwp_links_table_rows_file_size( $o_s_link );
559
+ fwp_links_table_rows_errors_since( $the_error );
560
+ fwp_links_table_rows_next_update( $o_s_link );
561
+ ?>
562
  </td>
563
  </tr>
564
+ <?php
565
+ unset( $o_s_link );
566
+
567
  endforeach;
568
  else :
569
+ ?>
570
  <tr><td colspan="4"><p>There are no websites currently listed for syndication.</p></td></tr>
571
+ <?php
572
+
573
  endif;
574
+
575
+ ?>
576
+
577
  </tbody>
578
  </table>
579
+
580
+ <?php
581
+
582
+ endif;
583
+ } /* function fwp_syndication_manage_page_links_table_rows ( ) */
584
+
585
+ /**
586
+ * Output HTML message indicating feed errors, if a feed has been returning errors, in Syndicated Sites table.
587
+ *
588
+ * @param mixed $the_error If last poll on this feed was successful, this is null.
589
+ * If last poll returned an error, contains an array with 'since' (timestamp of first time an error was an encountered), 'ts' (timestamp of most recent time an error was encountered), and 'object' (a WP_Error object representing the most recent error when you polled the feed).
590
+ */
591
+ function fwp_links_table_rows_errors_since( $the_error ) {
592
+ if ( ! is_null( $the_error ) ) :
593
+
594
+ $s_elapsed = fwp_time_elapsed( $the_error['since'] );
595
+ $s_recent = fwp_time_elapsed( $the_error['ts'] );
596
+ ?>
597
+
598
+ <div class="returning-errors"><p><strong>Returning errors</strong> since <?php print esc_html( $s_elapsed ); ?></p>
599
+ <p>Most recent (<?php print esc_html( $s_recent ); ?>):
600
+ <?php
601
+ foreach ( $the_error['object']->get_error_messages() as $mesg ) :
602
+ printf( '<br/><code>%s</code>', esc_html( $mesg ) );
603
+ endforeach;
604
+ ?>
605
+ </p>
606
+ </div>
607
+
608
+ <?php
609
+ endif;
610
+ }
611
+
612
+ /**
613
+ * Output the "Last checked..." status message in Syndicated Sites table.
614
+ *
615
+ * @param SyndicatedLink $o_s_link The SyndicatedLink object representing the feed displayed on this row.
616
+ */
617
+ function fwp_links_table_rows_last_updated( $o_s_link ) {
618
+ if ( ! is_null( $o_s_link->setting( 'update/last' ) ) ) :
619
+ print esc_html( 'Last checked ' . fwp_time_elapsed( $o_s_link->setting( 'update/last' ) ) );
620
+ else :
621
+ esc_html_e( 'None yet' );
622
+ endif;
623
+
624
+ $ttl = $o_s_link->setting( 'update/ttl' );
625
+ if ( is_numeric( $ttl ) ) :
626
+ $next = $o_s_link->setting( 'update/last' ) + $o_s_link->setting( 'update/fudge' ) + ( (int) $ttl * 60 );
627
+
628
+ if ( 'automatically' !== $o_s_link->setting( 'update/timed' ) ) :
629
+
630
+ print ' &middot; Next ';
631
+ print esc_html( fwp_relative_time_string( $next ) );
632
+
633
+ endif;
634
+ endif;
635
+
636
+ }
637
+
638
+ /**
639
+ * Return a status message indicating when a feed will next be polled, based on a next-update timestamp.
640
+ *
641
+ * @param int $ts Timestamp for next updrate.
642
+ * @param bool $ago Display "[relative time] ago", or "ASAP", if the timestamp is in the past.
643
+ */
644
+ function fwp_relative_time_string( $ts, $ago = false ) {
645
+
646
+ $dt = ( $ts - time() );
647
+
648
+ if ( $dt < 0 && ! $ago ) :
649
+ $ret = 'ASAP';
650
+ elseif ( $dt < 60 * 60 ) :
651
+ $ret = fwp_time_elapsed( $ts );
652
+ elseif ( $dt < 60 * 60 * 24 ) :
653
+ $ret = wp_date( 'g:ia', $ts );
654
+ else :
655
+ $ret = wp_date( 'F j', $ts );
656
+ endif;
657
+ return $ret;
658
+ }
659
+
660
+ /**
661
+ * Output the File Size / Format status message in Syndicated Sites table.
662
+ *
663
+ * @param SyndicatedLink $o_s_link Object representing the feed displayed on this row.
664
+ */
665
+ function fwp_links_table_rows_file_size( $o_s_link ) {
666
+
667
+ $mesg_file_size_lines = array();
668
+
669
+ $feed_type = $o_s_link->get_feed_type();
670
+
671
+ if ( ! is_null( $o_s_link->setting( 'link/item count' ) ) ) :
672
+ $n = $o_s_link->setting( 'link/item count' );
673
+
674
+ // translators: %1$d is the item count; %2$s is the plural marker (if any) for item.
675
+ $mesg_file_size_lines[] = sprintf( __( '%1$d item%2$s' ), $n, _s( $n ) ) . ', ' . $feed_type;
676
+
677
+ endif;
678
+
679
+ if ( is_null( $o_s_link->setting( 'update/error' ) ) ) :
680
+
681
+ if ( ! is_null( $o_s_link->setting( 'link/filesize' ) ) ) :
682
+ $mesg_file_size_lines[] = size_format( $o_s_link->setting( 'link/filesize' ) ) . ' total';
683
+ endif;
684
+
685
+ endif;
686
+
687
+ if ( count( $mesg_file_size_lines ) > 0 ) :
688
+
689
+ print '<div>';
690
+ $sep = '';
691
+ foreach ( $mesg_file_size_lines as $line ) :
692
+ print esc_html( $sep );
693
+ print esc_html( $line );
694
+ $sep = ' / ';
695
+ endforeach;
696
+ print '</div>';
697
+
698
  endif;
 
699
 
700
+ }
701
+
702
+ /**
703
+ * Output the Scheduled For Next Update status message in Syndicated Sites table.
704
+ *
705
+ * @param SyndicatedLink $o_s_link Object representing the feed displayed on this row.
706
+ */
707
+ function fwp_links_table_rows_next_update( $o_s_link ) {
708
+ $ttl = $o_s_link->setting( 'update/ttl' );
709
+ ?>
710
+ <div style="max-width: 30.0em; font-size: 0.9em;"><div style="font-style:italic;">
711
+ <?php
712
+ if ( is_numeric( $ttl ) ) :
713
+ $next = $o_s_link->setting( 'update/last' ) + $o_s_link->setting( 'update/fudge' ) + ( (int) $ttl * 60 );
714
+ if ( 'automatically' === $o_s_link->setting( 'update/timed' ) ) :
715
+ if ( $next < time() ) :
716
+ print 'Ready and waiting to be updated since ';
717
+ else :
718
+ print 'Scheduled for next update ';
719
+ endif;
720
+
721
+ print esc_html( fwp_time_elapsed( $next ) );
722
+ if ( FEEDWORDPRESS_DEBUG ) :
723
+ $interval = ( ( $next - time() ) / 60 );
724
+ printf( ' [%d minute%s]', intval( $interval ), esc_html( _s( $interval ) ) );
725
+ endif;
726
+ else :
727
+ printf( '. Scheduled to be checked for updates every %d minute%s', intval( $ttl ), esc_html( _s( $ttl ) ) );
728
+ ?>
729
+ </div>
730
+
731
+ <div style="size:0.9em; margin-top: 0.5em">This update schedule was requested by the feed provider
732
+ <?php
733
+ if ( $o_s_link->setting( 'update/xml' ) ) :
734
+ ?>
735
+ using a standard <code style="font-size: inherit; padding: 0; background: transparent">&lt;<?php print esc_html( $o_s_link->setting( 'update/xml' ) ); ?>&gt;</code> element
736
+ <?php
737
+ endif;
738
+ endif;
739
+ else :
740
+ print 'Scheduled for update as soon as possible';
741
+ endif;
742
+ print '.';
743
+ ?>
744
+ </div></div>
745
+ <?php
746
+ }
authors-page.php CHANGED
@@ -256,26 +256,31 @@ name to delete the rule. Fill in a new name at the bottom to create a new rule.)
256
  <?php endif;
257
  } /* FeedWordPressAuthorsPage::display () */
258
 
259
- function accept_POST ($post) {
260
- if (isset($post['fix_mismatch']) and (strlen($post['fix_mismatch']) > 0)) :
261
- $this->fix_mismatch($post);
 
 
 
 
 
262
  else :
263
- parent::accept_POST($post);
264
  endif;
265
  }
266
 
267
- function fix_mismatch ($post) {
268
  global $wpdb;
269
 
270
- if ('newuser'==$post['fix_mismatch_to']) :
271
- $newuser_name = trim($post['fix_mismatch_to_newuser']);
272
- $to = fwp_insert_new_user($newuser_name);
273
- else :
274
- $to = $post['fix_mismatch_to'];
275
  endif;
276
 
277
- $from = (int) $post['fix_mismatch_from'];
278
- if (is_numeric($from)) :
 
279
  // Make a list of all the items by this author
280
  // syndicated from this feed...
281
  $post_ids = $wpdb->get_col("
@@ -321,32 +326,34 @@ name to delete the rule. Fill in a new name at the bottom to create a new rule.)
321
  $this->updated = false;
322
  }
323
 
324
- function save_settings ($post) {
325
 
326
  if ($this->for_feed_settings()) :
327
  $alter = array ();
328
 
329
  // Unfamiliar author rule
330
- if (isset($post["unfamiliar_author"])) :
331
- if ('newuser'==$post['unfamiliar_author']) :
332
- $new_name = trim($post["unfamiliar_author_newuser"]);
333
- $this->link->map_name_to_new_user(/*name=*/ NULL, $new_name);
 
334
  else :
335
  $this->link->update_setting(
336
  "unfamiliar author",
337
- $post['unfamiliar_author'],
338
  'site-default'
339
  );
340
  endif;
341
  endif;
342
 
343
  // Handle author mapping rules
344
- if (isset($post['author_rules_name'])
345
- and isset($post['author_rules_action'])) :
346
- if (isset($post['author_rules_name']['all'])) :
347
- if (strlen($post['author_rules_name']['all']) > 0) :
348
- $post['author_rules_name'] = array(
349
- 'all' => $post['author_rules_name']['all'],
 
350
  );
351
 
352
  // Erase all the rest.
@@ -354,14 +361,15 @@ name to delete the rule. Fill in a new name at the bottom to create a new rule.)
354
  endif;
355
 
356
  unset($this->link->settings['map authors']);
357
- foreach ($post['author_rules_name'] as $key => $name) :
358
  // Normalize for case and whitespace
359
- $name = strtolower(trim($name));
360
- $author_action = strtolower(trim($post['author_rules_action'][$key]));
361
-
362
- if (strlen($name) > 0) :
363
- if ('newuser' == $author_action) :
364
- $new_name = trim($post['author_rules_newuser'][$key]);
 
365
  $this->link->map_name_to_new_user($name, $new_name);
366
  else :
367
  $this->link->settings['map authors']['name'][$name] = $author_action;
@@ -370,47 +378,51 @@ name to delete the rule. Fill in a new name at the bottom to create a new rule.)
370
  endforeach;
371
  endif;
372
 
373
- if (isset($post['add_author_rule_name'])
374
- and isset($post['add_author_rule_action'])) :
375
- $name = strtolower(trim($post['add_author_rule_name']));
376
- $author_action = strtolower(trim($post['add_author_rule_action']));
377
-
 
378
  if (strlen($name) > 0) :
379
  if ('newuser' == $author_action) :
380
- $new_name = trim($post['add_author_rule_newuser']);
381
  $this->link->map_name_to_new_user($name, $new_name);
382
  else :
383
  $this->link->settings['map authors']['name'][$name] = $author_action;
384
  endif;
385
  endif;
386
  endif;
 
387
  else :
388
- if ('newuser'==$post['unfamiliar_author']) :
389
- $new_name = trim($post['unfamiliar_author_newuser']);
390
- $new_id = fwp_insert_new_user($new_name);
391
- if (is_numeric($new_id)) :
392
- update_option('feedwordpress_unfamiliar_author', $new_id);
 
 
393
  else :
394
  // TODO: Add some error detection and reporting
395
  // Put WP_Error stuff into $this->mesg ?
396
  endif;
397
  else :
398
- update_option('feedwordpress_unfamiliar_author', $post['unfamiliar_author']);
399
  endif;
400
 
401
- update_option('feedwordpress_do_not_match_author_by_email',
402
- (isset($post['match_author_by_email'])
403
- and 'yes'==$post['match_author_by_email'])
404
- ? 'no'
405
- : 'yes'
406
  );
407
 
408
- if (isset($post['null_emails'])) :
409
- update_option('feedwordpress_null_email_set', $post['null_emails']);
 
410
  endif;
411
  endif;
412
 
413
- parent::save_settings($post);
414
  $this->refresh_author_list();
415
  }
416
  } /* class FeedWordPressAuthorsPage */
256
  <?php endif;
257
  } /* FeedWordPressAuthorsPage::display () */
258
 
259
+ public function fix_mismatch_requested () {
260
+ $fix = FeedWordPress::post( 'fix_mismatch' );
261
+ return ( ! is_null( $fix ) && strlen( $fix ) > 0 );
262
+ }
263
+
264
+ function accept_POST () {
265
+ if ( self::fix_mismatch_requested() ) :
266
+ $this->fix_mismatch();
267
  else :
268
+ parent::accept_POST();
269
  endif;
270
  }
271
 
272
+ function fix_mismatch () {
273
  global $wpdb;
274
 
275
+ $to = FeedWordPress::post( 'fix_mismatch_to' );
276
+ if ( 'newuser' === $fix_to ) :
277
+ $newuser_name = trim( FeedWordPress::post('fix_mismatch_to_newuser', '' ) );
278
+ $to = fwp_insert_new_user( $newuser_name );
 
279
  endif;
280
 
281
+ $from = (int) FeedWordPress::post( 'fix_mismatch_from' );
282
+ if ( is_numeric( $from ) ) :
283
+
284
  // Make a list of all the items by this author
285
  // syndicated from this feed...
286
  $post_ids = $wpdb->get_col("
326
  $this->updated = false;
327
  }
328
 
329
+ function save_settings () {
330
 
331
  if ($this->for_feed_settings()) :
332
  $alter = array ();
333
 
334
  // Unfamiliar author rule
335
+ $unfamiliar_author = FeedWordPress::post( 'unfamiliar_author' );
336
+ if ( ! is_null( $unfamiliar_author ) ) :
337
+ if ( 'newuser' == $unfamiliar_author ) :
338
+ $new_name = trim( FeedWordPress::post( "unfamiliar_author_newuser" ) );
339
+ $this->link->map_name_to_new_user(/*name=*/ null, $new_name);
340
  else :
341
  $this->link->update_setting(
342
  "unfamiliar author",
343
+ $unfamiliar_author,
344
  'site-default'
345
  );
346
  endif;
347
  endif;
348
 
349
  // Handle author mapping rules
350
+ $author_rules_name = FeedWordPress::post( 'author_rules_name' );
351
+ $author_rules_action = FeedWordPress::post('author_rules_action' );
352
+ if ( ! ( is_null( $author_rules_name ) || is_null( $author_rules_action ) ) ) :
353
+ if ( isset( $author_rules_name['all'] ) ) :
354
+ if ( strlen( $author_rules_name['all']) > 0 ) :
355
+ $author_rules_name = array(
356
+ 'all' => $author_rules_name['all'],
357
  );
358
 
359
  // Erase all the rest.
361
  endif;
362
 
363
  unset($this->link->settings['map authors']);
364
+ foreach ($author_rules_name as $key => $name) :
365
  // Normalize for case and whitespace
366
+ $name = strtolower( trim( $name ) );
367
+ $author_action = strtolower( trim( $author_rules_action[$key] ) );
368
+
369
+ $author_rules_newuser = FeedWordPress::post('author_rules_newuser' );
370
+ if ( strlen($name) > 0 ) :
371
+ if ( 'newuser' == $author_action ) :
372
+ $new_name = trim( $author_rules_newuser[ $key ] );
373
  $this->link->map_name_to_new_user($name, $new_name);
374
  else :
375
  $this->link->settings['map authors']['name'][$name] = $author_action;
378
  endforeach;
379
  endif;
380
 
381
+ $name = FeedWordPress::post( 'add_author_rule_name');
382
+ $author_action = FeedWordPress::post( 'add_author_rule_action' );
383
+ if ( ! ( is_null( $name ) || is_null( $author_action ) ) ) :
384
+ $name = strtolower( trim( $name ) );
385
+ $author_action = strtolower( trim( $author_action ) );
386
+
387
  if (strlen($name) > 0) :
388
  if ('newuser' == $author_action) :
389
+ $new_name = trim( FeedWordPress::post( 'add_author_rule_newuser' ));
390
  $this->link->map_name_to_new_user($name, $new_name);
391
  else :
392
  $this->link->settings['map authors']['name'][$name] = $author_action;
393
  endif;
394
  endif;
395
  endif;
396
+
397
  else :
398
+
399
+ $unfamiliar_author = FeedWordPress::post( 'unfamiliar_author' );
400
+ if ( 'newuser' === $unfamiliar_author ) :
401
+ $new_name = FeedWordPress::post( 'unfamiliar_author_newuser' );
402
+ $new_id = fwp_insert_new_user( trim( $new_name ) );
403
+ if ( is_numeric( $new_id ) ) :
404
+ update_option( 'feedwordpress_unfamiliar_author', $new_id );
405
  else :
406
  // TODO: Add some error detection and reporting
407
  // Put WP_Error stuff into $this->mesg ?
408
  endif;
409
  else :
410
+ update_option( 'feedwordpress_unfamiliar_author', $unfamiliar_author );
411
  endif;
412
 
413
+ $by_email = FeedWordPress::post( 'match_author_by_email' );
414
+ update_option(
415
+ 'feedwordpress_do_not_match_author_by_email',
416
+ ( isset( $by_email ) && 'yes' == $by_email ) ? 'no' : 'yes'
 
417
  );
418
 
419
+ $null_emails = FeedWordPress::post( 'null_emails', null, 'textarea' );
420
+ if ( ! is_null( $null_emails ) ) :
421
+ update_option( 'feedwordpress_null_email_set', $null_emails );
422
  endif;
423
  endif;
424
 
425
+ parent::save_settings();
426
  $this->refresh_author_list();
427
  }
428
  } /* class FeedWordPressAuthorsPage */
categories-page.php CHANGED
@@ -25,7 +25,19 @@ class FeedWordPressCategoriesPage extends FeedWordPressAdminPage {
25
  return $name;
26
  }
27
 
28
-
 
 
 
 
 
 
 
 
 
 
 
 
29
  function feed_categories_box ($page, $box = NULL) {
30
  $link = $page->link;
31
 
@@ -109,13 +121,10 @@ class FeedWordPressCategoriesPage extends FeedWordPressAdminPage {
109
  // Yup. Let's add a site-default option
110
  $currently = $um[$GUC]['label'];
111
  $defaultLi = array(
112
- 'site-default' => array(
113
- 'label' => sprintf(
114
- __('Use the <a href="%s">site-wide setting</a> <span class="current-setting">Currently: <strong>%s</strong></span>'),
115
- $href,
116
- $currently
117
  ),
118
- ), );
119
  $unmatchedColumns[$what] = array(
120
  $defaultLi,
121
  );
@@ -196,9 +205,7 @@ class FeedWordPressCategoriesPage extends FeedWordPressAdminPage {
196
  <table class="twofer">
197
  <tbody>
198
  <tr><td class="equals first <?php if ($defaulted['cats']) : ?>active<?php else: ?>inactive<?php endif; ?>"><p><label><input type="radio" name="match_default[cats]"
199
- value="yes" <?php if ($defaulted['cats']) : ?> checked="checked"<?php endif; ?> />
200
- Use the <a href="<?php print esc_url( $href ); ?>">site-wide setting</a>
201
- <span class="current-setting">Currently: <strong><?php print esc_html( $globalMatchLabels['cats'] ); ?></strong></span></label></p></td>
202
  <td class="equals second <?php if ($defaulted['cats']) : ?>inactive<?php else: ?>active<?php endif; ?>"><p><label><input type="radio" name="match_default[cats]"
203
  value="no" <?php if (!$defaulted['cats']) : ?> checked="checked"<?php endif; ?> />
204
  Do something different with this feed.</label>
@@ -236,9 +243,14 @@ the feed that don't have any local matches yet...</p>
236
  <tr>
237
  <?php foreach ($unmatchedColumns['category'] as $index => $column) : ?>
238
  <td class="equals <?php print (($index == 0) ? 'first' : 'second'); ?> inactive"><ul class="options">
239
- <?php foreach ($column as $name => $li) : ?>
240
- <li><label><input type="radio" name="unfamiliar_category" value="<?php print esc_attr( $name ); ?>"<?php fwp_checked_flag($unmatchedRadio['category'][$name]); ?> /> <?php print esc_html( $li['label'] ); ?></label></li>
241
- <?php endforeach; ?>
 
 
 
 
 
242
  </ul></td>
243
  <?php endforeach; ?>
244
  </tr>
@@ -260,8 +272,7 @@ like those handled above.</p>
260
  <tbody>
261
  <tr><td class="equals first <?php if ($defaulted['tags']) : ?>active<?php else: ?>inactive<?php endif; ?>"><p><label><input type="radio" name="match_default[tags]"
262
  value="yes" <?php if ($defaulted['tags']) : ?> checked="checked"<?php endif; ?> />
263
- Use the <a href="<?php print esc_url( $href ); ?>">site-wide setting</a>
264
- <span class="current-setting">Currently: <strong><?php print esc_html( $globalMatchLabels['tags'] ); ?></strong></span></label></p>
265
  </td>
266
  <td class="equals second <?php if ($defaulted['tags']) : ?>inactive<?php else: ?>active<?php endif; ?>"><p><label><input type="radio" name="match_default[tags]"
267
  value="no" <?php if (!$defaulted['tags']) : ?> checked="checked"<?php endif; ?> />
@@ -301,7 +312,7 @@ inline tags that don't have any local matches yet...</p>
301
  <?php foreach ($unmatchedColumns['post_tag'] as $index => $column) : ?>
302
  <td class="equals <?php print (($index == 0) ? 'first' : 'second'); ?> inactive"><ul class="options">
303
  <?php foreach ($column as $name => $li) : ?>
304
- <li><label><input type="radio" name="unfamiliar_post_tag" value="<?php print esc_attr( $name ); ?>"<?php fwp_checked_flag($unmatchedRadio['post_tag'][$name]); ?> /> <?php print esc_html( $li['label'] ); ?></label></li>
305
  <?php endforeach; ?>
306
  </ul></td>
307
  <?php endforeach; ?>
@@ -321,8 +332,7 @@ inline tags that don't have any local matches yet...</p>
321
  <td class="equals first <?php if ($defaulted['filter']) : ?>active<?php else: ?>inactive<?php endif; ?>">
322
  <p><label><input type="radio" name="match_default[filter]"
323
  value="yes" <?php if ($defaulted['filter']) : ?> checked="checked"<?php endif; ?> />
324
- Use the <a href="<?php print esc_url( $href ); ?>">site-wide setting</a>
325
- <span class="current-setting">Currently: <strong><?php print esc_html( $globalMatchLabels['filter'] ); ?></strong></span></label></p>
326
  </td>
327
  <td class="equals second <?php if ($defaulted['filter']) : ?>inactive<?php else: ?>active<?php endif; ?>">
328
  <p><label><input type="radio" name="match_default[filter]"
@@ -496,18 +506,19 @@ blank.</p></td>
496
  <?php
497
  } /* FeedWordPressCategoriesPage::categories_box () */
498
 
499
- function save_settings ($post) {
500
- if (isset($post['match_categories'])) :
501
- foreach ($post['match_categories'] as $what => $set) :
 
502
  // Defaulting is controlled by a separate radio button
503
- if ($this->for_feed_settings()
504
- and isset($post['match_default'])
505
- and isset($post['match_default'][$what])
506
- and $post['match_default'][$what]=='yes') :
507
- $set = NULL; // Defaulted!
508
  endif;
509
 
510
- $this->update_setting("match/$what", $set, NULL);
511
  endforeach;
512
  endif;
513
  $optionMap = $this->term_option_map();
@@ -515,20 +526,16 @@ blank.</p></td>
515
 
516
  $saveTerms = array(); $separateSaveTerms = array('category' => array(), 'post_tag' => array());
517
 
518
- if (!isset($post['tax_input'])) : $post['tax_input'] = array(); endif;
519
-
 
 
520
  // Merge in data from older-notation category check boxes
521
- if (isset($post['post_category'])) :
522
- // Just merging in for processing below.
523
- $post['tax_input']['category'] = array_merge(
524
- (isset($post['tax_input']['category']) ? $post['tax_input']['category'] : array()),
525
- $post['post_category']
526
- );
527
- endif;
528
 
529
  // Process data from term tag boxes and check boxes
530
- foreach ($post['tax_input'] as $tax => $terms) :
531
- $saveTerms[$tax] = array();
532
  if (is_array($terms)) : // Numeric IDs from checklist
533
  foreach ($terms as $term) :
534
  if ($term) :
@@ -546,18 +553,17 @@ blank.</p></td>
546
  endif;
547
  endforeach;
548
 
549
- if (isset($post['post_category'])) :
550
- foreach ($post['post_category'] as $cat) :
551
- $separateSaveTerms['category'][] = '{category#'.$cat.'}';
552
- endforeach;
553
- endif;
554
 
555
  // Unmatched categories and tags
556
  foreach (array('category', 'post_tag') as $what) :
557
- if (isset($post["unfamiliar_{$what}"])) :
 
558
  $this->update_setting(
559
  "unfamiliar {$what}",
560
- $post["unfamiliar_{$what}"],
561
  'site-default'
562
  );
563
  endif;
@@ -581,19 +587,21 @@ blank.</p></td>
581
 
582
  if ($this->for_feed_settings()) :
583
  // Category splitting regex
584
- if (isset($post['cat_split'])) :
585
- $this->link->update_setting('cat_split', trim($post['cat_split']), '');
 
586
  endif;
587
 
588
  // Treat global terms (cats, tags, etc.) as additional,
589
  // or as defaults to be overridden and replaced?
590
- if (isset($post['add_global'])) :
591
- foreach ($post['add_global'] as $what => $value) :
 
592
  $this->link->update_setting("add/$what", $value);
593
  endforeach;
594
  endif;
595
  endif;
596
- parent::save_settings($post);
597
  } /* FeedWordPressCategoriesPage::save_settings() */
598
 
599
  function display () {
25
  return $name;
26
  }
27
 
28
+ public function setting_radio_label( $li ) {
29
+ if ( is_array($li['label'] ) ) :
30
+ list( $a_href, $s_currently ) = $li['label'];
31
+ printf(
32
+ __('Use the <a href="%s">site-wide setting</a> <span class="current-setting">Currently: <strong>%s</strong></span>'),
33
+ esc_url( $a_href ),
34
+ esc_html( $s_currently )
35
+ );
36
+ else :
37
+ print esc_html( $li['label'] );
38
+ endif;
39
+ }
40
+
41
  function feed_categories_box ($page, $box = NULL) {
42
  $link = $page->link;
43
 
121
  // Yup. Let's add a site-default option
122
  $currently = $um[$GUC]['label'];
123
  $defaultLi = array(
124
+ 'site-default' => array(
125
+ 'label' => [ $href, $currently ],
 
 
 
126
  ),
127
+ );
128
  $unmatchedColumns[$what] = array(
129
  $defaultLi,
130
  );
205
  <table class="twofer">
206
  <tbody>
207
  <tr><td class="equals first <?php if ($defaulted['cats']) : ?>active<?php else: ?>inactive<?php endif; ?>"><p><label><input type="radio" name="match_default[cats]"
208
+ value="yes" <?php if ($defaulted['cats']) : ?> checked="checked"<?php endif; ?> /><?php $this->setting_radio_label( array( "label" => array ( $href, $globalMatchLabels['cats'] ) ) ); ?></label></p></td>
 
 
209
  <td class="equals second <?php if ($defaulted['cats']) : ?>inactive<?php else: ?>active<?php endif; ?>"><p><label><input type="radio" name="match_default[cats]"
210
  value="no" <?php if (!$defaulted['cats']) : ?> checked="checked"<?php endif; ?> />
211
  Do something different with this feed.</label>
243
  <tr>
244
  <?php foreach ($unmatchedColumns['category'] as $index => $column) : ?>
245
  <td class="equals <?php print (($index == 0) ? 'first' : 'second'); ?> inactive"><ul class="options">
246
+ <?php
247
+ foreach ($column as $name => $li) :
248
+ ?>
249
+ <li><label><input type="radio" name="unfamiliar_category" value="<?php print esc_attr( $name ); ?>"<?php fwp_checked_flag($unmatchedRadio['category'][$name]); ?> /> <?php
250
+ $this->setting_radio_label( $li );
251
+ ?></label></li>
252
+ <?php
253
+ endforeach; ?>
254
  </ul></td>
255
  <?php endforeach; ?>
256
  </tr>
272
  <tbody>
273
  <tr><td class="equals first <?php if ($defaulted['tags']) : ?>active<?php else: ?>inactive<?php endif; ?>"><p><label><input type="radio" name="match_default[tags]"
274
  value="yes" <?php if ($defaulted['tags']) : ?> checked="checked"<?php endif; ?> />
275
+ <?php $this->setting_radio_label( array( "label" => array( $href, $globalMatchLabels['tags'] ) ) ); ?></label></p>
 
276
  </td>
277
  <td class="equals second <?php if ($defaulted['tags']) : ?>inactive<?php else: ?>active<?php endif; ?>"><p><label><input type="radio" name="match_default[tags]"
278
  value="no" <?php if (!$defaulted['tags']) : ?> checked="checked"<?php endif; ?> />
312
  <?php foreach ($unmatchedColumns['post_tag'] as $index => $column) : ?>
313
  <td class="equals <?php print (($index == 0) ? 'first' : 'second'); ?> inactive"><ul class="options">
314
  <?php foreach ($column as $name => $li) : ?>
315
+ <li><label><input type="radio" name="unfamiliar_post_tag" value="<?php print esc_attr( $name ); ?>"<?php fwp_checked_flag($unmatchedRadio['post_tag'][$name]); ?> /> <?php $this->setting_radio_label( $li ); ?></label></li>
316
  <?php endforeach; ?>
317
  </ul></td>
318
  <?php endforeach; ?>
332
  <td class="equals first <?php if ($defaulted['filter']) : ?>active<?php else: ?>inactive<?php endif; ?>">
333
  <p><label><input type="radio" name="match_default[filter]"
334
  value="yes" <?php if ($defaulted['filter']) : ?> checked="checked"<?php endif; ?> />
335
+ <?php $this->setting_radio_label( array( "label" => array( $href, $globalMatchLabels['filter'] ) ) ); ?></label></p>
 
336
  </td>
337
  <td class="equals second <?php if ($defaulted['filter']) : ?>inactive<?php else: ?>active<?php endif; ?>">
338
  <p><label><input type="radio" name="match_default[filter]"
506
  <?php
507
  } /* FeedWordPressCategoriesPage::categories_box () */
508
 
509
+ function save_settings () {
510
+ $match_categories = FeedWordPress::post( 'match_categories', array() );
511
+ if ( is_array( $match_categories ) ) :
512
+ foreach ( $match_categories as $what => $set) :
513
  // Defaulting is controlled by a separate radio button
514
+ $match_default = FeedWordPress::post( 'match_default', array() );
515
+ $match_default_here = ( is_array( $match_default ) && array_key_exists( $what, $match_default ) ? $match_default[ $what ] : null );
516
+
517
+ if ( FeedWordPress::affirmative( $match_default_here ) ) :
518
+ $set = null; // Defaulted!
519
  endif;
520
 
521
+ $this->update_setting( "match/$what", $set, null );
522
  endforeach;
523
  endif;
524
  $optionMap = $this->term_option_map();
526
 
527
  $saveTerms = array(); $separateSaveTerms = array('category' => array(), 'post_tag' => array());
528
 
529
+ $tax_input = FeedWordPress::post( 'tax_input', array() );
530
+ $tax_input_cats = ( isset( $tax_input['category'] ) ? $tax_input['category'] : array() );
531
+ $post_category = FeedWordPress::post( 'post_category', array() );
532
+
533
  // Merge in data from older-notation category check boxes
534
+ $tax_input['category'] = array_merge( $tax_input_cats, $post_category );
 
 
 
 
 
 
535
 
536
  // Process data from term tag boxes and check boxes
537
+ foreach ( $tax_input as $tax => $terms ) :
538
+ $saveTerms[ $tax ] = array();
539
  if (is_array($terms)) : // Numeric IDs from checklist
540
  foreach ($terms as $term) :
541
  if ($term) :
553
  endif;
554
  endforeach;
555
 
556
+ foreach ( $post_category as $cat ) :
557
+ $separateSaveTerms['category'][] = '{category#' .$cat . '}';
558
+ endforeach;
 
 
559
 
560
  // Unmatched categories and tags
561
  foreach (array('category', 'post_tag') as $what) :
562
+ $unfamiliar = FeedWordPress::post( "unfamiliar_{$what}" );
563
+ if ( ! is_null( $unfamiliar ) ) :
564
  $this->update_setting(
565
  "unfamiliar {$what}",
566
+ $unfamiliar,
567
  'site-default'
568
  );
569
  endif;
587
 
588
  if ($this->for_feed_settings()) :
589
  // Category splitting regex
590
+ $cat_split = FeedWordPress::post( 'cat_split' );
591
+ if ( ! is_null( $cat_split ) ) :
592
+ $this->link->update_setting( 'cat_split', trim( $cat_split ), '' );
593
  endif;
594
 
595
  // Treat global terms (cats, tags, etc.) as additional,
596
  // or as defaults to be overridden and replaced?
597
+ $add_global = FeedWordPress::post( 'add_global', array() );
598
+ if ( is_array( $add_global ) ) :
599
+ foreach ($add_global as $what => $value) :
600
  $this->link->update_setting("add/$what", $value);
601
  endforeach;
602
  endif;
603
  endif;
604
+ parent::save_settings();
605
  } /* FeedWordPressCategoriesPage::save_settings() */
606
 
607
  function display () {
diagnostics-page.php CHANGED
@@ -25,8 +25,8 @@ class FeedWordPressDiagnosticsPage extends FeedWordPressAdminPage {
25
  FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_diagnostics', /*capability=*/ 'manage_options');
26
 
27
  if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
28
- $this->accept_POST($_POST);
29
- do_action('feedwordpress_admin_page_diagnostics_save', $_POST, $this);
30
  endif;
31
 
32
  ////////////////////////////////////////////////
@@ -68,46 +68,44 @@ class FeedWordPressDiagnosticsPage extends FeedWordPressAdminPage {
68
  $this->close_sheet();
69
  } /* FeedWordPressDiagnosticsPage::display () */
70
 
71
- function accept_POST ($post) {
72
- if (isset($post['submit'])
73
- or isset($post['save'])
74
- or isset($post['feedwordpress_diagnostics_do'])) :
75
- update_option('feedwordpress_debug', $post['feedwordpress_debug']);
76
- update_option('feedwordpress_secret_key', $post['feedwordpress_secret_key']);
77
 
78
- if (!isset($post['diagnostics_output'])
79
- or !is_array($post['diagnostics_output'])) :
80
- $post['diagnostics_output'] = array();
81
- endif;
82
- update_option('feedwordpress_diagnostics_output', $post['diagnostics_output']);
 
83
 
84
- if (!isset($post['diagnostics_show'])
85
- or !is_array($post['diagnostics_show'])) :
86
- $post['diagnostics_show'] = array();
87
- endif;
88
- update_option('feedwordpress_diagnostics_show', $post['diagnostics_show']);
89
 
90
- if ($post['diagnostics_show']
91
- and in_array('updated_feeds:errors:persistent', $post['diagnostics_show'])) :
92
- update_option('feedwordpress_diagnostics_persistent_errors_hours', (int) $post['diagnostics_persistent_error_hours']);
93
  else :
94
- delete_option('feedwordpress_diagnostics_persistent_errors_hours');
95
  endif;
96
 
97
- if (in_array('email', $post['diagnostics_output'])) :
98
- $ded = $post['diagnostics_email_destination'];
99
- if ('mailto'==$ded) :
100
- $ded .= ':'.$post['diagnostics_email_destination_address'];
101
  endif;
102
 
103
- update_option('feedwordpress_diagnostics_email_destination', $ded);
104
  else :
105
- delete_option('feedwordpress_diagnostics_email_destination');
106
  endif;
107
 
108
- if (isset($post['feedwordpress_diagnostics_do'])) :
109
- foreach ($post['feedwordpress_diagnostics_do'] as $do => $value) :
110
- do_action('feedwordpress_diagnostics_do_'.$do, $post);
111
  endforeach;
112
  endif;
113
 
@@ -323,9 +321,9 @@ testing but absolutely inappropriate for a production server.</p>
323
  } /* FeedWordPressDiagnosticsPage::updates_box () */
324
 
325
  static function tests_box ($page, $box = NULL) {
326
- $url = MyPHP::request('http_test_url');
327
- $method = MyPHP::request('http_test_method');
328
- $xpath = MyPHP::request('http_test_xpath');
329
 
330
  $aMethods = array(
331
  'wp_remote_request',
@@ -405,38 +403,42 @@ function clone_http_test_args_keyvalue_prototype () {
405
  } /* FeedWordPressDiagnosticsPage::tests_box () */
406
 
407
  private $test_html;
408
- public function do_http_test ($post) {
409
- if (isset($post['http_test_url']) and isset($post['http_test_method'])) :
410
- $url = $post['http_test_url'];
 
411
 
412
  $args = array();
413
- if (isset($post['http_test_args_key'])) :
414
- foreach ($post['http_test_args_key'] as $idx => $name) :
 
415
  $name = trim($name);
416
  if (strlen($name) > 0) :
417
- $value = NULL;
418
- if (isset($post['http_test_args_value'])
419
- and isset($post['http_test_args_value'][$idx])) :
420
- $value = $post['http_test_args_value'][$idx];
 
421
  endif;
422
 
423
- if (preg_match('/^javascript:(.*)$/i', $value, $refs)) :
424
- if (function_exists('json_decode')) :
425
- $json_value = json_decode($refs[1]);
426
- if (!is_null($json_value)) :
427
  $value = $json_value;
428
  endif;
429
  endif;
430
  endif;
431
 
432
- $args[$name] = $value;
433
  endif;
434
  endforeach;
435
  endif;
436
 
437
- switch ($post['http_test_method']) :
438
  case 'wp_remote_request' :
439
  $out = wp_remote_request($url, $args);
 
440
  break;
441
  case 'FeedWordPie_File' :
442
  $out = new FeedWordPie_File($url);
@@ -444,36 +446,35 @@ function clone_http_test_args_keyvalue_prototype () {
444
  case 'FeedWordPress::fetch' :
445
  $out = FeedWordPress::fetch($url);
446
 
447
- if (isset($post['http_test_xpath'])) :
448
- if (strlen($post['http_test_xpath']) > 0) :
449
-
450
- $xpath = $post['http_test_xpath'];
451
-
452
- if ( !is_wp_error($out) ) :
453
- $expr = new FeedWordPressParsedPostMeta($xpath);
454
-
455
- $feed = new MagpieMockLink( $out, $url );
456
- $posts = $feed->live_posts();
457
-
458
- $post = new SyndicatedPost($posts[0], $feed);
459
- $meta = $expr->do_substitutions($post);
460
-
461
- $out = array(
462
- "post_title" => $post->entry->get_title(),
463
- "post_link" => $post->permalink(),
464
- "guid" => $post->guid(),
465
- "expression" => $xpath,
466
- "results" => $meta,
467
- "pie" => $out,
468
- );
469
- endif;
470
  endif;
471
  endif;
472
  break;
473
  endswitch;
474
 
475
- $this->test_html['url'] = $url;
476
- $this->test_html['http_test'] = esc_html(MyPHP::val($out));
477
  endif;
478
  } /* FeedWordPressDiagnosticsPage::do_http_test () */
479
 
25
  FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_diagnostics', /*capability=*/ 'manage_options');
26
 
27
  if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
28
+ $this->accept_POST();
29
+ do_action('feedwordpress_admin_page_diagnostics_save', null, $this);
30
  endif;
31
 
32
  ////////////////////////////////////////////////
68
  $this->close_sheet();
69
  } /* FeedWordPressDiagnosticsPage::display () */
70
 
71
+ public function do_requested () {
72
+ return ( ! is_null( self::what_requested() ) );
73
+ }
 
 
 
74
 
75
+ public function what_requested () {
76
+ return FeedWordPress::post( 'feedwordpress_diagnostics_do' );
77
+ }
78
+
79
+ function accept_POST () {
80
+ if ( self::save_requested() || self::do_requested() ) :
81
 
82
+ update_option( 'feedwordpress_debug', FeedWordPress::post( 'feedwordpress_debug' ) );
83
+ update_option( 'feedwordpress_secret_key', FeedWordPress::post( 'feedwordpress_secret_key' ) );
84
+
85
+ update_option( 'feedwordpress_diagnostics_output', FeedWordPress::post( 'diagnostics_output' ) );
86
+ update_option( 'feedwordpress_diagnostics_show', FeedWordPress::post( 'diagnostics_show' ) );
87
 
88
+ if ( FeedWordPress::post( 'diagnostics_show' )
89
+ and in_array( 'updated_feeds:errors:persistent', FeedWordPress::post( 'diagnostics_show' ) ) ) :
90
+ update_option('feedwordpress_diagnostics_persistent_errors_hours', (int) FeedWordPress::post( 'diagnostics_persistent_error_hours' ) );
91
  else :
92
+ delete_option( 'feedwordpress_diagnostics_persistent_errors_hours' );
93
  endif;
94
 
95
+ if ( in_array( 'email', FeedWordPress::post( 'diagnostics_output' ) ) ) :
96
+ $ded = FeedWordPress::post('diagnostics_email_destination' );
97
+ if ( 'mailto' == $ded ) :
98
+ $ded .= ':' . FeedWordPress::post('diagnostics_email_destination_address' );
99
  endif;
100
 
101
+ update_option( 'feedwordpress_diagnostics_email_destination', $ded );
102
  else :
103
+ delete_option( 'feedwordpress_diagnostics_email_destination' );
104
  endif;
105
 
106
+ if ( self::do_requested() ) :
107
+ foreach ( self::what_requested() as $do => $value) :
108
+ do_action( 'feedwordpress_diagnostics_do_'.$do );
109
  endforeach;
110
  endif;
111
 
321
  } /* FeedWordPressDiagnosticsPage::updates_box () */
322
 
323
  static function tests_box ($page, $box = NULL) {
324
+ $url = FeedWordPress::param( 'http_test_url' );
325
+ $method = FeedWordPress::param( 'http_test_method' );
326
+ $xpath = FeedWordPress::param( 'http_test_xpath' );
327
 
328
  $aMethods = array(
329
  'wp_remote_request',
403
  } /* FeedWordPressDiagnosticsPage::tests_box () */
404
 
405
  private $test_html;
406
+ public function do_http_test () {
407
+ $url = FeedWordPress::post( 'http_test_url' );
408
+ $method = FeedWordPress::post( 'http_test_method' );
409
+ if ( ! ( is_null( $url ) || is_null( $method ) ) ) :
410
 
411
  $args = array();
412
+ $keys = FeedWordPress::post( 'http_test_args_key' );
413
+ if ( ! is_null( $keys ) ) :
414
+ foreach ( $keys as $idx => $name ) :
415
  $name = trim($name);
416
  if (strlen($name) > 0) :
417
+ $values = FeedWordPress::post('http_test_args_value', array() );
418
+
419
+ $value = null;
420
+ if ( isset( $values[ $idx ] ) ) :
421
+ $value = $values[$idx];
422
  endif;
423
 
424
+ if ( preg_match('/^javascript:(.*)$/i', $value, $refs) ) :
425
+ if ( function_exists('json_decode') ) :
426
+ $json_value = json_decode( $refs[1] );
427
+ if ( ! is_null($json_value) ) :
428
  $value = $json_value;
429
  endif;
430
  endif;
431
  endif;
432
 
433
+ $args[ $name ] = $value;
434
  endif;
435
  endforeach;
436
  endif;
437
 
438
+ switch ( $method ) :
439
  case 'wp_remote_request' :
440
  $out = wp_remote_request($url, $args);
441
+ unset( $out[ 'http_response' ] );
442
  break;
443
  case 'FeedWordPie_File' :
444
  $out = new FeedWordPie_File($url);
446
  case 'FeedWordPress::fetch' :
447
  $out = FeedWordPress::fetch($url);
448
 
449
+ $s_xpath = FeedWordPress::post( 'http_test_xpath', '' );
450
+ if ( strlen( $s_xpath ) > 0 ) :
451
+
452
+ $xpath = FeedWordPress::post( 'http_test_xpath' );
453
+
454
+ if ( !is_wp_error($out) ) :
455
+ $expr = new FeedWordPressParsedPostMeta($xpath);
456
+
457
+ $feed = new MagpieMockLink( $out, $url );
458
+ $posts = $feed->live_posts();
459
+
460
+ $post = new SyndicatedPost($posts[0], $feed);
461
+ $meta = $expr->do_substitutions($post);
462
+
463
+ $out = array(
464
+ "post_title" => $post->entry->get_title(),
465
+ "post_link" => $post->permalink(),
466
+ "guid" => $post->guid(),
467
+ "expression" => $xpath,
468
+ "results" => $meta,
469
+ "pie" => $out,
470
+ );
 
471
  endif;
472
  endif;
473
  break;
474
  endswitch;
475
 
476
+ $this->test_html['url'] = $url;
477
+ $this->test_html['http_test'] = esc_html( MyPHP::val($out) );
478
  endif;
479
  } /* FeedWordPressDiagnosticsPage::do_http_test () */
480
 
feeds-page.php CHANGED
@@ -103,7 +103,7 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
103
  } /* FeedWordPressFeedsPage constructor */
104
 
105
  function display () {
106
- global $fwp_post;
107
  global $post_source;
108
 
109
  $this->boxes_by_methods = array(
@@ -125,9 +125,10 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
125
  $source = $this->dispatch;
126
  endif;
127
 
128
- if (isset($_REQUEST['feedfinder'])
129
- or (isset($_REQUEST['action']) and $_REQUEST['action']=='feedfinder')
130
- or (isset($_REQUEST['action']) and $_REQUEST['action']==FWP_SYNDICATE_NEW)) :
 
131
  // If this is a POST, validate source and user credentials
132
  FeedWordPressCompatibility::validate_http_request(/*action=*/ $source, /*capability=*/ 'manage_links');
133
 
@@ -429,8 +430,8 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
429
  <td><?php
430
  $this->setting_radio_control('update_incremental', 'update_incremental',
431
  /*options=*/ array(
432
- 'incremental' => '<strong>Incremental.</strong> When items no longer appear on the feed, keep them in the WordPress posts table.',
433
- 'complete' => '<strong>Complete.</strong> When items no longer appear on the feed, they are obsolete; retire them from the WordPress posts table.',
434
  ),
435
  /*params=*/ array(
436
  'setting-default' => NULL,
@@ -819,11 +820,11 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
819
  function display_feedfinder () {
820
  global $wpdb;
821
 
822
- $lookup = (isset($_REQUEST['lookup']) ? $_REQUEST['lookup'] : NULL);
823
 
824
- $auth = MyPHP::request('link_rss_auth_method');
825
- $username = MyPHP::request('link_rss_username');
826
- $password = MyPHP::request('link_rss_password');
827
  $credentials = array(
828
  "authentication" => $auth,
829
  "username" => $username,
@@ -1098,8 +1099,7 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
1098
  } /* FeedWordPressFeedsPage::display_feedfinder() */
1099
 
1100
  function display_alt_feed_box ($lookup, $params = false) {
1101
- global $fwp_post;
1102
-
1103
  if (is_bool($params)) :
1104
  $params = array("alt" => $params);
1105
  endif;
@@ -1162,26 +1162,36 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
1162
  <?php
1163
  } /* FeedWordPressFeedsPage::display_alt_feed_box() */
1164
 
1165
- function save_settings ($post) {
1166
  if ($this->for_feed_settings()) :
1167
-
1168
- if (isset($post['link_rss_params_key'])) :
 
 
 
 
 
1169
  $qp = array();
1170
- foreach ($post['link_rss_params_key'] as $index => $key) :
1171
  if (strlen($key) > 0) :
1172
- if (isset($post['link_rss_params_value'][$index])
1173
- and strlen($post['link_rss_params_value'][$index])) :
1174
- $value = $post['link_rss_params_value'][$index];
1175
- $qp[] = array($key, $value);
 
 
 
1176
  endif;
1177
  endif;
1178
  endforeach;
1179
  $this->update_setting('query parameters', serialize($qp));
 
1180
  endif;
1181
 
1182
  // custom feed settings first
1183
- foreach ($post['notes'] as $mn) :
1184
- $mn['key0'] = (isset($mn['key0']) ? trim($mn['key0']) : NULL);
 
1185
  $mn['key1'] = trim($mn['key1']);
1186
  if (preg_match("\007^(("
1187
  .implode(')|(',$this->special_settings)
@@ -1204,114 +1214,125 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
1204
 
1205
  foreach (array('name', 'description', 'url') as $what) :
1206
  // We have a checkbox for "No," so if it's unchecked, mark as "Yes."
1207
- $this->link->settings["hardcode {$what}"] = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes');
1208
  if (FeedWordPress::affirmative($this->link->settings, "hardcode {$what}")) :
1209
- $this->link->link->{'link_'.$what} = $post['link'.$what];
1210
  endif;
1211
  endforeach;
1212
-
1213
  // Update scheduling
1214
- if (isset($post['update_schedule'])) :
1215
- $this->link->settings['update/hold'] = $post['update_schedule'];
 
1216
  endif;
1217
 
1218
- if (isset($post['use_default_update_window']) and strtolower($post['use_default_update_window'])=='yes') :
 
 
1219
  unset($this->link->settings['update/window']);
1220
- elseif (isset($post['update_window'])):
1221
- if ((int) $post['update_window'] > 0) :
1222
- $this->link->settings['update/window'] = (int) $post['update_window'];
 
1223
  endif;
1224
  endif;
1225
 
1226
  else :
1227
  // Global
1228
- update_option('feedwordpress_cat_id', $post['syndication_category']);
1229
 
1230
- if (!isset($post['automatic_updates']) or !in_array($post['automatic_updates'], array('init', 'shutdown'))) :
1231
- $automatic_updates = NULL;
1232
- else :
1233
- $automatic_updates = $post['automatic_updates'];
1234
  endif;
1235
  update_option('feedwordpress_automatic_updates', $automatic_updates);
1236
 
1237
- if (isset($post['update_window'])):
1238
- if ((int) $post['update_window'] > 0) :
1239
- update_option('feedwordpress_update_window', (int) $post['update_window']);
 
 
1240
  endif;
1241
  endif;
1242
 
1243
- update_option('feedwordpress_update_time_limit', ($post['update_time_limit']=='yes')?(int) $post['time_limit_seconds']:0);
 
 
 
 
 
1244
 
1245
  foreach (array('name', 'description', 'url') as $what) :
1246
  // We have a checkbox for "No," so if it's unchecked, mark as "Yes."
1247
- $hardcode = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes');
1248
- update_option("feedwordpress_hardcode_{$what}", $hardcode);
1249
  endforeach;
1250
 
1251
  endif;
1252
-
1253
- if (isset($post['update_pause'])) :
1254
- $this->update_setting('update/pause', $post['update_pause']);
 
1255
  endif;
1256
 
1257
- if (isset($post['fetch_timeout'])) :
1258
- if (isset($post['fetch_timeout_default']) and $post['fetch_timeout_default']=='yes') :
1259
- $timeout = NULL;
1260
- else :
1261
- $timeout = $post['fetch_timeout'];
1262
  endif;
1263
 
1264
- if (is_int($timeout)) :
1265
- $timeout = intval($timeout);
1266
  endif;
1267
- $this->update_setting('fetch timeout', $timeout);
1268
  endif;
1269
-
1270
- if (isset($post['update_incremental'])) :
1271
- $this->update_setting('update_incremental', $post['update_incremental']);
 
1272
  endif;
1273
 
1274
- if (isset($post['tombstones'])) :
1275
- $this->update_setting('tombstones', $post['tombstones']);
 
1276
  endif;
1277
 
1278
- if (isset($post['update_minimum'])) :
1279
- $this->update_setting('update/minimum', $post['update_minimum']);
 
1280
  endif;
1281
 
 
1282
  if (
1283
- isset($post['link_rss_auth_method'])
1284
- and $post['link_rss_auth_method']
1285
- and ('-' != $post['link_rss_auth_method'])
1286
  ) :
1287
- $this->update_setting('http auth method', $post['link_rss_auth_method']);
1288
- else :
1289
- $this->update_setting('http auth method', NULL);
1290
  endif;
1291
-
 
 
1292
  if (
1293
- isset($post['link_rss_username'])
1294
- and (strlen($post['link_rss_username']) > 0)
1295
- and ('-' != $post['link_rss_auth_method'])
1296
  ) :
1297
- $this->update_setting('http username', $post['link_rss_username']);
1298
- else :
1299
- $this->update_setting('http username', NULL);
1300
  endif;
 
1301
 
 
1302
  if (
1303
- isset($post['link_rss_password'])
1304
- and (strlen($post['link_rss_password']) > 0)
1305
- and ('-' != $post['link_rss_auth_method'])
1306
  ) :
1307
- $this->update_setting('http password', $post['link_rss_password']);
1308
- else :
1309
- $this->update_setting('http password', NULL);
1310
  endif;
 
1311
 
1312
- $this->updatedPosts->accept_POST($post);
1313
 
1314
- parent::save_settings($post);
1315
  } /* FeedWordPressFeedsPage::save_settings() */
1316
 
1317
  } /* class FeedWordPressFeedsPage */
103
  } /* FeedWordPressFeedsPage constructor */
104
 
105
  function display () {
106
+
107
  global $post_source;
108
 
109
  $this->boxes_by_methods = array(
125
  $source = $this->dispatch;
126
  endif;
127
 
128
+ $feedfinder = FeedWordPress::param( 'feedfinder' );
129
+ $action = FeedWordPress::param( 'action' );
130
+ if ( $feedfinder || in_array( $action, array( 'feedfinder', FWP_SYNDICATE_NEW ) ) ) :
131
+
132
  // If this is a POST, validate source and user credentials
133
  FeedWordPressCompatibility::validate_http_request(/*action=*/ $source, /*capability=*/ 'manage_links');
134
 
430
  <td><?php
431
  $this->setting_radio_control('update_incremental', 'update_incremental',
432
  /*options=*/ array(
433
+ 'incremental' => '**Incremental.** When items no longer appear on the feed, keep them in the WordPress posts table.',
434
+ 'complete' => '**Complete.** When items no longer appear on the feed, they are obsolete; retire them from the WordPress posts table.',
435
  ),
436
  /*params=*/ array(
437
  'setting-default' => NULL,
820
  function display_feedfinder () {
821
  global $wpdb;
822
 
823
+ $lookup = FeedWordPress::param( 'lookup' );
824
 
825
+ $auth = FeedWordPress::param( 'link_rss_auth_method' );
826
+ $username = FeedWordPress::param( 'link_rss_username' );
827
+ $password = FeedWordPress::param( 'link_rss_password' );
828
  $credentials = array(
829
  "authentication" => $auth,
830
  "username" => $username,
1099
  } /* FeedWordPressFeedsPage::display_feedfinder() */
1100
 
1101
  function display_alt_feed_box ($lookup, $params = false) {
1102
+
 
1103
  if (is_bool($params)) :
1104
  $params = array("alt" => $params);
1105
  endif;
1162
  <?php
1163
  } /* FeedWordPressFeedsPage::display_alt_feed_box() */
1164
 
1165
+ function save_settings () {
1166
  if ($this->for_feed_settings()) :
1167
+
1168
+ $params_key = FeedWordPress::post( 'link_rss_params_key', array() );
1169
+
1170
+ if ( is_array( $params_key ) && count($params_key) > 0 ) :
1171
+
1172
+ $params_values = FeedWordPress::post( 'link_rss_params_value', array() );
1173
+
1174
  $qp = array();
1175
+ foreach ( $params_key as $index => $key ) :
1176
  if (strlen($key) > 0) :
1177
+
1178
+ if ( isset( $params_values[ $index ] ) ) :
1179
+
1180
+ $params_value = $params_values[ $index ];
1181
+ if ( strlen($params_value) > 0 ) :
1182
+ $qp[] = array( $key, $params_value );
1183
+ endif;
1184
  endif;
1185
  endif;
1186
  endforeach;
1187
  $this->update_setting('query parameters', serialize($qp));
1188
+
1189
  endif;
1190
 
1191
  // custom feed settings first
1192
+ $param_notes = FeedWordPress::post( 'notes', array() );
1193
+ foreach ( $param_notes as $mn ) :
1194
+ $mn['key0'] = ( isset($mn['key0']) ? trim($mn['key0']) : null );
1195
  $mn['key1'] = trim($mn['key1']);
1196
  if (preg_match("\007^(("
1197
  .implode(')|(',$this->special_settings)
1214
 
1215
  foreach (array('name', 'description', 'url') as $what) :
1216
  // We have a checkbox for "No," so if it's unchecked, mark as "Yes."
1217
+ $this->link->settings["hardcode {$what}"] = FeedWordPress::post( "hardcode_{$what}", 'yes' );
1218
  if (FeedWordPress::affirmative($this->link->settings, "hardcode {$what}")) :
1219
+ $this->link->link->{'link_'.$what} = FeedWordPress::post( 'link' . $what );
1220
  endif;
1221
  endforeach;
1222
+
1223
  // Update scheduling
1224
+ $update_schedule = FeedWordPress::post( 'update_schedule' );
1225
+ if ( ! is_null( $update_schedule ) ) :
1226
+ $this->link->settings['update/hold'] = $update_schedule;
1227
  endif;
1228
 
1229
+ $use_default_update_window = FeedWordPress::post( 'use_default_update_window' );
1230
+ $update_window = FeedWordPress::post( 'update_window' );
1231
+ if ( FeedWordPress::affirmative( $use_default_update_window ) ) :
1232
  unset($this->link->settings['update/window']);
1233
+ elseif ( ! is_null( $update_window ) ) :
1234
+ $update_window = intval( $update_window );
1235
+ if ( $update_window > 0 ) :
1236
+ $this->link->settings['update/window'] = $update_window;
1237
  endif;
1238
  endif;
1239
 
1240
  else :
1241
  // Global
1242
+ update_option('feedwordpress_cat_id', FeedWordPress::post( 'syndication_category' ) );
1243
 
1244
+ $automatic_updates = FeedWordPress::post( 'automatic_updates' );
1245
+ if ( ! in_array( $automatic_updates, array( 'init', 'shutdown' ) ) ) :
1246
+ $automatic_updates = null;
 
1247
  endif;
1248
  update_option('feedwordpress_automatic_updates', $automatic_updates);
1249
 
1250
+ $update_window = FeedWordPress::post( 'update_window' );
1251
+ if ( ! is_null( $update_window ) ) :
1252
+ $update_window = intval( $update_window );
1253
+ if ( $update_window > 0 ) :
1254
+ update_option( 'feedwordpress_update_window', $update_window );
1255
  endif;
1256
  endif;
1257
 
1258
+ $update_time_limit = FeedWordPress::post( 'update_time_limit' );
1259
+ $time_limit_seconds = 0;
1260
+ if ( FeedWordPress::affirmative( $update_time_limit ) ) :
1261
+ $time_limit_seconds = intval( FeedWordPress::post( 'time_limit_seconds' ) );
1262
+ endif;
1263
+ update_option( 'feedwordpress_update_time_limit', $time_limit_seconds );
1264
 
1265
  foreach (array('name', 'description', 'url') as $what) :
1266
  // We have a checkbox for "No," so if it's unchecked, mark as "Yes."
1267
+ $hardcode = FeedWordPress::post( "hardcode_{$what}", 'yes' );
1268
+ update_option( "feedwordpress_hardcode_{$what}", $hardcode );
1269
  endforeach;
1270
 
1271
  endif;
1272
+
1273
+ $update_pause = FeedWordPress::post( 'update_pause' );
1274
+ if ( ! is_null( $update_pause ) ) :
1275
+ $this->update_setting( 'update/pause', $update_pause );
1276
  endif;
1277
 
1278
+ $fetch_timeout = FeedWordPress::post( 'fetch_timeout' );
1279
+ if ( ! is_null( $fetch_timeout ) ) :
1280
+ $fetch_timeout_default = FeedWordPress::post( 'fetch_timeout_default' );
1281
+ if ( FeedWordPress::affirmative( $fetch_timeout_default ) ) :
1282
+ $fetch_timeout = null;
1283
  endif;
1284
 
1285
+ if ( is_int( $fetch_timeout ) ) :
1286
+ $fetch_timeout = intval( $fetch_timeout );
1287
  endif;
1288
+ $this->update_setting( 'fetch timeout', $fetch_timeout );
1289
  endif;
1290
+
1291
+ $update_incremental = FeedWordPress::post( 'update_incremental' );
1292
+ if ( ! is_null( $update_incremental ) ) :
1293
+ $this->update_setting( 'update_incremental', $update_incremental );
1294
  endif;
1295
 
1296
+ $tombstones = FeedWordPress::post( 'tombstones' );
1297
+ if ( ! is_null( $tombstones ) ) :
1298
+ $this->update_setting('tombstones', $tombstones );
1299
  endif;
1300
 
1301
+ $update_minimum = FeedWordPress::post( 'update_minimum' );
1302
+ if ( ! is_null( $update_minimum ) ) :
1303
+ $this->update_setting( 'update/minimum', $update_minimum );
1304
  endif;
1305
 
1306
+ $link_rss_auth_method = FeedWordPress::post( 'link_rss_auth_method' );
1307
  if (
1308
+ ! $link_rss_auth_method
1309
+ || '-' == $link_rss_auth_method
 
1310
  ) :
1311
+ $link_rss_auth_method = null;
 
 
1312
  endif;
1313
+ $this->update_setting( 'http auth method', $link_rss_auth_method );
1314
+
1315
+ $link_rss_username = FeedWordPress::post( 'link_rss_username' );
1316
  if (
1317
+ ! $link_rss_username
1318
+ || is_null( $link_rss_auth_method )
 
1319
  ) :
1320
+ $link_rss_username = null;
 
 
1321
  endif;
1322
+ $this->update_setting( 'http username', $link_rss_username );
1323
 
1324
+ $link_rss_password = FeedWordPress::post( 'link_rss_password' );
1325
  if (
1326
+ strlen( $link_rss_password ) == 0
1327
+ || is_null( $link_rss_auth_method )
 
1328
  ) :
1329
+ $link_rss_password = null;
 
 
1330
  endif;
1331
+ $this->update_setting( 'http password', $link_rss_password );
1332
 
1333
+ $this->updatedPosts->accept_POST();
1334
 
1335
+ parent::save_settings();
1336
  } /* FeedWordPressFeedsPage::save_settings() */
1337
 
1338
  } /* class FeedWordPressFeedsPage */
feedwordpress.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: FeedWordPress
4
  Plugin URI: http://feedwordpress.radgeek.com/
5
  Description: simple and flexible Atom/RSS syndication for WordPress
6
- Version: 2022.0208
7
  Author: C. Johnson
8
  Author URI: https://feedwordpress.radgeek.com/contact/
9
  License: GPL
@@ -11,7 +11,7 @@ License: GPL
11
 
12
  /**
13
  * @package FeedWordPress
14
- * @version 2022.0208
15
  */
16
 
17
  # This plugin uses code derived from:
@@ -30,7 +30,7 @@ License: GPL
30
  ## CONSTANTS & DEFAULTS ############################################################
31
  ####################################################################################
32
 
33
- define ('FEEDWORDPRESS_VERSION', '2022.0208');
34
  define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://feedwordpress.radgeek.com/contact');
35
 
36
  if (!defined('FEEDWORDPRESS_BLEG')) :
@@ -48,11 +48,11 @@ define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors');
48
  define ('DEFAULT_UPDATE_PERIOD', 60); // value in minutes
49
  define ('FEEDWORDPRESS_DEFAULT_CHECKIN_INTERVAL', DEFAULT_UPDATE_PERIOD/10);
50
 
51
- if (isset($_REQUEST['feedwordpress_debug'])) :
52
- $feedwordpress_debug = sanitize_text_field($_REQUEST['feedwordpress_debug']);
53
- else :
54
- $feedwordpress_debug = get_option('feedwordpress_debug');
55
- endif;
56
 
57
  if (is_string($feedwordpress_debug)) :
58
  $feedwordpress_debug = ($feedwordpress_debug == 'yes');
@@ -126,9 +126,8 @@ if (count($unmetCoreDependencies) > 0) :
126
  require_once(ABSPATH . WPINC . "/class-feed.php");
127
  endif;
128
 
129
- // Dependences: modules packaged with FeedWordPress plugin
130
- $dir = dirname(__FILE__);
131
- require_once("${dir}/externals/myphp/myphp.class.php");
132
  require_once("${dir}/feedwordpressadminpage.class.php");
133
  require_once("${dir}/feedwordpresssettingsui.class.php");
134
  require_once("${dir}/feedwordpressdiagnostic.class.php");
@@ -155,19 +154,6 @@ require_once("${dir}/feedwordpresslocalpost.class.php");
155
  ## GLOBAL PARAMETERS ###############################################################
156
  ####################################################################################
157
 
158
- // $fwp_post used to be a global variable used to make it easier to cope
159
- // with the frustrating sometime presence of "Magic Quotes" in earlier
160
- // versions of PHP (<http://php.net/manual/en/security.magicquotes.php>).
161
- // Magic quotes were DEPRECATED as of PHP 5.3.0, and REMOVED as of PHP
162
- // 5.4.0, so for the time being $fwp_post just gets a copy of $_POST.
163
- global $fwp_post;
164
-
165
- if (is_array($_POST)) :
166
- $fwp_post = $_POST;
167
- else:
168
- $fwp_post = null;
169
- endif;
170
-
171
  // Get the path relative to the plugins directory in which FWP is stored
172
  preg_match (
173
  '|'.preg_quote(WP_PLUGIN_DIR).'/(.+)$|',
@@ -705,11 +691,7 @@ class FeedWordPress {
705
  // This is a horrible fucking kludge that I have to do because the
706
  // admin notice code is triggered before the code that updates the
707
  // setting.
708
- if (isset($_REQUEST['feedwordpress_debug'])) :
709
- $feedwordpress_debug = sanitize_text_field($_REQUEST['feedwordpress_debug']);
710
- else :
711
- $feedwordpress_debug = get_option('feedwordpress_debug');
712
- endif;
713
 
714
  FeedWordPressSettingsUI::get_template_part('notice-debug-mode', $feedwordpress_debug, 'html');
715
  } /* function FeedWordPress::check_debug () */
@@ -967,16 +949,16 @@ class FeedWordPress {
967
 
968
  public function last_update_all () {
969
  $last = get_option('feedwordpress_last_update_all');
970
- if ($this->has_secret() and MyPHP::request('automatic_update')) :
971
  $last = 1; // A long, long time ago.
972
- elseif ($this->has_secret() and MyPHP::request('last_update_all')) :
973
- $last = MyPHP::request('last_update_all');
974
  endif;
975
  return $last;
976
  } /* FeedWordPress::last_update_all () */
977
 
978
  public function force_update_all () {
979
- return ($this->has_secret() and MyPHP::request('force_update_feeds'));
980
  } /* FeedWordPress::force_update_all () */
981
 
982
  public function stale () {
@@ -1060,7 +1042,7 @@ class FeedWordPress {
1060
  wp_die( sprintf( __( 'You cannot retire this item. %s is currently editing.' ), $user->display_name ) );
1061
  endif;
1062
 
1063
- if (MyPHP::request('fwp_post_delete')=='zap') :
1064
  FeedWordPress::diagnostic('syndicated_posts', 'Zapping existing post # '.$p->ID.' "'.$p->post_title.'" due to user request.');
1065
 
1066
  $old_status = $post->post_status;
@@ -1101,11 +1083,11 @@ class FeedWordPress {
1101
  // magic parameter is activated, the WordPress trashcan is
1102
  // temporarily de-activated.
1103
 
1104
- if (MyPHP::request('fwp_post_delete')=='nuke') :
1105
  // Get post ID #
1106
- $post_id = MyPHP::request('post');
1107
  if (!$post_id) :
1108
- $post_id = MyPHP::request('post_ID');
1109
  endif;
1110
 
1111
  // Make sure we've got the right nonce and all that.
@@ -1114,11 +1096,11 @@ class FeedWordPress {
1114
  // If so, disable the trashcan.
1115
  define('EMPTY_TRASH_DAYS', 0);
1116
 
1117
- elseif (MyPHP::request('fwp_post_delete')=='zap' OR MyPHP::request('fwp_post_delete') == 'unzap') :
1118
  // Get post ID #
1119
- $post_id = MyPHP::request('post');
1120
  if (!$post_id) :
1121
- $post_id = MyPHP::request('post_ID');
1122
  endif;
1123
 
1124
  // Make sure we've got the right nonce and all that
@@ -1134,15 +1116,15 @@ class FeedWordPress {
1134
  } /* FeedWordPress::admin_api () */
1135
 
1136
  public function all_admin_notices () {
1137
- if (MyPHP::request('zapped')) :
1138
- $n = intval(MyPHP::request('zapped'));
1139
  ?>
1140
  <div id="message" class="updated"><p><?php print esc_html( $n ); ?> syndicated item<?php print esc_html( $n != 1 ? 's' : '' ); ?> zapped. <strong>These items will not be re-syndicated.</strong> If this was a mistake, you must <strong>immediately</strong> Un-Zap them in the Zapped items section to avoid losing the data.</p></div>
1141
  <?php
1142
  endif;
1143
 
1144
- if (MyPHP::request('unzapped')) :
1145
- $n = intval(MyPHP::request('unzapped'));
1146
  ?>
1147
  <div id="message" class="updated"><p><?php print esc-html( $n ); ?> syndicated item<?php print esc_html( $n != 1 ? 's' : '' ) ?> un-zapped and restored to normal.</p></div>
1148
  <?php
@@ -1311,7 +1293,7 @@ class FeedWordPress {
1311
  } /* FeedWordPress::fwp_feeds () */
1312
 
1313
  public function fwp_feedcontents () {
1314
- $feed_id = MyPHP::request('feed_id');
1315
 
1316
  // Let's load up some data from the feed . . .
1317
  $feed = $this->subscription($feed_id);
@@ -1344,9 +1326,9 @@ class FeedWordPress {
1344
  } /* FeedWordPress::fwp_feedcontents () */
1345
 
1346
  public function fwp_xpathtest () {
1347
- $xpath = MyPHP::request('xpath');
1348
- $feed_id = MyPHP::request('feed_id');
1349
- $post_id = MyPHP::request('post_id');
1350
 
1351
  $expr = new FeedWordPressParsedPostMeta($xpath);
1352
 
@@ -1552,7 +1534,7 @@ class FeedWordPress {
1552
  } /* FeedWordPress::clear_cache_magic_url() */
1553
 
1554
  public function clear_cache_requested () {
1555
- return MyPHP::request('clear_cache');
1556
  } /* FeedWordPress::clear_cache_requested() */
1557
 
1558
  public function update_magic_url () {
@@ -1562,7 +1544,7 @@ class FeedWordPress {
1562
  if (self::update_requested()) :
1563
  /*DBG*/ header("Content-Type: text/plain");
1564
 
1565
- $this->update_hooked = "Initiating a CRON JOB CHECK-IN ON UPDATE SCHEDULE due to URL parameter = ".trim($this->val($_REQUEST['update_feedwordpress']));
1566
 
1567
  $this->update($this->update_requested_url());
1568
 
@@ -1594,15 +1576,18 @@ class FeedWordPress {
1594
  } /* FeedWordPress::update_magic_url () */
1595
 
1596
  public static function update_requested () {
1597
- return MyPHP::request('update_feedwordpress');
1598
  } /* FeedWordPress::update_requested() */
1599
 
1600
  public function update_requested_url () {
1601
  $ret = null;
1602
 
1603
- if (($_REQUEST['update_feedwordpress']=='*')
1604
- or (preg_match('|^[a-z]+://.*|i', $_REQUEST['update_feedwordpress']))) :
1605
- $ret = $_REQUEST['update_feedwordpress'];
 
 
 
1606
  endif;
1607
 
1608
  return $ret;
@@ -2012,14 +1997,29 @@ class FeedWordPress {
2012
  } /* FeedWordPress::cache_lifetime () */
2013
 
2014
  # Utility functions for handling text settings
2015
- static function negative ($f, $setting) {
 
 
 
 
 
 
 
 
 
 
 
 
 
2016
  $nego = array ('n', 'no', 'f', 'false');
2017
- return (isset($f[$setting]) and in_array(strtolower($f[$setting]), $nego));
 
2018
  } /* FeedWordPress::negative () */
2019
 
2020
- static function affirmative ($f, $setting) {
2021
  $affirmo = array ('y', 'yes', 't', 'true', 1);
2022
- return (isset($f[$setting]) and in_array(strtolower($f[$setting]), $affirmo));
 
2023
  } /* FeedWordPress::affirmative () */
2024
 
2025
  # Internal debugging functions
@@ -2030,7 +2030,7 @@ class FeedWordPress {
2030
  $output = get_option('feedwordpress_diagnostics_output', array());
2031
  $dlog = get_option('feedwordpress_diagnostics_log', array());
2032
 
2033
- $diagnostic_nesting = count(explode(":", $level));
2034
 
2035
  if (FeedWordPressDiagnostic::is_on($level)) :
2036
  foreach ($output as $method) :
@@ -2042,14 +2042,14 @@ class FeedWordPress {
2042
  break;
2043
  case 'echo_in_cronjob' :
2044
  if (self::update_requested()) :
2045
- echo self::log_prefix()." ".$out."\n";
2046
  endif;
2047
  break;
2048
  case 'admin_footer' :
2049
  $feedwordpress_admin_footer[] = $out;
2050
  break;
2051
  case 'error_log' :
2052
- error_log(self::log_prefix().' '.$out);
2053
  break;
2054
  case 'email' :
2055
 
@@ -2075,7 +2075,7 @@ class FeedWordPress {
2075
  } /* FeedWordPress::diagnostic () */
2076
 
2077
  public function email_diagnostics_override () {
2078
- return ($this->has_secret() and isset($_REQUEST['feedwordpress_email_diagnostics']) and !!$_REQUEST['feedwordpress_email_diagnostics']);
2079
  } /* FeedWordPress::email_diagnostics_override () */
2080
 
2081
  public function has_emailed_diagnostics ($dlog) {
@@ -2233,7 +2233,7 @@ EOMAIL;
2233
  static function admin_footer () {
2234
  global $feedwordpress_admin_footer;
2235
  foreach ($feedwordpress_admin_footer as $line) :
2236
- echo '<div><pre>'.$line.'</pre></div>';
2237
  endforeach;
2238
  } /* FeedWordPress::admin_footer () */
2239
 
@@ -2284,14 +2284,39 @@ EOMAIL;
2284
  // compatibility with add-ons, older code, etc. Maybe someday they
2285
  // will go away.
2286
  // -------------------------------------------------------------------
2287
- static function param ($key, $type = 'REQUEST', $default = null) {
2288
- return MyPHP::param($key, $default, $type);
2289
  } /* FeedWordPress::param () */
2290
 
2291
- static function post ($key, $default = null) {
2292
- return MyPHP::post($key, $default);
2293
  } /* FeedWordPress::post () */
2294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2295
  static function val ($v, $no_newlines = false) {
2296
  return MyPHP::val($v, $no_newlines);
2297
  } /* FeedWordPress::val () */
3
  Plugin Name: FeedWordPress
4
  Plugin URI: http://feedwordpress.radgeek.com/
5
  Description: simple and flexible Atom/RSS syndication for WordPress
6
+ Version: 2022.0222
7
  Author: C. Johnson
8
  Author URI: https://feedwordpress.radgeek.com/contact/
9
  License: GPL
11
 
12
  /**
13
  * @package FeedWordPress
14
+ * @version 2022.0222
15
  */
16
 
17
  # This plugin uses code derived from:
30
  ## CONSTANTS & DEFAULTS ############################################################
31
  ####################################################################################
32
 
33
+ define ('FEEDWORDPRESS_VERSION', '2022.0222');
34
  define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://feedwordpress.radgeek.com/contact');
35
 
36
  if (!defined('FEEDWORDPRESS_BLEG')) :
48
  define ('DEFAULT_UPDATE_PERIOD', 60); // value in minutes
49
  define ('FEEDWORDPRESS_DEFAULT_CHECKIN_INTERVAL', DEFAULT_UPDATE_PERIOD/10);
50
 
51
+ // Dependencies: modules packaged with FeedWordPress plugin
52
+ $dir = dirname( __FILE__ );
53
+ require_once("${dir}/externals/myphp/myphp.class.php");
54
+
55
+ $feedwordpress_debug = FeedWordPress::param( 'feedwordpress_debug', get_option('feedwordpress_debug') );
56
 
57
  if (is_string($feedwordpress_debug)) :
58
  $feedwordpress_debug = ($feedwordpress_debug == 'yes');
126
  require_once(ABSPATH . WPINC . "/class-feed.php");
127
  endif;
128
 
129
+ // Dependencies: modules packaged with FeedWordPress plugin
130
+ $dir = dirname( __FILE__ );
 
131
  require_once("${dir}/feedwordpressadminpage.class.php");
132
  require_once("${dir}/feedwordpresssettingsui.class.php");
133
  require_once("${dir}/feedwordpressdiagnostic.class.php");
154
  ## GLOBAL PARAMETERS ###############################################################
155
  ####################################################################################
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  // Get the path relative to the plugins directory in which FWP is stored
158
  preg_match (
159
  '|'.preg_quote(WP_PLUGIN_DIR).'/(.+)$|',
691
  // This is a horrible fucking kludge that I have to do because the
692
  // admin notice code is triggered before the code that updates the
693
  // setting.
694
+ $feedwordpress_debug = FeedWordPress::param( 'feedwordpress_debug', get_option( 'feedwordpress_debug' ) );
 
 
 
 
695
 
696
  FeedWordPressSettingsUI::get_template_part('notice-debug-mode', $feedwordpress_debug, 'html');
697
  } /* function FeedWordPress::check_debug () */
949
 
950
  public function last_update_all () {
951
  $last = get_option('feedwordpress_last_update_all');
952
+ if ( $this->has_secret() and FeedWordPress::param('automatic_update') ) :
953
  $last = 1; // A long, long time ago.
954
+ elseif ( $this->has_secret() and FeedWordPress::param('last_update_all') ) :
955
+ $last = FeedWordPress::param( 'last_update_all' );
956
  endif;
957
  return $last;
958
  } /* FeedWordPress::last_update_all () */
959
 
960
  public function force_update_all () {
961
+ return ($this->has_secret() and FeedWordPress::param( 'force_update_feeds' ));
962
  } /* FeedWordPress::force_update_all () */
963
 
964
  public function stale () {
1042
  wp_die( sprintf( __( 'You cannot retire this item. %s is currently editing.' ), $user->display_name ) );
1043
  endif;
1044
 
1045
+ if (FeedWordPress::param( 'fwp_post_delete' ) == 'zap') :
1046
  FeedWordPress::diagnostic('syndicated_posts', 'Zapping existing post # '.$p->ID.' "'.$p->post_title.'" due to user request.');
1047
 
1048
  $old_status = $post->post_status;
1083
  // magic parameter is activated, the WordPress trashcan is
1084
  // temporarily de-activated.
1085
 
1086
+ if (FeedWordPress::param( 'fwp_post_delete' ) == 'nuke') :
1087
  // Get post ID #
1088
+ $post_id = FeedWordPress::param( 'post' );
1089
  if (!$post_id) :
1090
+ $post_id = FeedWordPress::param( 'post_ID' );
1091
  endif;
1092
 
1093
  // Make sure we've got the right nonce and all that.
1096
  // If so, disable the trashcan.
1097
  define('EMPTY_TRASH_DAYS', 0);
1098
 
1099
+ elseif ( FeedWordPress::param( 'fwp_post_delete' ) == 'zap' || FeedWordPress::param( 'fwp_post_delete' ) == 'unzap' ) :
1100
  // Get post ID #
1101
+ $post_id = FeedWordPress::param( 'post' );
1102
  if (!$post_id) :
1103
+ $post_id = FeedWordPress::param( 'post_ID' );
1104
  endif;
1105
 
1106
  // Make sure we've got the right nonce and all that
1116
  } /* FeedWordPress::admin_api () */
1117
 
1118
  public function all_admin_notices () {
1119
+ if (FeedWordPress::param( 'zapped' )) :
1120
+ $n = intval( FeedWordPress::param( 'zapped' ) );
1121
  ?>
1122
  <div id="message" class="updated"><p><?php print esc_html( $n ); ?> syndicated item<?php print esc_html( $n != 1 ? 's' : '' ); ?> zapped. <strong>These items will not be re-syndicated.</strong> If this was a mistake, you must <strong>immediately</strong> Un-Zap them in the Zapped items section to avoid losing the data.</p></div>
1123
  <?php
1124
  endif;
1125
 
1126
+ if ( FeedWordPress::param( 'unzapped' ) ) :
1127
+ $n = intval( FeedWordPress::param( 'unzapped' ) );
1128
  ?>
1129
  <div id="message" class="updated"><p><?php print esc-html( $n ); ?> syndicated item<?php print esc_html( $n != 1 ? 's' : '' ) ?> un-zapped and restored to normal.</p></div>
1130
  <?php
1293
  } /* FeedWordPress::fwp_feeds () */
1294
 
1295
  public function fwp_feedcontents () {
1296
+ $feed_id = FeedWordPress::param( 'feed_id' );
1297
 
1298
  // Let's load up some data from the feed . . .
1299
  $feed = $this->subscription($feed_id);
1326
  } /* FeedWordPress::fwp_feedcontents () */
1327
 
1328
  public function fwp_xpathtest () {
1329
+ $xpath = FeedWordPress::param( 'xpath' );
1330
+ $feed_id = FeedWordPress::param( 'feed_id' );
1331
+ $post_id = FeedWordPress::param( 'post_id' );
1332
 
1333
  $expr = new FeedWordPressParsedPostMeta($xpath);
1334
 
1534
  } /* FeedWordPress::clear_cache_magic_url() */
1535
 
1536
  public function clear_cache_requested () {
1537
+ return FeedWordPress::param( 'clear_cache' );
1538
  } /* FeedWordPress::clear_cache_requested() */
1539
 
1540
  public function update_magic_url () {
1544
  if (self::update_requested()) :
1545
  /*DBG*/ header("Content-Type: text/plain");
1546
 
1547
+ $this->update_hooked = "Initiating a CRON JOB CHECK-IN ON UPDATE SCHEDULE due to URL parameter = " . trim( $this->val( FeedWordPress::param('update_feedwordpress' ) ) );
1548
 
1549
  $this->update($this->update_requested_url());
1550
 
1576
  } /* FeedWordPress::update_magic_url () */
1577
 
1578
  public static function update_requested () {
1579
+ return FeedWordPress::param( 'update_feedwordpress' );
1580
  } /* FeedWordPress::update_requested() */
1581
 
1582
  public function update_requested_url () {
1583
  $ret = null;
1584
 
1585
+ $uf = FeedWordPress::update_requested();
1586
+ if (
1587
+ ( '*' == $uf )
1588
+ || ( preg_match( '|^[a-z]+://.*|i', $uf ) )
1589
+ ) :
1590
+ $ret = $uf;
1591
  endif;
1592
 
1593
  return $ret;
1997
  } /* FeedWordPress::cache_lifetime () */
1998
 
1999
  # Utility functions for handling text settings
2000
+ static function get_field( $f, $setting = null ) {
2001
+
2002
+ $ret = $f;
2003
+ if ( ! is_null( $setting ) ) :
2004
+ $ret = null;
2005
+ if ( array_key_exists( $setting, $f ) ) :
2006
+ $ret = $f[ $setting ];
2007
+ endif;
2008
+ endif;
2009
+ return $ret;
2010
+
2011
+ } /* FeedWordPress::get_field () */
2012
+
2013
+ static function negative ($f, $setting = null) {
2014
  $nego = array ('n', 'no', 'f', 'false');
2015
+ $q = self::get_field( $f, $setting );
2016
+ return in_array( strtolower( trim( $q ) ), $nego );
2017
  } /* FeedWordPress::negative () */
2018
 
2019
+ static function affirmative ($f, $setting = null) {
2020
  $affirmo = array ('y', 'yes', 't', 'true', 1);
2021
+ $q = self::get_field( $f, $setting );
2022
+ return in_array( strtolower( trim( $q ) ), $affirmo );
2023
  } /* FeedWordPress::affirmative () */
2024
 
2025
  # Internal debugging functions
2030
  $output = get_option('feedwordpress_diagnostics_output', array());
2031
  $dlog = get_option('feedwordpress_diagnostics_log', array());
2032
 
2033
+ $diagnostic_nesting = count( explode( ":", $level ) );
2034
 
2035
  if (FeedWordPressDiagnostic::is_on($level)) :
2036
  foreach ($output as $method) :
2042
  break;
2043
  case 'echo_in_cronjob' :
2044
  if (self::update_requested()) :
2045
+ echo self::log_prefix() . ' ' . esc_html( $out ) . "\n";
2046
  endif;
2047
  break;
2048
  case 'admin_footer' :
2049
  $feedwordpress_admin_footer[] = $out;
2050
  break;
2051
  case 'error_log' :
2052
+ error_log(self::log_prefix() . ' ' . $out);
2053
  break;
2054
  case 'email' :
2055
 
2075
  } /* FeedWordPress::diagnostic () */
2076
 
2077
  public function email_diagnostics_override () {
2078
+ return ( $this->has_secret() and ! ! FeedWordPress::param( 'feedwordpress_email_diagnostics' ) );
2079
  } /* FeedWordPress::email_diagnostics_override () */
2080
 
2081
  public function has_emailed_diagnostics ($dlog) {
2233
  static function admin_footer () {
2234
  global $feedwordpress_admin_footer;
2235
  foreach ($feedwordpress_admin_footer as $line) :
2236
+ echo '<div><pre>' . esc_html( $line ) . '</pre></div>';
2237
  endforeach;
2238
  } /* FeedWordPress::admin_footer () */
2239
 
2284
  // compatibility with add-ons, older code, etc. Maybe someday they
2285
  // will go away.
2286
  // -------------------------------------------------------------------
2287
+ static function param( $key, $type = 'REQUEST', $default = null, $sanitizer = null ) {
2288
+ return self::sanitized_parameter( MyPHP::param( $key, $default, $type ), $sanitizer );
2289
  } /* FeedWordPress::param () */
2290
 
2291
+ static function post( $key, $default = null, $sanitizer = null ) {
2292
+ return self::sanitized_parameter( MyPHP::post( $key, $default, $type ), $sanitizer );
2293
  } /* FeedWordPress::post () */
2294
 
2295
+ static function shallow_sanitize( $item, $sanitizer = null ) {
2296
+ if ( $sanitizer == 'raw' ) :
2297
+ $value = $item;
2298
+ elseif ( $sanitizer == 'textarea' ) :
2299
+ $value = sanitize_textarea_field( $item );
2300
+ else :
2301
+ $value = sanitize_text_field( $item );
2302
+ endif;
2303
+ return $value;
2304
+ }
2305
+
2306
+ static function sanitized_parameter( $value, $sanitizer = null ) {
2307
+ if ( $sanitizer === 'raw' || is_scalar( $value ) ) :
2308
+ $ret = self::shallow_sanitize( $value, $sanitizer );
2309
+ elseif ( is_array( $value ) ) :
2310
+ $ret = array();
2311
+ foreach ( $value as $key => $item ) :
2312
+ $ret[ $key ] = self::sanitized_parameter( $item, $sanitizer );
2313
+ endforeach;
2314
+ else :
2315
+ $ret = null; // "Sanitized" objects or resources currently get nothing.
2316
+ endif;
2317
+ return $ret;
2318
+ }
2319
+
2320
  static function val ($v, $no_newlines = false) {
2321
  return MyPHP::val($v, $no_newlines);
2322
  } /* FeedWordPress::val () */
feedwordpress.wp-admin.post-edit.functions.php CHANGED
@@ -54,9 +54,12 @@ function feedwordpress_post_edit_controls () {
54
  endif;
55
  } /* function feedwordpress_post_edit_controls () */
56
 
57
- function feedwordpress_save_post_edit_controls ( $post_id ) {
58
  global $post;
59
- if (!isset($_POST['feedwordpress_noncename']) or !wp_verify_nonce($_POST['feedwordpress_noncename'], plugin_basename(__FILE__))) :
 
 
 
60
  return $post_id;
61
  endif;
62
 
@@ -69,12 +72,15 @@ function feedwordpress_save_post_edit_controls ( $post_id ) {
69
  // The data in $_POST is for applying only to the post actually
70
  // in the edit window, i.e. $post
71
  if ($post_id != $post->ID) :
72
- return $post_id;
73
  endif;
74
 
75
  // Check permissions
76
  $cap[0] = 'edit_post';
77
- $cap[1] = 'edit_' . $_POST['post_type'];
 
 
 
78
  if (
79
  !current_user_can( $cap[0], $post_id )
80
  and !current_user_can( $cap[1], $post_id )
@@ -83,10 +89,10 @@ function feedwordpress_save_post_edit_controls ( $post_id ) {
83
  endif;
84
 
85
  // OK, we're golden. Now let's save some data.
86
- if (isset($_POST['freeze_updates'])) :
87
- $sFreezeUpdates = sanitize_text_field($_POST['freeze_updates']);
88
- update_post_meta($post_id, '_syndication_freeze_updates', sanitize_meta('_syndication_freeze_updates', $sFreezeUpdates, 'post'));
89
- $ret = $sFreezeUpdates;
90
 
91
  // If you make manual edits through the WordPress editing
92
  // UI then they should be run through normal WP formatting
54
  endif;
55
  } /* function feedwordpress_post_edit_controls () */
56
 
57
+ function feedwordpress_save_post_edit_controls( $post_id ) {
58
  global $post;
59
+
60
+ $noncename = FeedWordPress::post( 'feedwordpress_noncename' );
61
+
62
+ if ( is_null( $noncename ) || ! wp_verify_nonce( $noncename, plugin_basename( __FILE__ ) ) ) :
63
  return $post_id;
64
  endif;
65
 
72
  // The data in $_POST is for applying only to the post actually
73
  // in the edit window, i.e. $post
74
  if ($post_id != $post->ID) :
75
+ return $post_id;
76
  endif;
77
 
78
  // Check permissions
79
  $cap[0] = 'edit_post';
80
+
81
+ $post_type = FeedWordPress::post( 'post_type' );
82
+ $cap[1] = sanitize_key( 'edit_' . $post_type );
83
+
84
  if (
85
  !current_user_can( $cap[0], $post_id )
86
  and !current_user_can( $cap[1], $post_id )
89
  endif;
90
 
91
  // OK, we're golden. Now let's save some data.
92
+ $freeze_updates = FeedWordPress::post( 'freeze_updates' );
93
+ if ( ! is_null( $freeze_updates ) ) :
94
+ update_post_meta($post_id, '_syndication_freeze_updates', sanitize_meta('_syndication_freeze_updates', $freeze_updates, 'post'));
95
+ $ret = $freeze_updates;
96
 
97
  // If you make manual edits through the WordPress editing
98
  // UI then they should be run through normal WP formatting
feedwordpressadminpage.class.php CHANGED
@@ -8,6 +8,9 @@
8
  * settings on particular feeds.
9
  *
10
  */
 
 
 
11
  class FeedWordPressAdminPage {
12
  protected $context;
13
  protected $updated = false;
@@ -53,13 +56,13 @@ class FeedWordPressAdminPage {
53
  return __($name);
54
  } /* FeedWordPressAdminPage::pagename () */
55
 
56
- public function accept_POST ($post) {
57
- if ($this->for_feed_settings() and $this->update_requested_in($post)) :
58
  $this->update_feed();
59
- elseif ($this->save_requested_in($post)) : // User mashed Save Changes
60
- $this->save_settings($post);
61
  endif;
62
- do_action($this->dispatch.'_post', $post, $this);
63
  }
64
 
65
  public function update_feed () {
@@ -94,8 +97,8 @@ class FeedWordPressAdminPage {
94
  remove_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
95
  }
96
 
97
- public function save_settings ($post) {
98
- do_action($this->dispatch.'_save', $post, $this);
99
 
100
  if ($this->for_feed_settings()) :
101
  // Save settings
@@ -156,15 +159,14 @@ class FeedWordPressAdminPage {
156
  endif;
157
  } /* FeedWordPressAdminPage::update_setting () */
158
 
159
- public function save_requested_in ($post) {
160
- return (isset($post['save']) or isset($post['submit']));
161
  }
162
- public function update_requested_in ($post) {
163
- return (isset($post['update']) and (strlen($post['update']) > 0));
164
  }
165
 
166
  public function submitted_link_id () {
167
- global $fwp_post;
168
 
169
  // Presume global unless we get a specific link ID
170
  $link_id = NULL;
@@ -176,13 +178,13 @@ class FeedWordPressAdminPage {
176
  'feedfinder',
177
  );
178
  foreach ($submit_buttons as $field) :
179
- if (isset($fwp_post[$field])) :
180
- $link_id = MyPHP::request('save_link_id');
181
  endif;
182
  endforeach;
183
 
184
- if (is_null($link_id) and isset($_REQUEST['link_id'])) :
185
- $link_id = MyPHP::request('link_id');
186
  endif;
187
 
188
  return $link_id;
@@ -436,7 +438,6 @@ class FeedWordPressAdminPage {
436
  }
437
 
438
  public function display () {
439
- global $fwp_post;
440
 
441
  if (FeedWordPress::needs_upgrade()) :
442
  fwp_upgrade_page();
@@ -449,7 +450,7 @@ class FeedWordPressAdminPage {
449
  // Process POST request, if any ////////////////
450
  ////////////////////////////////////////////////
451
  if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
452
- $this->accept_POST($fwp_post);
453
  else :
454
  $this->updated = false;
455
  endif;
@@ -569,31 +570,39 @@ class FeedWordPressAdminPage {
569
  public function setting_radio_control ($localName, $globalName, $options, $params = array()) {
570
  global $fwp_path;
571
 
572
- if (isset($params['filename'])) : $filename = $params['filename'];
573
- else : $filename = basename($this->filename);
574
- endif;
575
-
576
- if (isset($params['site-wide-url'])) : $href = $params['site-wide-url'];
577
- else : $href = $this->admin_page_href($filename);
578
- endif;
 
 
 
579
 
580
- if (isset($params['setting-default'])) : $settingDefault = $params['setting-default'];
581
- else : $settingDefault = NULL;
 
 
582
  endif;
583
 
584
- if (isset($params['global-setting-default'])) : $globalSettingDefault = $params['global-setting-default'];
585
- else : $globalSettingDefault = $settingDefault;
 
 
586
  endif;
587
 
588
  $globalSetting = get_option('feedwordpress_'.$globalName, $globalSettingDefault);
589
- if ($this->for_feed_settings()) :
590
  $setting = $this->link->setting($localName, NULL, $settingDefault);
591
  else :
592
  $setting = $globalSetting;
593
  endif;
594
 
595
- if (isset($params['offer-site-wide'])) : $offerSiteWide = $params['offer-site-wide'];
596
- else : $offerSiteWide = $this->for_feed_settings();
 
597
  endif;
598
 
599
  // This allows us to provide an alternative set of human-readable
@@ -682,7 +691,12 @@ class FeedWordPressAdminPage {
682
  elseif (is_null($labels)) :
683
  print $globalSetting;
684
  else :
685
- print $labels[$globalSetting];
 
 
 
 
 
686
  endif; ?></strong> (<a href="<?php print esc_url( $href ); ?>">change</a>)</span></li>
687
  </ul></td>
688
 
@@ -705,11 +719,25 @@ class FeedWordPressAdminPage {
705
  else :
706
  ?>
707
  <ul class="options">
708
- <?php foreach ($options as $value => $label) : ?>
 
 
 
 
 
 
 
 
709
  <li><label><input type="radio" name="<?php print esc_attr( $inputName ); ?>"
710
  value="<?php print esc_attr( $value ); ?>"
711
  <?php print fwp_checked_flag($checked, $value); ?> />
712
- <?php print esc_html( $label ); ?></label></li>
 
 
 
 
 
 
713
  <?php endforeach; ?>
714
  </ul> <!-- class="options" -->
715
  <?php
8
  * settings on particular feeds.
9
  *
10
  */
11
+
12
+ define( 'FWP_BOLD_PREFIX_REGEX', '/^[*][*] ([^*]+) [*][*] \s+ (\S.*)$/x');
13
+
14
  class FeedWordPressAdminPage {
15
  protected $context;
16
  protected $updated = false;
56
  return __($name);
57
  } /* FeedWordPressAdminPage::pagename () */
58
 
59
+ public function accept_POST () {
60
+ if ( $this->for_feed_settings() and $this->update_requested() ) :
61
  $this->update_feed();
62
+ elseif ($this->save_requested()) : // User mashed Save Changes
63
+ $this->save_settings();
64
  endif;
65
+ do_action($this->dispatch.'_post', null, $this);
66
  }
67
 
68
  public function update_feed () {
97
  remove_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
98
  }
99
 
100
+ public function save_settings () {
101
+ do_action($this->dispatch.'_save', null, $this);
102
 
103
  if ($this->for_feed_settings()) :
104
  // Save settings
159
  endif;
160
  } /* FeedWordPressAdminPage::update_setting () */
161
 
162
+ public function save_requested () {
163
+ return ! ( is_null( MyPHP::post('save') ) && is_null( MyPHP::post('submit') ) );
164
  }
165
+ public function update_requested () {
166
+ return ( strlen( MyPHP::post('update', '') ) > 0 );
167
  }
168
 
169
  public function submitted_link_id () {
 
170
 
171
  // Presume global unless we get a specific link ID
172
  $link_id = NULL;
178
  'feedfinder',
179
  );
180
  foreach ($submit_buttons as $field) :
181
+ if ( ! is_null( MyPHP::request($field) ) ) :
182
+ $link_id = sanitize_text_field( MyPHP::request('save_link_id') );
183
  endif;
184
  endforeach;
185
 
186
+ if ( is_null($link_id) ) :
187
+ $link_id = sanitize_text_field( MyPHP::request( 'link_id' ) );
188
  endif;
189
 
190
  return $link_id;
438
  }
439
 
440
  public function display () {
 
441
 
442
  if (FeedWordPress::needs_upgrade()) :
443
  fwp_upgrade_page();
450
  // Process POST request, if any ////////////////
451
  ////////////////////////////////////////////////
452
  if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
453
+ $this->accept_POST();
454
  else :
455
  $this->updated = false;
456
  endif;
570
  public function setting_radio_control ($localName, $globalName, $options, $params = array()) {
571
  global $fwp_path;
572
 
573
+ $params = wp_parse_args(
574
+ $params,
575
+ array(
576
+ 'filename' => basename($this->filename),
577
+ 'site-wide-url' => null,
578
+ 'setting-default' => null,
579
+ 'global-setting-default' => null,
580
+ 'offer-site-wide' => null,
581
+ )
582
+ );
583
 
584
+ $filename = $params['filename'];
585
+ $href = $params['site-wide-url'];
586
+ if ( is_null( $href ) ) :
587
+ $href = $this->admin_page_href( $filename );
588
  endif;
589
 
590
+ $settingDefault = $params['setting-default'];
591
+ $globalSettingDefault = $params['global-setting-default'];
592
+ if ( is_null( $globalSettingDefault ) ) :
593
+ $globalSettingDefault = $settingDefault;
594
  endif;
595
 
596
  $globalSetting = get_option('feedwordpress_'.$globalName, $globalSettingDefault);
597
+ if ( $this->for_feed_settings() ) :
598
  $setting = $this->link->setting($localName, NULL, $settingDefault);
599
  else :
600
  $setting = $globalSetting;
601
  endif;
602
 
603
+ $offerSiteWide = $params['offer-site-wide'];
604
+ if ( is_null( $offerSiteWide ) ) :
605
+ $offerSiteWide = $this->for_feed_settings();
606
  endif;
607
 
608
  // This allows us to provide an alternative set of human-readable
691
  elseif (is_null($labels)) :
692
  print $globalSetting;
693
  else :
694
+ $label = $labels[ $globalSetting ];
695
+ if ( preg_match( FWP_BOLD_PREFIX_REGEX, $label, $ref ) ) :
696
+ $label = $ref[1] . ' ' . $ref[2];
697
+ endif;
698
+
699
+ print esc_html( $label );
700
  endif; ?></strong> (<a href="<?php print esc_url( $href ); ?>">change</a>)</span></li>
701
  </ul></td>
702
 
719
  else :
720
  ?>
721
  <ul class="options">
722
+ <?php
723
+ foreach ($options as $value => $label) :
724
+ if ( preg_match( FWP_BOLD_PREFIX_REGEX, $label, $ref ) ) :
725
+ $prefix = $ref[1];
726
+ $label = $ref[2];
727
+ else :
728
+ $prefix = null;
729
+ endif;
730
+ ?>
731
  <li><label><input type="radio" name="<?php print esc_attr( $inputName ); ?>"
732
  value="<?php print esc_attr( $value ); ?>"
733
  <?php print fwp_checked_flag($checked, $value); ?> />
734
+ <?php
735
+ if ( !is_null($prefix) ) :
736
+ printf( '<strong>%s</strong> ', esc_html( $prefix ) );
737
+ endif;
738
+ printf( '%s', esc_html( $label ) );
739
+ ?>
740
+ </label></li>
741
  <?php endforeach; ?>
742
  </ul> <!-- class="options" -->
743
  <?php
feedwordpressdiagnostic.class.php CHANGED
@@ -66,13 +66,14 @@ class FeedWordPressDiagnostic {
66
  endif;
67
 
68
  print '<p><strong>Critical error:</strong> There may be a bug in FeedWordPress. Please <a href="'.FEEDWORDPRESS_AUTHOR_CONTACT.'">contact the author</a> and paste the following information into your e-mail:</p>';
69
- print "\n<plaintext>";
70
- print "Triggered at ${location}\n";
71
- print "FeedWordPress: ".FEEDWORDPRESS_VERSION."\n";
72
- print "WordPress: {$wp_version}\n";
73
- print "PHP: ".phpversion()."\n";
74
  print "Error data: ";
75
- print $varname.": "; var_dump($var); echo "\n";
 
76
  die;
77
  } /* FeedWordPressDiagnostic::critical_bug () */
78
 
66
  endif;
67
 
68
  print '<p><strong>Critical error:</strong> There may be a bug in FeedWordPress. Please <a href="'.FEEDWORDPRESS_AUTHOR_CONTACT.'">contact the author</a> and paste the following information into your e-mail:</p>';
69
+ print "\n<pre>";
70
+ print "Triggered at " . esc_html($location) . "\n";
71
+ print "FeedWordPress: " . esc_html( FEEDWORDPRESS_VERSION ) . "\n";
72
+ print "WordPress: " . esc_html( $wp_version ) . "\n";
73
+ print "PHP: " . esc_html( phpversion() ) . "\n";
74
  print "Error data: ";
75
+ print esc_html($varname) . ": " . esc_html( MyPHP::val( $var ) ) . "\n";
76
+ print "\n</pre>";
77
  die;
78
  } /* FeedWordPressDiagnostic::critical_bug () */
79
 
feedwordpresssyndicationpage.class.php CHANGED
@@ -58,7 +58,7 @@ class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
58
  endif;
59
 
60
  // this may be output into HTML, and it should really only ever be Y or N...
61
- $sVisibility = (isset($_REQUEST['visibility']) ? sanitize_text_field($_REQUEST['visibility']) : $defaultVisibility);
62
  $visibility = preg_replace('/[^YyNn]+/', '', $sVisibility);
63
 
64
  return (strlen($visibility) > 0 ? $visibility : $defaultVisibility);
@@ -91,23 +91,21 @@ class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
91
  * requested_link_ids_sql ()
92
  *
93
  * @return string An SQL list literal containing the link IDs, sanitized
94
- * and escaped for direct use in MySQL queries.
95
  *
96
  * @uses sanitize_ids_sql()
97
  */
98
  public function requested_link_ids_sql () {
99
  // Multiple link IDs passed in link_ids[]=...
100
- $aLinkIdParameters = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
101
- $link_ids = array();
102
- foreach ($aLinkIdParameters as $uLinkId) :
103
- $sLinkId = sanitize_text_field($uLinkId);
104
- array_push($link_ids, $sLinkId);
105
- endforeach;
106
 
 
 
 
 
 
107
  // Or single in link_id=...
108
- if (isset($_REQUEST['link_id'])) :
109
- $sLinkId = sanitize_text_field($_REQUEST['link_id']);
110
- array_push($link_ids, $sLinkId);
111
  endif;
112
 
113
  // Now use method to sanitize for safe use in MySQL queries.
@@ -120,7 +118,7 @@ class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
120
  function updates_requested () {
121
  global $wpdb;
122
 
123
- if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) :
124
  // Only do things with side-effects for HTTP POST or command line
125
  $fwp_update_invoke = 'post';
126
  else :
@@ -147,8 +145,8 @@ class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
147
  else : // This should never happen
148
  FeedWordPressDiagnostic::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__, __FILE__);
149
  endif;
150
- elseif (!is_null(MyPHP::post('update_uri'))) :
151
- $targets = MyPHP::post('update_uri');
152
  if (!is_array($targets)) :
153
  $targets = array($targets);
154
  endif;
@@ -164,20 +162,32 @@ class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
164
  return $update_set;
165
  }
166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  function accept_multiadd () {
168
- global $fwp_post;
169
 
170
- if (isset($fwp_post['cancel']) and $fwp_post['cancel']==__(FWP_CANCEL_BUTTON)) :
171
  return true; // Continue ....
172
  endif;
173
 
174
  // If this is a POST, validate source and user credentials
175
  FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
176
 
177
- $in = (isset($fwp_post['multilookup']) ? $fwp_post['multilookup'] : '')
178
- .(isset($fwp_post['opml_lookup']) ? $fwp_post['opml_lookup'] : '');
179
- if (isset($fwp_post['confirm']) and $fwp_post['confirm']=='multiadd') :
180
- $chex = $fwp_post['multilookup'];
181
  $added = array(); $errors = array();
182
  foreach ($chex as $feed) :
183
  if (isset($feed['add']) and $feed['add']=='yes') :
@@ -196,22 +206,28 @@ class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
196
  endforeach;
197
 
198
  print "<div class='updated'>\n";
199
- print "<p>Added ".count($added)." new syndicated sources.</p>";
 
200
  if (count($errors) > 0) :
201
  print "<p>FeedWordPress encountered errors trying to add the following sources:</p>
202
  <ul>\n";
203
  foreach ($errors as $err) :
204
  $url = $err[0];
205
- $short = esc_html(feedwordpress_display_url($url));
206
- $url = esc_html($url);
207
- $wp = $err[1];
208
- if (is_wp_error($err[1])) :
 
 
 
 
 
209
  $error = $err[1];
210
- $mesg = " (<code>".$error->get_error_messages()."</code>)";
211
- else :
212
- $mesg = '';
213
  endif;
214
- print "<li><a href='$url'>$short</a>$mesg</li>\n";
 
 
215
  endforeach;
216
  print "</ul>\n";
217
  endif;
@@ -255,7 +271,6 @@ class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
255
  }
256
 
257
  function multiadd_box ($page, $box = NULL) {
258
- global $fwp_post;
259
 
260
  $localData = NULL;
261
 
@@ -266,11 +281,11 @@ class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
266
  /*FIXME: check whether $_FILES['opml_upload']['error'] === UPLOAD_ERR_OK or not...*/
267
  $localData = file_get_contents($_FILES['opml_upload']['tmp_name']);
268
  $merge_all = true;
269
- elseif (isset($fwp_post['multilookup'])) :
270
- $in = $fwp_post['multilookup'];
271
  $merge_all = false;
272
- elseif (isset($fwp_post['opml_lookup'])) :
273
- $in = $fwp_post['opml_lookup'];
274
  $merge_all = true;
275
  else :
276
  $in = '';
@@ -382,7 +397,6 @@ class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
382
 
383
  function display () {
384
  global $wpdb;
385
- global $fwp_post;
386
 
387
  if (FeedWordPress::needs_upgrade()) :
388
  fwp_upgrade_page();
@@ -391,28 +405,28 @@ class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
391
 
392
  $cont = true;
393
  $dispatcher = array(
394
- "feedfinder" => 'fwp_feedfinder_page',
395
- FWP_SYNDICATE_NEW => 'fwp_feedfinder_page',
396
- "switchfeed" => 'fwp_switchfeed_page',
397
  FWP_UNSUB_CHECKED => 'multidelete_page',
398
  FWP_DELETE_CHECKED => 'multidelete_page',
399
  'Unsubscribe' => 'multidelete_page',
400
  FWP_RESUB_CHECKED => 'multiundelete_page',
401
  );
402
-
403
- $act = MyPHP::request('action');
404
- if (isset($dispatcher[$act])) :
405
- $method = $dispatcher[$act];
406
- if (method_exists($this, $method)) :
407
  $cont = $this->{$method}();
408
  else :
409
  $cont = call_user_func($method);
410
  endif;
411
- elseif (isset($fwp_post['multiadd']) and $fwp_post['multiadd']==FWP_SYNDICATE_NEW) :
412
- $cont = $this->accept_multiadd($fwp_post);
413
  endif;
414
 
415
- if ($cont):
416
  $links = $this->sources('Y');
417
  $potential_updates = (!$this->show_inactive() and (count($this->sources('Y')) > 0));
418
 
@@ -868,8 +882,14 @@ regular donation</a>) using an existing PayPal account or any major credit card.
868
  if (count($alter) > 0) :
869
  echo "<div class=\"updated\">\n";
870
  if (count($errs) > 0) :
871
- echo "There were some problems processing your ";
872
- echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]";
 
 
 
 
 
 
873
  else :
874
  echo "Your unsubscribe request(s) have been processed.";
875
  endif;
@@ -1052,7 +1072,97 @@ regular donation</a>) using an existing PayPal account or any major credit card.
1052
  endif;
1053
  } /* FeedWordPressSyndicationPage::multiundelete_page() */
1054
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1055
 
 
 
 
 
 
 
 
 
 
 
 
1056
 
1057
  } /* class FeedWordPressSyndicationPage */
1058
 
@@ -1108,11 +1218,11 @@ define('FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*
1108
  define('FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 183 /*days*/));
1109
  function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
1110
  $bleg_box_hidden = null;
1111
- if (isset($_POST['maybe_later'])) :
1112
  $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET;
1113
- elseif (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
1114
  $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET;
1115
- elseif (isset($_POST['go_away'])) :
1116
  $bleg_box_hidden = 'permanent';
1117
  endif;
1118
 
@@ -1129,7 +1239,7 @@ function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
1129
  ));
1130
 
1131
  $bleg_box_ready = apply_filters( 'feedwordpress_bleg_box_ready', $bleg_box_ready );
1132
- if (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
1133
  $object->bleg_thanks($subject, $box);
1134
  elseif ($bleg_box_ready) :
1135
  $object->bleg_box($object, $box);
@@ -1170,84 +1280,3 @@ function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
1170
  </form>
1171
  <?php
1172
  } /* function fwp_syndication_manage_page_update_box () */
1173
-
1174
- function fwp_feedfinder_page () {
1175
- global $post_source, $fwp_post, $syndicationPage;
1176
-
1177
- if (isset($fwp_post['opml_lookup']) or isset($_FILES['opml_upload'])) :
1178
- $syndicationPage->accept_multiadd();
1179
- return true;
1180
- else :
1181
- $post_source = 'feedwordpress_feeds';
1182
-
1183
- // With action=feedfinder, this goes directly to the feedfinder page
1184
- include_once(dirname(__FILE__) . '/feeds-page.php');
1185
- return false;
1186
- endif;
1187
- } /* function fwp_feedfinder_page () */
1188
-
1189
- function fwp_switchfeed_page () {
1190
- global $wpdb;
1191
- global $fwp_post, $fwp_path;
1192
-
1193
- // If this is a POST, validate source and user credentials
1194
- FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
1195
-
1196
- $changed = false;
1197
- if (!isset($fwp_post['Cancel'])):
1198
- if (isset($fwp_post['save_link_id']) and ($fwp_post['save_link_id']=='*')) :
1199
- $changed = true;
1200
- $link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']);
1201
- if ($link_id):
1202
- $existingLink = new SyndicatedLink($link_id);
1203
- $adminPageHref = $this->admin_page_href('feeds-page.php', array( "link_id" => $link_id ));
1204
- ?>
1205
- <div class="updated"><p><a href="<?php print esc_url($fwp_post['feed_link']); ?>"><?php print esc_html($fwp_post['feed_title']); ?></a>
1206
- has been added as a contributing site, using the feed at
1207
- &lt;<a href="<?php print esc_url($fwp_post['feed']); ?>"><?php print esc_html($fwp_post['feed']); ?></a>&gt;.
1208
- | <a href="<?php print esc_url( $adminPageHref ); ?>">Configure settings</a>.</p></div>
1209
- <?php else: ?>
1210
- <div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo esc_html($wpdb->last_error); ?>]</p></div>
1211
- <?php endif;
1212
- elseif (isset($fwp_post['save_link_id'])):
1213
- $existingLink = new SyndicatedLink($fwp_post['save_link_id']);
1214
- $changed = $existingLink->set_uri($fwp_post['feed']);
1215
-
1216
- if ($changed):
1217
- $home = $existingLink->homepage(/*from feed=*/ false);
1218
- $name = $existingLink->name(/*from feed=*/ false);
1219
- ?>
1220
- <div class="updated"><p>Feed for <a href="<?php echo esc_html($home); ?>"><?php echo esc_html($name); ?></a>
1221
- updated to &lt;<a href="<?php echo esc_html($fwp_post['feed']); ?>"><?php echo esc_html($fwp_post['feed']); ?></a>&gt;.</p></div>
1222
- <?php
1223
- endif;
1224
- endif;
1225
- endif;
1226
-
1227
- if (isset($existingLink)) :
1228
- $auth = MyPHP::post('link_rss_auth_method');
1229
- if (!is_null($auth) and (strlen($auth) > 0) and ($auth != '-')) :
1230
- $existingLink->update_setting('http auth method', $auth);
1231
- $existingLink->update_setting('http username',
1232
- MyPHP::post('link_rss_username')
1233
- );
1234
- $existingLink->update_setting('http password',
1235
- MyPHP::post('link_rss_password')
1236
- );
1237
- else :
1238
- $existingLink->update_setting('http auth method', NULL);
1239
- $existingLink->update_setting('http username', NULL);
1240
- $existingLink->update_setting('http password', NULL);
1241
- endif;
1242
- do_action('feedwordpress_admin_switchfeed', $fwp_post['feed'], $existingLink);
1243
- $existingLink->save_settings(/*reload=*/ true);
1244
- endif;
1245
-
1246
- if (!$changed) :
1247
- ?>
1248
- <div class="updated"><p>Nothing was changed.</p></div>
1249
- <?php
1250
- endif;
1251
- return true; // Continue
1252
- }
1253
-
58
  endif;
59
 
60
  // this may be output into HTML, and it should really only ever be Y or N...
61
+ $sVisibility = FeedWordPress::param( 'visibility', $defaultVisibility );
62
  $visibility = preg_replace('/[^YyNn]+/', '', $sVisibility);
63
 
64
  return (strlen($visibility) > 0 ? $visibility : $defaultVisibility);
91
  * requested_link_ids_sql ()
92
  *
93
  * @return string An SQL list literal containing the link IDs, sanitized
94
+ * and escaped for direct use in MySQL queries.
95
  *
96
  * @uses sanitize_ids_sql()
97
  */
98
  public function requested_link_ids_sql () {
99
  // Multiple link IDs passed in link_ids[]=...
 
 
 
 
 
 
100
 
101
+ $link_ids = array_map(
102
+ 'sanitize_text_field',
103
+ (array) MyPHP::request( 'link_ids', array() )
104
+ );
105
+
106
  // Or single in link_id=...
107
+ if ( ! is_null(MyPHP::request( 'link_id' ) ) ) :
108
+ array_push( $link_ids, sanitize_text_field( MyPHP::request( 'link_id' ) ) );
 
109
  endif;
110
 
111
  // Now use method to sanitize for safe use in MySQL queries.
118
  function updates_requested () {
119
  global $wpdb;
120
 
121
+ if ( FeedWordPress::post( 'update' ) || FeedWordPress::post( 'action' ) || FeedWordPress::post( 'update_uri' ) ) :
122
  // Only do things with side-effects for HTTP POST or command line
123
  $fwp_update_invoke = 'post';
124
  else :
145
  else : // This should never happen
146
  FeedWordPressDiagnostic::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__, __FILE__);
147
  endif;
148
+ elseif (!is_null(FeedWordPress::post('update_uri'))) :
149
+ $targets = FeedWordPress::post('update_uri');
150
  if (!is_array($targets)) :
151
  $targets = array($targets);
152
  endif;
162
  return $update_set;
163
  }
164
 
165
+ public function cancel_requested () {
166
+ $cancel = FeedWordPress::post( 'cancel' );
167
+ return ( $cancel === __( FWP_CANCEL_BUTTON ) );
168
+ }
169
+ public function multiadd_requested () {
170
+ $multiadd = FeedWordPress::post( 'multiadd' );
171
+ return ( $multiadd === FWP_SYNDICATE_NEW );
172
+ }
173
+ public function multiadd_confirm_requested () {
174
+ $confirm = FeedWordPress::post( 'confirm' );
175
+ return ( $confirm === 'multiadd' );
176
+ }
177
+
178
  function accept_multiadd () {
 
179
 
180
+ if ( $this->cancel_requested() ) :
181
  return true; // Continue ....
182
  endif;
183
 
184
  // If this is a POST, validate source and user credentials
185
  FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
186
 
187
+ $in = FeedWordPress::post( 'multilookup', '' )
188
+ . FeedWordPress::post( 'opml_lookup', '' );
189
+ if ( $this->multiadd_confirm_requested() ) :
190
+ $chex = FeedWordPress::post( 'multilookup' );
191
  $added = array(); $errors = array();
192
  foreach ($chex as $feed) :
193
  if (isset($feed['add']) and $feed['add']=='yes') :
206
  endforeach;
207
 
208
  print "<div class='updated'>\n";
209
+ print "<p>Added " . count($added) . " new syndicated sources.</p>";
210
+
211
  if (count($errors) > 0) :
212
  print "<p>FeedWordPress encountered errors trying to add the following sources:</p>
213
  <ul>\n";
214
  foreach ($errors as $err) :
215
  $url = $err[0];
216
+ $short = feedwordpress_display_url($url);
217
+
218
+ printf(
219
+ '<li><a href="%s">%s</a>',
220
+ esc_url( $url ),
221
+ esc_html( $short )
222
+ );
223
+
224
+ if ( is_wp_error( $err[1] ) ) :
225
  $error = $err[1];
226
+ printf( ' (<code>%s</code>)', esc_html( $error->get_error_messages() ) );
 
 
227
  endif;
228
+
229
+ print "</li>\n";
230
+
231
  endforeach;
232
  print "</ul>\n";
233
  endif;
271
  }
272
 
273
  function multiadd_box ($page, $box = NULL) {
 
274
 
275
  $localData = NULL;
276
 
281
  /*FIXME: check whether $_FILES['opml_upload']['error'] === UPLOAD_ERR_OK or not...*/
282
  $localData = file_get_contents($_FILES['opml_upload']['tmp_name']);
283
  $merge_all = true;
284
+ elseif ( ! is_null( FeedWordPress::post( 'multilookup' ) ) ) :
285
+ $in = FeedWordPress::post( 'multilookup' );
286
  $merge_all = false;
287
+ elseif ( ! is_null( FeedWordPress::post( 'opml_lookup' ) ) ) :
288
+ $in = FeedWordPress::post( 'opml_lookup' );
289
  $merge_all = true;
290
  else :
291
  $in = '';
397
 
398
  function display () {
399
  global $wpdb;
 
400
 
401
  if (FeedWordPress::needs_upgrade()) :
402
  fwp_upgrade_page();
405
 
406
  $cont = true;
407
  $dispatcher = array(
408
+ "feedfinder" => 'feedfinder_page',
409
+ FWP_SYNDICATE_NEW => 'feedfinder_page',
410
+ "switchfeed" => 'switchfeed_page',
411
  FWP_UNSUB_CHECKED => 'multidelete_page',
412
  FWP_DELETE_CHECKED => 'multidelete_page',
413
  'Unsubscribe' => 'multidelete_page',
414
  FWP_RESUB_CHECKED => 'multiundelete_page',
415
  );
416
+
417
+ $act = FeedWordPress::param( 'action' );
418
+ if ( isset( $dispatcher[ $act ] ) ) :
419
+ $method = $dispatcher[ $act ];
420
+ if ( method_exists( $this, $method ) ) :
421
  $cont = $this->{$method}();
422
  else :
423
  $cont = call_user_func($method);
424
  endif;
425
+ elseif ( $this->multiadd_requested() ) :
426
+ $cont = $this->accept_multiadd();
427
  endif;
428
 
429
+ if ( $cont ):
430
  $links = $this->sources('Y');
431
  $potential_updates = (!$this->show_inactive() and (count($this->sources('Y')) > 0));
432
 
882
  if (count($alter) > 0) :
883
  echo "<div class=\"updated\">\n";
884
  if (count($errs) > 0) :
885
+ echo "There were some problems processing your unsubscribe request. [SQL: ";
886
+ $sep = '';
887
+ foreach ( $errs as $err ) :
888
+ print esc_html($sep);
889
+ print esc_html($err);
890
+ $sep = '; ';
891
+ endforeach;
892
+ echo "]";
893
  else :
894
  echo "Your unsubscribe request(s) have been processed.";
895
  endif;
1072
  endif;
1073
  } /* FeedWordPressSyndicationPage::multiundelete_page() */
1074
 
1075
+ public function switchfeed_page () {
1076
+ global $wpdb;
1077
+ global $fwp_path;
1078
+
1079
+ // If this is a POST, validate source and user credentials
1080
+ FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
1081
+
1082
+ $changed = false;
1083
+ if ( is_null( FeedWordPress::post( 'Cancel' ) ) ):
1084
+ $save_link_id = FeedWordPress::post( 'save_link_id' );
1085
+
1086
+ if ( $save_link_id == '*' ) :
1087
+ $changed = true;
1088
+
1089
+ $feed_title = FeedWordPress::post( 'feed_title' );
1090
+ $feed_link = FeedWordPress::post( 'feed_link' );
1091
+ $feed = FeedWordPress::post( 'feed' );
1092
+
1093
+ $link_id = FeedWordPress::syndicate_link( $feed_title, $feed_link, $feed );
1094
+ if ($link_id):
1095
+ $existingLink = new SyndicatedLink($link_id);
1096
+ $adminPageHref = $this->admin_page_href( 'feeds-page.php', array( "link_id" => $link_id ) );
1097
+ ?>
1098
+ <div class="updated"><p><a href="<?php print esc_url($feed_link); ?>"><?php print esc_html($feed_title); ?></a>
1099
+ has been added as a contributing site, using the feed at
1100
+ &lt;<a href="<?php print esc_url( $feed ); ?>"><?php print esc_html( $feed ); ?></a>&gt;.
1101
+ | <a href="<?php print esc_url( $adminPageHref ); ?>">Configure settings</a>.</p></div>
1102
+ <?php
1103
+ else:
1104
+ ?>
1105
+ <div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo esc_html($wpdb->last_error); ?>]</p></div>
1106
+ <?php
1107
+ endif;
1108
+ elseif ( ! is_null( $save_link_id ) ):
1109
+ $feed = FeedWordPress::post( 'feed' );
1110
+ $existingLink = new SyndicatedLink( $save_link_id );
1111
+
1112
+ $changed = $existingLink->set_uri($feed);
1113
+
1114
+ if ($changed):
1115
+ $home = $existingLink->homepage(/*from feed=*/ false);
1116
+ $name = $existingLink->name(/*from feed=*/ false);
1117
+ ?>
1118
+ <div class="updated"><p>Feed for <a href="<?php echo esc_html($home); ?>"><?php echo esc_html($name); ?></a>
1119
+ updated to &lt;<a href="<?php echo esc_html( $feed ); ?>"><?php echo esc_html( $feed ); ?></a>&gt;.</p></div>
1120
+ <?php
1121
+ endif;
1122
+ endif;
1123
+ endif;
1124
+
1125
+ if (isset($existingLink)) :
1126
+ $auth = FeedWordPress::post('link_rss_auth_method');
1127
+ if (!is_null($auth) and (strlen($auth) > 0) and ($auth != '-')) :
1128
+ $existingLink->update_setting('http auth method', $auth);
1129
+ $existingLink->update_setting('http username',
1130
+ FeedWordPress::post('link_rss_username')
1131
+ );
1132
+ $existingLink->update_setting('http password',
1133
+ FeedWordPress::post('link_rss_password')
1134
+ );
1135
+ else :
1136
+ $existingLink->update_setting('http auth method', NULL);
1137
+ $existingLink->update_setting('http username', NULL);
1138
+ $existingLink->update_setting('http password', NULL);
1139
+ endif;
1140
+ do_action('feedwordpress_admin_switchfeed', FeedWordPress::post( 'feed' ), $existingLink);
1141
+ $existingLink->save_settings(/*reload=*/ true);
1142
+ endif;
1143
+
1144
+ if (!$changed) :
1145
+ ?>
1146
+ <div class="updated"><p>Nothing was changed.</p></div>
1147
+ <?php
1148
+ endif;
1149
+ return true; // Continue.
1150
+ }
1151
+
1152
+ function feedfinder_page () {
1153
+ global $post_source;
1154
 
1155
+ if ( FeedWordPress::post( 'opml_lookup' ) or isset( $_FILES['opml_upload'] ) ) :
1156
+ $this->accept_multiadd();
1157
+ return true;
1158
+ else :
1159
+ $post_source = 'feedwordpress_feeds';
1160
+
1161
+ // With action=feedfinder, this goes directly to the feedfinder page
1162
+ include_once(dirname(__FILE__) . '/feeds-page.php');
1163
+ return false;
1164
+ endif;
1165
+ } /* function feedfinder_page () */
1166
 
1167
  } /* class FeedWordPressSyndicationPage */
1168
 
1218
  define('FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 183 /*days*/));
1219
  function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
1220
  $bleg_box_hidden = null;
1221
+ if ( FeedWordPress::post( 'maybe_later' ) ) :
1222
  $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET;
1223
+ elseif ( FeedWordPress::post( 'paid' ) ) :
1224
  $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET;
1225
+ elseif ( FeedWordPress::post( 'go_away' ) ) :
1226
  $bleg_box_hidden = 'permanent';
1227
  endif;
1228
 
1239
  ));
1240
 
1241
  $bleg_box_ready = apply_filters( 'feedwordpress_bleg_box_ready', $bleg_box_ready );
1242
+ if ( FeedWordPress::post( 'paid' ) ) :
1243
  $object->bleg_thanks($subject, $box);
1244
  elseif ($bleg_box_ready) :
1245
  $object->bleg_box($object, $box);
1280
  </form>
1281
  <?php
1282
  } /* function fwp_syndication_manage_page_update_box () */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
performance-page.php CHANGED
@@ -21,8 +21,8 @@ class FeedWordPressPerformancePage extends FeedWordPressAdminPage {
21
  FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_performance', /*capability=*/ 'manage_options');
22
 
23
  if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
24
- $this->accept_POST($_POST);
25
- do_action('feedwordpress_admin_page_performance_save', $_POST, $this);
26
  endif;
27
 
28
  ////////////////////////////////////////////////
@@ -61,22 +61,22 @@ class FeedWordPressPerformancePage extends FeedWordPressAdminPage {
61
  $this->close_sheet();
62
  } /* FeedWordPressPerformancePage::display () */
63
 
64
- function accept_POST ($post) {
65
  global $feedwordpress;
66
 
67
- if (isset($post['create_index'])) :
68
  FeedWordPress::create_guid_index();
69
  $this->updated = __('guid column index created on database table.');
70
  endif;
71
- if (isset($post['remove_index'])) :
72
  FeedWordPress::remove_guid_index();
73
  $this->updated = __('guid column index removed from database table.');
74
  endif;
75
 
76
- if (isset($post['clear_cache'])) :
77
  $N = $feedwordpress->clear_cache();
78
  $feeds = (($N == 1) ? __("feed") : __("feeds"));
79
- $this->updated = sprintf(__("Cleared %d cached %s from WordPress database."), $N, $feeds);
80
  endif;
81
 
82
  } /* FeedWordPressPerformancePage::accept_POST () */
21
  FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_performance', /*capability=*/ 'manage_options');
22
 
23
  if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
24
+ $this->accept_POST();
25
+ do_action('feedwordpress_admin_page_performance_save', null, $this);
26
  endif;
27
 
28
  ////////////////////////////////////////////////
61
  $this->close_sheet();
62
  } /* FeedWordPressPerformancePage::display () */
63
 
64
+ function accept_POST () {
65
  global $feedwordpress;
66
 
67
+ if ( ! is_null( FeedWordPress::post( 'create_index' ) ) ) :
68
  FeedWordPress::create_guid_index();
69
  $this->updated = __('guid column index created on database table.');
70
  endif;
71
+ if ( ! is_null( FeedWordPress::post( 'remove_index' ) ) ) :
72
  FeedWordPress::remove_guid_index();
73
  $this->updated = __('guid column index removed from database table.');
74
  endif;
75
 
76
+ if ( ! is_null( FeedWordPress::post( 'clear_cache' ) ) ) :
77
  $N = $feedwordpress->clear_cache();
78
  $feeds = (($N == 1) ? __("feed") : __("feeds"));
79
+ $this->updated = sprintf( __("Cleared %d cached %s from WordPress database."), $N, $feeds );
80
  endif;
81
 
82
  } /* FeedWordPressPerformancePage::accept_POST () */
posts-page.php CHANGED
@@ -28,86 +28,93 @@ class FeedWordPressPostsPage extends FeedWordPressAdminPage {
28
  );
29
  } /* FeedWordPressPostsPage constructor */
30
 
31
- function save_settings ($post) {
32
  // custom post settings
33
  $custom_settings = $this->custom_post_settings();
34
 
35
- foreach ($post['notes'] as $mn) :
36
- if (isset($mn['key0'])) :
37
- $mn['key0'] = trim($mn['key0']);
38
- if (strlen($mn['key0']) > 0) :
39
- unset($custom_settings[$mn['key0']]); // out with the old
 
40
  endif;
41
  endif;
42
-
43
- if (isset($mn['key1'])) :
44
- $mn['key1'] = trim($mn['key1']);
45
 
46
- if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
47
- $custom_settings[$mn['key1']] = $mn['value']; // in with the new
 
 
 
48
  endif;
49
  endif;
50
  endforeach;
51
 
52
- $this->updatedPosts->accept_POST($post);
53
  if ($this->for_feed_settings()) :
54
  $alter = array ();
55
 
56
  $this->link->settings['postmeta'] = serialize($custom_settings);
57
 
58
- if (isset($post['resolve_relative'])) :
59
- $this->link->settings['resolve relative'] = $post['resolve_relative'];
60
  endif;
61
- if (isset($post['munge_permalink'])) :
62
- $this->link->settings['munge permalink'] = $post['munge_permalink'];
63
  endif;
64
- if (isset($post['munge_comments_feed_links'])) :
65
- $this->link->settings['munge comments feed links'] = $post['munge_comments_feed_links'];
66
  endif;
67
 
68
  // Post status, comment status, ping status
69
  foreach (array('post', 'comment', 'ping') as $what) :
70
  $sfield = "feed_{$what}_status";
71
- if (isset($post[$sfield])) :
72
- if ($post[$sfield]=='site-default') :
73
- unset($this->link->settings["{$what} status"]);
 
74
  else :
75
- $this->link->settings["{$what} status"] = $post[$sfield];
76
  endif;
77
  endif;
78
  endforeach;
79
 
80
- if (isset($post['syndicated_post_type'])) :
81
- if ($post['syndicated_post_type']=='default') :
82
  unset($this->link->settings['syndicated post type']);
83
  else :
84
- $this->link->settings['syndicated post type'] = $post['syndicated_post_type'];
85
  endif;
86
  endif;
87
 
88
  else :
89
  // update_option ...
90
- if (isset($post['feed_post_status'])) :
91
- update_option('feedwordpress_syndicated_post_status', $post['feed_post_status']);
 
 
92
  endif;
93
 
94
  update_option('feedwordpress_custom_settings', serialize($custom_settings));
95
 
96
- $sMungePermalink = sanitize_text_field($_REQUEST['munge_permalink']);
97
- $sUseAggregatorSourceData = sanitize_text_field($_REQUEST['use_aggregator_source_data']);
98
- $sFormattingFilters = sanitize_text_field($_REQUEST['formatting_filters']);
99
- $sFeedCommentStatus = (isset($_REQUEST['feed_comment_status']) ? sanitize_text_field($_REQUEST['feed_comment_status']) : '');
100
- $sFeedPingStatus = (isset($_REQUEST['feed_ping_status']) ? sanitize_text_field($_REQUEST['feed_ping_status']) : '');
101
-
 
 
 
102
  update_option('feedwordpress_munge_permalink', $sMungePermalink);
103
  update_option('feedwordpress_use_aggregator_source_data', $sUseAggregatorSourceData);
104
  update_option('feedwordpress_formatting_filters', $sFormattingFilters);
105
 
106
- if (isset($post['resolve_relative'])) :
107
- update_option('feedwordpress_resolve_relative', $post['resolve_relative']);
108
  endif;
109
- if (isset($post['munge_comments_feed_links'])) :
110
- update_option('feedwordpress_munge_comments_feed_links', $post['munge_comments_feed_links']);
111
  endif;
112
 
113
  if ( $sFeedCommentStatus == 'open' ) :
@@ -121,37 +128,35 @@ class FeedWordPressPostsPage extends FeedWordPressAdminPage {
121
  else :
122
  update_option('feedwordpress_syndicated_ping_status', 'closed');
123
  endif;
124
-
125
- if (isset($post['syndicated_post_type'])) :
126
- update_option('feedwordpress_syndicated_post_type', $post['syndicated_post_type']);
127
  endif;
128
  endif;
129
 
130
- if (isset($post['save']) or isset($post['submit'])) :
131
- if (isset($post['boilerplate'])) :
132
- foreach ($post['boilerplate'] as $index => $line) :
133
- if (0 == strlen(trim($line['template']))) :
134
- unset($post['boilerplate'][$index]);
135
- endif;
136
- endforeach;
137
 
138
- // Convert indexes to 0..(N-1) to avoid possible collisions
139
- $post['boilerplate'] = array_values($post['boilerplate']);
140
 
141
- if ($this->for_feed_settings()) :
142
- $this->link->settings['boilerplate rules'] = serialize($post['boilerplate']);
143
- $this->link->save_settings(/*reload=*/ true);
144
- else :
145
- update_option('feedwordpress_boilerplate', $post['boilerplate']);
146
- endif;
147
- endif;
148
-
149
- if (isset($post['boilerplate_hook_order'])) :
150
- $this->update_setting('boilerplate hook order', intval($post['boilerplate_hook_order']));
151
  endif;
152
  endif;
153
 
154
- parent::save_settings($post);
 
 
 
155
  }
156
 
157
  /**
28
  );
29
  } /* FeedWordPressPostsPage constructor */
30
 
31
+ function save_settings () {
32
  // custom post settings
33
  $custom_settings = $this->custom_post_settings();
34
 
35
+ $posted_notes = FeedWordPress::post( 'notes', array(), 'text' );
36
+ foreach ( $posted_notes as $mn ) :
37
+ if ( isset( $mn['key0'] ) ) :
38
+ $mn['key0'] = trim( $mn['key0'] );
39
+ if ( strlen( $mn['key0'] ) > 0 ) :
40
+ unset( $custom_settings[ $mn['key0'] ] ); // out with the old
41
  endif;
42
  endif;
 
 
 
43
 
44
+ if ( isset( $mn['key1'] ) ) :
45
+ $mn['key1'] = trim( $mn['key1'] );
46
+
47
+ if ( ( $mn['action']=='update' ) and ( strlen( $mn['key1'] ) > 0 ) ) :
48
+ $custom_settings[ $mn['key1'] ] = $mn['value']; // in with the new
49
  endif;
50
  endif;
51
  endforeach;
52
 
53
+ $this->updatedPosts->accept_POST();
54
  if ($this->for_feed_settings()) :
55
  $alter = array ();
56
 
57
  $this->link->settings['postmeta'] = serialize($custom_settings);
58
 
59
+ if ( ! is_null( FeedWordPress::post( 'resolve_relative', null ) ) ) :
60
+ $this->link->settings['resolve relative'] = FeedWordPress::post( 'resolve_relative', null, 'text' );
61
  endif;
62
+ if ( ! is_null( FeedWordPress::post('munge_permalink', null, 'text' ) ) ) :
63
+ $this->link->settings['munge permalink'] = FeedWordPress::post( 'munge_permalink', null, 'text' );
64
  endif;
65
+ if ( ! is_null( FeedWordPress::post('munge_comments_feed_links', null, 'text' ) ) ) :
66
+ $this->link->settings['munge comments feed links'] = FeedWordPress::post( 'munge_comments_feed_links', null, 'text' );
67
  endif;
68
 
69
  // Post status, comment status, ping status
70
  foreach (array('post', 'comment', 'ping') as $what) :
71
  $sfield = "feed_{$what}_status";
72
+ if ( ! is_null( FeedWordPress::post( $sfield, null, 'text' ) ) ) :
73
+ $afield = sprintf( '%s status', $what );
74
+ if ( FeedWordPress::post( $sfield, null, 'text' ) == 'site-default' ) :
75
+ unset($this->link->settings[ $afield ]);
76
  else :
77
+ $this->link->settings[ $afield ] = FeedWordPress::post( $sfield, null, 'text' );
78
  endif;
79
  endif;
80
  endforeach;
81
 
82
+ if ( ! is_null( FeedWordPress::post('syndicated_post_type', null, 'text' ) ) ) :
83
+ if ( FeedWordPress::post( 'syndicated_post_type', null, 'text' ) == 'default' ) :
84
  unset($this->link->settings['syndicated post type']);
85
  else :
86
+ $this->link->settings['syndicated post type'] = FeedWordPress::post( 'syndicated_post_type', null, 'text' );
87
  endif;
88
  endif;
89
 
90
  else :
91
  // update_option ...
92
+ if ( ! is_null( FeedWordPress::post( 'feed_post_status', null ) ) ) :
93
+
94
+ update_option('feedwordpress_syndicated_post_status', FeedWordPress::post( 'feed_post_status', null, 'text' ) );
95
+
96
  endif;
97
 
98
  update_option('feedwordpress_custom_settings', serialize($custom_settings));
99
 
100
+ $sMungePermalink = FeedWordPress::post('munge_permalink', null, 'text' );
101
+ $sUseAggregatorSourceData = FeedWordPress::post( 'use_aggregator_source_data', null, 'text' );
102
+ $sFormattingFilters = FeedWordPress::post('formatting_filters', null, 'text' );
103
+ $sFeedCommentStatus = FeedWordPress::post( 'feed_comment_status', '', 'text' );
104
+ $sFeedPingStatus = FeedWordPress::post( 'feed_ping_status', '', 'text' );
105
+ $sResolveRelative = FeedWordPress::post( 'resolve_relative', null, 'text' );
106
+ $sMungeCommentsFeedLinks = FeedWordPress::post( 'munge_comments_feed_links', null, 'text' );
107
+ $sSyndicatedPostType = FeedWordPress::post( 'syndicated_post_type', null, 'text' );
108
+
109
  update_option('feedwordpress_munge_permalink', $sMungePermalink);
110
  update_option('feedwordpress_use_aggregator_source_data', $sUseAggregatorSourceData);
111
  update_option('feedwordpress_formatting_filters', $sFormattingFilters);
112
 
113
+ if ( ! is_null( $sResolveRelative ) ) :
114
+ update_option('feedwordpress_resolve_relative', $sResolveRelative );
115
  endif;
116
+ if ( ! is_null( $sMungeCommentsFeedLinks ) ) :
117
+ update_option('feedwordpress_munge_comments_feed_links', $sMungeCommentsFeedLinks );
118
  endif;
119
 
120
  if ( $sFeedCommentStatus == 'open' ) :
128
  else :
129
  update_option('feedwordpress_syndicated_ping_status', 'closed');
130
  endif;
131
+
132
+ if ( ! is_null( $sSyndicatedPostType ) ) :
133
+ update_option('feedwordpress_syndicated_post_type', $sSyndicatedPostType );
134
  endif;
135
  endif;
136
 
137
+ $boilerplate = FeedWordPress::post( 'boilerplate', array(), 'raw' );
138
+ if ( count($boilerplate) > 0 ) :
139
+ foreach ( $boilerplate as $index => $line) :
140
+ if ( 0 == strlen( trim( $line['template'] ) ) ) :
141
+ unset( $boilerplate[$index] );
142
+ endif;
143
+ endforeach;
144
 
145
+ // Convert indexes to 0..(N-1) to avoid possible collisions
146
+ $boilerplate = array_values( $boilerplate );
147
 
148
+ if ($this->for_feed_settings()) :
149
+ $this->link->settings['boilerplate rules'] = serialize( $boilerplate );
150
+ $this->link->save_settings(/*reload=*/ true);
151
+ else :
152
+ update_option( 'feedwordpress_boilerplate', $boilerplate );
 
 
 
 
 
153
  endif;
154
  endif;
155
 
156
+ $boilerplate_hook_order = FeedWordPress::post( 'boilerplate_hook_order', 10, 'text' );
157
+ $this->update_setting('boilerplate hook order', intval( $boilerplate_hook_order ) );
158
+
159
+ parent::save_settings();
160
  }
161
 
162
  /**
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://feedwordpress.radgeek.com/donate/
4
  Tags: syndication, aggregation, feed, atom, rss
5
  Requires at least: 4.5
6
  Tested up to: 5.9
7
- Stable tag: 2022.0208
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -65,6 +65,10 @@ FeedWordPress has many options which can be accessed through the WordPress Dashb
65
 
66
  == Changelog ==
67
 
 
 
 
 
68
  = 2022.0204 =
69
 
70
  * ADDITIONAL CODE CLEANUP: This version does some additional code clean-up to remove some obsolete methods of generating output, and to do a better job of sanitizing input and escaping output in the FeedWordPress administrative dashboard.
4
  Tags: syndication, aggregation, feed, atom, rss
5
  Requires at least: 4.5
6
  Tested up to: 5.9
7
+ Stable tag: 2022.0222
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
65
 
66
  == Changelog ==
67
 
68
+ = 2022.0222 =
69
+
70
+ * ADDITIONAL CODE CLEANUP: This version does some additional code clean-up to remove some obsolete methods of generating output, and to do a better job of sanitizing input and escaping output in the FeedWordPress administrative dashboard.
71
+
72
  = 2022.0204 =
73
 
74
  * ADDITIONAL CODE CLEANUP: This version does some additional code clean-up to remove some obsolete methods of generating output, and to do a better job of sanitizing input and escaping output in the FeedWordPress administrative dashboard.
updatedpostscontrol.class.php CHANGED
@@ -49,15 +49,15 @@ class UpdatedPostsControl {
49
  <?php
50
  } /* UpdatedPostsControl::display() */
51
 
52
- function accept_POST ($post) {
53
  if ($this->page->for_feed_settings()) :
54
- if (isset($post['freeze_updates'])) :
55
- $this->page->link->settings['freeze updates'] = $post['freeze_updates'];
56
  endif;
57
  else :
58
  // Updated posts
59
- if (isset($post['freeze_updates'])) :
60
- update_option('feedwordpress_freeze_updates', $post['freeze_updates']);
61
  endif;
62
  endif;
63
  } /* UpdatedPostsControl::accept_POST() */
49
  <?php
50
  } /* UpdatedPostsControl::display() */
51
 
52
+ function accept_POST () {
53
  if ($this->page->for_feed_settings()) :
54
+ if ( ! is_null( FeedWordPress::post( 'freeze_updates' ) ) ) :
55
+ $this->page->link->settings['freeze updates'] = FeedWordPress::post( 'freeze_updates' );
56
  endif;
57
  else :
58
  // Updated posts
59
+ if ( ! is_null( FeedWordPress::post( 'freeze_updates' ) ) ) :
60
+ update_option('feedwordpress_freeze_updates', FeedWordPress::post( 'freeze_updates' ));
61
  endif;
62
  endif;
63
  } /* UpdatedPostsControl::accept_POST() */