Version Description
Download this release
Release Info
Developer | radgeek |
Plugin | FeedWordPress |
Version | 2009.1111 |
Comparing to | |
See all releases |
Code changes from version 2009.0707 to 2009.1111
- ChangeLog.text +10 -0
- MagpieRSS-upgrade/rss.php +47 -46
- admin-ui.php +496 -22
- authors-page.php +217 -254
- backend-page.php +142 -0
- categories-page.php +154 -225
- compatability.php +91 -0
- feeds-page.php +800 -0
- feedwordpress.php +232 -115
- posts-page.php +350 -330
- readme.txt +3 -3
- syndicatedlink.class.php +86 -6
- syndicatedpost.class.php +91 -7
- syndication-options.php +0 -243
- syndication.php +289 -674
ChangeLog.text
CHANGED
@@ -1,5 +1,15 @@
|
|
1 |
FeedWordPress Change Log
|
2 |
========================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
Changes from 2009.0618 to 2009.0707
|
4 |
-----------------------------------
|
5 |
* BUGFIX: WORDPRESS 2.8 AJAX COMPATIBILITY ISSUES RESOLVED (blank or
|
1 |
FeedWordPress Change Log
|
2 |
========================
|
3 |
+
Changes from 2009.0707 to Trunk
|
4 |
+
-------------------------------
|
5 |
+
* NEW INTERFACE HOOKS
|
6 |
+
|
7 |
+
* FILTER API: SyndicatedPost::isTaggedAs
|
8 |
+
|
9 |
+
* BUGIFX: SILENT FAILURE OF "SYNDICATE" BUTTON FIXED
|
10 |
+
|
11 |
+
* BUGFIX: MagpieRSS "ILLEGAL OFFSET TYPE" ERROR MESSAGE FIXED
|
12 |
+
|
13 |
Changes from 2009.0618 to 2009.0707
|
14 |
-----------------------------------
|
15 |
* BUGFIX: WORDPRESS 2.8 AJAX COMPATIBILITY ISSUES RESOLVED (blank or
|
MagpieRSS-upgrade/rss.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Author: Kellan Elliot-McCrea <kellan@protest.net>
|
5 |
* WordPress development team <http://www.wordpress.org/>
|
6 |
* Charles Johnson <technophilia@radgeek.com>
|
7 |
-
* Version: 2009.
|
8 |
* License: GPL
|
9 |
*
|
10 |
* Provenance:
|
@@ -146,6 +146,9 @@ class MagpieRSS {
|
|
146 |
'http://madskills.com/public/xml/rss/module/trackback/' => 'trackback',
|
147 |
'http://web.resource.org/cc/' => 'cc',
|
148 |
'http://search.yahoo.com/mrss' => 'media',
|
|
|
|
|
|
|
149 |
);
|
150 |
|
151 |
var $_XMLBASE_RESOLVE = array (
|
@@ -321,7 +324,7 @@ class MagpieRSS {
|
|
321 |
|
322 |
// check for a namespace, and split if found
|
323 |
// Don't munge content tags
|
324 |
-
$ns = $this->
|
325 |
if ( empty($this->incontent) ) {
|
326 |
$el = strtolower($ns['element']);
|
327 |
$this->current_namespace = $ns['effective'];
|
@@ -514,7 +517,7 @@ class MagpieRSS {
|
|
514 |
}
|
515 |
|
516 |
function feed_end_element ($p, $el) {
|
517 |
-
$closer = $this->
|
518 |
|
519 |
if ( $this->incontent ) {
|
520 |
$opener = array_pop($this->incontent);
|
@@ -579,7 +582,7 @@ class MagpieRSS {
|
|
579 |
}
|
580 |
|
581 |
// Namespace handling functions
|
582 |
-
function
|
583 |
$namespaces = end($this->stack['xmlns']);
|
584 |
$ns = '';
|
585 |
if ( strpos( $element, ':' ) ) {
|
@@ -1204,7 +1207,7 @@ endif;
|
|
1204 |
version will be return, if it exists (and if MAGPIE_CACHE_FRESH_ONLY is off)
|
1205 |
\*=======================================================================*/
|
1206 |
|
1207 |
-
define('MAGPIE_VERSION', '2009.
|
1208 |
|
1209 |
$MAGPIE_ERROR = "";
|
1210 |
|
@@ -1401,8 +1404,8 @@ function _fetch_remote_file ($url, $headers = "" ) {
|
|
1401 |
if (function_exists('wp_remote_request')) :
|
1402 |
$resp = wp_remote_request($url, array(
|
1403 |
'headers' => $headers,
|
1404 |
-
'timeout' => MAGPIE_FETCH_TIME_OUT
|
1405 |
-
);
|
1406 |
|
1407 |
if ( is_wp_error($resp) ) :
|
1408 |
$error = $resp->get_error_messages();
|
@@ -1439,46 +1442,44 @@ function _fetch_remote_file ($url, $headers = "" ) {
|
|
1439 |
Output: parsed RSS object (see rss_parse)
|
1440 |
\*=======================================================================*/
|
1441 |
function _response_to_rss ($resp, $url = null) {
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
$rss->header[$field] = $val;
|
1460 |
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
}
|
1483 |
|
1484 |
/*=======================================================================*\
|
4 |
* Author: Kellan Elliot-McCrea <kellan@protest.net>
|
5 |
* WordPress development team <http://www.wordpress.org/>
|
6 |
* Charles Johnson <technophilia@radgeek.com>
|
7 |
+
* Version: 2009.0725
|
8 |
* License: GPL
|
9 |
*
|
10 |
* Provenance:
|
146 |
'http://madskills.com/public/xml/rss/module/trackback/' => 'trackback',
|
147 |
'http://web.resource.org/cc/' => 'cc',
|
148 |
'http://search.yahoo.com/mrss' => 'media',
|
149 |
+
'http://search.yahoo.com/mrss/' => 'media',
|
150 |
+
'http://video.search.yahoo.com/mrss' => 'media',
|
151 |
+
'http://video.search.yahoo.com/mrss/' => 'media',
|
152 |
);
|
153 |
|
154 |
var $_XMLBASE_RESOLVE = array (
|
324 |
|
325 |
// check for a namespace, and split if found
|
326 |
// Don't munge content tags
|
327 |
+
$ns = $this->xmlns($element);
|
328 |
if ( empty($this->incontent) ) {
|
329 |
$el = strtolower($ns['element']);
|
330 |
$this->current_namespace = $ns['effective'];
|
517 |
}
|
518 |
|
519 |
function feed_end_element ($p, $el) {
|
520 |
+
$closer = $this->xmlns($el);
|
521 |
|
522 |
if ( $this->incontent ) {
|
523 |
$opener = array_pop($this->incontent);
|
582 |
}
|
583 |
|
584 |
// Namespace handling functions
|
585 |
+
function xmlns ($element) {
|
586 |
$namespaces = end($this->stack['xmlns']);
|
587 |
$ns = '';
|
588 |
if ( strpos( $element, ':' ) ) {
|
1207 |
version will be return, if it exists (and if MAGPIE_CACHE_FRESH_ONLY is off)
|
1208 |
\*=======================================================================*/
|
1209 |
|
1210 |
+
define('MAGPIE_VERSION', '2009.0725');
|
1211 |
|
1212 |
$MAGPIE_ERROR = "";
|
1213 |
|
1404 |
if (function_exists('wp_remote_request')) :
|
1405 |
$resp = wp_remote_request($url, array(
|
1406 |
'headers' => $headers,
|
1407 |
+
'timeout' => MAGPIE_FETCH_TIME_OUT
|
1408 |
+
));
|
1409 |
|
1410 |
if ( is_wp_error($resp) ) :
|
1411 |
$error = $resp->get_error_messages();
|
1442 |
Output: parsed RSS object (see rss_parse)
|
1443 |
\*=======================================================================*/
|
1444 |
function _response_to_rss ($resp, $url = null) {
|
1445 |
+
$rss = new MagpieRSS( $resp->results, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING, $url );
|
1446 |
+
|
1447 |
+
// if RSS parsed successfully
|
1448 |
+
if ( $rss and !$rss->ERROR) {
|
1449 |
+
$rss->http_status = $resp->status;
|
1450 |
+
|
1451 |
+
// find Etag, and Last-Modified
|
1452 |
+
foreach($resp->headers as $index => $h) {
|
1453 |
+
if (is_string($index)) :
|
1454 |
+
$field = $index;
|
1455 |
+
$val = $h;
|
1456 |
+
elseif (strpos($h, ": ")) :
|
1457 |
+
list($field, $val) = explode(": ", $h, 2);
|
1458 |
+
else :
|
1459 |
+
$field = $h; $val = '';
|
1460 |
+
endif;
|
|
|
|
|
1461 |
|
1462 |
+
$rss->header[$field] = $val;
|
1463 |
+
|
1464 |
+
if ( $field == 'ETag' ) :
|
1465 |
+
$rss->etag = $val;
|
1466 |
+
elseif ( $field == 'Last-Modified' ) :
|
1467 |
+
$rss->last_modified = $val;
|
1468 |
+
endif;
|
1469 |
+
}
|
1470 |
+
|
1471 |
+
return $rss;
|
1472 |
+
} // else construct error message
|
1473 |
+
else {
|
1474 |
+
$errormsg = "Failed to parse RSS file.";
|
1475 |
+
|
1476 |
+
if ($rss) {
|
1477 |
+
$errormsg .= " (" . $rss->ERROR . ")";
|
1478 |
+
}
|
1479 |
+
error($errormsg);
|
1480 |
+
|
1481 |
+
return false;
|
1482 |
+
} // end if ($rss and !$rss->error)
|
1483 |
}
|
1484 |
|
1485 |
/*=======================================================================*\
|
admin-ui.php
CHANGED
@@ -1,36 +1,335 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) :
|
|
|
4 |
?>
|
5 |
<div class="submitbox" id="submitlink">
|
6 |
<div id="previewview"></div>
|
7 |
<div class="inside"></div>
|
8 |
|
9 |
<p class="submit">
|
10 |
-
<input type="submit" name="
|
11 |
</p>
|
12 |
</div>
|
13 |
<?php
|
14 |
endif;
|
15 |
}
|
16 |
|
17 |
-
function
|
18 |
if (!fwp_test_wp_version(FWP_SCHEMA_25)) :
|
19 |
if (is_null($caption)) : $caption = __('Save Changes »'); endif;
|
20 |
?>
|
21 |
<p class="submit">
|
22 |
-
<input type="submit" name="
|
23 |
</p>
|
24 |
<?php
|
25 |
endif;
|
26 |
}
|
27 |
|
28 |
-
function
|
29 |
if (fwp_test_wp_version(FWP_SCHEMA_27)) :
|
30 |
if (is_null($caption)) : $caption = __('Save Changes'); endif;
|
31 |
?>
|
32 |
<p class="submit">
|
33 |
-
<input class="button-primary" type="submit" name="
|
34 |
</p>
|
35 |
<?php
|
36 |
endif;
|
@@ -56,8 +355,8 @@ function fwp_authors_single_submit ($link = NULL) {
|
|
56 |
}
|
57 |
|
58 |
function fwp_option_box_opener ($legend, $id, $class = "stuffbox") {
|
59 |
-
|
60 |
-
if (
|
61 |
?>
|
62 |
<div id="<?php print $id; ?>" class="<?php print $class; ?>">
|
63 |
<h3><?php print htmlspecialchars($legend); ?></h3>
|
@@ -65,7 +364,8 @@ function fwp_option_box_opener ($legend, $id, $class = "stuffbox") {
|
|
65 |
<?php
|
66 |
else :
|
67 |
?>
|
68 |
-
<
|
|
|
69 |
<?php
|
70 |
endif;
|
71 |
}
|
@@ -79,7 +379,7 @@ function fwp_option_box_closer () {
|
|
79 |
<?php
|
80 |
else :
|
81 |
?>
|
82 |
-
</
|
83 |
<?php
|
84 |
endif;
|
85 |
}
|
@@ -90,7 +390,6 @@ function fwp_tags_box ($tags, $object) {
|
|
90 |
$desc = "<p style=\"font-size:smaller;font-style:bold;margin:0\">Tag $object as...</p>";
|
91 |
|
92 |
if (fwp_test_wp_version(FWP_SCHEMA_28)) : // WordPress 2.8+
|
93 |
-
fwp_option_box_opener(__('Tags'), 'tagsdiv', 'postbox');
|
94 |
?>
|
95 |
<?php print $desc; ?>
|
96 |
<div class="tagsdiv" id="post_tag">
|
@@ -114,7 +413,6 @@ function fwp_tags_box ($tags, $object) {
|
|
114 |
</div>
|
115 |
<?php
|
116 |
else :
|
117 |
-
fwp_option_box_opener(__('Tags'), 'tagsdiv', 'postbox');
|
118 |
?>
|
119 |
<?php print $desc; ?>
|
120 |
<p id="jaxtag"><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo implode(",", $tags); ?>" /></p>
|
@@ -157,7 +455,7 @@ function fwp_category_box ($checked, $object, $tags = array()) {
|
|
157 |
<?php
|
158 |
elseif (fwp_test_wp_version(FWP_SCHEMA_20)) : // WordPress 2.x
|
159 |
?>
|
160 |
-
<div id="moremeta">
|
161 |
<div id="grabit" class="dbx-group">
|
162 |
<fieldset id="categorydiv" class="dbx-box">
|
163 |
<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
|
@@ -216,7 +514,6 @@ function fwp_author_list () {
|
|
216 |
|
217 |
class FeedWordPressSettingsUI {
|
218 |
function instead_of_posts_box ($link_id = null) {
|
219 |
-
fwp_option_box_opener('Syndicated Posts, Comments & Pings', 'syndicatedpostsdiv', 'postbox');
|
220 |
if (!is_null($link_id)) :
|
221 |
$from_this_feed = 'from this feed';
|
222 |
$by_default = '';
|
@@ -227,11 +524,10 @@ class FeedWordPressSettingsUI {
|
|
227 |
$id_param = "";
|
228 |
endif;
|
229 |
?>
|
230 |
-
<p>Use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php<?php print $id_param; ?>"><?php _e('Posts'); ?></a>
|
231 |
settings page to set up how new posts <?php print $from_this_feed; ?> will be published<?php $by_default; ?>, whether they will accept
|
232 |
comments and pings, any custom fields that should be set on each post, etc.</p>
|
233 |
<?php
|
234 |
-
fwp_option_box_closer();
|
235 |
} /* FeedWordPressSettingsUI::instead_of_posts_box () */
|
236 |
|
237 |
function instead_of_authors_box ($link_id = null) {
|
@@ -245,7 +541,6 @@ comments and pings, any custom fields that should be set on each post, etc.</p>
|
|
245 |
$id_param = "";
|
246 |
endif;
|
247 |
|
248 |
-
fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox')
|
249 |
?>
|
250 |
<p>Use the <a
|
251 |
href="admin.php?page=<?php print $GLOBALS['fwp_path']
|
@@ -254,7 +549,6 @@ href="admin.php?page=<?php print $GLOBALS['fwp_path']
|
|
254 |
<?php print $from_this_feed; ?> will be assigned to
|
255 |
authors.</p>
|
256 |
<?php
|
257 |
-
fwp_option_box_closer();
|
258 |
} /* FeedWordPressSettingsUI::instead_of_authors_box () */
|
259 |
|
260 |
function instead_of_categories_box ($link_id = null) {
|
@@ -268,14 +562,66 @@ authors.</p>
|
|
268 |
$id_param = "";
|
269 |
endif;
|
270 |
|
271 |
-
fwp_option_box_opener(__('Categories & Tags'), 'categorydiv', 'postbox');
|
272 |
?>
|
273 |
-
<p>Use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php<?php print $id_param; ?>"><?php _e('Categories
|
274 |
-
settings page to set up how new posts <?php print $from_this_feed; ?> are assigned categories or tags<?php print $by_default; ?>.</p>
|
275 |
<?php
|
276 |
-
fwp_option_box_closer();
|
277 |
} /* FeedWordPressSettingsUI::instead_of_categories_box () */
|
278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
} /* class FeedWordPressSettingsUI */
|
280 |
|
281 |
function fwp_insert_new_user ($newuser_name) {
|
@@ -306,3 +652,131 @@ function fwp_insert_new_user ($newuser_name) {
|
|
306 |
return $ret;
|
307 |
} /* fwp_insert_new_user () */
|
308 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
class FeedWordPressAdminPage {
|
3 |
+
var $context;
|
4 |
+
var $updated = false;
|
5 |
+
var $link = NULL;
|
6 |
+
var $dispatch = NULL;
|
7 |
+
var $filename = NULL;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Construct the admin page object.
|
11 |
+
*
|
12 |
+
* @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings
|
13 |
+
*/
|
14 |
+
function FeedWordPressAdminPage ($page = 'feedwordpressadmin', $link = NULL) {
|
15 |
+
$this->link = $link;
|
16 |
+
|
17 |
+
// Set meta-box context name
|
18 |
+
$this->context = $page;
|
19 |
+
if ($this->for_feed_settings()) :
|
20 |
+
$this->context .= 'forfeed';
|
21 |
+
endif;
|
22 |
+
} /* FeedWordPressAdminPage constructor */
|
23 |
+
|
24 |
+
function for_feed_settings () { return (is_object($this->link) and method_exists($this->link, 'found') and $this->link->found()); }
|
25 |
+
function for_default_settings () { return !$this->for_feed_settings(); }
|
26 |
+
|
27 |
+
/*static*/ function submitted_link_id () {
|
28 |
+
global $fwp_post;
|
29 |
+
|
30 |
+
// Presume global unless we get a specific link ID
|
31 |
+
$link_id = NULL;
|
32 |
+
|
33 |
+
$submit_buttons = array(
|
34 |
+
'save',
|
35 |
+
'submit',
|
36 |
+
'fix_mismatch',
|
37 |
+
'feedfinder',
|
38 |
+
);
|
39 |
+
foreach ($submit_buttons as $field) :
|
40 |
+
if (isset($fwp_post[$field])) :
|
41 |
+
$link_id = $_REQUEST['save_link_id'];
|
42 |
+
endif;
|
43 |
+
endforeach;
|
44 |
+
|
45 |
+
if (is_null($link_id) and isset($_REQUEST['link_id'])) :
|
46 |
+
$link_id = $_REQUEST['link_id'];
|
47 |
+
endif;
|
48 |
+
|
49 |
+
return $link_id;
|
50 |
+
} /* FeedWordPressAdminPage::submitted_link_id() */
|
51 |
+
|
52 |
+
/*static*/ function submitted_link () {
|
53 |
+
$link_id = FeedWordPressAdminPage::submitted_link_id();
|
54 |
+
if (is_numeric($link_id) and $link_id) :
|
55 |
+
$link =& new SyndicatedLink($link_id);
|
56 |
+
else :
|
57 |
+
$link = NULL;
|
58 |
+
endif;
|
59 |
+
return $link;
|
60 |
+
} /* FeedWordPressAdminPage::submitted_link () */
|
61 |
+
|
62 |
+
function stamp_link_id ($field = null) {
|
63 |
+
if (is_null($field)) : $field = 'save_link_id'; endif;
|
64 |
+
?>
|
65 |
+
<input type="hidden" name="<?php print wp_specialchars($field, 'both'); ?>" value="<?php print ($this->for_feed_settings() ? $this->link->id : '*'); ?>" />
|
66 |
+
<?php
|
67 |
+
} /* FeedWordPressAdminPage::stamp_link_id () */
|
68 |
+
|
69 |
+
function these_posts_phrase () {
|
70 |
+
if ($this->for_feed_settings()) :
|
71 |
+
$phrase = __('posts from this feed');
|
72 |
+
else :
|
73 |
+
$phrase = __('syndicated posts');
|
74 |
+
endif;
|
75 |
+
return $phrase;
|
76 |
+
} /* FeedWordPressAdminPage::these_posts_phrase() */
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Provides a uniquely identifying name for the interface context for
|
80 |
+
* use with add_meta_box() and do_meta_boxes(),
|
81 |
+
*
|
82 |
+
* @return string the context name
|
83 |
+
*
|
84 |
+
* @see add_meta_box()
|
85 |
+
* @see do_meta_boxes()
|
86 |
+
*/
|
87 |
+
function meta_box_context () {
|
88 |
+
return $this->context;
|
89 |
+
} /* FeedWordPressAdminPage::meta_box_context () */
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Outputs JavaScript to fix AJAX toggles settings.
|
93 |
+
*
|
94 |
+
* @uses FeedWordPressAdminPage::meta_box_context()
|
95 |
+
*/
|
96 |
+
function fix_toggles () {
|
97 |
+
FeedWordPressSettingsUI::fix_toggles_js($this->meta_box_context());
|
98 |
+
} /* FeedWordPressAdminPage::fix_toggles() */
|
99 |
+
|
100 |
+
function ajax_interface_js () {
|
101 |
+
?>
|
102 |
+
<script type="text/javascript">
|
103 |
+
function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) {
|
104 |
+
if (typeof(visibleStyle)=='undefined') visibleStyle = 'block';
|
105 |
+
|
106 |
+
var rollup=document.getElementById(item);
|
107 |
+
var newuser=document.getElementById(appear);
|
108 |
+
var sitewide=document.getElementById(disappear);
|
109 |
+
if (rollup) {
|
110 |
+
if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) {
|
111 |
+
if (newuser) newuser.style.display=visibleStyle;
|
112 |
+
if (sitewide) sitewide.style.display='none';
|
113 |
+
} else {
|
114 |
+
if (newuser) newuser.style.display='none';
|
115 |
+
if (sitewide) sitewide.style.display=visibleStyle;
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
</script>
|
120 |
+
|
121 |
+
<?php
|
122 |
+
} /* FeedWordPressAdminPage::ajax_interface_js () */
|
123 |
+
|
124 |
+
function display_feed_select_dropdown() {
|
125 |
+
$links = FeedWordPress::syndicated_links();
|
126 |
+
if (fwp_test_wp_version(FWP_SCHEMA_27)) :
|
127 |
+
?>
|
128 |
+
<style type="text/css">
|
129 |
+
#post-search {
|
130 |
+
float: right;
|
131 |
+
margin:11px 12px 0;
|
132 |
+
min-width: 130px;
|
133 |
+
position:relative;
|
134 |
+
}
|
135 |
+
.fwpfs {
|
136 |
+
color: #dddddd;
|
137 |
+
background:#797979 url(<?php bloginfo('home') ?>/wp-admin/images/fav.png) repeat-x scroll left center;
|
138 |
+
border-color:#777777 #777777 #666666 !important; -moz-border-radius-bottomleft:12px;
|
139 |
+
-moz-border-radius-bottomright:12px;
|
140 |
+
-moz-border-radius-topleft:12px;
|
141 |
+
-moz-border-radius-topright:12px;
|
142 |
+
border-style:solid;
|
143 |
+
border-width:1px;
|
144 |
+
line-height:15px;
|
145 |
+
padding:3px 30px 4px 12px;
|
146 |
+
}
|
147 |
+
.fwpfs.slide-down {
|
148 |
+
border-bottom-color: #626262;
|
149 |
+
-moz-border-radius-bottomleft:0;
|
150 |
+
-moz-border-radius-bottomright:0;
|
151 |
+
-moz-border-radius-topleft:12px;
|
152 |
+
-moz-border-radius-topright:12px;
|
153 |
+
background-image:url(<?php bloginfo('home') ?>/wp-admin/images/fav-top.png);
|
154 |
+
background-position:0 top;
|
155 |
+
background-repeat:repeat-x;
|
156 |
+
border-bottom-style:solid;
|
157 |
+
border-bottom-width:1px;
|
158 |
+
}
|
159 |
+
</style>
|
160 |
+
|
161 |
+
<script type="text/javascript">
|
162 |
+
jQuery(document).ready(function($){
|
163 |
+
$('.fwpfs').toggle(
|
164 |
+
function(){$('.fwpfs').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideDown') ) { $('.fwpfs').addClass('slide-down'); }}, 10) },
|
165 |
+
function(){$('.fwpfs').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideUp') ) { $('.fwpfs').removeClass('slide-down'); }}, 10) }
|
166 |
+
);
|
167 |
+
$('.fwpfs').bind(
|
168 |
+
'change',
|
169 |
+
function () { this.form.submit(); }
|
170 |
+
);
|
171 |
+
$('#post-search .button').css( 'display', 'none' );
|
172 |
+
});
|
173 |
+
</script>
|
174 |
+
<?php
|
175 |
+
endif;
|
176 |
+
|
177 |
+
?>
|
178 |
+
<p id="post-search">
|
179 |
+
<select name="link_id" class="fwpfs" style="max-width: 20.0em;">
|
180 |
+
<option value="*"<?php if ($this->for_default_settings()) : ?> selected="selected"<?php endif; ?>>- defaults for all feeds -</option>
|
181 |
+
<?php if ($links) : foreach ($links as $ddlink) : ?>
|
182 |
+
<option value="<?php print (int) $ddlink->link_id; ?>"<?php if (!is_null($this->link) and ($this->link->id==$ddlink->link_id)) : ?> selected="selected"<?php endif; ?>><?php print wp_specialchars($ddlink->link_name, 1); ?></option>
|
183 |
+
<?php endforeach; endif; ?>
|
184 |
+
</select>
|
185 |
+
<input class="button" type="submit" name="go" value="<?php _e('Go') ?> »" />
|
186 |
+
</p>
|
187 |
+
<?php
|
188 |
+
} /* FeedWordPressAdminPage::display_feed_select_dropdown() */
|
189 |
+
|
190 |
+
function display_sheet_header ($pagename = 'Syndication', $all = false) {
|
191 |
+
if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_27)) :
|
192 |
+
?>
|
193 |
+
<div class="icon32"><img src="<?php print wp_specialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png', 1); ?>" alt="" /></div>
|
194 |
+
<?php
|
195 |
+
endif;
|
196 |
+
?>
|
197 |
+
|
198 |
+
<h2><?php print wp_specialchars(__($pagename.($all ? '' : ' Settings')), 1); ?><?php if ($this->for_feed_settings()) : ?>: <?php echo wp_specialchars($this->link->link->link_name, 1); ?><?php endif; ?></h2>
|
199 |
+
<?php
|
200 |
+
}
|
201 |
+
|
202 |
+
function display_update_notice_if_updated ($pagename = 'Syndication', $mesg = NULL) {
|
203 |
+
if ($this->updated) :
|
204 |
+
if ($this->updated === true) :
|
205 |
+
$mesg = $pagename . ' settings updated.';
|
206 |
+
else :
|
207 |
+
$mesg = $this->updated;
|
208 |
+
endif;
|
209 |
+
endif;
|
210 |
+
|
211 |
+
if (!is_null($mesg)) :
|
212 |
+
?>
|
213 |
+
<div class="updated">
|
214 |
+
<p><?php print wp_specialchars($mesg, 1); ?></p>
|
215 |
+
</div>
|
216 |
+
<?php
|
217 |
+
endif;
|
218 |
+
} /* FeedWordPressAdminPage::display_update_notice_if_updated() */
|
219 |
+
|
220 |
+
function display_settings_scope_message () {
|
221 |
+
if ($this->for_feed_settings()) :
|
222 |
+
?>
|
223 |
+
<p>These settings only affect posts syndicated from
|
224 |
+
<strong><?php echo wp_specialchars($this->link->link->link_name, 1); ?></strong>.</p>
|
225 |
+
<?php
|
226 |
+
else :
|
227 |
+
?>
|
228 |
+
<p>These settings affect posts syndicated from any feed unless they are overridden
|
229 |
+
by settings for that specific feed.</p>
|
230 |
+
<?php
|
231 |
+
endif;
|
232 |
+
} /* FeedWordPressAdminPage::display_settings_scope_message () */
|
233 |
+
|
234 |
+
/*static*/ function has_link () { return true; }
|
235 |
+
|
236 |
+
function open_sheet ($header) {
|
237 |
+
// Set up prepatory AJAX stuff
|
238 |
+
$this->ajax_interface_js();
|
239 |
+
if (function_exists('add_meta_box')) :
|
240 |
+
add_action(
|
241 |
+
FeedWordPressCompatibility::bottom_script_hook($this->filename),
|
242 |
+
/*callback=*/ array($this, 'fix_toggles'),
|
243 |
+
/*priority=*/ 10000
|
244 |
+
);
|
245 |
+
FeedWordPressSettingsUI::ajax_nonce_fields();
|
246 |
+
endif;
|
247 |
+
|
248 |
+
?>
|
249 |
+
<div class="wrap" style="position:relative">
|
250 |
+
<?php
|
251 |
+
if (!is_null($header)) :
|
252 |
+
$this->display_sheet_header($header);
|
253 |
+
endif;
|
254 |
+
|
255 |
+
if (!is_null($this->dispatch)) :
|
256 |
+
?>
|
257 |
+
<form action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename($this->filename); ?>" method="post">
|
258 |
+
<div><?php
|
259 |
+
FeedWordPressCompatibility::stamp_nonce($this->dispatch);
|
260 |
+
$this->stamp_link_id();
|
261 |
+
?></div>
|
262 |
+
<?php
|
263 |
+
endif;
|
264 |
+
|
265 |
+
if ($this->has_link()) :
|
266 |
+
$this->display_feed_select_dropdown();
|
267 |
+
$this->display_settings_scope_message();
|
268 |
+
endif;
|
269 |
+
|
270 |
+
if (function_exists('do_meta_boxes')) :
|
271 |
+
?>
|
272 |
+
<div id="poststuff">
|
273 |
+
<?php
|
274 |
+
else :
|
275 |
+
?>
|
276 |
+
</div> <!-- class="wrap" -->
|
277 |
+
<?php
|
278 |
+
endif;
|
279 |
+
|
280 |
+
if (!is_null($this->dispatch)) :
|
281 |
+
fwp_settings_form_single_submit();
|
282 |
+
endif;
|
283 |
+
} /* FeedWordPressAdminPage::open_sheet () */
|
284 |
+
|
285 |
+
function close_sheet () {
|
286 |
+
// WordPress 2.5+
|
287 |
+
if (function_exists('do_meta_boxes')) :
|
288 |
+
?>
|
289 |
+
</div> <!-- id="poststuff" -->
|
290 |
+
<?php if (!is_null($this->dispatch)) : ?>
|
291 |
+
<?php fwp_settings_form_single_submit_closer(); ?>
|
292 |
+
</form>
|
293 |
+
<?php endif; ?>
|
294 |
+
</div> <!-- class="wrap" -->
|
295 |
+
<?php
|
296 |
+
endif;
|
297 |
+
}
|
298 |
+
} /* class FeedWordPressAdminPage */
|
299 |
+
|
300 |
+
function fwp_settings_form_single_submit ($caption = NULL) {
|
301 |
if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) :
|
302 |
+
if (is_null($caption)) : $caption = __('Save'); endif;
|
303 |
?>
|
304 |
<div class="submitbox" id="submitlink">
|
305 |
<div id="previewview"></div>
|
306 |
<div class="inside"></div>
|
307 |
|
308 |
<p class="submit">
|
309 |
+
<input type="submit" name="save" value="<?php print $caption; ?>" />
|
310 |
</p>
|
311 |
</div>
|
312 |
<?php
|
313 |
endif;
|
314 |
}
|
315 |
|
316 |
+
function fwp_settings_form_periodic_submit ($caption = NULL) {
|
317 |
if (!fwp_test_wp_version(FWP_SCHEMA_25)) :
|
318 |
if (is_null($caption)) : $caption = __('Save Changes »'); endif;
|
319 |
?>
|
320 |
<p class="submit">
|
321 |
+
<input type="submit" name="save" value="<?php print $caption; ?>" />
|
322 |
</p>
|
323 |
<?php
|
324 |
endif;
|
325 |
}
|
326 |
|
327 |
+
function fwp_settings_form_single_submit_closer ($caption = NULL) {
|
328 |
if (fwp_test_wp_version(FWP_SCHEMA_27)) :
|
329 |
if (is_null($caption)) : $caption = __('Save Changes'); endif;
|
330 |
?>
|
331 |
<p class="submit">
|
332 |
+
<input class="button-primary" type="submit" name="save" value="<?php print $caption; ?>" />
|
333 |
</p>
|
334 |
<?php
|
335 |
endif;
|
355 |
}
|
356 |
|
357 |
function fwp_option_box_opener ($legend, $id, $class = "stuffbox") {
|
358 |
+
// WordPress 2.5+
|
359 |
+
if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_25)) :
|
360 |
?>
|
361 |
<div id="<?php print $id; ?>" class="<?php print $class; ?>">
|
362 |
<h3><?php print htmlspecialchars($legend); ?></h3>
|
364 |
<?php
|
365 |
else :
|
366 |
?>
|
367 |
+
<div class="wrap">
|
368 |
+
<h2><?php print htmlspecialchars($legend); ?></h2>
|
369 |
<?php
|
370 |
endif;
|
371 |
}
|
379 |
<?php
|
380 |
else :
|
381 |
?>
|
382 |
+
</div> <!-- class="wrap" -->
|
383 |
<?php
|
384 |
endif;
|
385 |
}
|
390 |
$desc = "<p style=\"font-size:smaller;font-style:bold;margin:0\">Tag $object as...</p>";
|
391 |
|
392 |
if (fwp_test_wp_version(FWP_SCHEMA_28)) : // WordPress 2.8+
|
|
|
393 |
?>
|
394 |
<?php print $desc; ?>
|
395 |
<div class="tagsdiv" id="post_tag">
|
413 |
</div>
|
414 |
<?php
|
415 |
else :
|
|
|
416 |
?>
|
417 |
<?php print $desc; ?>
|
418 |
<p id="jaxtag"><input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo implode(",", $tags); ?>" /></p>
|
455 |
<?php
|
456 |
elseif (fwp_test_wp_version(FWP_SCHEMA_20)) : // WordPress 2.x
|
457 |
?>
|
458 |
+
<div id="moremeta" style="position: relative; right: auto">
|
459 |
<div id="grabit" class="dbx-group">
|
460 |
<fieldset id="categorydiv" class="dbx-box">
|
461 |
<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
|
514 |
|
515 |
class FeedWordPressSettingsUI {
|
516 |
function instead_of_posts_box ($link_id = null) {
|
|
|
517 |
if (!is_null($link_id)) :
|
518 |
$from_this_feed = 'from this feed';
|
519 |
$by_default = '';
|
524 |
$id_param = "";
|
525 |
endif;
|
526 |
?>
|
527 |
+
<p>Use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php<?php print $id_param; ?>"><?php _e('Posts & Links'); ?></a>
|
528 |
settings page to set up how new posts <?php print $from_this_feed; ?> will be published<?php $by_default; ?>, whether they will accept
|
529 |
comments and pings, any custom fields that should be set on each post, etc.</p>
|
530 |
<?php
|
|
|
531 |
} /* FeedWordPressSettingsUI::instead_of_posts_box () */
|
532 |
|
533 |
function instead_of_authors_box ($link_id = null) {
|
541 |
$id_param = "";
|
542 |
endif;
|
543 |
|
|
|
544 |
?>
|
545 |
<p>Use the <a
|
546 |
href="admin.php?page=<?php print $GLOBALS['fwp_path']
|
549 |
<?php print $from_this_feed; ?> will be assigned to
|
550 |
authors.</p>
|
551 |
<?php
|
|
|
552 |
} /* FeedWordPressSettingsUI::instead_of_authors_box () */
|
553 |
|
554 |
function instead_of_categories_box ($link_id = null) {
|
562 |
$id_param = "";
|
563 |
endif;
|
564 |
|
|
|
565 |
?>
|
566 |
+
<p>Use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php<?php print $id_param; ?>"><?php _e('Categories'.FEEDWORDPRESS_AND_TAGS); ?></a>
|
567 |
+
settings page to set up how new posts <?php print $from_this_feed; ?> are assigned categories <?php if (FeedWordPressCompatibility::post_tags()) : ?>or tags<?php endif; ?><?php print $by_default; ?>.</p>
|
568 |
<?php
|
|
|
569 |
} /* FeedWordPressSettingsUI::instead_of_categories_box () */
|
570 |
|
571 |
+
/*static*/ function ajax_nonce_fields () {
|
572 |
+
if (function_exists('wp_nonce_field')) :
|
573 |
+
echo "<form style='display: none' method='get' action=''>\n<p>\n";
|
574 |
+
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
575 |
+
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
576 |
+
echo "</p>\n</form>\n";
|
577 |
+
endif;
|
578 |
+
} /* FeedWordPressSettingsUI::ajax_nonce_fields () */
|
579 |
+
|
580 |
+
/*static*/ function fix_toggles_js ($context) {
|
581 |
+
?>
|
582 |
+
<script type="text/javascript">
|
583 |
+
jQuery(document).ready( function($) {
|
584 |
+
<?php if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
|
585 |
+
// In case someone got here first...
|
586 |
+
jQuery('.postbox h3').unbind('click');
|
587 |
+
|
588 |
+
add_postbox_toggles('<?php print $context; ?>');
|
589 |
+
<?php elseif (FeedWordPressCompatibility::test_version(FWP_SCHEMA_27)) : ?>
|
590 |
+
// In case someone got here first...
|
591 |
+
$('.postbox h3, .postbox .handlediv').unbind('click');
|
592 |
+
$('.postbox h3 a').unbind('click');
|
593 |
+
$('.hide-postbox-tog').unbind('click');
|
594 |
+
$('.columns-prefs input[type="radio"]').unbind('click');
|
595 |
+
$('.meta-box-sortables').sortable('destroy');
|
596 |
+
|
597 |
+
postboxes.add_postbox_toggles('<?php print $context; ?>');
|
598 |
+
<?php endif; ?>
|
599 |
+
} );
|
600 |
+
</script>
|
601 |
+
<?php
|
602 |
+
} /* FeedWordPressSettingsUI::fix_toggles_js () */
|
603 |
+
|
604 |
+
function magic_input_tip_js ($id) {
|
605 |
+
if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_25)) :
|
606 |
+
?>
|
607 |
+
<script type="text/javascript">
|
608 |
+
jQuery(document).ready( function () {
|
609 |
+
var inputBox = jQuery("#<?php print $id; ?>");
|
610 |
+
var boxEl = inputBox.get(0);
|
611 |
+
if (boxEl.value==boxEl.defaultValue) { inputBox.addClass('form-input-tip'); }
|
612 |
+
inputBox.focus(function() {
|
613 |
+
if ( this.value == this.defaultValue )
|
614 |
+
jQuery(this).val( '' ).removeClass( 'form-input-tip' );
|
615 |
+
});
|
616 |
+
inputBox.blur(function() {
|
617 |
+
if ( this.value == '' )
|
618 |
+
jQuery(this).val( this.defaultValue ).addClass( 'form-input-tip' );
|
619 |
+
});
|
620 |
+
} );
|
621 |
+
</script>
|
622 |
+
<?php
|
623 |
+
endif;
|
624 |
+
} /* FeedWordPressSettingsUI::magic_input_tip_js () */
|
625 |
} /* class FeedWordPressSettingsUI */
|
626 |
|
627 |
function fwp_insert_new_user ($newuser_name) {
|
652 |
return $ret;
|
653 |
} /* fwp_insert_new_user () */
|
654 |
|
655 |
+
function fwp_add_meta_box ($id, $title, $callback, $page, $context = 'advanced', $priority = 'default', $callback_args = null) {
|
656 |
+
if (function_exists('add_meta_box')) :
|
657 |
+
return add_meta_box($id, $title, $callback, $page, $context, $priority, $callback_args);
|
658 |
+
else :
|
659 |
+
/* Re-used as per terms of the GPL from add_meta_box() in WordPress 2.8.1 wp-admin/includes/template.php. */
|
660 |
+
global $wp_meta_boxes;
|
661 |
+
|
662 |
+
if ( !isset($wp_meta_boxes) )
|
663 |
+
$wp_meta_boxes = array();
|
664 |
+
if ( !isset($wp_meta_boxes[$page]) )
|
665 |
+
$wp_meta_boxes[$page] = array();
|
666 |
+
if ( !isset($wp_meta_boxes[$page][$context]) )
|
667 |
+
$wp_meta_boxes[$page][$context] = array();
|
668 |
+
|
669 |
+
foreach ( array_keys($wp_meta_boxes[$page]) as $a_context ) {
|
670 |
+
foreach ( array('high', 'core', 'default', 'low') as $a_priority ) {
|
671 |
+
if ( !isset($wp_meta_boxes[$page][$a_context][$a_priority][$id]) )
|
672 |
+
continue;
|
673 |
+
|
674 |
+
// If a core box was previously added or removed by a plugin, don't add.
|
675 |
+
if ( 'core' == $priority ) {
|
676 |
+
// If core box previously deleted, don't add
|
677 |
+
if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] )
|
678 |
+
return;
|
679 |
+
// If box was added with default priority, give it core priority to maintain sort order
|
680 |
+
if ( 'default' == $a_priority ) {
|
681 |
+
$wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id];
|
682 |
+
unset($wp_meta_boxes[$page][$a_context]['default'][$id]);
|
683 |
+
}
|
684 |
+
return;
|
685 |
+
}
|
686 |
+
// If no priority given and id already present, use existing priority
|
687 |
+
if ( empty($priority) ) {
|
688 |
+
$priority = $a_priority;
|
689 |
+
// else if we're adding to the sorted priortiy, we don't know the title or callback. Glab them from the previously added context/priority.
|
690 |
+
} elseif ( 'sorted' == $priority ) {
|
691 |
+
$title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title'];
|
692 |
+
$callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback'];
|
693 |
+
$callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args'];
|
694 |
+
}
|
695 |
+
// An id can be in only one priority and one context
|
696 |
+
if ( $priority != $a_priority || $context != $a_context )
|
697 |
+
unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]);
|
698 |
+
}
|
699 |
+
}
|
700 |
+
|
701 |
+
if ( empty($priority) )
|
702 |
+
$priority = 'low';
|
703 |
+
|
704 |
+
if ( !isset($wp_meta_boxes[$page][$context][$priority]) )
|
705 |
+
$wp_meta_boxes[$page][$context][$priority] = array();
|
706 |
+
|
707 |
+
$wp_meta_boxes[$page][$context][$priority][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $callback_args);
|
708 |
+
endif;
|
709 |
+
} /* function fwp_add_meta_box () */
|
710 |
+
|
711 |
+
function fwp_do_meta_boxes($page, $context, $object) {
|
712 |
+
if (function_exists('do_meta_boxes')) :
|
713 |
+
$ret = do_meta_boxes($page, $context, $object);
|
714 |
+
|
715 |
+
// Avoid JavaScript error from WordPress 2.5 bug
|
716 |
+
?>
|
717 |
+
<div style="display: none">
|
718 |
+
<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
|
719 |
+
</div>
|
720 |
+
<?php
|
721 |
+
return $ret;
|
722 |
+
else :
|
723 |
+
/* Derived as per terms of the GPL from do_meta_boxes() in WordPress 2.8.1 wp-admin/includes/template.php. */
|
724 |
+
global $wp_meta_boxes;
|
725 |
+
static $already_sorted = false;
|
726 |
+
|
727 |
+
//do_action('do_meta_boxes', $page, $context, $object);
|
728 |
+
|
729 |
+
echo "<div id='$context-sortables' class='meta-box-sortables'>\n";
|
730 |
+
|
731 |
+
$i = 0;
|
732 |
+
do {
|
733 |
+
if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) )
|
734 |
+
break;
|
735 |
+
|
736 |
+
foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) {
|
737 |
+
if ( isset($wp_meta_boxes[$page][$context][$priority]) ) {
|
738 |
+
foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) {
|
739 |
+
if ( false == $box || ! $box['title'] )
|
740 |
+
continue;
|
741 |
+
$i++;
|
742 |
+
fwp_option_box_opener($box['title'], $box['id'], 'postbox' /*. postbox_classes($box['id'], $page)*/);
|
743 |
+
call_user_func($box['callback'], $object, $box);
|
744 |
+
fwp_option_box_closer();
|
745 |
+
|
746 |
+
if (is_object($object) and method_exists($object, 'interstitial')) :
|
747 |
+
$object->interstitial();
|
748 |
+
else :
|
749 |
+
// Submit button for WP 1.5, early 2.x style
|
750 |
+
fwp_settings_form_periodic_submit();
|
751 |
+
endif;
|
752 |
+
}
|
753 |
+
}
|
754 |
+
}
|
755 |
+
} while(0);
|
756 |
+
|
757 |
+
echo "</div>";
|
758 |
+
|
759 |
+
return $i;
|
760 |
+
endif;
|
761 |
+
} /* function fwp_do_meta_boxes() */
|
762 |
+
|
763 |
+
function fwp_remove_meta_box($id, $page, $context) {
|
764 |
+
if (function_exists('remove_meta_box')) :
|
765 |
+
return remove_meta_box($id, $page, $context);
|
766 |
+
else :
|
767 |
+
/* Re-used as per terms of the GPL from remove_meta_box() in WordPress 2.8.1 wp-admin/includes/template.php */
|
768 |
+
global $wp_meta_boxes;
|
769 |
+
|
770 |
+
if ( !isset($wp_meta_boxes) )
|
771 |
+
$wp_meta_boxes = array();
|
772 |
+
if ( !isset($wp_meta_boxes[$page]) )
|
773 |
+
$wp_meta_boxes[$page] = array();
|
774 |
+
if ( !isset($wp_meta_boxes[$page][$context]) )
|
775 |
+
$wp_meta_boxes[$page][$context] = array();
|
776 |
+
|
777 |
+
foreach ( array('high', 'core', 'default', 'low') as $priority )
|
778 |
+
$wp_meta_boxes[$page][$context][$priority][$id] = false;
|
779 |
+
endif;
|
780 |
+
} /* function fwp_remove_meta_box() */
|
781 |
+
|
782 |
+
|
authors-page.php
CHANGED
@@ -1,25 +1,175 @@
|
|
1 |
<?php
|
2 |
require_once(dirname(__FILE__) . '/admin-ui.php');
|
3 |
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
-
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
endif;
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
endif;
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
$mesg = null;
|
24 |
|
25 |
if (isset($GLOBALS['fwp_post']['fix_mismatch'])) :
|
@@ -197,264 +347,79 @@ function fwp_authors_page () {
|
|
197 |
|
198 |
$updated_link = true;
|
199 |
endif;
|
200 |
-
else :
|
201 |
-
$updated_link = false;
|
202 |
-
endif;
|
203 |
|
204 |
-
|
205 |
-
|
206 |
-
if (is_object($link) and $link->found()) :
|
207 |
-
if (is_string($link->settings["unfamiliar author"])) :
|
208 |
-
$key = $link->settings["unfamiliar author"];
|
209 |
-
else:
|
210 |
-
$key = 'site-default';
|
211 |
-
endif;
|
212 |
else :
|
213 |
-
$
|
214 |
endif;
|
|
|
|
|
|
|
|
|
215 |
|
216 |
-
$
|
217 |
-
|
218 |
-
$match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email"));
|
219 |
-
$null_emails = FeedWordPress::null_email_set();
|
220 |
?>
|
221 |
-
<script type="text/javascript">
|
222 |
-
function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) {
|
223 |
-
if (typeof(visibleStyle)=='undefined') visibleStyle = 'block';
|
224 |
-
|
225 |
-
var rollup=document.getElementById(item);
|
226 |
-
var newuser=document.getElementById(appear);
|
227 |
-
var sitewide=document.getElementById(disappear);
|
228 |
-
if (rollup) {
|
229 |
-
if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) {
|
230 |
-
if (newuser) newuser.style.display=visibleStyle;
|
231 |
-
if (sitewide) sitewide.style.display='none';
|
232 |
-
} else {
|
233 |
-
if (newuser) newuser.style.display='none';
|
234 |
-
if (sitewide) sitewide.style.display=visibleStyle;
|
235 |
-
}
|
236 |
-
}
|
237 |
-
}
|
238 |
-
</script>
|
239 |
-
|
240 |
-
<?php if ($updated_link) : ?>
|
241 |
<div class="updated"><p>Syndicated author settings updated.</p></div>
|
242 |
<?php elseif (!is_null($mesg)) : ?>
|
243 |
<div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div>
|
244 |
-
<?php endif;
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
<input type="hidden" name="save_link_id" value="<?php echo $link_id; ?>" />
|
254 |
-
<?php
|
255 |
-
else :
|
256 |
-
?>
|
257 |
-
<input type="hidden" name="save_link_id" value="*" />
|
258 |
-
<?php
|
259 |
endif;
|
260 |
-
?>
|
261 |
-
</div>
|
262 |
|
263 |
-
|
264 |
-
|
265 |
-
<div
|
266 |
-
<?php
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
background:#797979 url(<?php bloginfo('home') ?>/wp-admin/images/fav.png) repeat-x scroll left center;
|
279 |
-
border-color:#777777 #777777 #666666 !important; -moz-border-radius-bottomleft:12px;
|
280 |
-
-moz-border-radius-bottomright:12px;
|
281 |
-
-moz-border-radius-topleft:12px;
|
282 |
-
-moz-border-radius-topright:12px;
|
283 |
-
border-style:solid;
|
284 |
-
border-width:1px;
|
285 |
-
line-height:15px;
|
286 |
-
padding:3px 30px 4px 12px;
|
287 |
-
}
|
288 |
-
.fwpfs.slide-down {
|
289 |
-
border-bottom-color: #626262;
|
290 |
-
-moz-border-radius-bottomleft:0;
|
291 |
-
-moz-border-radius-bottomright:0;
|
292 |
-
-moz-border-radius-topleft:12px;
|
293 |
-
-moz-border-radius-topright:12px;
|
294 |
-
background-image:url(<?php bloginfo('home') ?>/wp-admin/images/fav-top.png);
|
295 |
-
background-position:0 top;
|
296 |
-
background-repeat:repeat-x;
|
297 |
-
border-bottom-style:solid;
|
298 |
-
border-bottom-width:1px;
|
299 |
-
}
|
300 |
-
</style>
|
301 |
-
|
302 |
-
<script type="text/javascript">
|
303 |
-
jQuery(document).ready(function($){
|
304 |
-
$('.fwpfs').toggle(
|
305 |
-
function(){$('.fwpfs').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideDown') ) { $('.fwpfs').addClass('slide-down'); }}, 10) },
|
306 |
-
function(){$('.fwpfs').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideUp') ) { $('.fwpfs').removeClass('slide-down'); }}, 10) }
|
307 |
-
);
|
308 |
-
$('.fwpfs').bind(
|
309 |
-
'change',
|
310 |
-
function () { this.form.submit(); }
|
311 |
-
);
|
312 |
-
$('#post-search .button').css( 'display', 'none' );
|
313 |
-
});
|
314 |
-
</script>
|
315 |
-
<?php endif; /* else : */?>
|
316 |
-
<p id="post-search">
|
317 |
-
<select name="link_id" class="fwpfs" style="max-width: 20.0em;">
|
318 |
-
<option value="*"<?php if (is_null($link) or !$link->found()) : ?> selected="selected"<?php endif; ?>>- defaults for all feeds -</option>
|
319 |
-
<?php if ($links) : foreach ($links as $ddlink) : ?>
|
320 |
-
<option value="<?php print (int) $ddlink->link_id; ?>"<?php if (!is_null($link) and ($link->link->link_id==$ddlink->link_id)) : ?> selected="selected"<?php endif; ?>><?php print wp_specialchars($ddlink->link_name, 1); ?></option>
|
321 |
-
<?php endforeach; endif; ?>
|
322 |
-
</select>
|
323 |
-
<input class="button" type="submit" name="go" value="<?php _e('Go') ?> »" />
|
324 |
-
</p>
|
325 |
-
<?php /* endif; */ ?>
|
326 |
-
|
327 |
-
<?php if (!is_null($link) and $link->found()) : ?>
|
328 |
-
<p>These settings only affect posts syndicated from
|
329 |
-
<strong><?php echo wp_specialchars($link->link->link_name, 1); ?></strong>.</p>
|
330 |
-
<?php else : ?>
|
331 |
-
<p>These settings affect posts syndicated from any feed unless they are overridden
|
332 |
-
by settings for that specific feed.</p>
|
333 |
-
<?php endif; ?>
|
334 |
-
|
335 |
-
<?php
|
336 |
-
$authorlist = fwp_author_list();
|
337 |
-
?>
|
338 |
-
<table class="form-table">
|
339 |
-
<tbody>
|
340 |
-
<tr>
|
341 |
-
<th>New authors</th>
|
342 |
-
<td><span>Authors who haven't been syndicated before</span>
|
343 |
-
<select style="max-width: 27.0em" id="unfamiliar-author" name="unfamiliar_author" onchange="contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');">
|
344 |
-
<?php if (is_object($link) and $link->found()) : ?>
|
345 |
-
<option value="site-default"<?php print $unfamiliar['site-default']; ?>>are handled according to the default for all feeds</option>
|
346 |
-
<?php endif; ?>
|
347 |
-
<option value="create"<?php $unfamiliar['create']; ?>>will have a new author account created for them</option>
|
348 |
-
<?php foreach ($authorlist as $author_id => $author_name) : ?>
|
349 |
-
<option value="<?php echo $author_id; ?>"<?php print $unfamiliar[$author_id]; ?>>will have their posts attributed to <?php echo $author_name; ?></option>
|
350 |
-
<?php endforeach; ?>
|
351 |
-
<option value="newuser">will have their posts attributed to a new user...</option>
|
352 |
-
<option value="filter"<?php print $unfamiliar['filter'] ?>>get filtered out</option>
|
353 |
-
</select>
|
354 |
|
355 |
-
|
356 |
-
|
357 |
-
|
|
|
|
|
|
|
|
|
|
|
358 |
|
359 |
-
|
360 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
?>
|
362 |
-
<
|
363 |
-
<td>For attributing posts by specific authors. Blank out a name to delete the rule. Fill in a new name at the bottom to create a new rule.</p>
|
364 |
-
<table style="width: 100%">
|
365 |
<?php
|
366 |
-
|
367 |
-
?>
|
368 |
-
<?php
|
369 |
-
$i=0;
|
370 |
-
foreach ($link->settings['map authors'] as $author_rules) :
|
371 |
-
foreach ($author_rules as $author_name => $author_action) :
|
372 |
-
$i++;
|
373 |
?>
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
<select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="contextual_appearance('author-rules-<?php echo $i; ?>', 'author-rules-<?php echo $i; ?>-newuser', 'author-rules-<?php echo $i; ?>-default', 'newuser', 'inline');">
|
378 |
-
<?php foreach ($authorlist as $local_author_id => $local_author_name) : ?>
|
379 |
-
<option value="<?php echo $local_author_id; ?>"<?php if ($local_author_id==$author_action) : echo ' selected="selected"'; endif; ?>>are assigned to <?php echo $local_author_name; ?></option>
|
380 |
-
<?php endforeach; ?>
|
381 |
-
<option value="newuser">will be assigned to a new user...</option>
|
382 |
-
<option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
|
383 |
-
</select>
|
384 |
-
|
385 |
-
<span id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></span>
|
386 |
-
</td>
|
387 |
-
</tr>
|
388 |
-
<?php endforeach;
|
389 |
-
endforeach;
|
390 |
-
endif;
|
391 |
-
?>
|
392 |
-
|
393 |
-
<tr>
|
394 |
-
<th style="text-align: left; width: 15.0em">Posts by <input type="text" name="add_author_rule_name" size="11" /></th>
|
395 |
-
<td>
|
396 |
-
<select id="add-author-rule" name="add_author_rule_action" onchange="contextual_appearance('add-author-rule', 'add-author-rule-newuser', 'add-author-rule-default', 'newuser', 'inline');">
|
397 |
-
<?php foreach ($authorlist as $author_id => $author_name) : ?>
|
398 |
-
<option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
|
399 |
-
<?php endforeach; ?>
|
400 |
-
<option value="newuser">will be assigned to a new user...</option>
|
401 |
-
<option value="filter">get filtered out</option>
|
402 |
-
</select>
|
403 |
-
|
404 |
-
<span id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></span>
|
405 |
-
</td>
|
406 |
-
</tr>
|
407 |
-
</table>
|
408 |
-
</td>
|
409 |
-
</tr>
|
410 |
-
<?php endif; ?>
|
411 |
-
|
412 |
-
<?php if (!(is_object($link) and $link->found())) : ?>
|
413 |
-
<tr>
|
414 |
-
<th scope="row">Matching Authors</th>
|
415 |
-
<td><ul style="list-style: none; margin: 0; padding: 0;">
|
416 |
-
<li><div><label><input id="match-author-by-email" type="checkbox" name="match_author_by_email" value="yes" <?php if ($match_author_by_email) : ?>checked="checked" <?php endif; ?>onchange="contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);" /> Treat syndicated authors with the same e-mail address as the same author.</label></div>
|
417 |
-
<div id="unless-null-email">
|
418 |
-
<p>Unless the e-mail address is one of the following anonymous e-mail addresses:</p>
|
419 |
-
<textarea name="null_emails" rows="3" style="width: 100%">
|
420 |
-
<?php print implode("\n", $null_emails); ?>
|
421 |
-
</textarea>
|
422 |
-
</div></li>
|
423 |
-
</ul></td>
|
424 |
-
</tr>
|
425 |
-
<?php else : ?>
|
426 |
-
<th scope="row">Fixing mis-matched authors:</th>
|
427 |
-
<td><p style="margin: 0.5em 0px">Take all the posts from this feed attributed to
|
428 |
-
<select name="fix_mismatch_from">
|
429 |
-
<?php foreach ($authorlist as $author_id => $author_name) : ?>
|
430 |
-
<option value="<?php echo $author_id; ?>"><?php echo $author_name; ?></option>
|
431 |
-
<?php endforeach; ?>
|
432 |
-
</select>
|
433 |
-
and instead
|
434 |
-
<select id="fix-mismatch-to" name="fix_mismatch_to" onchange="contextual_appearance('fix-mismatch-to', 'fix-mismatch-to-newuser', null, 'newuser', 'inline');">
|
435 |
-
<?php foreach ($authorlist as $author_id => $author_name) : ?>
|
436 |
-
<option value="<?php echo $author_id; ?>">re-assign them to <?php echo $author_name; ?></option>
|
437 |
-
<?php endforeach; ?>
|
438 |
-
<option value="newuser">re-assign them to a new user...</option>
|
439 |
-
<option value="filter">delete them</option>
|
440 |
-
</select>
|
441 |
-
|
442 |
-
<span id="fix-mismatch-to-newuser">named <input type="text" name="fix_mismatch_to_newuser" value="" /></span>
|
443 |
-
<input type="submit" class="button" name="fix_mismatch" value="Fix it!" />
|
444 |
-
</td>
|
445 |
-
</td>
|
446 |
-
<?php endif; ?>
|
447 |
-
</tbody>
|
448 |
-
</table>
|
449 |
-
|
450 |
-
<p class="submit">
|
451 |
-
<input class="button-primary" type="submit" name="save" value="Save Changes" />
|
452 |
-
</p>
|
453 |
|
454 |
<script type="text/javascript">
|
455 |
contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');
|
456 |
<?php if (is_object($link) and $link->found()) : ?>
|
457 |
-
<?php for ($j=1; $j<=$
|
458 |
contextual_appearance('author-rules-<?php echo $j; ?>', 'author-rules-<?php echo $j; ?>-newuser', 'author-rules-<?php echo $j; ?>-default', 'newuser', 'inline');
|
459 |
<?php endfor; ?>
|
460 |
contextual_appearance('add-author-rule', 'add-author-rule-newuser', 'add-author-rule-default', 'newuser', 'inline');
|
@@ -463,8 +428,6 @@ and instead
|
|
463 |
contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);
|
464 |
<?php endif; ?>
|
465 |
</script>
|
466 |
-
</form>
|
467 |
-
</div> <!-- class="wrap" -->
|
468 |
<?php
|
469 |
} /* function fwp_authors_page () */
|
470 |
|
1 |
<?php
|
2 |
require_once(dirname(__FILE__) . '/admin-ui.php');
|
3 |
|
4 |
+
class FeedWordPressAuthorsPage extends FeedWordPressAdminPage {
|
5 |
+
var $authorlist = NULL;
|
6 |
+
var $rule_count = 0;
|
7 |
+
|
8 |
+
function FeedWordPressAuthorsPage ($link) {
|
9 |
+
FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressauthors', $link);
|
10 |
+
$this->authorlist = fwp_author_list();
|
11 |
+
$this->dispatch = 'feedwordpress_author_settings';
|
12 |
+
$this->filename = __FILE__;
|
13 |
+
}
|
14 |
+
|
15 |
+
/*static*/ function syndicated_authors_box ($page, $box = NULL) {
|
16 |
+
$link = $page->link;
|
17 |
+
$unfamiliar = array ('create' => '','default' => '','filter' => '');
|
18 |
+
|
19 |
+
if ($page->for_feed_settings()) :
|
20 |
+
if (is_string($link->settings["unfamiliar author"])) :
|
21 |
+
$key = $link->settings["unfamiliar author"];
|
22 |
+
else:
|
23 |
+
$key = 'site-default';
|
24 |
+
endif;
|
25 |
+
else :
|
26 |
+
$key = FeedWordPress::on_unfamiliar('author');
|
27 |
+
endif;
|
28 |
+
$unfamiliar[$key] = ' selected="selected"';
|
29 |
|
30 |
+
$match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email"));
|
31 |
+
$null_emails = FeedWordPress::null_email_set();
|
32 |
|
33 |
+
// Hey ho, let's go...
|
34 |
+
?>
|
35 |
+
<table class="form-table">
|
36 |
+
<tbody>
|
37 |
+
<tr>
|
38 |
+
<th>New authors</th>
|
39 |
+
<td><span>Authors who haven't been syndicated before</span>
|
40 |
+
<select style="max-width: 27.0em" id="unfamiliar-author" name="unfamiliar_author" onchange="contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');">
|
41 |
+
<?php if ($page->for_feed_settings()) : ?>
|
42 |
+
<option value="site-default"<?php print $unfamiliar['site-default']; ?>>are handled according to the default for all feeds</option>
|
43 |
+
<?php endif; ?>
|
44 |
+
<option value="create"<?php $unfamiliar['create']; ?>>will have a new author account created for them</option>
|
45 |
+
<?php foreach ($page->authorlist as $author_id => $author_name) : ?>
|
46 |
+
<option value="<?php echo $author_id; ?>"<?php print $unfamiliar[$author_id]; ?>>will have their posts attributed to <?php echo $author_name; ?></option>
|
47 |
+
<?php endforeach; ?>
|
48 |
+
<option value="newuser">will have their posts attributed to a new user...</option>
|
49 |
+
<option value="filter"<?php print $unfamiliar['filter'] ?>>get filtered out</option>
|
50 |
+
</select>
|
51 |
+
|
52 |
+
<span id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></span></p>
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
|
56 |
+
<?php
|
57 |
+
if ($page->for_feed_settings()) :
|
58 |
+
?>
|
59 |
+
<tr><th>Syndicated authors</th>
|
60 |
+
<td>For attributing posts by specific authors. Blank out a name to delete the rule. Fill in a new name at the bottom to create a new rule.</p>
|
61 |
+
<table style="width: 100%">
|
62 |
+
<?php
|
63 |
+
if (isset($link->settings['map authors'])) :
|
64 |
+
?>
|
65 |
+
<?php
|
66 |
+
$page->rule_count=0;
|
67 |
+
foreach ($link->settings['map authors'] as $author_rules) :
|
68 |
+
foreach ($author_rules as $author_name => $author_action) :
|
69 |
+
$page->rule_count++;
|
70 |
+
?>
|
71 |
+
<tr>
|
72 |
+
<th style="text-align: left; width: 15.0em">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" size="11" /></th>
|
73 |
+
<td>
|
74 |
+
<select id="author-rules-<?php echo $page->rule_count; ?>" name="author_rules_action[]" onchange="contextual_appearance('author-rules-<?php echo $page->rule_count; ?>', 'author-rules-<?php echo $page->rule_count; ?>-newuser', 'author-rules-<?php echo $page->rule_count; ?>-default', 'newuser', 'inline');">
|
75 |
+
<?php foreach ($page->authorlist as $local_author_id => $local_author_name) : ?>
|
76 |
+
<option value="<?php echo $local_author_id; ?>"<?php if ($local_author_id==$author_action) : echo ' selected="selected"'; endif; ?>>are assigned to <?php echo $local_author_name; ?></option>
|
77 |
+
<?php endforeach; ?>
|
78 |
+
<option value="newuser">will be assigned to a new user...</option>
|
79 |
+
<option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
|
80 |
+
</select>
|
81 |
+
|
82 |
+
<span id="author-rules-<?php echo $page->rule_count; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></span>
|
83 |
+
</td>
|
84 |
+
</tr>
|
85 |
+
<?php endforeach;
|
86 |
+
endforeach;
|
87 |
endif;
|
88 |
+
?>
|
89 |
|
90 |
+
<tr>
|
91 |
+
<th style="text-align: left; width: 15.0em">Posts by <input type="text" name="add_author_rule_name" size="11" /></th>
|
92 |
+
<td>
|
93 |
+
<select id="add-author-rule" name="add_author_rule_action" onchange="contextual_appearance('add-author-rule', 'add-author-rule-newuser', 'add-author-rule-default', 'newuser', 'inline');">
|
94 |
+
<?php foreach ($page->authorlist as $author_id => $author_name) : ?>
|
95 |
+
<option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
|
96 |
+
<?php endforeach; ?>
|
97 |
+
<option value="newuser">will be assigned to a new user...</option>
|
98 |
+
<option value="filter">get filtered out</option>
|
99 |
+
</select>
|
100 |
+
|
101 |
+
<span id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></span>
|
102 |
+
</td>
|
103 |
+
</tr>
|
104 |
+
</table>
|
105 |
+
</td>
|
106 |
+
</tr>
|
107 |
+
<?php endif; ?>
|
108 |
+
|
109 |
+
<?php if ($page->for_default_settings()) : ?>
|
110 |
+
<tr>
|
111 |
+
<th scope="row">Matching Authors</th>
|
112 |
+
<td><ul style="list-style: none; margin: 0; padding: 0;">
|
113 |
+
<li><div><label><input id="match-author-by-email" type="checkbox" name="match_author_by_email" value="yes" <?php if ($match_author_by_email) : ?>checked="checked" <?php endif; ?>onchange="contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);" /> Treat syndicated authors with the same e-mail address as the same author.</label></div>
|
114 |
+
<div id="unless-null-email">
|
115 |
+
<p>Unless the e-mail address is one of the following anonymous e-mail addresses:</p>
|
116 |
+
<textarea name="null_emails" rows="3" style="width: 100%">
|
117 |
+
<?php print implode("\n", $null_emails); ?>
|
118 |
+
</textarea>
|
119 |
+
</div></li>
|
120 |
+
</ul></td>
|
121 |
+
</tr>
|
122 |
+
<?php endif; ?>
|
123 |
+
</tbody>
|
124 |
+
</table>
|
125 |
+
<?php
|
126 |
+
} /* FeedWordPressAuthorsPage::syndicated_authors_box () */
|
127 |
+
|
128 |
+
/*static*/ function fix_authors_box ($page, $box = NULL) {
|
129 |
+
?>
|
130 |
+
<table class="form-table">
|
131 |
+
<tbody>
|
132 |
+
<tr>
|
133 |
+
<th scope="row">Fixing mis-matched authors:</th>
|
134 |
+
<td><p style="margin: 0.5em 0px">Take all the posts from this feed attributed to
|
135 |
+
<select name="fix_mismatch_from">
|
136 |
+
<?php foreach ($page->authorlist as $author_id => $author_name) : ?>
|
137 |
+
<option value="<?php echo $author_id; ?>"><?php echo $author_name; ?></option>
|
138 |
+
<?php endforeach; ?>
|
139 |
+
</select>
|
140 |
+
and instead
|
141 |
+
<select id="fix-mismatch-to" name="fix_mismatch_to" onchange="contextual_appearance('fix-mismatch-to', 'fix-mismatch-to-newuser', null, 'newuser', 'inline');">
|
142 |
+
<?php foreach ($page->authorlist as $author_id => $author_name) : ?>
|
143 |
+
<option value="<?php echo $author_id; ?>">re-assign them to <?php echo $author_name; ?></option>
|
144 |
+
<?php endforeach; ?>
|
145 |
+
<option value="newuser">re-assign them to a new user...</option>
|
146 |
+
<option value="filter">delete them</option>
|
147 |
+
</select>
|
148 |
+
|
149 |
+
<span id="fix-mismatch-to-newuser">named <input type="text" name="fix_mismatch_to_newuser" value="" /></span>
|
150 |
+
<input type="submit" class="button" name="fix_mismatch" value="Fix it!" />
|
151 |
+
</td>
|
152 |
+
</tr>
|
153 |
+
</tbody>
|
154 |
+
</table>
|
155 |
+
<?php
|
156 |
+
} /* FeedWordPressAuthorsPage::fix_authors_box () */
|
157 |
+
} /* class FeedWordPressAuthorsPage */
|
158 |
+
|
159 |
+
function fwp_authors_page () {
|
160 |
+
global $wpdb, $wp_db_version;
|
161 |
+
|
162 |
+
if (FeedWordPress::needs_upgrade()) :
|
163 |
+
fwp_upgrade_page();
|
164 |
+
return;
|
165 |
endif;
|
166 |
|
167 |
+
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_author_settings', /*capability=*/ 'manage_links');
|
168 |
+
|
169 |
+
$link = FeedWordPressAdminPage::submitted_link();
|
170 |
+
$link_id = $link->id;
|
171 |
+
$authorsPage = new FeedWordPressAuthorsPage($link);
|
172 |
+
|
173 |
$mesg = null;
|
174 |
|
175 |
if (isset($GLOBALS['fwp_post']['fix_mismatch'])) :
|
347 |
|
348 |
$updated_link = true;
|
349 |
endif;
|
|
|
|
|
|
|
350 |
|
351 |
+
do_action('feedwordpress_admin_page_authors_save', $GLOBALS['fwp_post'], $authorsPage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
else :
|
353 |
+
$updated_link = false;
|
354 |
endif;
|
355 |
+
|
356 |
+
////////////////////////////////////////////////
|
357 |
+
// Prepare settings page ///////////////////////
|
358 |
+
////////////////////////////////////////////////
|
359 |
|
360 |
+
if ($updated_link) :
|
|
|
|
|
|
|
361 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
<div class="updated"><p>Syndicated author settings updated.</p></div>
|
363 |
<?php elseif (!is_null($mesg)) : ?>
|
364 |
<div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div>
|
365 |
+
<?php endif;
|
366 |
+
|
367 |
+
if (function_exists('add_meta_box')) :
|
368 |
+
add_action(
|
369 |
+
FeedWordPressCompatibility::bottom_script_hook(__FILE__),
|
370 |
+
/*callback=*/ array($authorsPage, 'fix_toggles'),
|
371 |
+
/*priority=*/ 10000
|
372 |
+
);
|
373 |
+
FeedWordPressSettingsUI::ajax_nonce_fields();
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
endif;
|
|
|
|
|
375 |
|
376 |
+
$authorsPage->open_sheet('Syndicated Author');
|
377 |
+
?>
|
378 |
+
<div id="post-body">
|
379 |
+
<?php
|
380 |
+
////////////////////////////////////////////////
|
381 |
+
// Display settings boxes //////////////////////
|
382 |
+
////////////////////////////////////////////////
|
383 |
+
|
384 |
+
$boxes_by_methods = array(
|
385 |
+
'syndicated_authors_box' => __('Syndicated Authors'),
|
386 |
+
'fix_authors_box' => __('Reassign Authors'),
|
387 |
+
);
|
388 |
+
if ($authorsPage->for_default_settings()) :
|
389 |
+
unset($boxes_by_methods['fix_authors_box']);
|
390 |
+
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
|
392 |
+
foreach ($boxes_by_methods as $method => $row) :
|
393 |
+
if (is_array($row)) :
|
394 |
+
$id = $row['id'];
|
395 |
+
$title = $row['title'];
|
396 |
+
else :
|
397 |
+
$id = 'feedwordpress_'.$method;
|
398 |
+
$title = $row;
|
399 |
+
endif;
|
400 |
|
401 |
+
fwp_add_meta_box(
|
402 |
+
/*id=*/ $id,
|
403 |
+
/*title=*/ $title,
|
404 |
+
/*callback=*/ array('FeedWordPressAuthorsPage', $method),
|
405 |
+
/*page=*/ $authorsPage->meta_box_context(),
|
406 |
+
/*context=*/ $authorsPage->meta_box_context()
|
407 |
+
);
|
408 |
+
endforeach;
|
409 |
+
do_action('feedwordpress_admin_page_authors_meta_boxes', $authorsPage);
|
410 |
?>
|
411 |
+
<div class="metabox-holder">
|
|
|
|
|
412 |
<?php
|
413 |
+
fwp_do_meta_boxes($authorsPage->meta_box_context(), $authorsPage->meta_box_context(), $authorsPage);
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
?>
|
415 |
+
</div> <!-- class="metabox-holder" -->
|
416 |
+
</div> <!-- id="post-body" -->
|
417 |
+
<?php $authorsPage->close_sheet(); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
|
419 |
<script type="text/javascript">
|
420 |
contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');
|
421 |
<?php if (is_object($link) and $link->found()) : ?>
|
422 |
+
<?php for ($j=1; $j<=$authorsPage->rule_count; $j++) : ?>
|
423 |
contextual_appearance('author-rules-<?php echo $j; ?>', 'author-rules-<?php echo $j; ?>-newuser', 'author-rules-<?php echo $j; ?>-default', 'newuser', 'inline');
|
424 |
<?php endfor; ?>
|
425 |
contextual_appearance('add-author-rule', 'add-author-rule-newuser', 'add-author-rule-default', 'newuser', 'inline');
|
428 |
contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);
|
429 |
<?php endif; ?>
|
430 |
</script>
|
|
|
|
|
431 |
<?php
|
432 |
} /* function fwp_authors_page () */
|
433 |
|
backend-page.php
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once(dirname(__FILE__) . '/admin-ui.php');
|
3 |
+
|
4 |
+
class FeedWordPressBackendPage extends FeedWordPressAdminPage {
|
5 |
+
function FeedWordPressBackendPage () {
|
6 |
+
// Set meta-box context name
|
7 |
+
FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressbackendpage');
|
8 |
+
$this->dispatch = 'feedwordpress_backend';
|
9 |
+
$this->filename = __FILE__;
|
10 |
+
}
|
11 |
+
|
12 |
+
function has_link () { return false; }
|
13 |
+
|
14 |
+
function display () {
|
15 |
+
global $wpdb, $wp_db_version, $fwp_path;
|
16 |
+
global $fwp_post;
|
17 |
+
|
18 |
+
if (FeedWordPress::needs_upgrade()) :
|
19 |
+
fwp_upgrade_page();
|
20 |
+
return;
|
21 |
+
endif;
|
22 |
+
|
23 |
+
// If this is a POST, validate source and user credentials
|
24 |
+
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_backend', /*capability=*/ 'manage_options');
|
25 |
+
|
26 |
+
if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
|
27 |
+
$this->accept_POST($fwp_post);
|
28 |
+
do_action('feedwordpress_admin_page_backend_save', $GLOBALS['fwp_post'], $this);
|
29 |
+
endif;
|
30 |
+
|
31 |
+
////////////////////////////////////////////////
|
32 |
+
// Prepare settings page ///////////////////////
|
33 |
+
////////////////////////////////////////////////
|
34 |
+
|
35 |
+
$this->display_update_notice_if_updated('Back End');
|
36 |
+
|
37 |
+
$this->open_sheet('FeedWordPress Back End');
|
38 |
+
?>
|
39 |
+
<div id="post-body">
|
40 |
+
<?php
|
41 |
+
$boxes_by_methods = array(
|
42 |
+
'performance_box' => __('Performance'),
|
43 |
+
'diagnostics_box' => __('Diagnostics'),
|
44 |
+
);
|
45 |
+
|
46 |
+
foreach ($boxes_by_methods as $method => $title) :
|
47 |
+
fwp_add_meta_box(
|
48 |
+
/*id=*/ 'feedwordpress_'.$method,
|
49 |
+
/*title=*/ $title,
|
50 |
+
/*callback=*/ array('FeedWordPressBackendPage', $method),
|
51 |
+
/*page=*/ $this->meta_box_context(),
|
52 |
+
/*context=*/ $this->meta_box_context()
|
53 |
+
);
|
54 |
+
endforeach;
|
55 |
+
do_action('feedwordpress_admin_page_backend_meta_boxes', $this);
|
56 |
+
?>
|
57 |
+
<div class="metabox-holder">
|
58 |
+
<?php
|
59 |
+
fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
|
60 |
+
?>
|
61 |
+
</div> <!-- class="metabox-holder" -->
|
62 |
+
</div> <!-- id="post-body" -->
|
63 |
+
|
64 |
+
<?php
|
65 |
+
$this->close_sheet();
|
66 |
+
} /* FeedWordPressBackendPage::display () */
|
67 |
+
|
68 |
+
function accept_POST ($post) {
|
69 |
+
if (isset($post['submit'])
|
70 |
+
or isset($post['save'])
|
71 |
+
or isset($post['create_index'])
|
72 |
+
or isset($post['clear_cache'])) :
|
73 |
+
update_option('feedwordpress_update_logging', $post['update_logging']);
|
74 |
+
update_option('feedwordpress_debug', $post['feedwordpress_debug']);
|
75 |
+
$this->updated = true; // Default update message
|
76 |
+
endif;
|
77 |
+
|
78 |
+
if (isset($post['create_index'])) :
|
79 |
+
FeedWordPress::create_guid_index();
|
80 |
+
$this->updated = __('Index created on database table.');
|
81 |
+
endif;
|
82 |
+
|
83 |
+
if (isset($_POST['clear_cache'])) :
|
84 |
+
FeedWordPress::clear_cache();
|
85 |
+
$this->updated = __("Cleared all cached feeds from WordPress database.");
|
86 |
+
endif;
|
87 |
+
} /* FeedWordPressBackendPage::accept_POST () */
|
88 |
+
|
89 |
+
/*static*/ function performance_box ($page, $box = NULL) {
|
90 |
+
// Hey ho, let's go...
|
91 |
+
?>
|
92 |
+
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
93 |
+
<tr style="vertical-align: top">
|
94 |
+
<th width="33%" scope="row">Feed cache:</th>
|
95 |
+
<td width="67%"><input class="button" type="submit" name="clear_cache" value="Clear all cached feeds from WordPress database" />
|
96 |
+
<p>This will clear all cached copies of feed data from the WordPress database
|
97 |
+
and force FeedWordPress to make a fresh scan for updates on syndicated feeds.</p></td></tr>
|
98 |
+
|
99 |
+
<tr style="vertical-align: top">
|
100 |
+
<th width="33%" scope="row">Guid index:</th>
|
101 |
+
<td width="67%"><input class="button" type="submit" name="create_index" value="Create index on guid column in posts database table" />
|
102 |
+
<p>Creating this index may significantly improve performance on some large
|
103 |
+
FeedWordPress installations.</p></td>
|
104 |
+
</tr>
|
105 |
+
</table>
|
106 |
+
<?php
|
107 |
+
} /* FeedWordPressBackendPage::performance_box () */
|
108 |
+
|
109 |
+
/*static*/ function diagnostics_box ($page, $box = NULL) {
|
110 |
+
$settings = array();
|
111 |
+
$settings['update_logging'] = (get_option('feedwordpress_update_logging')=='yes');
|
112 |
+
$settings['debug'] = (get_option('feedwordpress_debug')=='yes');
|
113 |
+
|
114 |
+
// Hey ho, let's go...
|
115 |
+
?>
|
116 |
+
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
117 |
+
<tr style="vertical-align: top">
|
118 |
+
<th width="33%" scope="row">Logging:</th>
|
119 |
+
<td width="67%"><select name="update_logging" size="1">
|
120 |
+
<option value="yes"<?php echo ($settings['update_logging'] ?' selected="selected"':''); ?>>log updates, new posts, and updated posts in PHP logs</option>
|
121 |
+
<option value="no"<?php echo ($settings['update_logging'] ?'':' selected="selected"'); ?>>don't log updates</option>
|
122 |
+
</select></td>
|
123 |
+
</tr>
|
124 |
+
<tr style="vertical-align: top">
|
125 |
+
<th width="33%" scope="row">Debugging mode:</th>
|
126 |
+
<td width="67%"><select name="feedwordpress_debug" size="1">
|
127 |
+
<option value="yes"<?php echo ($settings['debug'] ? ' selected="selected"' : ''); ?>>on</option>
|
128 |
+
<option value="no"<?php echo ($settings['debug'] ? '' : ' selected="selected"'); ?>>off</option>
|
129 |
+
</select>
|
130 |
+
<p>When debugging mode is <strong>ON</strong>, FeedWordPress displays many diagnostic error messages,
|
131 |
+
warnings, and notices that are ordinarily suppressed, and turns off all caching of feeds. Use with
|
132 |
+
caution: this setting is absolutely inappropriate for a production server.</p>
|
133 |
+
</td>
|
134 |
+
</tr>
|
135 |
+
</table>
|
136 |
+
<?php
|
137 |
+
} /* FeedWordPressBackendPage::performance_box () */
|
138 |
+
} /* class FeedWordPressBackendPage */
|
139 |
+
|
140 |
+
$backendPage = new FeedWordPressBackendPage;
|
141 |
+
$backendPage->display();
|
142 |
+
|
categories-page.php
CHANGED
@@ -1,31 +1,124 @@
|
|
1 |
<?php
|
2 |
require_once(dirname(__FILE__) . '/admin-ui.php');
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
function fwp_categories_page () {
|
5 |
global $wpdb, $wp_db_version;
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_categories_settings', /*capability=*/ 'manage_links');
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
elseif (isset($_REQUEST['link_id'])) :
|
12 |
-
$link_id = $_REQUEST['link_id'];
|
13 |
-
else :
|
14 |
-
$link_id = NULL;
|
15 |
-
endif;
|
16 |
|
17 |
-
|
18 |
-
$link =& new SyndicatedLink($link_id);
|
19 |
-
else :
|
20 |
-
$link = NULL;
|
21 |
-
endif;
|
22 |
|
23 |
$mesg = null;
|
24 |
|
25 |
////////////////////////////////////////////////
|
26 |
// Process POST request, if any /////////////////
|
27 |
////////////////////////////////////////////////
|
28 |
-
if (isset($GLOBALS['fwp_post']['save'])) :
|
29 |
$saveCats = array();
|
30 |
if (isset($GLOBALS['fwp_post']['post_category'])) :
|
31 |
foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) :
|
@@ -81,7 +174,7 @@ function fwp_categories_page () {
|
|
81 |
SET $alter_set
|
82 |
WHERE link_id='$link_id'
|
83 |
");
|
84 |
-
$
|
85 |
|
86 |
// reload link information from DB
|
87 |
if (function_exists('clean_bookmark_cache')) :
|
@@ -105,230 +198,68 @@ function fwp_categories_page () {
|
|
105 |
|
106 |
update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']);
|
107 |
|
108 |
-
$
|
109 |
endif;
|
|
|
|
|
110 |
else :
|
111 |
-
$
|
112 |
endif;
|
113 |
|
114 |
////////////////////////////////////////////////
|
115 |
-
//
|
116 |
////////////////////////////////////////////////
|
117 |
|
118 |
-
$
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
else : $cats = array();
|
126 |
-
endif;
|
127 |
-
|
128 |
-
$tags = $link->settings['tags'];
|
129 |
-
else :
|
130 |
-
$ucKey = FeedWordPress::on_unfamiliar('category');
|
131 |
-
$ucDefault = 'create';
|
132 |
-
|
133 |
-
$cats = array_map('trim',
|
134 |
-
preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_cats'))
|
135 |
-
);
|
136 |
-
$tags = array_map('trim',
|
137 |
-
preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_tags'))
|
138 |
-
);
|
139 |
-
endif;
|
140 |
-
|
141 |
-
if (!is_string($ucKey) or !array_key_exists($ucKey, $unfamiliar)) :
|
142 |
-
$ucKey = $ucDefault;
|
143 |
-
endif;
|
144 |
-
$unfamiliar[$ucKey] = ' checked="checked"';
|
145 |
-
|
146 |
-
$dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL);
|
147 |
-
?>
|
148 |
-
<script type="text/javascript">
|
149 |
-
function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) {
|
150 |
-
if (typeof(visibleStyle)=='undefined') visibleStyle = 'block';
|
151 |
-
|
152 |
-
var rollup=document.getElementById(item);
|
153 |
-
var newuser=document.getElementById(appear);
|
154 |
-
var sitewide=document.getElementById(disappear);
|
155 |
-
if (rollup) {
|
156 |
-
if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) {
|
157 |
-
if (newuser) newuser.style.display=visibleStyle;
|
158 |
-
if (sitewide) sitewide.style.display='none';
|
159 |
-
} else {
|
160 |
-
if (newuser) newuser.style.display='none';
|
161 |
-
if (sitewide) sitewide.style.display=visibleStyle;
|
162 |
-
}
|
163 |
-
}
|
164 |
-
}
|
165 |
-
</script>
|
166 |
-
|
167 |
-
<?php if ($updated_link) : ?>
|
168 |
-
<div class="updated"><p>Syndicated categories and tags settings updated.</p></div>
|
169 |
-
<?php elseif (!is_null($mesg)) : ?>
|
170 |
-
<div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div>
|
171 |
-
<?php endif; ?>
|
172 |
-
|
173 |
-
<div class="wrap">
|
174 |
-
<form style="position: relative" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
|
175 |
-
<div><?php
|
176 |
-
FeedWordPressCompatibility::stamp_nonce('feedwordpress_categories_settings');
|
177 |
-
|
178 |
-
if (is_numeric($link_id) and $link_id) :
|
179 |
-
?>
|
180 |
-
<input type="hidden" name="save_link_id" value="<?php echo $link_id; ?>" />
|
181 |
-
<?php
|
182 |
-
else :
|
183 |
-
?>
|
184 |
-
<input type="hidden" name="save_link_id" value="*" />
|
185 |
-
<?php
|
186 |
-
endif;
|
187 |
-
?>
|
188 |
-
</div>
|
189 |
-
|
190 |
-
<?php $links = FeedWordPress::syndicated_links(); ?>
|
191 |
-
<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
|
192 |
-
<div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
|
193 |
-
<?php endif; ?>
|
194 |
-
<h2>Categories & Tags Settings<?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2>
|
195 |
-
|
196 |
-
<style type="text/css">
|
197 |
-
table.edit-form th { width: 27%; vertical-align: top; }
|
198 |
-
table.edit-form td { width: 73%; vertical-align: top; }
|
199 |
-
table.edit-form td ul.options { margin: 0; padding: 0; list-style: none; }
|
200 |
-
</style>
|
201 |
-
|
202 |
-
<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
|
203 |
-
<style type="text/css">
|
204 |
-
#post-search {
|
205 |
-
float: right;
|
206 |
-
margin:11px 12px 0;
|
207 |
-
min-width: 130px;
|
208 |
-
position:relative;
|
209 |
-
}
|
210 |
-
.fwpfs {
|
211 |
-
color: #dddddd;
|
212 |
-
background:#797979 url(<?php bloginfo('home') ?>/wp-admin/images/fav.png) repeat-x scroll left center;
|
213 |
-
border-color:#777777 #777777 #666666 !important; -moz-border-radius-bottomleft:12px;
|
214 |
-
-moz-border-radius-bottomright:12px;
|
215 |
-
-moz-border-radius-topleft:12px;
|
216 |
-
-moz-border-radius-topright:12px;
|
217 |
-
border-style:solid;
|
218 |
-
border-width:1px;
|
219 |
-
line-height:15px;
|
220 |
-
padding:3px 30px 4px 12px;
|
221 |
-
}
|
222 |
-
.fwpfs.slide-down {
|
223 |
-
border-bottom-color: #626262;
|
224 |
-
-moz-border-radius-bottomleft:0;
|
225 |
-
-moz-border-radius-bottomright:0;
|
226 |
-
-moz-border-radius-topleft:12px;
|
227 |
-
-moz-border-radius-topright:12px;
|
228 |
-
background-image:url(<?php bloginfo('home') ?>/wp-admin/images/fav-top.png);
|
229 |
-
background-position:0 top;
|
230 |
-
background-repeat:repeat-x;
|
231 |
-
border-bottom-style:solid;
|
232 |
-
border-bottom-width:1px;
|
233 |
-
}
|
234 |
</style>
|
235 |
-
|
236 |
-
<script type="text/javascript">
|
237 |
-
jQuery(document).ready(function($){
|
238 |
-
$('.fwpfs').toggle(
|
239 |
-
function(){$('.fwpfs').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideDown') ) { $('.fwpfs').addClass('slide-down'); }}, 10) },
|
240 |
-
function(){$('.fwpfs').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideUp') ) { $('.fwpfs').removeClass('slide-down'); }}, 10) }
|
241 |
-
);
|
242 |
-
$('.fwpfs').bind(
|
243 |
-
'change',
|
244 |
-
function () { this.form.submit(); }
|
245 |
-
);
|
246 |
-
$('#post-search .button').css( 'display', 'none' );
|
247 |
-
});
|
248 |
-
</script>
|
249 |
-
<?php endif; /* else : */?>
|
250 |
-
<p id="post-search">
|
251 |
-
<select name="link_id" class="fwpfs" style="max-width: 20.0em;">
|
252 |
-
<option value="*"<?php if (is_null($link) or !$link->found()) : ?> selected="selected"<?php endif; ?>>- defaults for all feeds -</option>
|
253 |
-
<?php if ($links) : foreach ($links as $ddlink) : ?>
|
254 |
-
<option value="<?php print (int) $ddlink->link_id; ?>"<?php if (!is_null($link) and ($link->link->link_id==$ddlink->link_id)) : ?> selected="selected"<?php endif; ?>><?php print wp_specialchars($ddlink->link_name, 1); ?></option>
|
255 |
-
<?php endforeach; endif; ?>
|
256 |
-
</select>
|
257 |
-
<input class="button" type="submit" name="go" value="<?php _e('Go') ?> »" />
|
258 |
-
</p>
|
259 |
-
<?php /* endif; */ ?>
|
260 |
-
|
261 |
-
<?php if (!is_null($link) and $link->found()) : ?>
|
262 |
-
<p>These settings only affect posts syndicated from
|
263 |
-
<strong><?php echo wp_specialchars($link->link->link_name, 1); ?></strong>.</p>
|
264 |
-
<?php else : ?>
|
265 |
-
<p>These settings affect posts syndicated from any feed unless they are overridden
|
266 |
-
by settings for that specific feed.</p>
|
267 |
-
<?php endif; ?>
|
268 |
-
|
269 |
-
<div id="poststuff">
|
270 |
-
<div id="post-body">
|
271 |
-
<?php
|
272 |
-
fwp_option_box_opener("Feed Categories & Tags", 'fromfeeddiv', 'postbox');
|
273 |
-
?>
|
274 |
-
<table class="edit-form">
|
275 |
-
<tr>
|
276 |
-
<th scope="row">Unfamiliar categories:</th>
|
277 |
-
<td><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p>
|
278 |
-
|
279 |
-
<ul class="options">
|
280 |
-
<?php if (is_object($link) and ($link->found())) : ?>
|
281 |
-
<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['site-default']; ?> /> use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>">site-wide setting</a>
|
282 |
-
(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li>
|
283 |
-
<?php endif; ?>
|
284 |
|
285 |
-
<
|
|
|
|
|
|
|
|
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
|
|
|
|
|
|
|
|
295 |
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
If the feed does not provide multiple categories in a single element, leave this
|
306 |
-
blank.</p></td>
|
307 |
-
</tr>
|
308 |
-
<?php endif; ?>
|
309 |
-
</table>
|
310 |
-
<?php
|
311 |
-
fwp_option_box_closer();
|
312 |
-
fwp_linkedit_periodic_submit();
|
313 |
?>
|
|
|
314 |
<?php
|
315 |
-
|
316 |
-
fwp_category_box($dogs, 'all syndicated posts'.((is_object($link) and $link->found()) ? ' from this feed':''));
|
317 |
?>
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
if (fwp_test_wp_version(FWP_SCHEMA_25)) :
|
323 |
-
fwp_tags_box($tags, 'all syndicated posts'.((is_object($link) and $link->found()) ? ' from this feed':''));
|
324 |
-
fwp_linkedit_periodic_submit();
|
325 |
-
endif; ?>
|
326 |
-
</div>
|
327 |
-
</div>
|
328 |
-
|
329 |
-
<p class="submit">
|
330 |
-
<input class="button-primary" type="submit" name="save" value="Save Changes" />
|
331 |
-
</p>
|
332 |
|
333 |
<script type="text/javascript">
|
334 |
contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');
|
@@ -342,8 +273,6 @@ endif; ?>
|
|
342 |
contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);
|
343 |
<?php endif; ?>
|
344 |
</script>
|
345 |
-
</form>
|
346 |
-
</div> <!-- class="wrap" -->
|
347 |
<?php
|
348 |
} /* function fwp_categories_page () */
|
349 |
|
1 |
<?php
|
2 |
require_once(dirname(__FILE__) . '/admin-ui.php');
|
3 |
|
4 |
+
class FeedWordPressCategoriesPage extends FeedWordPressAdminPage {
|
5 |
+
function FeedWordPressCategoriesPage ($link) {
|
6 |
+
FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresscategories', $link);
|
7 |
+
$this->dispatch = 'feedwordpress_categories_settings';
|
8 |
+
$this->filename = __FILE__;
|
9 |
+
}
|
10 |
+
|
11 |
+
/*static*/ function feed_categories_box ($page, $box = NULL) {
|
12 |
+
|
13 |
+
$link = $page->link;
|
14 |
+
|
15 |
+
$unfamiliar = array ('create'=>'','tag' => '', 'default'=>'','filter'=>'');
|
16 |
+
if ($page->for_feed_settings()) :
|
17 |
+
$unfamiliar['site-default'] = '';
|
18 |
+
$ucKey = $link->settings["unfamiliar category"];
|
19 |
+
$ucDefault = 'site-default';
|
20 |
+
else :
|
21 |
+
$ucKey = FeedWordPress::on_unfamiliar('category');
|
22 |
+
$ucDefault = 'create';
|
23 |
+
endif;
|
24 |
+
|
25 |
+
if (!is_string($ucKey) or !array_key_exists($ucKey, $unfamiliar)) :
|
26 |
+
$ucKey = $ucDefault;
|
27 |
+
endif;
|
28 |
+
$unfamiliar[$ucKey] = ' checked="checked"';
|
29 |
+
|
30 |
+
// Hey ho, let's go...
|
31 |
+
?>
|
32 |
+
<table class="edit-form">
|
33 |
+
<tr>
|
34 |
+
<th scope="row">Unfamiliar categories:</th>
|
35 |
+
<td><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p>
|
36 |
+
|
37 |
+
<ul class="options">
|
38 |
+
<?php if ($page->for_feed_settings()) : ?>
|
39 |
+
<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['site-default']; ?> /> use the <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>">site-wide setting</a>
|
40 |
+
(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li>
|
41 |
+
<?php endif; ?>
|
42 |
+
|
43 |
+
<li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['create']; ?> /> create a new category</label></li>
|
44 |
+
|
45 |
+
<?php if (FeedWordPressCompatibility::post_tags()) : ?>
|
46 |
+
<li><label><input type="radio" name="unfamiliar_category" value="tag"<?php echo $unfamiliar['tag']; ?>/> create a new tag</label></li>
|
47 |
+
<?php endif; ?>
|
48 |
+
|
49 |
+
<li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['default']; ?> /> don't create new categories<?php if (fwp_test_wp_version(FWP_SCHEMA_23)) : ?> or tags<?php endif; ?></label></li>
|
50 |
+
<li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar['filter']; ?> /> don't create new categories<?php if (fwp_test_wp_version(FWP_SCHEMA_23)) : ?> or tags<?php endif; ?> and don't syndicate posts unless they match at least one familiar category</label></li>
|
51 |
+
</ul></td>
|
52 |
+
</tr>
|
53 |
+
|
54 |
+
<?php if ($page->for_feed_settings()) : ?>
|
55 |
+
<tr>
|
56 |
+
<th scope="row">Multiple categories:</th>
|
57 |
+
<td>
|
58 |
+
<input type="text" size="20" id="cat_split" name="cat_split" value="<?php if (isset($link->settings['cat_split'])) : echo htmlspecialchars($link->settings['cat_split']); endif; ?>" />
|
59 |
+
<p class="setting-description">Enter a <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Perl-compatible regular expression</a> here if the feed provides multiple
|
60 |
+
categories in a single category element. The regular expression should match
|
61 |
+
the characters used to separate one category from the next. If the feed uses
|
62 |
+
spaces (like <a href="http://del.icio.us/">del.icio.us</a>), use the pattern "\s".
|
63 |
+
If the feed does not provide multiple categories in a single element, leave this
|
64 |
+
blank.</p></td>
|
65 |
+
</tr>
|
66 |
+
<?php endif; ?>
|
67 |
+
</table>
|
68 |
+
<?php
|
69 |
+
} /* FeedWordPressCategoriesPage::feed_categories_box() */
|
70 |
+
|
71 |
+
function categories_box ($page, $box = NULL) {
|
72 |
+
$link = $page->link;
|
73 |
+
if ($page->for_feed_settings()) :
|
74 |
+
if (is_array($link->settings['cats'])) : $cats = $link->settings['cats'];
|
75 |
+
else : $cats = array();
|
76 |
+
endif;
|
77 |
+
else :
|
78 |
+
$cats = array_map('trim',
|
79 |
+
preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_cats'))
|
80 |
+
);
|
81 |
+
endif;
|
82 |
+
$dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL);
|
83 |
+
|
84 |
+
fwp_category_box($dogs, 'all '.$page->these_posts_phrase());
|
85 |
+
} /* FeedWordPressCategoriesPage::categories_box () */
|
86 |
+
|
87 |
+
function tags_box ($page, $box = NULL) {
|
88 |
+
$link = $page->link;
|
89 |
+
if ($page->for_feed_settings()) :
|
90 |
+
$tags = $link->settings['tags'];
|
91 |
+
else :
|
92 |
+
$tags = array_map('trim',
|
93 |
+
preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_tags'))
|
94 |
+
);
|
95 |
+
endif;
|
96 |
+
|
97 |
+
fwp_tags_box($tags, 'all '.$page->these_posts_phrase());
|
98 |
+
} /* FeedWordPressCategoriesPage::tags_box () */
|
99 |
+
}
|
100 |
+
|
101 |
function fwp_categories_page () {
|
102 |
global $wpdb, $wp_db_version;
|
103 |
+
|
104 |
+
if (FeedWordPress::needs_upgrade()) :
|
105 |
+
fwp_upgrade_page();
|
106 |
+
return;
|
107 |
+
endif;
|
108 |
|
109 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_categories_settings', /*capability=*/ 'manage_links');
|
110 |
|
111 |
+
$link = FeedWordPressAdminPage::submitted_link();
|
112 |
+
$link_id = $link->id;
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
+
$catsPage = new FeedWordPressCategoriesPage($link);
|
|
|
|
|
|
|
|
|
115 |
|
116 |
$mesg = null;
|
117 |
|
118 |
////////////////////////////////////////////////
|
119 |
// Process POST request, if any /////////////////
|
120 |
////////////////////////////////////////////////
|
121 |
+
if (isset($GLOBALS['fwp_post']['save']) or isset($GLOBALS['fwp_post']['submit'])) :
|
122 |
$saveCats = array();
|
123 |
if (isset($GLOBALS['fwp_post']['post_category'])) :
|
124 |
foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) :
|
174 |
SET $alter_set
|
175 |
WHERE link_id='$link_id'
|
176 |
");
|
177 |
+
$catsPage->updated = true;
|
178 |
|
179 |
// reload link information from DB
|
180 |
if (function_exists('clean_bookmark_cache')) :
|
198 |
|
199 |
update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']);
|
200 |
|
201 |
+
$catsPage->updated = true;
|
202 |
endif;
|
203 |
+
|
204 |
+
do_action('feedwordpress_admin_page_categories_save', $GLOBALS['fwp_post'], $catsPage);
|
205 |
else :
|
206 |
+
$catsPage->updated = false;
|
207 |
endif;
|
208 |
|
209 |
////////////////////////////////////////////////
|
210 |
+
// Prepare settings page ///////////////////////
|
211 |
////////////////////////////////////////////////
|
212 |
|
213 |
+
$catsPage->display_update_notice_if_updated('Syndicated categories'.FEEDWORDPRESS_AND_TAGS, $mesg);
|
214 |
+
$catsPage->open_sheet('Categories'.FEEDWORDPRESS_AND_TAGS);
|
215 |
+
?>
|
216 |
+
<style type="text/css">
|
217 |
+
table.edit-form th { width: 27%; vertical-align: top; }
|
218 |
+
table.edit-form td { width: 73%; vertical-align: top; }
|
219 |
+
table.edit-form td ul.options { margin: 0; padding: 0; list-style: none; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
+
<div id="post-body">
|
223 |
+
<?php
|
224 |
+
////////////////////////////////////////////////
|
225 |
+
// Display settings boxes //////////////////////
|
226 |
+
////////////////////////////////////////////////
|
227 |
|
228 |
+
$boxes_by_methods = array(
|
229 |
+
'feed_categories_box' => __('Feed Categories'.FEEDWORDPRESS_AND_TAGS),
|
230 |
+
'categories_box' => array('title' => __('Categories'), 'id' => 'categorydiv'),
|
231 |
+
'tags_box' => __('Tags'),
|
232 |
+
);
|
233 |
+
if (!FeedWordPressCompatibility::post_tags()) :
|
234 |
+
unset($boxes_by_methods['tags_box']);
|
235 |
+
endif;
|
236 |
|
237 |
+
foreach ($boxes_by_methods as $method => $row) :
|
238 |
+
if (is_array($row)) :
|
239 |
+
$id = $row['id'];
|
240 |
+
$title = $row['title'];
|
241 |
+
else :
|
242 |
+
$id = 'feedwordpress_'.$method;
|
243 |
+
$title = $row;
|
244 |
+
endif;
|
245 |
|
246 |
+
fwp_add_meta_box(
|
247 |
+
/*id=*/ $id,
|
248 |
+
/*title=*/ $title,
|
249 |
+
/*callback=*/ array('FeedWordPressCategoriesPage', $method),
|
250 |
+
/*page=*/ $catsPage->meta_box_context(),
|
251 |
+
/*context=*/ $catsPage->meta_box_context()
|
252 |
+
);
|
253 |
+
endforeach;
|
254 |
+
do_action('feedwordpress_admin_page_categories_meta_boxes', $catsPage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
?>
|
256 |
+
<div class="metabox-holder">
|
257 |
<?php
|
258 |
+
fwp_do_meta_boxes($catsPage->meta_box_context(), $catsPage->meta_box_context(), $catsPage);
|
|
|
259 |
?>
|
260 |
+
</div> <!-- class="metabox-holder" -->
|
261 |
+
</div> <!-- id="post-body" -->
|
262 |
+
<?php $catsPage->close_sheet(); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
|
264 |
<script type="text/javascript">
|
265 |
contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');
|
273 |
contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);
|
274 |
<?php endif; ?>
|
275 |
</script>
|
|
|
|
|
276 |
<?php
|
277 |
} /* function fwp_categories_page () */
|
278 |
|
compatability.php
CHANGED
@@ -16,6 +16,85 @@ function fwp_test_wp_version ($floor, $ceiling = NULL) {
|
|
16 |
} /* function fwp_test_wp_version () */
|
17 |
|
18 |
class FeedWordPressCompatibility {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
/*static*/ function validate_http_request ($action = -1, $capability = null) {
|
20 |
// Only worry about this if we're using a method with significant side-effects
|
21 |
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') :
|
@@ -41,8 +120,20 @@ class FeedWordPressCompatibility {
|
|
41 |
wp_nonce_field($action);
|
42 |
endif;
|
43 |
} /* FeedWordPressCompatibility::stamp_nonce() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
} /* class FeedWordPressCompatibility */
|
45 |
|
|
|
|
|
46 |
if (!function_exists('stripslashes_deep')) {
|
47 |
function stripslashes_deep($value) {
|
48 |
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
|
16 |
} /* function fwp_test_wp_version () */
|
17 |
|
18 |
class FeedWordPressCompatibility {
|
19 |
+
/*static*/ function test_version ($floor, $ceiling = null) {
|
20 |
+
return fwp_test_wp_version($floor, $ceiling);
|
21 |
+
} /* FeedWordPressCompatibility::test_version() */
|
22 |
+
|
23 |
+
/*static*/ function insert_link_category ($name) {
|
24 |
+
global $wpdb;
|
25 |
+
|
26 |
+
$name = $wpdb->escape($name);
|
27 |
+
|
28 |
+
// WordPress 2.3+ term/taxonomy API
|
29 |
+
if (function_exists('wp_insert_term')) :
|
30 |
+
$term = wp_insert_term($name, 'link_category');
|
31 |
+
$cat_id = $term['term_id'];
|
32 |
+
// WordPress 2.1, 2.2 category API. By the way, why the fuck is this API function only available in a wp-admin module?
|
33 |
+
elseif (function_exists('wp_insert_category') and !fwp_test_wp_version(FWP_SCHEMA_20, FWP_SCHEMA_21)) :
|
34 |
+
$cat_id = wp_insert_category(array('cat_name' => $name));
|
35 |
+
// WordPress 1.5 and 2.0.x
|
36 |
+
elseif (fwp_test_wp_version(0, FWP_SCHEMA_21)) :
|
37 |
+
$result = $wpdb->query("
|
38 |
+
INSERT INTO $wpdb->linkcategories
|
39 |
+
SET
|
40 |
+
cat_id = 0,
|
41 |
+
cat_name='$name',
|
42 |
+
show_images='N',
|
43 |
+
show_description='N',
|
44 |
+
show_rating='N',
|
45 |
+
show_updated='N',
|
46 |
+
sort_order='name'
|
47 |
+
");
|
48 |
+
$cat_id = $wpdb->insert_id;
|
49 |
+
// This should never happen.
|
50 |
+
else :
|
51 |
+
FeedWordPress::critical_bug('FeedWordPress::link_category_id::wp_db_version', $wp_db_version, __LINE__);
|
52 |
+
endif;
|
53 |
+
|
54 |
+
// Return newly-created category ID
|
55 |
+
return $cat_id;
|
56 |
+
} /* FeedWordPressCompatibility::insert_link_category () */
|
57 |
+
|
58 |
+
/*static*/ function link_category_id ($value, $key = 'cat_name') {
|
59 |
+
global $wpdb;
|
60 |
+
|
61 |
+
$cat_id = NULL;
|
62 |
+
|
63 |
+
// WordPress 2.3 introduces a new taxonomy/term API
|
64 |
+
if (function_exists('is_term')) :
|
65 |
+
$the_term = is_term($value, 'link_category');
|
66 |
+
|
67 |
+
// Sometimes, in some versions, we get a row
|
68 |
+
if (is_array($the_term)) :
|
69 |
+
$cat_id = $the_term['term_id'];
|
70 |
+
|
71 |
+
// other times we get an integer result
|
72 |
+
else :
|
73 |
+
$cat_id = $the_term;
|
74 |
+
endif;
|
75 |
+
|
76 |
+
// WordPress 2.1 and 2.2 use a common table for both link and post categories
|
77 |
+
elseif (fwp_test_wp_version(FWP_SCHEMA_21, FWP_SCHEMA_23)) :
|
78 |
+
$value = $wpdb->escape($value);
|
79 |
+
$cat_id = $wpdb->get_var("SELECT cat_id FROM {$wpdb->categories} WHERE {$key}='$value'");
|
80 |
+
|
81 |
+
// WordPress 1.5 and 2.0.x have a separate table for link categories
|
82 |
+
elseif (fwp_test_wp_version(0, FWP_SCHEMA_21)):
|
83 |
+
$value = $wpdb->escape($value);
|
84 |
+
$cat_id = $wpdb->get_var("SELECT cat_id FROM {$wpdb->linkcategories} WHERE {$key}='$value'");
|
85 |
+
|
86 |
+
// This should never happen.
|
87 |
+
else :
|
88 |
+
FeedWordPress::critical_bug(__CLASS__.'::'.__METHOD__.'::wp_db_version', $wp_db_version, __LINE__);
|
89 |
+
endif;
|
90 |
+
|
91 |
+
return $cat_id;
|
92 |
+
} /* FeedWordPressCompatibility::link_category_id () */
|
93 |
+
|
94 |
+
/*static*/ function post_tags () {
|
95 |
+
return FeedWordPressCompatibility::test_version(FWP_SCHEMA_23);
|
96 |
+
} /* FeedWordPressCompatibility::post_tags () */
|
97 |
+
|
98 |
/*static*/ function validate_http_request ($action = -1, $capability = null) {
|
99 |
// Only worry about this if we're using a method with significant side-effects
|
100 |
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') :
|
120 |
wp_nonce_field($action);
|
121 |
endif;
|
122 |
} /* FeedWordPressCompatibility::stamp_nonce() */
|
123 |
+
|
124 |
+
/*static*/ function bottom_script_hook ($filename) {
|
125 |
+
global $fwp_path;
|
126 |
+
|
127 |
+
$hook = 'admin_footer';
|
128 |
+
if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_28)) : // WordPress 2.8+
|
129 |
+
$hook = $hook . '-' . $fwp_path . '/' . basename($filename);
|
130 |
+
endif;
|
131 |
+
return $hook;
|
132 |
+
} /* FeedWordPressCompatibility::bottom_script_hook() */
|
133 |
} /* class FeedWordPressCompatibility */
|
134 |
|
135 |
+
define('FEEDWORDPRESS_AND_TAGS', (FeedWordPressCompatibility::post_tags() ? ' & Tags' : ''));
|
136 |
+
|
137 |
if (!function_exists('stripslashes_deep')) {
|
138 |
function stripslashes_deep($value) {
|
139 |
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
|
feeds-page.php
ADDED
@@ -0,0 +1,800 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once(dirname(__FILE__) . '/admin-ui.php');
|
3 |
+
require_once(dirname(__FILE__) . '/magpiemocklink.class.php');
|
4 |
+
require_once(dirname(__FILE__) . '/feedfinder.class.php');
|
5 |
+
|
6 |
+
class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
7 |
+
var $HTTPStatusMessages = array (
|
8 |
+
200 => 'OK. FeedWordPress had no problems retrieving the content at this URL but the content does not seem to be a feed, and does not seem to include links to any feeds.',
|
9 |
+
201 => 'Created',
|
10 |
+
202 => 'Accepted',
|
11 |
+
203 => 'Non-Authoritative information',
|
12 |
+
204 => 'No Content',
|
13 |
+
205 => 'Reset Content',
|
14 |
+
206 => 'Partial Content',
|
15 |
+
300 => 'Multiple Choices',
|
16 |
+
301 => 'Moved Permanently',
|
17 |
+
302 => 'Found',
|
18 |
+
303 => 'See Other',
|
19 |
+
304 => 'Not Modified',
|
20 |
+
305 => 'Use Proxy',
|
21 |
+
307 => 'Temporary Redirect',
|
22 |
+
400 => 'Bad Request',
|
23 |
+
401 => 'Unauthorized. This URL probably needs a username and password for you to access it.',
|
24 |
+
402 => 'Payment Required',
|
25 |
+
403 => 'Forbidden. The URL is not made available for the machine that FeedWordPress is running on.',
|
26 |
+
404 => 'Not Found. There is nothing at this URL. Have you checked the address for typos?',
|
27 |
+
405 => 'Method Not Allowed',
|
28 |
+
406 => 'Not Acceptable',
|
29 |
+
407 => 'Proxy Authentication Required',
|
30 |
+
408 => 'Request Timeout',
|
31 |
+
409 => 'Conflict',
|
32 |
+
410 => 'Gone. This URL is no longer available on this server and no forwarding address is known.',
|
33 |
+
411 => 'Length Required',
|
34 |
+
412 => 'Precondition Failed',
|
35 |
+
413 => 'Request Entity Too Large',
|
36 |
+
414 => 'Request URI Too Long',
|
37 |
+
415 => 'Unsupported Media Type',
|
38 |
+
416 => 'Requested Range Not Satisfiable',
|
39 |
+
417 => 'Expectation Failed',
|
40 |
+
500 => 'Internal Server Error. Something unexpected went wrong with the configuration of the server that hosts this URL. You might try again later to see if this issue has been resolved.',
|
41 |
+
501 => 'Not Implemented',
|
42 |
+
502 => 'Bad Gateway',
|
43 |
+
503 => 'Service Unavailable. The server is currently unable to handle the request due to a temporary overloading or maintenance of the server that hosts this URL. This is probably a temporary condition and you should try again later to see if the issue has been resolved.',
|
44 |
+
504 => 'Gateway Timeout',
|
45 |
+
505 => 'HTTP Version Not Supported',
|
46 |
+
);
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Constructs the Feeds page object
|
50 |
+
*
|
51 |
+
* @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings
|
52 |
+
*/
|
53 |
+
function FeedWordPressFeedsPage ($link = -1) {
|
54 |
+
if (is_numeric($link) and -1 == $link) :
|
55 |
+
$link = FeedWordPressAdminPage::submitted_link();
|
56 |
+
endif;
|
57 |
+
|
58 |
+
FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressfeeds', $link);
|
59 |
+
|
60 |
+
$this->dispatch = get_class($this);
|
61 |
+
$this->filename = __FILE__;
|
62 |
+
} /* FeedWordPressFeedsPage constructor */
|
63 |
+
|
64 |
+
var $special_settings = array ( /* Regular expression syntax is OK here */
|
65 |
+
'cats',
|
66 |
+
'cat_split',
|
67 |
+
'hardcode name',
|
68 |
+
'hardcode url',
|
69 |
+
'hardcode description',
|
70 |
+
'hardcode categories', /* Deprecated */
|
71 |
+
'post status',
|
72 |
+
'comment status',
|
73 |
+
'ping status',
|
74 |
+
'unfamiliar author',
|
75 |
+
'unfamliar categories', /* Deprecated */
|
76 |
+
'unfamiliar category',
|
77 |
+
'map authors',
|
78 |
+
'tags',
|
79 |
+
'postmeta',
|
80 |
+
'update/.*',
|
81 |
+
'feed/.*',
|
82 |
+
'link/.*',
|
83 |
+
);
|
84 |
+
|
85 |
+
function display () {
|
86 |
+
global $wpdb;
|
87 |
+
global $fwp_post;
|
88 |
+
global $post_source;
|
89 |
+
|
90 |
+
if (FeedWordPress::needs_upgrade()) :
|
91 |
+
fwp_upgrade_page();
|
92 |
+
return;
|
93 |
+
endif;
|
94 |
+
|
95 |
+
// Allow overriding of normal source for FeedFinder, which may
|
96 |
+
// be called from multiple points.
|
97 |
+
if (isset($post_source) and !is_null($post_source)) :
|
98 |
+
$source = $post_source;
|
99 |
+
else :
|
100 |
+
$source = get_class($this);
|
101 |
+
endif;
|
102 |
+
|
103 |
+
// If this is a POST, validate source and user credentials
|
104 |
+
FeedWordPressCompatibility::validate_http_request(/*action=*/ $source, /*capability=*/ 'manage_links');
|
105 |
+
|
106 |
+
if (isset($_REQUEST['feedfinder'])
|
107 |
+
or (isset($_REQUEST['action']) and $_REQUEST['action']=='feedfinder')
|
108 |
+
or (isset($_REQUEST['action']) and $_REQUEST['action']==FWP_SYNDICATE_NEW)) :
|
109 |
+
return $this->display_feedfinder(); // re-route to Feed Finder page
|
110 |
+
else :
|
111 |
+
if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
|
112 |
+
$this->accept_POST($fwp_post);
|
113 |
+
do_action('feedwordpress_admin_page_feeds_save', $GLOBALS['fwp_post'], $this);
|
114 |
+
endif;
|
115 |
+
|
116 |
+
////////////////////////////////////////////////
|
117 |
+
// Prepare settings page ///////////////////////
|
118 |
+
////////////////////////////////////////////////
|
119 |
+
|
120 |
+
$this->ajax_interface_js();
|
121 |
+
$this->display_update_notice_if_updated('Syndicated feed');
|
122 |
+
$this->open_sheet('Feed and Update');
|
123 |
+
?>
|
124 |
+
<div id="post-body">
|
125 |
+
<?php
|
126 |
+
////////////////////////////////////////////////
|
127 |
+
// Display settings boxes //////////////////////
|
128 |
+
////////////////////////////////////////////////
|
129 |
+
|
130 |
+
$boxes_by_methods = array(
|
131 |
+
'feed_information_box' => __('Feed Information'),
|
132 |
+
'global_feeds_box' => __('Update Scheduling'),
|
133 |
+
'posts_box' => __('Syndicated Posts, Links, Comments & Pings'),
|
134 |
+
'authors_box' => __('Syndicated Authors'),
|
135 |
+
'categories_box' => __('Categories'.FEEDWORDPRESS_AND_TAGS),
|
136 |
+
'custom_settings_box' => __('Custom Feed Settings (for use in templates)'),
|
137 |
+
);
|
138 |
+
if ($this->for_default_settings()) :
|
139 |
+
unset($boxes_by_methods['custom_settings_box']);
|
140 |
+
endif;
|
141 |
+
|
142 |
+
foreach ($boxes_by_methods as $method => $row) :
|
143 |
+
if (is_array($row)) :
|
144 |
+
$id = $row['id'];
|
145 |
+
$title = $row['title'];
|
146 |
+
else :
|
147 |
+
$id = 'feedwordpress_'.$method;
|
148 |
+
$title = $row;
|
149 |
+
endif;
|
150 |
+
|
151 |
+
fwp_add_meta_box(
|
152 |
+
/*id=*/ $id,
|
153 |
+
/*title=*/ $title,
|
154 |
+
/*callback=*/ array(get_class($this), $method),
|
155 |
+
/*page=*/ $this->meta_box_context(),
|
156 |
+
/*context=*/ $this->meta_box_context()
|
157 |
+
);
|
158 |
+
endforeach;
|
159 |
+
do_action('feedwordpress_admin_page_feeds_meta_boxes', $this);
|
160 |
+
?>
|
161 |
+
<div class="metabox-holder">
|
162 |
+
<?php
|
163 |
+
fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
|
164 |
+
?>
|
165 |
+
</div> <!-- class="metabox-holder" -->
|
166 |
+
</div> <!-- id="post-body" -->
|
167 |
+
<?php $this->close_sheet(); ?>
|
168 |
+
|
169 |
+
<script type="text/javascript">
|
170 |
+
var els = ['name', 'description', 'url'];
|
171 |
+
for (var i = 0; i < els.length; i++) {
|
172 |
+
contextual_appearance(
|
173 |
+
/*item=*/ 'basics-hardcode-'+els[i],
|
174 |
+
/*appear=*/ 'basics-'+els[i]+'-view',
|
175 |
+
/*disappear=*/ 'basics-'+els[i]+'-edit',
|
176 |
+
/*value=*/ 'no',
|
177 |
+
/*visibleStyle=*/ 'block',
|
178 |
+
/*checkbox=*/ true
|
179 |
+
);
|
180 |
+
} /* for */
|
181 |
+
</script>
|
182 |
+
<?php
|
183 |
+
endif;
|
184 |
+
return false; // Don't continue
|
185 |
+
} /* FeedWordPressFeedsPage::display() */
|
186 |
+
|
187 |
+
/*static*/ function global_feeds_box ($page, $box = NULL) {
|
188 |
+
global $wpdb;
|
189 |
+
|
190 |
+
$defaultUpdateWindow = get_option('feedwordpress_update_window');
|
191 |
+
if (!is_numeric($defaultUpdateWindow)) :
|
192 |
+
$defaultUpdateWindow = DEFAULT_UPDATE_PERIOD;
|
193 |
+
else :
|
194 |
+
$defaultUpdateWindow = (int) $defaultUpdateWindow;
|
195 |
+
endif;
|
196 |
+
?>
|
197 |
+
|
198 |
+
<table class="edit-form">
|
199 |
+
<?php
|
200 |
+
if ($page->for_default_settings()) :
|
201 |
+
$automatic_updates = get_option('feedwordpress_automatic_updates');
|
202 |
+
$update_time_limit = (int) get_option('feedwordpress_update_time_limit');
|
203 |
+
?>
|
204 |
+
|
205 |
+
<tr>
|
206 |
+
<th scope="row">Updates:</th>
|
207 |
+
<td><select id="automatic-updates-selector" name="automatic_updates" size="1" onchange="contextual_appearance('automatic-updates-selector', 'cron-job-explanation', null, 'no');">
|
208 |
+
<option value="shutdown"<?php echo ($automatic_updates=='shutdown')?' selected="selected"':''; ?>>automatically check for updates after pages load</option>
|
209 |
+
<option value="init"<?php echo ($automatic_updates=='init')?' selected="selected"':''; ?>>automatically check for updates before pages load</option>
|
210 |
+
<option value="no"<?php echo (!$automatic_updates)?' selected="selected"':''; ?>>cron job or manual updates</option>
|
211 |
+
</select>
|
212 |
+
<div id="cron-job-explanation" class="setting-description">
|
213 |
+
<p>If you want to use a cron job,
|
214 |
+
you can perform scheduled updates by sending regularly-scheduled
|
215 |
+
requests to <a href="<?php bloginfo('home'); ?>?update_feedwordpress=1"><code><?php bloginfo('home') ?>?update_feedwordpress=1</code></a>
|
216 |
+
For example, inserting the following line in your crontab:</p>
|
217 |
+
<pre style="font-size: 0.80em"><code>*/10 * * * * /usr/bin/curl --silent <?php bloginfo('home'); ?>?update_feedwordpress=1</code></pre>
|
218 |
+
<p class="setting-description">will check in every 10 minutes
|
219 |
+
and check for updates on any feeds that are ready to be polled for updates.</p>
|
220 |
+
</div>
|
221 |
+
</td>
|
222 |
+
</tr>
|
223 |
+
|
224 |
+
<tr>
|
225 |
+
<th scope="row"><?php print __('Update scheduling:') ?></th>
|
226 |
+
<td><p style="margin-top:0px">How long should FeedWordPress wait between updates before it considers a feed ready to be polled for updates again?</p>
|
227 |
+
<p style="font-style: italic; margin-left: 2.0em"><label>Wait <input type="text" name="update_window" value="<?php print $defaultUpdateWindow; ?>" size="4" /> minutes between polling.</label></p>
|
228 |
+
<div class="setting-description">
|
229 |
+
<p<?php if ($defaultUpdateWindow<50) : ?> style="color: white; background-color: #703030; padding: 1.0em;"<?php endif; ?>><strong>Recommendation.</strong> Unless you are positive that you have the webmaster's permission, you generally should not set FeedWordPress to poll feeds more frequently than once every 60 minutes. Many webmasters consider more frequent automated polling to be abusive, and may complain to your web host, or ban your IP address, as retaliation for hammering their servers too hard.</p>
|
230 |
+
<p><strong>Note.</strong> This is a default setting that FeedWordPress uses to schedule updates when the feed does not provide any scheduling requests. If a feed does provide update scheduling information (through elements such as <code><rss:ttl></code> or <code><sy:updateFrequency></code>), FeedWordPress will respect the feed's request.</p>
|
231 |
+
</div></td>
|
232 |
+
</tr>
|
233 |
+
|
234 |
+
<tr>
|
235 |
+
<th scope="row"><?php print __('Time limit on updates'); ?>:</th>
|
236 |
+
<td><select id="time-limit" name="update_time_limit" size="1" onchange="contextual_appearance('time-limit', 'time-limit-box', null, 'yes');">
|
237 |
+
<option value="no"<?php echo ($update_time_limit>0)?'':' selected="selected"'; ?>>no time limit on updates</option>
|
238 |
+
<option value="yes"<?php echo ($update_time_limit>0)?' selected="selected"':''; ?>>limit updates to no more than...</option>
|
239 |
+
</select>
|
240 |
+
<span id="time-limit-box"><label><input type="text" name="time_limit_seconds" value="<?php print $update_time_limit; ?>" size="5" /> seconds</label></span>
|
241 |
+
</tr>
|
242 |
+
|
243 |
+
<?php else :
|
244 |
+
$useDefaultUpdateWindow = !(isset($page->link->settings['update/window']));
|
245 |
+
|
246 |
+
$updateWindow = (isset($page->link->settings['update/window']) ? $page->link->settings['update/window'] : null);
|
247 |
+
if (!is_numeric($updateWindow)) :
|
248 |
+
$updateWindow = 60;
|
249 |
+
else :
|
250 |
+
$updateWindow = (int) $updateWindow;
|
251 |
+
endif;
|
252 |
+
|
253 |
+
?>
|
254 |
+
|
255 |
+
<tr>
|
256 |
+
<th scope="row"><?php _e('Last update') ?>:</th>
|
257 |
+
<td><?php
|
258 |
+
if (isset($page->link->settings['update/last'])) :
|
259 |
+
echo fwp_time_elapsed($page->link->settings['update/last'])." ";
|
260 |
+
else :
|
261 |
+
echo " none yet";
|
262 |
+
endif;
|
263 |
+
?></td></tr>
|
264 |
+
|
265 |
+
<tr><th><?php _e('Next update') ?>:</th>
|
266 |
+
<td><?php
|
267 |
+
$holdem = (isset($page->link->settings['update/hold']) ? $page->link->settings['update/hold'] : 'scheduled');
|
268 |
+
?>
|
269 |
+
<select name="update_schedule">
|
270 |
+
<option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
|
271 |
+
echo " (";
|
272 |
+
if (isset($page->link->settings['update/ttl']) and is_numeric($page->link->settings['update/ttl'])) :
|
273 |
+
if (isset($page->link->settings['update/timed']) and $page->link->settings['update/timed']=='automatically') :
|
274 |
+
echo 'next: ';
|
275 |
+
$next = $page->link->settings['update/last'] + ((int) $page->link->settings['update/ttl'] * 60);
|
276 |
+
if (strftime('%x', time()) != strftime('%x', $next)) :
|
277 |
+
echo strftime('%x', $next)." ";
|
278 |
+
endif;
|
279 |
+
echo strftime('%X', $page->link->settings['update/last']+((int) $page->link->settings['update/ttl']*60));
|
280 |
+
else :
|
281 |
+
echo "every ".$page->link->settings['update/ttl']." minute".(($page->link->settings['update/ttl']!=1)?"s":"");
|
282 |
+
endif;
|
283 |
+
else:
|
284 |
+
echo "next scheduled update";
|
285 |
+
endif;
|
286 |
+
echo ")";
|
287 |
+
?></option>
|
288 |
+
<option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option>
|
289 |
+
<option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option>
|
290 |
+
</select></td></tr>
|
291 |
+
|
292 |
+
<tr>
|
293 |
+
<th scope="row"><?php print __('Update scheduling:') ?></th>
|
294 |
+
<td><p style="margin-top:0px">How long should FeedWordPress wait between updates before it considers this feed ready to be polled for updates again?</p>
|
295 |
+
<ul>
|
296 |
+
<li><label><input type="radio" name="use_default_update_window" value="Yes" <?php if ($useDefaultUpdateWindow) : ?>checked="checked"<?php endif; ?> /> Use site-wide setting (currently <?php print $defaultUpdateWindow; ?> minutes)</li>
|
297 |
+
<li><label><input type="radio" name="use_default_update_window" value="No" <?php if (!$useDefaultUpdateWindow) : ?>checked="checked"<?php endif; ?> /> Wait <input type="text" name="update_window" value="<?php print $updateWindow; ?>" size="4" /> minutes between polling.</label></li>
|
298 |
+
</ul>
|
299 |
+
|
300 |
+
<div class="setting-description">
|
301 |
+
<p<?php if ($updateWindow<50) : ?> style="color: white; background-color: #703030; padding: 1.0em;"<?php endif; ?>><strong>Recommendation.</strong> Unless you are positive that you have the webmaster's permission, you generally should not set FeedWordPress to poll feeds more frequently than once every 60 minutes. Many webmasters consider more frequent automated polling to be abusive, and may complain to your web host, or ban your IP address, as retaliation for hammering their servers too hard.</p>
|
302 |
+
<p><strong>Note.</strong> This is a default setting that FeedWordPress uses to schedule updates when the feed does not provide any scheduling requests. If this feed does provide update scheduling information (through elements such as <code><rss:ttl></code> or <code><sy:updateFrequency></code>), FeedWordPress will respect the feed's request.</p>
|
303 |
+
</div></td>
|
304 |
+
</tr>
|
305 |
+
<?php endif; ?>
|
306 |
+
|
307 |
+
|
308 |
+
</table>
|
309 |
+
<script type="text/javascript">
|
310 |
+
contextual_appearance('automatic-updates-selector', 'cron-job-explanation', null, 'no');
|
311 |
+
contextual_appearance('time-limit', 'time-limit-box', null, 'yes');
|
312 |
+
</script>
|
313 |
+
<?php
|
314 |
+
} /* FeedWordPressFeedsPage::global_feeds_box() */
|
315 |
+
|
316 |
+
function feed_information_box ($page, $box = NULL) {
|
317 |
+
global $wpdb;
|
318 |
+
if ($page->for_feed_settings()) :
|
319 |
+
$info['name'] = wp_specialchars($page->link->link->link_name, 1);
|
320 |
+
$info['description'] = wp_specialchars($page->link->link->link_description, 'both');
|
321 |
+
$info['url'] = wp_specialchars($page->link->link->link_url, 1);
|
322 |
+
$rss_url = $page->link->link->link_rss;
|
323 |
+
|
324 |
+
$hardcode['name'] = $page->link->hardcode('name');
|
325 |
+
$hardcode['description'] = $page->link->hardcode('description');
|
326 |
+
$hardcode['url'] = $page->link->hardcode('url');
|
327 |
+
else :
|
328 |
+
$cat_id = FeedWordPress::link_category_id();
|
329 |
+
if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_21)) :
|
330 |
+
$results = get_categories(array(
|
331 |
+
"type" => 'link',
|
332 |
+
"hide_empty" => false,
|
333 |
+
));
|
334 |
+
|
335 |
+
// Guarantee that the Contributors category will be in the drop-down chooser, even if it is empty.
|
336 |
+
$found_link_category_id = false;
|
337 |
+
foreach ($results as $row) :
|
338 |
+
// Normalize case
|
339 |
+
if (!isset($row->cat_id)) : $row->cat_id = $row->cat_ID; endif;
|
340 |
+
|
341 |
+
if ($row->cat_id == $cat_id) : $found_link_category_id = true; endif;
|
342 |
+
endforeach;
|
343 |
+
|
344 |
+
if (!$found_link_category_id) : $results[] = get_category($cat_id); endif;
|
345 |
+
else :
|
346 |
+
$results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
|
347 |
+
endif;
|
348 |
+
|
349 |
+
$info = array();
|
350 |
+
$rss_url = null;
|
351 |
+
|
352 |
+
$hardcode['name'] = get_option('feedwordpress_hardcode_name');
|
353 |
+
$hardcode['description'] = get_option('feedwordpress_hardcode_description');
|
354 |
+
$hardcode['url'] = get_option('feedwordpress_hardcode_url');
|
355 |
+
endif;
|
356 |
+
|
357 |
+
// Hey ho, let's go
|
358 |
+
?>
|
359 |
+
<style type="text/css">
|
360 |
+
table.edit-form { width: 100%; }
|
361 |
+
table.edit-form th { width: 25%; vertical-align: top; text-align: right; padding: 0.5em; }
|
362 |
+
table.edit-form td { width: 75%; vertical-align: top; padding: 0.5em; }
|
363 |
+
table.edit-form td ul.options { margin: 0; padding: 0; list-style: none; }
|
364 |
+
</style>
|
365 |
+
|
366 |
+
<table class="edit-form">
|
367 |
+
|
368 |
+
<?php if ($page->for_feed_settings()) : ?>
|
369 |
+
|
370 |
+
<tr>
|
371 |
+
<th scope="row"><?php _e('Feed URL:') ?></th>
|
372 |
+
<td><a href="<?php echo wp_specialchars($rss_url, 'both'); ?>"><?php echo wp_specialchars($rss_url, 'both'); ?></a>
|
373 |
+
(<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($rss_url); ?>"
|
374 |
+
title="Check feed <<?php echo wp_specialchars($rss_url, 'both'); ?>> for validity">validate</a>)
|
375 |
+
<input type="submit" name="feedfinder" value="switch →" style="font-size:smaller" /></td>
|
376 |
+
</tr>
|
377 |
+
|
378 |
+
<?php
|
379 |
+
$rows = array(
|
380 |
+
"name" => __('Link Name'),
|
381 |
+
"description" => __('Short Description'),
|
382 |
+
"url" => __('Homepage'),
|
383 |
+
);
|
384 |
+
foreach ($rows as $what => $label) :
|
385 |
+
?>
|
386 |
+
<tr>
|
387 |
+
<th scope="row"><?php print $label ?></th>
|
388 |
+
<td>
|
389 |
+
<div id="basics-<?php print $what; ?>-edit"><input type="text" name="link<?php print $what; ?>"
|
390 |
+
value="<?php echo $info[$what]; ?>" style="width: 95%" /></div>
|
391 |
+
<div id="basics-<?php print $what; ?>-view">
|
392 |
+
<?php if ($what=='url') : ?><a href="<?php print $info[$what]; ?>"><?php else : ?><strong><?php endif; ?>
|
393 |
+
<?php print (strlen(trim($info[$what])) > 0) ? $info[$what] : '(none provided)'; ?>
|
394 |
+
<?php if ($what=='url') : ?></a><?php else : ?></strong><?php endif; ?></div>
|
395 |
+
|
396 |
+
<div>
|
397 |
+
<label><input id="basics-hardcode-<?php print $what; ?>"
|
398 |
+
type="radio" name="hardcode_<?php print $what; ?>" value="no"
|
399 |
+
<?php echo (($hardcode[$what]=='yes')?'':' checked="checked"');?>
|
400 |
+
onchange="contextual_appearance('basics-hardcode-<?php print $what; ?>', 'basics-<?php print $what; ?>-view', 'basics-<?php print $what; ?>-edit', 'no', 'block', /*checkbox=*/ true)"
|
401 |
+
/> Update automatically from feed</label>
|
402 |
+
<label><input type="radio" name="hardcode_<?php print $what; ?>" value="yes"
|
403 |
+
<?php echo (($hardcode[$what]!='yes')?'':' checked="checked"');?>
|
404 |
+
onchange="contextual_appearance('basics-hardcode-<?php print $what; ?>', 'basics-<?php print $what; ?>-view', 'basics-<?php print $what; ?>-edit', 'no', 'block', /*checkbox=*/ true)"
|
405 |
+
/> Edit manually</label>
|
406 |
+
</div>
|
407 |
+
</td>
|
408 |
+
</tr>
|
409 |
+
<?php
|
410 |
+
endforeach;
|
411 |
+
?>
|
412 |
+
|
413 |
+
<?php else : ?>
|
414 |
+
|
415 |
+
<tr>
|
416 |
+
<th scope="row">Syndicated Link category:</th>
|
417 |
+
<td><p><select name="syndication_category" size="1">
|
418 |
+
<?php
|
419 |
+
foreach ($results as $row) :
|
420 |
+
// Normalize case
|
421 |
+
if (!isset($row->cat_id)) : $row->cat_id = $row->cat_ID; endif;
|
422 |
+
|
423 |
+
echo "\n\t<option value=\"$row->cat_id\"";
|
424 |
+
if ($row->cat_id == $cat_id) :
|
425 |
+
echo " selected='selected'";
|
426 |
+
endif;
|
427 |
+
echo ">$row->cat_id: ".wp_specialchars($row->cat_name);
|
428 |
+
echo "</option>\n";
|
429 |
+
endforeach;
|
430 |
+
?></select></p>
|
431 |
+
<p class="setting-description">FeedWordPress will syndicate the
|
432 |
+
links placed under this link category.</p>
|
433 |
+
</td>
|
434 |
+
</tr>
|
435 |
+
|
436 |
+
<tr>
|
437 |
+
<th scope="row">Link Names:</th>
|
438 |
+
<td><label><input type="checkbox" name="hardcode_name" value="no"<?php echo (($hardcode['name']=='yes')?'':' checked="checked"');?>/> Update contributor titles automatically when the feed title changes</label></td>
|
439 |
+
</tr>
|
440 |
+
|
441 |
+
<tr>
|
442 |
+
<th scope="row">Short descriptions:</th>
|
443 |
+
<td><label><input type="checkbox" name="hardcode_description" value="no"<?php echo (($hardcode['description']=='yes')?'':' checked="checked"');?>/> Update contributor descriptions automatically when the feed tagline changes</label></td>
|
444 |
+
</tr>
|
445 |
+
|
446 |
+
<tr>
|
447 |
+
<th scope="row">Homepages:</th>
|
448 |
+
<td><label><input type="checkbox" name="hardcode_url" value="no"<?php echo (($hardcode['url']=='yes')?'':' checked="checked"');?>/> Update contributor homepages automatically when the feed link changes</label></td>
|
449 |
+
</tr>
|
450 |
+
|
451 |
+
<?php endif; ?>
|
452 |
+
|
453 |
+
</table>
|
454 |
+
<?php
|
455 |
+
} /* FeedWordPressFeedsPage::feed_information_box() */
|
456 |
+
|
457 |
+
function posts_box ($page, $box = NULL) {
|
458 |
+
FeedWordPressSettingsUI::instead_of_posts_box($page->link->id);
|
459 |
+
} /* FeedWordPressFeedsPage::posts_box() */
|
460 |
+
|
461 |
+
function authors_box ($page, $box = NULL) {
|
462 |
+
FeedWordPressSettingsUI::instead_of_authors_box($page->link->id);
|
463 |
+
} /* FeedWordPressFeedsPage::authors_box() */
|
464 |
+
|
465 |
+
function categories_box ($page, $box = NULL) {
|
466 |
+
FeedWordPressSettingsUI::instead_of_categories_box($page->link->id);
|
467 |
+
} /* FeedWordPressFeedsPage::categories_box() */
|
468 |
+
|
469 |
+
function custom_settings_box ($page, $box = NULL) {
|
470 |
+
?>
|
471 |
+
<p class="setting-description">These custom settings are special fields for the <strong>feed</strong> you are
|
472 |
+
syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create
|
473 |
+
custom fields on syndicated <strong>posts</strong>. If you want to create custom fields that are applied to each
|
474 |
+
individual post from this feed, set up the settings in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&link_id=<?php print $page->link->id; ?>">Syndicated Posts</a>.</p>
|
475 |
+
|
476 |
+
<div id="postcustomstuff">
|
477 |
+
<table id="meta-list" cellpadding="3">
|
478 |
+
<tr>
|
479 |
+
<th>Key</th>
|
480 |
+
<th>Value</th>
|
481 |
+
<th>Action</th>
|
482 |
+
</tr>
|
483 |
+
|
484 |
+
<?php
|
485 |
+
$i = 0;
|
486 |
+
foreach ($page->link->settings as $key => $value) :
|
487 |
+
if (!preg_match("\007^((".implode(')|(', $page->special_settings)."))$\007i", $key)) :
|
488 |
+
?>
|
489 |
+
<tr style="vertical-align:top">
|
490 |
+
<th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
|
491 |
+
<input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th>
|
492 |
+
<td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo wp_specialchars($value, 'both'); ?></textarea></td>
|
493 |
+
<td width="10%"><select name="notes[<?php echo $i; ?>][action]">
|
494 |
+
<option value="update">save changes</option>
|
495 |
+
<option value="delete">delete this setting</option>
|
496 |
+
</select></td>
|
497 |
+
</tr>
|
498 |
+
<?php
|
499 |
+
$i++;
|
500 |
+
endif;
|
501 |
+
endforeach;
|
502 |
+
?>
|
503 |
+
<tr>
|
504 |
+
<th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
|
505 |
+
<td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
|
506 |
+
<td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
|
507 |
+
</tr>
|
508 |
+
</table>
|
509 |
+
</div> <!-- id="postcustomstuff" -->
|
510 |
+
<?php
|
511 |
+
}
|
512 |
+
|
513 |
+
function display_feedfinder () {
|
514 |
+
global $wpdb;
|
515 |
+
|
516 |
+
$lookup = (isset($_REQUEST['lookup']) ? $_REQUEST['lookup'] : NULL);
|
517 |
+
|
518 |
+
if ($this->for_feed_settings()) : // Existing feed?
|
519 |
+
if (is_null($lookup)) : $lookup = $this->link->link->link_url; endif;
|
520 |
+
$name = wp_specialchars($this->link->link->link_name, 'both');
|
521 |
+
else: // Or a new subscription to add?
|
522 |
+
$name = "Subscribe to <code>".wp_specialchars(feedwordpress_display_url($lookup))."</code>";
|
523 |
+
endif;
|
524 |
+
?>
|
525 |
+
<style type="text/css">
|
526 |
+
form.fieldset {
|
527 |
+
clear: both;
|
528 |
+
}
|
529 |
+
.feed-sample {
|
530 |
+
float: right;
|
531 |
+
background-color: #D0D0D0;
|
532 |
+
color: black;
|
533 |
+
width: 45%;
|
534 |
+
font-size: 70%;
|
535 |
+
border-left: 1px dotted #A0A0A0;
|
536 |
+
margin-left: 1.0em;
|
537 |
+
}
|
538 |
+
.feed-sample p, .feed-sample h3 {
|
539 |
+
padding-left: 0.5em;
|
540 |
+
padding-right: 0.5em;
|
541 |
+
}
|
542 |
+
.feed-sample .feed-problem {
|
543 |
+
background-color: #ffd0d0;
|
544 |
+
border-bottom: 1px dotted black;
|
545 |
+
padding-bottom: 0.5em;
|
546 |
+
margin-bottom: 0.5em;
|
547 |
+
}
|
548 |
+
</style>
|
549 |
+
|
550 |
+
<div class="wrap">
|
551 |
+
<h2>Feed Finder: <?php echo $name; ?></h2>
|
552 |
+
|
553 |
+
<?php
|
554 |
+
$f =& new FeedFinder($lookup);
|
555 |
+
$feeds = $f->find();
|
556 |
+
if (count($feeds) > 0):
|
557 |
+
foreach ($feeds as $key => $f):
|
558 |
+
$rss = @fetch_rss($f);
|
559 |
+
if ($rss):
|
560 |
+
$feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link'];
|
561 |
+
$feed_link = isset($rss->channel['link'])?$rss->channel['link']:'';
|
562 |
+
$feed_type = ($rss->feed_type ? $rss->feed_type : 'Unknown');
|
563 |
+
else :
|
564 |
+
// Give us some sucky defaults
|
565 |
+
$feed_title = feedwordpress_display_url($lookup);
|
566 |
+
$feed_link = $lookup;
|
567 |
+
$feed_type = 'Unknown';
|
568 |
+
endif;
|
569 |
+
?>
|
570 |
+
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication.php" method="post">
|
571 |
+
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?></div>
|
572 |
+
<fieldset>
|
573 |
+
<legend><?php echo $feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend>
|
574 |
+
|
575 |
+
<?php
|
576 |
+
$this->stamp_link_id();
|
577 |
+
|
578 |
+
// No feed specified = add new feed; we
|
579 |
+
// need to pass along a starting title
|
580 |
+
// and homepage URL for the new Link.
|
581 |
+
if (!$this->for_feed_settings()):
|
582 |
+
?>
|
583 |
+
<input type="hidden" name="feed_title" value="<?php echo wp_specialchars($feed_title, 'both'); ?>" />
|
584 |
+
<input type="hidden" name="feed_link" value="<?php echo wp_specialchars($feed_link, 'both'); ?>" />
|
585 |
+
<?php
|
586 |
+
endif;
|
587 |
+
?>
|
588 |
+
|
589 |
+
<input type="hidden" name="feed" value="<?php echo wp_specialchars($f, 'both'); ?>" />
|
590 |
+
<input type="hidden" name="action" value="switchfeed" />
|
591 |
+
|
592 |
+
<div>
|
593 |
+
<div class="feed-sample">
|
594 |
+
|
595 |
+
<?php
|
596 |
+
if (count($rss->items) > 0):
|
597 |
+
// Prepare to display Sample Item
|
598 |
+
$link =& new MagpieMockLink($rss, $f);
|
599 |
+
$post =& new SyndicatedPost($rss->items[0], $link);
|
600 |
+
?>
|
601 |
+
<h3>Sample Item</h3>
|
602 |
+
<ul>
|
603 |
+
<li><strong>Title:</strong> <a href="<?php echo $post->post['meta']['syndication_permalink']; ?>"><?php echo $post->post['post_title']; ?></a></li>
|
604 |
+
<li><strong>Date:</strong> <?php print date('d-M-y g:i:s a', $post->published()); ?></li>
|
605 |
+
</ul>
|
606 |
+
<div class="entry">
|
607 |
+
<?php print $post->post['post_content']; ?>
|
608 |
+
</div>
|
609 |
+
<?php
|
610 |
+
else:
|
611 |
+
if (magpie_error()) :
|
612 |
+
print '<div class="feed-problem">';
|
613 |
+
print "<h3>Problem:</h3>\n";
|
614 |
+
print "<p>FeedWordPress encountered the following error
|
615 |
+
when trying to retrieve this feed:</p>";
|
616 |
+
print '<p style="margin: 1.0em 3.0em"><code>'.magpie_error().'</code></p>';
|
617 |
+
print "<p>If you think this is a temporary problem, you can still force FeedWordPress to add the subscription. FeedWordPress will not be able to find any syndicated posts until this problem is resolved.</p>";
|
618 |
+
print "</div>";
|
619 |
+
endif;
|
620 |
+
?>
|
621 |
+
<h3>No Items</h3>
|
622 |
+
<p>FeedWordPress found no posts on this feed.</p>
|
623 |
+
<?php
|
624 |
+
endif;
|
625 |
+
?>
|
626 |
+
</div>
|
627 |
+
|
628 |
+
<div>
|
629 |
+
<h3>Feed Information</h3>
|
630 |
+
<ul>
|
631 |
+
<li><strong>Homepage:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li>
|
632 |
+
<li><strong>Feed URL:</strong> <a href="<?php echo wp_specialchars($f, 'both'); ?>"><?php echo wp_specialchars($f, 'both'); ?></a> (<a title="Check feed <<?php echo wp_specialchars($f, 'both'); ?>> for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li>
|
633 |
+
<li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li>
|
634 |
+
<li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li>
|
635 |
+
</ul>
|
636 |
+
<div class="submit"><input type="submit" name="Use" value="« Use this feed" /></div>
|
637 |
+
<div class="submit"><input type="submit" name="Cancel" value="« Cancel" /></div>
|
638 |
+
</div>
|
639 |
+
</div>
|
640 |
+
</fieldset>
|
641 |
+
</form>
|
642 |
+
<?php
|
643 |
+
endforeach;
|
644 |
+
else:
|
645 |
+
print "<p><strong>".__('Error').":</strong> ".__("FeedWordPress couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>';
|
646 |
+
print ". ".__('Try another URL').".</p>";
|
647 |
+
|
648 |
+
// Diagnostics
|
649 |
+
print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n";
|
650 |
+
print "<h3>".__('Diagnostic information')."</h3>\n";
|
651 |
+
if (!is_null($f->error()) and strlen($f->error()) > 0) :
|
652 |
+
print "<h4>".__('HTTP request failure')."</h4>\n";
|
653 |
+
print "<p>".$f->error()."</p>\n";
|
654 |
+
else :
|
655 |
+
print "<h4>".__('HTTP request completed')."</h4>\n";
|
656 |
+
print "<p><strong>Status ".$f->status().":</strong> ".$this->HTTPStatusMessages[(int) $f->status()]."</p>\n";
|
657 |
+
endif;
|
658 |
+
|
659 |
+
// Do some more diagnostics if the API for it is available.
|
660 |
+
if (function_exists('_wp_http_get_object')) :
|
661 |
+
$httpObject = _wp_http_get_object();
|
662 |
+
$transports = $httpObject->_getTransport();
|
663 |
+
|
664 |
+
print "<h4>".__('HTTP Transports available').":</h4>\n";
|
665 |
+
print "<ol>\n";
|
666 |
+
print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n";
|
667 |
+
print "</ol>\n";
|
668 |
+
print "</div>\n";
|
669 |
+
endif;
|
670 |
+
|
671 |
+
endif;
|
672 |
+
?>
|
673 |
+
</div>
|
674 |
+
|
675 |
+
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
|
676 |
+
<div><?php
|
677 |
+
FeedWordPressCompatibility::stamp_nonce(get_class($this));
|
678 |
+
?></div>
|
679 |
+
<div class="wrap">
|
680 |
+
<h2>Use another feed</h2>
|
681 |
+
<div><label>Feed:</label>
|
682 |
+
<input type="text" name="lookup" id="use-another-feed" value="URI" />
|
683 |
+
<?php FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed'); ?>
|
684 |
+
<?php $this->stamp_link_id('link_id'); ?>
|
685 |
+
<input type="hidden" name="action" value="feedfinder" /></div>
|
686 |
+
<div class="submit"><input type="submit" value="Use this feed »" /></div>
|
687 |
+
</div>
|
688 |
+
</form>
|
689 |
+
<?php
|
690 |
+
return false; // Don't continue
|
691 |
+
} /* WordPressFeedsPage::display_feedfinder() */
|
692 |
+
|
693 |
+
function accept_POST ($post) {
|
694 |
+
global $wpdb;
|
695 |
+
|
696 |
+
// User mashed a Save Changes button
|
697 |
+
if (isset($post['save']) or isset($post['submit'])) :
|
698 |
+
if ($this->for_feed_settings()) :
|
699 |
+
$alter = array ();
|
700 |
+
|
701 |
+
// custom feed settings first
|
702 |
+
foreach ($post['notes'] as $mn) :
|
703 |
+
$mn['key0'] = trim($mn['key0']);
|
704 |
+
$mn['key1'] = trim($mn['key1']);
|
705 |
+
if (preg_match("\007^(("
|
706 |
+
.implode(')|(',$this->special_settings)
|
707 |
+
."))$\007i",
|
708 |
+
$mn['key1'])) :
|
709 |
+
$mn['key1'] = 'user/'.$mn['key1'];
|
710 |
+
endif;
|
711 |
+
|
712 |
+
if (strlen($mn['key0']) > 0) :
|
713 |
+
unset($this->link->settings[$mn['key0']]); // out with the old
|
714 |
+
endif;
|
715 |
+
|
716 |
+
if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
|
717 |
+
$this->link->settings[$mn['key1']] = $mn['value']; // in with the new
|
718 |
+
endif;
|
719 |
+
endforeach;
|
720 |
+
|
721 |
+
// now stuff through the web form
|
722 |
+
// hardcoded feed info
|
723 |
+
|
724 |
+
foreach (array('name', 'description', 'url') as $what) :
|
725 |
+
// We have a checkbox for "No," so if it's unchecked, mark as "Yes."
|
726 |
+
$this->link->settings["hardcode {$what}"] = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes');
|
727 |
+
if (FeedWordPress::affirmative($this->link->settings, "hardcode {$what}")) :
|
728 |
+
$alter[] = "link_{$what} = '".$wpdb->escape($post['link'.$what])."'";
|
729 |
+
endif;
|
730 |
+
endforeach;
|
731 |
+
|
732 |
+
// Update scheduling
|
733 |
+
if (isset($post['update_schedule'])) :
|
734 |
+
$this->link->settings['update/hold'] = $post['update_schedule'];
|
735 |
+
endif;
|
736 |
+
|
737 |
+
if (isset($post['use_default_update_window']) and strtolower($post['use_default_update_window'])=='yes') :
|
738 |
+
unset($this->link->settings['update/window']);
|
739 |
+
elseif (isset($post['update_window'])):
|
740 |
+
if ((int) $post['update_window'] > 0) :
|
741 |
+
$this->link->settings['update/window'] = (int) $post['update_window'];
|
742 |
+
endif;
|
743 |
+
endif;
|
744 |
+
|
745 |
+
$alter[] = "link_notes = '".$wpdb->escape($this->link->settings_to_notes())."'";
|
746 |
+
|
747 |
+
$alter_set = implode(", ", $alter);
|
748 |
+
|
749 |
+
// issue update query
|
750 |
+
$result = $wpdb->query("
|
751 |
+
UPDATE $wpdb->links
|
752 |
+
SET $alter_set
|
753 |
+
WHERE link_id='{$this->link->id}'
|
754 |
+
");
|
755 |
+
$this->updated = true;
|
756 |
+
|
757 |
+
// reload link information from DB
|
758 |
+
if (function_exists('clean_bookmark_cache')) :
|
759 |
+
clean_bookmark_cache($this->link->id);
|
760 |
+
endif;
|
761 |
+
$this->link = new SyndicatedLink($this->link->id);
|
762 |
+
else :
|
763 |
+
// Global
|
764 |
+
update_option('feedwordpress_cat_id', $post['syndication_category']);
|
765 |
+
|
766 |
+
if (!isset($post['automatic_updates']) or !in_array($post['automatic_updates'], array('init', 'shutdown'))) :
|
767 |
+
$automatic_updates = false;
|
768 |
+
else :
|
769 |
+
$automatic_updates = $post['automatic_updates'];
|
770 |
+
endif;
|
771 |
+
update_option('feedwordpress_automatic_updates', $automatic_updates);
|
772 |
+
|
773 |
+
if (isset($post['update_window'])):
|
774 |
+
if ((int) $post['update_window'] > 0) :
|
775 |
+
update_option('feedwordpress_update_window', (int) $post['update_window']);
|
776 |
+
endif;
|
777 |
+
endif;
|
778 |
+
|
779 |
+
update_option('feedwordpress_update_time_limit', ($post['update_time_limit']=='yes')?(int) $post['time_limit_seconds']:0);
|
780 |
+
|
781 |
+
foreach (array('name', 'description', 'url') as $what) :
|
782 |
+
// We have a checkbox for "No," so if it's unchecked, mark as "Yes."
|
783 |
+
$hardcode = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes');
|
784 |
+
update_option("feedwordpress_hardcode_{$what}", $hardcode);
|
785 |
+
endforeach;
|
786 |
+
|
787 |
+
$this->updated = true;
|
788 |
+
endif;
|
789 |
+
|
790 |
+
// Probably a "Go" button for the drop-down
|
791 |
+
else :
|
792 |
+
$this->updated = false;
|
793 |
+
endif;
|
794 |
+
} /* WordPressFeedsPage::accept_POST() */
|
795 |
+
|
796 |
+
} /* class FeedWordPressFeedsPage */
|
797 |
+
|
798 |
+
$feedsPage = new FeedWordPressFeedsPage;
|
799 |
+
$feedsPage->display();
|
800 |
+
|
feedwordpress.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: FeedWordPress
|
4 |
-
Plugin URI: http://
|
5 |
Description: simple and flexible Atom/RSS syndication for WordPress
|
6 |
-
Version: 2009.
|
7 |
Author: Charles Johnson
|
8 |
Author URI: http://radgeek.com/
|
9 |
License: GPL
|
@@ -28,13 +28,20 @@ License: GPL
|
|
28 |
|
29 |
# -- Don't change these unless you know what you're doing...
|
30 |
|
31 |
-
define ('FEEDWORDPRESS_VERSION', '2009.
|
32 |
define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
|
|
|
|
|
33 |
define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors');
|
|
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
endif;
|
39 |
define ('FEEDWORDPRESS_DEBUG', $feedwordpress_debug);
|
40 |
|
@@ -68,6 +75,8 @@ if (FEEDWORDPRESS_DEBUG) :
|
|
68 |
define('MAGPIE_CACHE_AGE', 1);
|
69 |
else :
|
70 |
define('MAGPIE_DEBUG', false);
|
|
|
|
|
71 |
endif;
|
72 |
|
73 |
// Note that the rss-functions.php that comes prepackaged with WordPress is
|
@@ -171,6 +180,7 @@ if (!FeedWordPress::needs_upgrade()) : // only work if the conditions are safe!
|
|
171 |
add_action('admin_menu', 'fwp_add_pages');
|
172 |
add_action('admin_notices', 'fwp_check_debug');
|
173 |
add_action('admin_notices', 'fwp_check_magpie');
|
|
|
174 |
|
175 |
# Inbound XML-RPC update methods
|
176 |
add_filter('xmlrpc_methods', 'feedwordpress_xmlrpc_hook');
|
@@ -194,11 +204,24 @@ if (!FeedWordPress::needs_upgrade()) : // only work if the conditions are safe!
|
|
194 |
add_action('feedwordpress_check_feed', 'log_feedwordpress_check_feed', 100);
|
195 |
add_action('feedwordpress_update_complete', 'log_feedwordpress_update_complete', 100);
|
196 |
endif;
|
197 |
-
|
198 |
-
# Cron-less auto-update. Hooray!
|
199 |
-
add_action('init', 'feedwordpress_auto_update');
|
200 |
-
add_action('init', 'feedwordpress_check_for_magpie_fix');
|
201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
# Default sanitizers
|
203 |
add_filter('syndicated_item_content', array('SyndicatedPost', 'resolve_relative_uris'), 0, 2);
|
204 |
add_filter('syndicated_item_content', array('SyndicatedPost', 'sanitize_content'), 0, 2);
|
@@ -221,6 +244,14 @@ function feedwordpress_check_for_magpie_fix () {
|
|
221 |
$source = dirname(__FILE__)."/MagpieRSS-upgrade/rss.php";
|
222 |
$destination = ABSPATH . WPINC . '/rss.php';
|
223 |
$success = @copy($source, $destination);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
$ret = (int) $success;
|
225 |
endif;
|
226 |
|
@@ -238,11 +269,19 @@ function feedwordpress_auto_update () {
|
|
238 |
$feedwordpress =& new FeedWordPress;
|
239 |
$feedwordpress->update();
|
240 |
endif;
|
241 |
-
|
|
|
|
|
|
|
242 |
if (FeedWordPress::update_requested()) :
|
|
|
|
|
|
|
|
|
|
|
243 |
exit;
|
244 |
endif;
|
245 |
-
} /*
|
246 |
|
247 |
################################################################################
|
248 |
## LOGGING FUNCTIONS: log status updates to error_log if you want it ###########
|
@@ -281,21 +320,54 @@ function log_feedwordpress_update_complete ($delta) {
|
|
281 |
: implode(' and ', $mesg)));
|
282 |
}
|
283 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
################################################################################
|
285 |
## TEMPLATE API: functions to make your templates syndication-aware ############
|
286 |
################################################################################
|
287 |
|
288 |
-
function is_syndicated () { return (strlen(get_syndication_feed_id()) > 0); }
|
289 |
|
290 |
-
function get_syndication_source_link ($original = NULL) {
|
291 |
if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data();
|
292 |
endif;
|
293 |
|
294 |
-
if ($original) : $vals = get_post_custom_values('syndication_source_uri_original');
|
295 |
else : $vals = array();
|
296 |
endif;
|
297 |
|
298 |
-
if (count($vals) == 0) : $vals = get_post_custom_values('syndication_source_uri');
|
299 |
endif;
|
300 |
|
301 |
if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif;
|
@@ -303,35 +375,69 @@ function get_syndication_source_link ($original = NULL) {
|
|
303 |
return $ret;
|
304 |
} /* function get_syndication_source_link() */
|
305 |
|
306 |
-
function the_syndication_source_link ($original = NULL
|
|
|
|
|
307 |
|
308 |
-
function
|
309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
endif;
|
311 |
|
312 |
-
|
313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
endif;
|
315 |
|
316 |
-
if (count($vals) == 0) :
|
|
|
317 |
endif;
|
318 |
|
319 |
-
if (count($vals) > 0) :
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
|
321 |
return $ret;
|
322 |
} /* function get_syndication_source() */
|
323 |
|
324 |
-
function the_syndication_source ($original = NULL) { echo get_syndication_source($original); }
|
325 |
|
326 |
-
function get_syndication_feed ($original = NULL) {
|
327 |
if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data();
|
328 |
endif;
|
329 |
|
330 |
-
if ($original) : $vals = get_post_custom_values('syndication_feed_original');
|
331 |
else : $vals = array();
|
332 |
endif;
|
333 |
-
|
334 |
-
if (count($vals) == 0) : $vals = get_post_custom_values('syndication_feed');
|
335 |
endif;
|
336 |
|
337 |
if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif;
|
@@ -339,17 +445,17 @@ function get_syndication_feed ($original = NULL) {
|
|
339 |
return $ret;
|
340 |
} /* function get_syndication_feed() */
|
341 |
|
342 |
-
function the_syndication_feed ($original = NULL) { echo get_syndication_feed
|
343 |
|
344 |
-
function get_syndication_feed_guid ($original = NULL) {
|
345 |
if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data();
|
346 |
endif;
|
347 |
|
348 |
-
if ($original) : $vals = get_post_custom_values('syndication_source_id_original');
|
349 |
else : $vals = array();
|
350 |
endif;
|
351 |
|
352 |
-
if (count($vals) == 0) : $vals = array(get_feed_meta('feed/id'));
|
353 |
endif;
|
354 |
|
355 |
if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif;
|
@@ -357,16 +463,16 @@ function get_syndication_feed_guid ($original = NULL) {
|
|
357 |
return $ret;
|
358 |
} /* function get_syndication_feed_guid () */
|
359 |
|
360 |
-
function the_syndication_feed_guid ($original = NULL) { echo get_syndication_feed_guid($original); }
|
361 |
|
362 |
-
function get_syndication_feed_id () { list($u) = get_post_custom_values('syndication_feed_id'); return $u; }
|
363 |
-
function the_syndication_feed_id () { echo get_syndication_feed_id(); }
|
364 |
|
365 |
$feedwordpress_linkcache = array (); // only load links from database once
|
366 |
|
367 |
-
function get_feed_meta ($key) {
|
368 |
global $wpdb, $feedwordpress_linkcache;
|
369 |
-
$feed_id = get_syndication_feed_id();
|
370 |
|
371 |
$ret = NULL;
|
372 |
if (strlen($feed_id) > 0):
|
@@ -382,11 +488,11 @@ function get_feed_meta ($key) {
|
|
382 |
return $ret;
|
383 |
} /* get_feed_meta() */
|
384 |
|
385 |
-
function get_syndication_permalink () {
|
386 |
-
list($u) = get_post_custom_values('syndication_permalink'); return $u;
|
387 |
}
|
388 |
-
function the_syndication_permalink () {
|
389 |
-
echo get_syndication_permalink();
|
390 |
}
|
391 |
|
392 |
################################################################################
|
@@ -469,21 +575,12 @@ function fwp_add_pages () {
|
|
469 |
$menu[] = WP_PLUGIN_URL.'/'.$fwp_path.'/feedwordpress-tiny.png';
|
470 |
endif;
|
471 |
|
472 |
-
if (fwp_test_wp_version(FWP_SCHEMA_26)) :
|
473 |
-
$options = __('Settings');
|
474 |
-
$longoptions = __('Syndication Settings');
|
475 |
-
else :
|
476 |
-
$options = __('Options');
|
477 |
-
$longoptions = __('Syndication Options');
|
478 |
-
endif;
|
479 |
-
|
480 |
call_user_func_array('add_menu_page', $menu);
|
481 |
-
add_submenu_page($fwp_path.'/syndication.php', 'Syndicated
|
|
|
482 |
add_submenu_page($fwp_path.'/syndication.php', 'Syndicated Authors', 'Authors', $fwp_capability['manage_options'], $fwp_path.'/authors-page.php');
|
483 |
-
add_submenu_page($fwp_path.'/syndication.php', 'Categories
|
484 |
-
add_submenu_page($fwp_path.'/syndication.php',
|
485 |
-
|
486 |
-
add_options_page($longoptions, 'Syndication', $fwp_capability['manage_options'], $fwp_path.'/syndication-options.php');
|
487 |
} /* function fwp_add_pages () */
|
488 |
|
489 |
function fwp_check_debug () {
|
@@ -508,7 +605,7 @@ for a production server.</p>
|
|
508 |
endif;
|
509 |
} /* function fwp_check_debug () */
|
510 |
|
511 |
-
define('EXPECTED_MAGPIE_VERSION', '2009.
|
512 |
function fwp_check_magpie () {
|
513 |
if (isset($_REQUEST['feedwordpress_magpie_fix'])) :
|
514 |
if ($_REQUEST['feedwordpress_magpie_fix']=='ignored') :
|
@@ -787,7 +884,7 @@ class FeedWordPress {
|
|
787 |
break;
|
788 |
endif;
|
789 |
|
790 |
-
$pinged_that = (is_null($uri) or in_array($uri, array($feed->uri(), $feed->homepage())));
|
791 |
|
792 |
if (!is_null($uri)) : // A site-specific ping always updates
|
793 |
$timely = true;
|
@@ -817,6 +914,9 @@ class FeedWordPress {
|
|
817 |
|
818 |
function stale () {
|
819 |
if (get_option('feedwordpress_automatic_updates')) :
|
|
|
|
|
|
|
820 |
$last = get_option('feedwordpress_last_update_all');
|
821 |
|
822 |
// If we haven't updated all yet, give it a time window
|
@@ -837,10 +937,6 @@ class FeedWordPress {
|
|
837 |
FeedWordPress::critical_bug('FeedWordPress::stale::last', $last, __LINE__);
|
838 |
endif;
|
839 |
|
840 |
-
// Explicit request for an update (e.g. from a cron job).
|
841 |
-
elseif (FeedWordPress::update_requested()) :
|
842 |
-
$ret = true;
|
843 |
-
|
844 |
else :
|
845 |
$ret = false;
|
846 |
endif;
|
@@ -848,9 +944,23 @@ class FeedWordPress {
|
|
848 |
} // FeedWordPress::stale()
|
849 |
|
850 |
function update_requested () {
|
851 |
-
return (
|
|
|
|
|
|
|
852 |
} // FeedWordPress::update_requested()
|
853 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
854 |
function syndicate_link ($name, $uri, $rss) {
|
855 |
global $wpdb;
|
856 |
|
@@ -860,14 +970,27 @@ class FeedWordPress {
|
|
860 |
// WordPress gets cranky if there's no homepage URI
|
861 |
if (!isset($uri) or strlen($uri)<1) : $uri = $rss; endif;
|
862 |
|
863 |
-
if (function_exists('wp_insert_link'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
864 |
$link_id = wp_insert_link(array(
|
865 |
"link_name" => $name,
|
866 |
"link_url" => $uri,
|
867 |
-
"link_category" =>
|
868 |
"link_rss" => $rss
|
869 |
));
|
870 |
-
|
871 |
$result = $wpdb->query("
|
872 |
INSERT INTO $wpdb->links
|
873 |
SET
|
@@ -877,10 +1000,18 @@ class FeedWordPress {
|
|
877 |
link_rss = '".$wpdb->escape($rss)."'
|
878 |
");
|
879 |
$link_id = $wpdb->insert_id;
|
880 |
-
|
881 |
return $link_id;
|
882 |
} // function FeedWordPress::syndicate_link()
|
883 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
884 |
function on_unfamiliar ($what = 'author', $override = NULL) {
|
885 |
$set = array(
|
886 |
'author' => array('create', 'default', 'filter'),
|
@@ -941,59 +1072,29 @@ class FeedWordPress {
|
|
941 |
|
942 |
$cat_id = get_option('feedwordpress_cat_id');
|
943 |
|
944 |
-
// If we don't yet
|
945 |
-
if (
|
946 |
-
$
|
947 |
-
|
948 |
-
// Look for something with the right name...
|
949 |
-
// -----------------------------------------
|
950 |
-
|
951 |
-
// WordPress 2.3 introduces a new taxonomy/term API
|
952 |
-
if (function_exists('is_term')) :
|
953 |
-
$cat_id = is_term($cat, 'link_category');
|
954 |
-
// WordPress 2.1 and 2.2 use a common table for both link and post categories
|
955 |
-
elseif (fwp_test_wp_version(FWP_SCHEMA_21, FWP_SCHEMA_23)) :
|
956 |
-
$cat_id = $wpdb->get_var("SELECT cat_id FROM {$wpdb->categories} WHERE cat_name='$cat'");
|
957 |
-
// WordPress 1.5 and 2.0.x have a separate table for link categories
|
958 |
-
elseif (fwp_test_wp_version(0, FWP_SCHEMA_21)):
|
959 |
-
$cat_id = $wpdb->get_var("SELECT cat_id FROM {$wpdb->linkcategories} WHERE cat_name='$cat'");
|
960 |
-
// This should never happen.
|
961 |
-
else :
|
962 |
-
FeedWordPress::critical_bug('FeedWordPress::link_category_id::wp_db_version', $wp_db_version, __LINE__);
|
963 |
-
endif;
|
964 |
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
// WordPress 2.3+ term/taxonomy API
|
969 |
-
if (function_exists('wp_insert_term')) :
|
970 |
-
$term = wp_insert_term($cat, 'link_category');
|
971 |
-
$cat_id = $term['term_id'];
|
972 |
-
// WordPress 2.1, 2.2 category API. By the way, why the fuck is this API function only available in a wp-admin module?
|
973 |
-
elseif (function_exists('wp_insert_category') and !fwp_test_wp_version(FWP_SCHEMA_20, FWP_SCHEMA_21)) :
|
974 |
-
$cat_id = wp_insert_category(array('cat_name' => $cat));
|
975 |
-
// WordPress 1.5 and 2.0.x
|
976 |
-
elseif (fwp_test_wp_version(0, FWP_SCHEMA_21)) :
|
977 |
-
$result = $wpdb->query("
|
978 |
-
INSERT INTO $wpdb->linkcategories
|
979 |
-
SET
|
980 |
-
cat_id = 0,
|
981 |
-
cat_name='$cat',
|
982 |
-
show_images='N',
|
983 |
-
show_description='N',
|
984 |
-
show_rating='N',
|
985 |
-
show_updated='N',
|
986 |
-
sort_order='name'
|
987 |
-
");
|
988 |
-
$cat_id = $wpdb->insert_id;
|
989 |
-
// This should never happen.
|
990 |
-
else :
|
991 |
-
FeedWordPress::critical_bug('FeedWordPress::link_category_id::wp_db_version', $wp_db_version, __LINE__);
|
992 |
-
endif;
|
993 |
endif;
|
994 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
995 |
update_option('feedwordpress_cat_id', $cat_id);
|
996 |
endif;
|
|
|
997 |
return $cat_id;
|
998 |
} // function FeedWordPress::link_category_id()
|
999 |
|
@@ -1072,12 +1173,14 @@ class FeedWordPress {
|
|
1072 |
|
1073 |
// Now fix the guids to avoid duplicate posts
|
1074 |
echo "<ul>";
|
1075 |
-
foreach ($this->feeds as $
|
|
|
1076 |
echo "<li>Fixing post meta-data for <cite>".$feed['link/name']."</cite> … "; flush();
|
1077 |
$rss = @fetch_rss($feed['link/uri']);
|
1078 |
if (is_array($rss->items)) :
|
1079 |
foreach ($rss->items as $item) :
|
1080 |
-
$
|
|
|
1081 |
$link = $wpdb->escape($item['link']);
|
1082 |
|
1083 |
$wpdb->query("
|
@@ -1103,6 +1206,20 @@ class FeedWordPress {
|
|
1103 |
");
|
1104 |
} /* FeedWordPress::create_guid_index () */
|
1105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1106 |
function magpie_version () {
|
1107 |
if (!defined('MAGPIE_VERSION')) : $magpie_version = $GLOBALS['wp_version'].'-default';
|
1108 |
else : $magpie_version = MAGPIE_VERSION;
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: FeedWordPress
|
4 |
+
Plugin URI: http://feedwordpress.radgeek.com/
|
5 |
Description: simple and flexible Atom/RSS syndication for WordPress
|
6 |
+
Version: 2009.1111
|
7 |
Author: Charles Johnson
|
8 |
Author URI: http://radgeek.com/
|
9 |
License: GPL
|
28 |
|
29 |
# -- Don't change these unless you know what you're doing...
|
30 |
|
31 |
+
define ('FEEDWORDPRESS_VERSION', '2009.0803');
|
32 |
define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
|
33 |
+
|
34 |
+
// Defaults
|
35 |
define ('DEFAULT_SYNDICATION_CATEGORY', 'Contributors');
|
36 |
+
define ('DEFAULT_UPDATE_PERIOD', 60); // value in minutes
|
37 |
|
38 |
+
if (isset($_REQUEST['feedwordpress_debug'])) :
|
39 |
+
$feedwordpress_debug = $_REQUEST['feedwordpress_debug'];
|
40 |
+
else :
|
41 |
+
$feedwordpress_debug = get_option('feedwordpress_debug');
|
42 |
+
if (is_string($feedwordpress_debug)) :
|
43 |
+
$feedwordpress_debug = ($feedwordpress_debug == 'yes');
|
44 |
+
endif;
|
45 |
endif;
|
46 |
define ('FEEDWORDPRESS_DEBUG', $feedwordpress_debug);
|
47 |
|
75 |
define('MAGPIE_CACHE_AGE', 1);
|
76 |
else :
|
77 |
define('MAGPIE_DEBUG', false);
|
78 |
+
|
79 |
+
define('MAGPIE_CACHE_AGE', 1*60);
|
80 |
endif;
|
81 |
|
82 |
// Note that the rss-functions.php that comes prepackaged with WordPress is
|
180 |
add_action('admin_menu', 'fwp_add_pages');
|
181 |
add_action('admin_notices', 'fwp_check_debug');
|
182 |
add_action('admin_notices', 'fwp_check_magpie');
|
183 |
+
add_action('init', 'feedwordpress_check_for_magpie_fix');
|
184 |
|
185 |
# Inbound XML-RPC update methods
|
186 |
add_filter('xmlrpc_methods', 'feedwordpress_xmlrpc_hook');
|
204 |
add_action('feedwordpress_check_feed', 'log_feedwordpress_check_feed', 100);
|
205 |
add_action('feedwordpress_update_complete', 'log_feedwordpress_update_complete', 100);
|
206 |
endif;
|
|
|
|
|
|
|
|
|
207 |
|
208 |
+
if (FeedWordPress::update_requested() and FEEDWORDPRESS_DEBUG) :
|
209 |
+
add_action('post_syndicated_item', 'debug_out_feedwordpress_post', 100);
|
210 |
+
add_action('update_syndicated_item', 'debug_out_feedwordpress_update_post', 100);
|
211 |
+
add_action('feedwordpress_update', 'debug_out_feedwordpress_update_feeds', 100);
|
212 |
+
add_action('feedwordpress_check_feed', 'debug_out_feedwordpress_check_feed', 100);
|
213 |
+
add_action('feedwordpress_update_complete', 'debug_out_feedwordpress_update_complete', 100);
|
214 |
+
endif;
|
215 |
+
|
216 |
+
# Cron-less auto-update. Hooray!
|
217 |
+
$autoUpdateHook = get_option('feedwordpress_automatic_updates');
|
218 |
+
if ($autoUpdateHook != 'init') :
|
219 |
+
$autoUpdateHook = 'shutdown';
|
220 |
+
endif;
|
221 |
+
add_action($autoUpdateHook, 'feedwordpress_auto_update');
|
222 |
+
|
223 |
+
add_action('init', 'feedwordpress_update_magic_url');
|
224 |
+
|
225 |
# Default sanitizers
|
226 |
add_filter('syndicated_item_content', array('SyndicatedPost', 'resolve_relative_uris'), 0, 2);
|
227 |
add_filter('syndicated_item_content', array('SyndicatedPost', 'sanitize_content'), 0, 2);
|
244 |
$source = dirname(__FILE__)."/MagpieRSS-upgrade/rss.php";
|
245 |
$destination = ABSPATH . WPINC . '/rss.php';
|
246 |
$success = @copy($source, $destination);
|
247 |
+
|
248 |
+
// Copy over rss-functions.php, too, to avoid collisions
|
249 |
+
// on pre-lapsarian versions of WordPress.
|
250 |
+
if ($success) :
|
251 |
+
$source = dirname(__FILE__)."/MagpieRSS-upgrade/rss-functions.php";
|
252 |
+
$destination = ABSPATH . WPINC . '/rss-functions.php';
|
253 |
+
$success = @copy($source, $destination);
|
254 |
+
endif;
|
255 |
$ret = (int) $success;
|
256 |
endif;
|
257 |
|
269 |
$feedwordpress =& new FeedWordPress;
|
270 |
$feedwordpress->update();
|
271 |
endif;
|
272 |
+
} /* feedwordpress_auto_update () */
|
273 |
+
|
274 |
+
function feedwordpress_update_magic_url () {
|
275 |
+
// Explicit update request in the HTTP request (e.g. from a cron job)
|
276 |
if (FeedWordPress::update_requested()) :
|
277 |
+
$feedwordpress =& new FeedWordPress;
|
278 |
+
$feedwordpress->update(FeedWordPress::update_requested_url());
|
279 |
+
|
280 |
+
// Magic URL should return nothing but a 200 OK header packet
|
281 |
+
// when successful.
|
282 |
exit;
|
283 |
endif;
|
284 |
+
} /* feedwordpress_magic_update_url () */
|
285 |
|
286 |
################################################################################
|
287 |
## LOGGING FUNCTIONS: log status updates to error_log if you want it ###########
|
320 |
: implode(' and ', $mesg)));
|
321 |
}
|
322 |
|
323 |
+
function debug_out_feedwordpress_post ($id) {
|
324 |
+
$post = wp_get_single_post($id);
|
325 |
+
print ("[".date('Y-m-d H:i:s')."][feedwordpress] posted "
|
326 |
+
."'{$post->post_title}' ({$post->post_date})\n");
|
327 |
+
}
|
328 |
+
|
329 |
+
function debug_out_feedwordpress_update_post ($id) {
|
330 |
+
$post = wp_get_single_post($id);
|
331 |
+
print ("[".date('Y-m-d H:i:s')."][feedwordpress] updated "
|
332 |
+
."'{$post->post_title}' ({$post->post_date})"
|
333 |
+
." (as of {$post->post_modified})\n");
|
334 |
+
}
|
335 |
+
|
336 |
+
function debug_out_feedwordpress_update_feeds ($uri) {
|
337 |
+
print ("[".date('Y-m-d H:i:s')."][feedwordpress] update('$uri')\n");
|
338 |
+
}
|
339 |
+
|
340 |
+
function debug_out_feedwordpress_check_feed ($feed) {
|
341 |
+
$uri = $feed['link/uri']; $name = $feed['link/name'];
|
342 |
+
print ("[".date('Y-m-d H:i:s')."][feedwordpress] Examining $name <$uri>\n");
|
343 |
+
}
|
344 |
+
|
345 |
+
function debug_out_feedwordpress_update_complete ($delta) {
|
346 |
+
$mesg = array();
|
347 |
+
if (isset($delta['new'])) $mesg[] = 'added '.$delta['new'].' new posts';
|
348 |
+
if (isset($delta['updated'])) $mesg[] = 'updated '.$delta['updated'].' existing posts';
|
349 |
+
if (empty($mesg)) $mesg[] = 'nothing changed';
|
350 |
+
|
351 |
+
print ("[".date('Y-m-d H:i:s')."][feedwordpress] "
|
352 |
+
.(is_null($delta) ? "Error: I don't syndicate that URI"
|
353 |
+
: implode(' and ', $mesg))."\n");
|
354 |
+
}
|
355 |
+
|
356 |
################################################################################
|
357 |
## TEMPLATE API: functions to make your templates syndication-aware ############
|
358 |
################################################################################
|
359 |
|
360 |
+
function is_syndicated ($id = NULL) { return (strlen(get_syndication_feed_id($id)) > 0); }
|
361 |
|
362 |
+
function get_syndication_source_link ($original = NULL, $id = NULL) {
|
363 |
if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data();
|
364 |
endif;
|
365 |
|
366 |
+
if ($original) : $vals = get_post_custom_values('syndication_source_uri_original', $id);
|
367 |
else : $vals = array();
|
368 |
endif;
|
369 |
|
370 |
+
if (count($vals) == 0) : $vals = get_post_custom_values('syndication_source_uri', $id);
|
371 |
endif;
|
372 |
|
373 |
if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif;
|
375 |
return $ret;
|
376 |
} /* function get_syndication_source_link() */
|
377 |
|
378 |
+
function the_syndication_source_link ($original = NULL, $id = NULL) {
|
379 |
+
echo get_syndication_source_link($original, $id);
|
380 |
+
}
|
381 |
|
382 |
+
function feedwordpress_display_url ($url, $before = 60, $after = 0) {
|
383 |
+
$bits = parse_url($url);
|
384 |
+
|
385 |
+
// Strip out crufty subdomains
|
386 |
+
$bits['host'] = preg_replace('/^www[0-9]*\./i', '', $bits['host']);
|
387 |
+
|
388 |
+
// Reassemble bit-by-bit with minimum of crufty elements
|
389 |
+
$url = (isset($bits['user'])?$bits['user'].'@':'')
|
390 |
+
.(isset($bits['host'])?$bits['host']:'')
|
391 |
+
.(isset($bits['path'])?$bits['path']:'')
|
392 |
+
.(isset($bits['query'])?'?'.$bits['query']:'');
|
393 |
+
|
394 |
+
if (strlen($url) > ($before+$after)) :
|
395 |
+
$url = substr($url, 0, $before).'…'.substr($url, 0 - $after, $after);
|
396 |
endif;
|
397 |
|
398 |
+
return $url;
|
399 |
+
}
|
400 |
+
|
401 |
+
function get_syndication_source ($original = NULL, $id = NULL) {
|
402 |
+
if (is_null($original)) :
|
403 |
+
$original = FeedWordPress::use_aggregator_source_data();
|
404 |
+
endif;
|
405 |
+
|
406 |
+
if ($original) :
|
407 |
+
$vals = get_post_custom_values('syndication_source_original', $id);
|
408 |
+
else :
|
409 |
+
$vals = array();
|
410 |
endif;
|
411 |
|
412 |
+
if (count($vals) == 0) :
|
413 |
+
$vals = get_post_custom_values('syndication_source', $id);
|
414 |
endif;
|
415 |
|
416 |
+
if (count($vals) > 0) :
|
417 |
+
$ret = $vals[0];
|
418 |
+
else :
|
419 |
+
$ret = NULL;
|
420 |
+
endif;
|
421 |
+
|
422 |
+
if (is_null($ret) or strlen(trim($ret)) == 0) :
|
423 |
+
// Fall back to URL of blog
|
424 |
+
$ret = feedwordpress_display_url(get_syndication_source_link());
|
425 |
+
endif;
|
426 |
|
427 |
return $ret;
|
428 |
} /* function get_syndication_source() */
|
429 |
|
430 |
+
function the_syndication_source ($original = NULL, $id = NULL) { echo get_syndication_source($original, $id); }
|
431 |
|
432 |
+
function get_syndication_feed ($original = NULL, $id = NULL) {
|
433 |
if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data();
|
434 |
endif;
|
435 |
|
436 |
+
if ($original) : $vals = get_post_custom_values('syndication_feed_original', $id);
|
437 |
else : $vals = array();
|
438 |
endif;
|
439 |
+
|
440 |
+
if (count($vals) == 0) : $vals = get_post_custom_values('syndication_feed', $id);
|
441 |
endif;
|
442 |
|
443 |
if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif;
|
445 |
return $ret;
|
446 |
} /* function get_syndication_feed() */
|
447 |
|
448 |
+
function the_syndication_feed ($original = NULL, $id = NULL) { echo get_syndication_feed($original, $id); }
|
449 |
|
450 |
+
function get_syndication_feed_guid ($original = NULL, $id = NULL) {
|
451 |
if (is_null($original)) : $original = FeedWordPress::use_aggregator_source_data();
|
452 |
endif;
|
453 |
|
454 |
+
if ($original) : $vals = get_post_custom_values('syndication_source_id_original', $id);
|
455 |
else : $vals = array();
|
456 |
endif;
|
457 |
|
458 |
+
if (count($vals) == 0) : $vals = array(get_feed_meta('feed/id', $id));
|
459 |
endif;
|
460 |
|
461 |
if (count($vals) > 0) : $ret = $vals[0]; else : $ret = NULL; endif;
|
463 |
return $ret;
|
464 |
} /* function get_syndication_feed_guid () */
|
465 |
|
466 |
+
function the_syndication_feed_guid ($original = NULL, $id = NULL) { echo get_syndication_feed_guid($original, $id); }
|
467 |
|
468 |
+
function get_syndication_feed_id ($id = NULL) { list($u) = get_post_custom_values('syndication_feed_id', $id); return $u; }
|
469 |
+
function the_syndication_feed_id ($id = NULL) { echo get_syndication_feed_id($id); }
|
470 |
|
471 |
$feedwordpress_linkcache = array (); // only load links from database once
|
472 |
|
473 |
+
function get_feed_meta ($key, $id = NULL) {
|
474 |
global $wpdb, $feedwordpress_linkcache;
|
475 |
+
$feed_id = get_syndication_feed_id($id);
|
476 |
|
477 |
$ret = NULL;
|
478 |
if (strlen($feed_id) > 0):
|
488 |
return $ret;
|
489 |
} /* get_feed_meta() */
|
490 |
|
491 |
+
function get_syndication_permalink ($id = NULL) {
|
492 |
+
list($u) = get_post_custom_values('syndication_permalink', $id); return $u;
|
493 |
}
|
494 |
+
function the_syndication_permalink ($id = NULL) {
|
495 |
+
echo get_syndication_permalink($id);
|
496 |
}
|
497 |
|
498 |
################################################################################
|
575 |
$menu[] = WP_PLUGIN_URL.'/'.$fwp_path.'/feedwordpress-tiny.png';
|
576 |
endif;
|
577 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
578 |
call_user_func_array('add_menu_page', $menu);
|
579 |
+
add_submenu_page($fwp_path.'/syndication.php', 'Syndicated Feeds & Updates', 'Feeds & Updates', $fwp_capability['manage_options'], $fwp_path.'/feeds-page.php');
|
580 |
+
add_submenu_page($fwp_path.'/syndication.php', 'Syndicated Posts & Links', 'Posts & Links', $fwp_capability['manage_options'], $fwp_path.'/posts-page.php');
|
581 |
add_submenu_page($fwp_path.'/syndication.php', 'Syndicated Authors', 'Authors', $fwp_capability['manage_options'], $fwp_path.'/authors-page.php');
|
582 |
+
add_submenu_page($fwp_path.'/syndication.php', 'Categories'.FEEDWORDPRESS_AND_TAGS, 'Categories'.FEEDWORDPRESS_AND_TAGS, $fwp_capability['manage_options'], $fwp_path.'/categories-page.php');
|
583 |
+
add_submenu_page($fwp_path.'/syndication.php', 'FeedWordPress Back End', 'Back End', $fwp_capability['manage_options'], $fwp_path.'/backend-page.php');
|
|
|
|
|
584 |
} /* function fwp_add_pages () */
|
585 |
|
586 |
function fwp_check_debug () {
|
605 |
endif;
|
606 |
} /* function fwp_check_debug () */
|
607 |
|
608 |
+
define('EXPECTED_MAGPIE_VERSION', '2009.0725');
|
609 |
function fwp_check_magpie () {
|
610 |
if (isset($_REQUEST['feedwordpress_magpie_fix'])) :
|
611 |
if ($_REQUEST['feedwordpress_magpie_fix']=='ignored') :
|
884 |
break;
|
885 |
endif;
|
886 |
|
887 |
+
$pinged_that = (is_null($uri) or ($uri=='*') or in_array($uri, array($feed->uri(), $feed->homepage())));
|
888 |
|
889 |
if (!is_null($uri)) : // A site-specific ping always updates
|
890 |
$timely = true;
|
914 |
|
915 |
function stale () {
|
916 |
if (get_option('feedwordpress_automatic_updates')) :
|
917 |
+
// Do our best to avoid possible simultaneous
|
918 |
+
// updates by getting up-to-the-minute settings.
|
919 |
+
|
920 |
$last = get_option('feedwordpress_last_update_all');
|
921 |
|
922 |
// If we haven't updated all yet, give it a time window
|
937 |
FeedWordPress::critical_bug('FeedWordPress::stale::last', $last, __LINE__);
|
938 |
endif;
|
939 |
|
|
|
|
|
|
|
|
|
940 |
else :
|
941 |
$ret = false;
|
942 |
endif;
|
944 |
} // FeedWordPress::stale()
|
945 |
|
946 |
function update_requested () {
|
947 |
+
return (
|
948 |
+
isset($_REQUEST['update_feedwordpress'])
|
949 |
+
and $_REQUEST['update_feedwordpress']
|
950 |
+
);
|
951 |
} // FeedWordPress::update_requested()
|
952 |
|
953 |
+
function update_requested_url () {
|
954 |
+
$ret = null;
|
955 |
+
|
956 |
+
if (($_REQUEST['update_feedwordpress']=='*')
|
957 |
+
or (preg_match('|^http://.*|i', $_REQUEST['update_feedwordpress']))) :
|
958 |
+
$ret = $_REQUEST['update_feedwordpress'];
|
959 |
+
endif;
|
960 |
+
|
961 |
+
return $ret;
|
962 |
+
} // FeedWordPress::update_requested_url()
|
963 |
+
|
964 |
function syndicate_link ($name, $uri, $rss) {
|
965 |
global $wpdb;
|
966 |
|
970 |
// WordPress gets cranky if there's no homepage URI
|
971 |
if (!isset($uri) or strlen($uri)<1) : $uri = $rss; endif;
|
972 |
|
973 |
+
if (function_exists('wp_insert_link')) : // WordPress 2.x
|
974 |
+
if (FeedWordPressCompatibility::test_version(0, FWP_SCHEMA_21)) :
|
975 |
+
// Morons.
|
976 |
+
$name = $wpdb->escape($name);
|
977 |
+
$uri = $wpdb->escape($uri);
|
978 |
+
$rss = $wpdb->escape($rss);
|
979 |
+
|
980 |
+
// Comes in as a single category
|
981 |
+
$linkCats = $cat_id;
|
982 |
+
else :
|
983 |
+
// Comes in as an array of categories
|
984 |
+
$linkCats = array($cat_id);
|
985 |
+
endif;
|
986 |
+
|
987 |
$link_id = wp_insert_link(array(
|
988 |
"link_name" => $name,
|
989 |
"link_url" => $uri,
|
990 |
+
"link_category" => $linkCats,
|
991 |
"link_rss" => $rss
|
992 |
));
|
993 |
+
else : // WordPress 1.5.x
|
994 |
$result = $wpdb->query("
|
995 |
INSERT INTO $wpdb->links
|
996 |
SET
|
1000 |
link_rss = '".$wpdb->escape($rss)."'
|
1001 |
");
|
1002 |
$link_id = $wpdb->insert_id;
|
1003 |
+
endif;
|
1004 |
return $link_id;
|
1005 |
} // function FeedWordPress::syndicate_link()
|
1006 |
|
1007 |
+
/*static*/ function syndicated_status ($what, $default) {
|
1008 |
+
$ret = get_option("feedwordpress_syndicated_{$what}_status");
|
1009 |
+
if (!$ret) :
|
1010 |
+
$ret = $default;
|
1011 |
+
endif;
|
1012 |
+
return $ret;
|
1013 |
+
} /* FeedWordPress::syndicated_status() */
|
1014 |
+
|
1015 |
function on_unfamiliar ($what = 'author', $override = NULL) {
|
1016 |
$set = array(
|
1017 |
'author' => array('create', 'default', 'filter'),
|
1072 |
|
1073 |
$cat_id = get_option('feedwordpress_cat_id');
|
1074 |
|
1075 |
+
// If we don't yet have the category ID stored, search by name
|
1076 |
+
if (!$cat_id) :
|
1077 |
+
$cat_id = FeedWordPressCompatibility::link_category_id(DEFAULT_SYNDICATION_CATEGORY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1078 |
|
1079 |
+
if ($cat_id) :
|
1080 |
+
// We found it; let's stamp it.
|
1081 |
+
update_option('feedwordpress_cat_id', $cat_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1082 |
endif;
|
1083 |
|
1084 |
+
// If we *do* have the category ID stored, verify that it exists
|
1085 |
+
else :
|
1086 |
+
$cat_id = FeedWordPressCompatibility::link_category_id((int) $cat_id, 'cat_id');
|
1087 |
+
endif;
|
1088 |
+
|
1089 |
+
// If we could not find an appropriate link category,
|
1090 |
+
// make a new one for ourselves.
|
1091 |
+
if (!$cat_id) :
|
1092 |
+
$cat_id = FeedWordPressCompatibility::insert_link_category(DEFAULT_SYNDICATION_CATEGORY);
|
1093 |
+
|
1094 |
+
// Stamp it
|
1095 |
update_option('feedwordpress_cat_id', $cat_id);
|
1096 |
endif;
|
1097 |
+
|
1098 |
return $cat_id;
|
1099 |
} // function FeedWordPress::link_category_id()
|
1100 |
|
1173 |
|
1174 |
// Now fix the guids to avoid duplicate posts
|
1175 |
echo "<ul>";
|
1176 |
+
foreach ($this->feeds as $syndicatedLink) :
|
1177 |
+
$feed = $syndicatedLink->settings;
|
1178 |
echo "<li>Fixing post meta-data for <cite>".$feed['link/name']."</cite> … "; flush();
|
1179 |
$rss = @fetch_rss($feed['link/uri']);
|
1180 |
if (is_array($rss->items)) :
|
1181 |
foreach ($rss->items as $item) :
|
1182 |
+
$post = new SyndicatedPost($item, $syndicatedLink);
|
1183 |
+
$guid = $wpdb->escape($post->guid()); // new GUID algorithm
|
1184 |
$link = $wpdb->escape($item['link']);
|
1185 |
|
1186 |
$wpdb->query("
|
1206 |
");
|
1207 |
} /* FeedWordPress::create_guid_index () */
|
1208 |
|
1209 |
+
function clear_cache () {
|
1210 |
+
global $wpdb;
|
1211 |
+
|
1212 |
+
// MagpieRSS stores its cached feeds in options table rows with
|
1213 |
+
// name = `rss_{md5 of url}` and timestamps for cached feeds in
|
1214 |
+
// table rows with name = `rss_{md5 of url}_ts`. The md5 is
|
1215 |
+
// always 32 characters in length, so the total option_name is
|
1216 |
+
// always over 32 characters.
|
1217 |
+
$wpdb->query("
|
1218 |
+
DELETE FROM {$wpdb->options}
|
1219 |
+
WHERE LOCATE('rss_', option_name) AND LENGTH(option_name) > 32
|
1220 |
+
");
|
1221 |
+
} /* FeedWordPress::clear_cache () */
|
1222 |
+
|
1223 |
function magpie_version () {
|
1224 |
if (!defined('MAGPIE_VERSION')) : $magpie_version = $GLOBALS['wp_version'].'-default';
|
1225 |
else : $magpie_version = MAGPIE_VERSION;
|
posts-page.php
CHANGED
@@ -1,32 +1,331 @@
|
|
1 |
<?php
|
2 |
require_once(dirname(__FILE__) . '/admin-ui.php');
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
function fwp_posts_page () {
|
5 |
global $wpdb, $wp_db_version;
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links');
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
$link_id = $_REQUEST['link_id'];
|
13 |
-
else :
|
14 |
-
$link_id = NULL;
|
15 |
-
endif;
|
16 |
-
|
17 |
-
if (is_numeric($link_id) and $link_id) :
|
18 |
-
$link =& new SyndicatedLink($link_id);
|
19 |
-
else :
|
20 |
-
$link = NULL;
|
21 |
-
endif;
|
22 |
|
23 |
$mesg = null;
|
24 |
|
25 |
////////////////////////////////////////////////
|
26 |
// Process POST request, if any /////////////////
|
27 |
////////////////////////////////////////////////
|
28 |
-
if (isset($GLOBALS['fwp_post']['save'])) :
|
29 |
-
// custom post
|
30 |
foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
|
31 |
$mn['key0'] = trim($mn['key0']);
|
32 |
$mn['key1'] = trim($mn['key1']);
|
@@ -100,343 +399,64 @@ function fwp_posts_page () {
|
|
100 |
|
101 |
$updated_link = true;
|
102 |
endif;
|
|
|
|
|
103 |
else :
|
104 |
$updated_link = false;
|
105 |
endif;
|
106 |
-
|
107 |
-
////////////////////////////////////////////////
|
108 |
-
// Get defaults from database //////////////////
|
109 |
-
////////////////////////////////////////////////
|
110 |
-
|
111 |
-
$post_status_global = get_option('feedwordpress_syndicated_post_status');
|
112 |
-
if (!$post_status_global) : $post_status_global = 'publish'; endif;
|
113 |
|
114 |
-
$
|
115 |
-
if (!$comment_status_global) : $comment_status_global = 'closed'; endif;
|
116 |
-
|
117 |
-
$ping_status_global = get_option('feedwordpress_syndicated_ping_status');
|
118 |
-
if (!$ping_status_global) : $ping_status_global = 'closed'; endif;
|
119 |
-
|
120 |
-
$status['post'] = array('publish' => '', 'private' => '', 'draft' => '');
|
121 |
-
if (SyndicatedPost::use_api('post_status_pending')) :
|
122 |
-
$status['post']['pending'] = '';
|
123 |
-
endif;
|
124 |
-
|
125 |
-
$status['comment'] = array('open' => '', 'closed' => '');
|
126 |
-
$status['ping'] = array('open' => '', 'closed' => '');
|
127 |
|
128 |
-
if (
|
129 |
-
$thePostsPhrase = __('posts from this feed');
|
130 |
-
|
131 |
-
foreach (array('post', 'comment', 'ping') as $what) :
|
132 |
-
$status[$what]['site-default'] = '';
|
133 |
-
if (isset($link->settings["{$what} status"])) :
|
134 |
-
$status[$what][$link->settings["{$what} status"]] = ' checked="checked"';
|
135 |
-
else :
|
136 |
-
$status[$what]['site-default'] = ' checked="checked"';
|
137 |
-
endif;
|
138 |
-
endforeach;
|
139 |
-
|
140 |
-
$custom_settings = $link->settings["postmeta"];
|
141 |
-
if ($custom_settings) :
|
142 |
-
$custom_settings = unserialize($custom_settings);
|
143 |
-
endif;
|
144 |
-
|
145 |
-
if (!is_array($custom_settings)) :
|
146 |
-
$custom_settings = array();
|
147 |
-
endif;
|
148 |
-
else :
|
149 |
-
$thePostsPhrase = __('syndicated posts');
|
150 |
-
|
151 |
-
$status['post'][$post_status_global] = ' checked="checked"';
|
152 |
-
$status['comment'][$comment_status_global] = ' checked="checked"';
|
153 |
-
$status['ping'][$ping_status_global] = ' checked="checked"';
|
154 |
-
|
155 |
-
$munge_permalink = get_option('feedwordpress_munge_permalink');
|
156 |
-
$formatting_filters = get_option('feedwordpress_formatting_filters');
|
157 |
-
$use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
|
158 |
-
|
159 |
-
$custom_settings = get_option('feedwordpress_custom_settings');
|
160 |
-
if ($custom_settings) :
|
161 |
-
$custom_settings = unserialize($custom_settings);
|
162 |
-
endif;
|
163 |
-
|
164 |
-
if (!is_array($custom_settings)) :
|
165 |
-
$custom_settings = array();
|
166 |
-
endif;
|
167 |
-
endif;
|
168 |
-
?>
|
169 |
-
<script type="text/javascript">
|
170 |
-
function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) {
|
171 |
-
if (typeof(visibleStyle)=='undefined') visibleStyle = 'block';
|
172 |
-
|
173 |
-
var rollup=document.getElementById(item);
|
174 |
-
var newuser=document.getElementById(appear);
|
175 |
-
var sitewide=document.getElementById(disappear);
|
176 |
-
if (rollup) {
|
177 |
-
if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) {
|
178 |
-
if (newuser) newuser.style.display=visibleStyle;
|
179 |
-
if (sitewide) sitewide.style.display='none';
|
180 |
-
} else {
|
181 |
-
if (newuser) newuser.style.display='none';
|
182 |
-
if (sitewide) sitewide.style.display=visibleStyle;
|
183 |
-
}
|
184 |
-
}
|
185 |
-
}
|
186 |
-
</script>
|
187 |
-
|
188 |
-
<?php if ($updated_link) : ?>
|
189 |
<div class="updated"><p>Syndicated posts settings updated.</p></div>
|
190 |
<?php elseif (!is_null($mesg)) : ?>
|
191 |
<div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div>
|
192 |
<?php endif; ?>
|
193 |
|
194 |
-
<div class="wrap">
|
195 |
-
<form style="position: relative" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
|
196 |
-
<div><?php
|
197 |
-
FeedWordPressCompatibility::stamp_nonce('feedwordpress_posts_settings');
|
198 |
-
|
199 |
-
if (is_numeric($link_id) and $link_id) :
|
200 |
-
?>
|
201 |
-
<input type="hidden" name="save_link_id" value="<?php echo $link_id; ?>" />
|
202 |
<?php
|
203 |
-
|
|
|
204 |
?>
|
205 |
-
<input type="hidden" name="save_link_id" value="*" />
|
206 |
-
<?php
|
207 |
-
endif;
|
208 |
-
?>
|
209 |
-
</div>
|
210 |
-
|
211 |
-
<?php $links = FeedWordPress::syndicated_links(); ?>
|
212 |
-
<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
|
213 |
-
<div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
|
214 |
-
<?php endif; ?>
|
215 |
-
|
216 |
-
<h2>Syndicated Post Settings<?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2>
|
217 |
-
|
218 |
<style type="text/css">
|
219 |
-
table.edit-form th { width: 27%; vertical-align: top; }
|
220 |
-
table.edit-form td { width: 73%; vertical-align: top; }
|
221 |
-
|
222 |
</style>
|
223 |
-
|
224 |
-
<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
|
225 |
-
<style type="text/css">
|
226 |
-
#post-search {
|
227 |
-
float: right;
|
228 |
-
margin:11px 12px 0;
|
229 |
-
min-width: 130px;
|
230 |
-
position:relative;
|
231 |
-
}
|
232 |
-
.fwpfs {
|
233 |
-
color: #dddddd;
|
234 |
-
background:#797979 url(<?php bloginfo('home') ?>/wp-admin/images/fav.png) repeat-x scroll left center;
|
235 |
-
border-color:#777777 #777777 #666666 !important; -moz-border-radius-bottomleft:12px;
|
236 |
-
-moz-border-radius-bottomright:12px;
|
237 |
-
-moz-border-radius-topleft:12px;
|
238 |
-
-moz-border-radius-topright:12px;
|
239 |
-
border-style:solid;
|
240 |
-
border-width:1px;
|
241 |
-
line-height:15px;
|
242 |
-
padding:3px 30px 4px 12px;
|
243 |
-
}
|
244 |
-
.fwpfs.slide-down {
|
245 |
-
border-bottom-color: #626262;
|
246 |
-
-moz-border-radius-bottomleft:0;
|
247 |
-
-moz-border-radius-bottomright:0;
|
248 |
-
-moz-border-radius-topleft:12px;
|
249 |
-
-moz-border-radius-topright:12px;
|
250 |
-
background-image:url(<?php bloginfo('home') ?>/wp-admin/images/fav-top.png);
|
251 |
-
background-position:0 top;
|
252 |
-
background-repeat:repeat-x;
|
253 |
-
border-bottom-style:solid;
|
254 |
-
border-bottom-width:1px;
|
255 |
-
}
|
256 |
-
</style>
|
257 |
-
|
258 |
-
<script type="text/javascript">
|
259 |
-
jQuery(document).ready(function($){
|
260 |
-
$('.fwpfs').toggle(
|
261 |
-
function(){$('.fwpfs').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideDown') ) { $('.fwpfs').addClass('slide-down'); }}, 10) },
|
262 |
-
function(){$('.fwpfs').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideUp') ) { $('.fwpfs').removeClass('slide-down'); }}, 10) }
|
263 |
-
);
|
264 |
-
$('.fwpfs').bind(
|
265 |
-
'change',
|
266 |
-
function () { this.form.submit(); }
|
267 |
-
);
|
268 |
-
$('#post-search .button').css( 'display', 'none' );
|
269 |
-
});
|
270 |
-
</script>
|
271 |
-
<?php endif; /* else : */?>
|
272 |
-
<p id="post-search">
|
273 |
-
<select name="link_id" class="fwpfs" style="max-width: 20.0em;">
|
274 |
-
<option value="*"<?php if (is_null($link) or !$link->found()) : ?> selected="selected"<?php endif; ?>>- defaults for all feeds -</option>
|
275 |
-
<?php if ($links) : foreach ($links as $ddlink) : ?>
|
276 |
-
<option value="<?php print (int) $ddlink->link_id; ?>"<?php if (!is_null($link) and ($link->link->link_id==$ddlink->link_id)) : ?> selected="selected"<?php endif; ?>><?php print wp_specialchars($ddlink->link_name, 1); ?></option>
|
277 |
-
<?php endforeach; endif; ?>
|
278 |
-
</select>
|
279 |
-
<input class="button" type="submit" name="go" value="<?php _e('Go') ?> »" />
|
280 |
-
</p>
|
281 |
-
<?php /* endif; */ ?>
|
282 |
-
|
283 |
-
<?php if (!is_null($link) and $link->found()) : ?>
|
284 |
-
<p>These settings only affect posts syndicated from
|
285 |
-
<strong><?php echo wp_specialchars($link->link->link_name, 1); ?></strong>.</p>
|
286 |
-
<?php else : ?>
|
287 |
-
<p>These settings affect posts syndicated from any feed unless they are overridden
|
288 |
-
by settings for that specific feed.</p>
|
289 |
-
<?php endif; ?>
|
290 |
-
|
291 |
-
<div id="poststuff">
|
292 |
<div id="post-body">
|
293 |
-
<?php fwp_option_box_opener('Publication', 'publicationdiv', 'postbox'); ?>
|
294 |
-
<table class="form-table" cellspacing="2" cellpadding="5">
|
295 |
-
<tr><th width="27%" scope="row" style="vertical-align:top">Status for new posts:</th>
|
296 |
-
<td width="73%" style="vertical-align:top"><ul style="margin:0; list-style:none">
|
297 |
-
|
298 |
-
<?php if (is_object($link) and $link->found()) : ?>
|
299 |
-
<li><label><input type="radio" name="feed_post_status" value="site-default"
|
300 |
-
<?php echo $status['post']['site-default']; ?> /> Use <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>">site-wide setting</a>
|
301 |
-
(currently: <strong><?php echo ($post_status_global ? $post_status_global : 'publish'); ?></strong>)</label></li>
|
302 |
-
<?php endif; ?>
|
303 |
-
|
304 |
-
<li><label><input type="radio" name="feed_post_status" value="publish"
|
305 |
-
<?php echo $status['post']['publish']; ?> /> Publish <?php print $thePostsPhrase; ?> immediately</label></li>
|
306 |
-
|
307 |
-
<?php if (SyndicatedPost::use_api('post_status_pending')) : ?>
|
308 |
-
<li><label><input type="radio" name="feed_post_status" value="pending"
|
309 |
-
<?php echo $status['post']['pending']; ?>/> Hold <?php print $thePostsPhrase; ?> for review; mark as Pending</label></li>
|
310 |
-
<?php endif; ?>
|
311 |
-
|
312 |
-
<li><label><input type="radio" name="feed_post_status" value="draft"
|
313 |
-
<?php echo $status['post']['draft']; ?> /> Save <?php print $thePostsPhrase; ?> as drafts</label></li>
|
314 |
-
<li><label><input type="radio" name="feed_post_status" value="private"
|
315 |
-
<?php echo $status['post']['private']; ?> /> Save <?php print $thePostsPhrase; ?> as private posts</label></li>
|
316 |
-
</ul></td>
|
317 |
-
</tr>
|
318 |
-
</table>
|
319 |
-
<?php
|
320 |
-
fwp_option_box_closer();
|
321 |
-
?>
|
322 |
-
|
323 |
-
<?php if (!(is_object($link) and $link->found())) : ?>
|
324 |
-
<?php fwp_option_box_opener('Formatting', 'formattingdiv', 'postbox'); ?>
|
325 |
-
<table class="form-table" cellspacing="2" cellpadding="5">
|
326 |
-
<tr><th scope="row">Formatting filters:</th>
|
327 |
-
<td><select name="formatting_filters" size="1">
|
328 |
-
<option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option>
|
329 |
-
<option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option>
|
330 |
-
</select>
|
331 |
-
<p class="setting-description">If you have trouble getting plugins to work that are supposed to insert
|
332 |
-
elements after posts (like relevant links or a social networking
|
333 |
-
<q>Share This</q> button), try changing this option to see if it fixes your
|
334 |
-
problem.</p>
|
335 |
-
</td></tr>
|
336 |
-
</table>
|
337 |
-
<?php fwp_option_box_closer(); ?>
|
338 |
-
|
339 |
-
<?php
|
340 |
-
fwp_option_box_opener('Links', 'linksdiv', 'postbox');
|
341 |
-
?>
|
342 |
-
<table class="form-table" cellspacing="2" cellpadding="5">
|
343 |
-
<tr><th scope="row">Permalinks:</th>
|
344 |
-
<td><select name="munge_permalink" size="1">
|
345 |
-
<option value="yes"<?php echo ($munge_permalink=='yes')?' selected="selected"':''; ?>>point to the copy on the original website</option>
|
346 |
-
<option value="no"<?php echo ($munge_permalink=='no')?' selected="selected"':''; ?>>point to the local copy on this website</option>
|
347 |
-
</select></td>
|
348 |
-
</tr>
|
349 |
-
|
350 |
-
<tr><th scope="row">Posts from aggregator feeds:</th>
|
351 |
-
<td><ul class="options">
|
352 |
-
<li><label><input type="radio" name="use_aggregator_source_data" value="no"<?php echo ($use_aggregator_source_data!="yes")?' checked="checked"':''; ?>> Give the aggregator itself as the source of posts from an aggregator feed.</label></li>
|
353 |
-
<li><label><input type="radio" name="use_aggregator_source_data" value="yes"<?php echo ($use_aggregator_source_data=="yes")?' checked="checked"':''; ?>> Give the original source of the post as the source, not the aggregator.</label></li>
|
354 |
-
</ul>
|
355 |
-
<p class="setting-description">Some feeds (for example, those produced by FeedWordPress) aggregate content from several different sources, and include information about the original source of the post.
|
356 |
-
This setting controls what FeedWordPress will give as the source of posts from
|
357 |
-
such an aggregator feed.</p>
|
358 |
-
</td></tr>
|
359 |
-
</table>
|
360 |
<?php
|
361 |
-
|
362 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
endif;
|
364 |
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
<li><label><input type="radio" name="feed_comment_status" value="open"<?php echo $status['comment']['open'] ?> /> Allow comments on syndicated posts</label></li>
|
377 |
-
<li><label><input type="radio" name="feed_comment_status" value="closed"<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts</label></li>
|
378 |
-
</ul></td></tr>
|
379 |
-
|
380 |
-
<tr><th scope="row"><?php print __('Pings') ?>:</th>
|
381 |
-
<td><ul class="options">
|
382 |
-
<?php if (is_object($link) and $link->found()) : ?>
|
383 |
-
<li><label><input type="radio" name="feed_ping_status" value="site-default"
|
384 |
-
<?php echo $status['ping']['site-default']; ?> /> Use <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>">site-wide setting</a>
|
385 |
-
(currently: <strong><?php echo $ping_status_global; ?></strong>)</label></li>
|
386 |
-
<?php endif; ?>
|
387 |
-
|
388 |
-
<li><label><input type="radio" name="feed_ping_status" value="open"<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts</label></li>
|
389 |
-
<li><label><input type="radio" name="feed_ping_status" value="closed"<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts</label></li>
|
390 |
-
</ul></td></tr>
|
391 |
-
</table>
|
392 |
-
<?php
|
393 |
-
fwp_option_box_closer();
|
394 |
-
fwp_linkedit_periodic_submit();
|
395 |
-
?>
|
396 |
-
|
397 |
-
<?php fwp_option_box_opener('Custom Post Settings (to apply to each syndicated post)', 'postcustom', 'postbox'); ?>
|
398 |
-
<div id="postcustomstuff">
|
399 |
-
<table id="meta-list" cellpadding="3">
|
400 |
-
<tr>
|
401 |
-
<th>Key</th>
|
402 |
-
<th>Value</th>
|
403 |
-
<th>Action</th>
|
404 |
-
</tr>
|
405 |
-
|
406 |
-
<?php
|
407 |
-
$i = 0;
|
408 |
-
foreach ($custom_settings as $key => $value) :
|
409 |
?>
|
410 |
-
|
411 |
-
<th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
|
412 |
-
<input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th>
|
413 |
-
<td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo wp_specialchars($value, 'both'); ?></textarea></td>
|
414 |
-
<td width="10%"><select name="notes[<?php echo $i; ?>][action]">
|
415 |
-
<option value="update">save changes</option>
|
416 |
-
<option value="delete">delete this setting</option>
|
417 |
-
</select></td>
|
418 |
-
</tr>
|
419 |
<?php
|
420 |
-
|
421 |
-
endforeach;
|
422 |
?>
|
423 |
-
|
424 |
-
|
425 |
-
<td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
|
426 |
-
<td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
|
427 |
-
</tr>
|
428 |
-
</table>
|
429 |
-
<?php fwp_option_box_closer(); ?>
|
430 |
-
|
431 |
-
</div>
|
432 |
-
</div>
|
433 |
-
|
434 |
-
<p class="submit">
|
435 |
-
<input class="button-primary" type="submit" name="save" value="Save Changes" />
|
436 |
-
</p>
|
437 |
-
</form>
|
438 |
-
</div> <!-- class="wrap" -->
|
439 |
<?php
|
|
|
440 |
} /* function fwp_posts_page () */
|
441 |
|
442 |
fwp_posts_page();
|
1 |
<?php
|
2 |
require_once(dirname(__FILE__) . '/admin-ui.php');
|
3 |
|
4 |
+
class FeedWordPressPostsPage extends FeedWordPressAdminPage {
|
5 |
+
var $link = NULL;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Construct the posts page object.
|
9 |
+
*
|
10 |
+
* @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings
|
11 |
+
*/
|
12 |
+
function FeedWordPressPostsPage ($link = NULL) {
|
13 |
+
FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresspostspage', $link);
|
14 |
+
$this->dispatch = 'feedwordpress_posts_settings';
|
15 |
+
$this->filename = __FILE__;
|
16 |
+
} /* FeedWordPressPostsPage constructor */
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Outputs "Publication" settings box.
|
20 |
+
*
|
21 |
+
* @since 2009.0713
|
22 |
+
* @param object $page of class FeedWordPressPostsPage tells us whether this is
|
23 |
+
* a page for one feed's settings or for global defaults
|
24 |
+
* @param array $box
|
25 |
+
*
|
26 |
+
* @uses FeedWordPressPostsPage::these_posts_phrase()
|
27 |
+
* @uses FeedWordPress::syndicated_status()
|
28 |
+
* @uses SyndicatedLink::syndicated_status()
|
29 |
+
* @uses SyndicatedPost::use_api()
|
30 |
+
* @uses fwp_option_box_opener()
|
31 |
+
* @uses fwp_option_box_closer()
|
32 |
+
*/
|
33 |
+
/*static*/ function publication_box ($page, $box = NULL) {
|
34 |
+
global $fwp_path;
|
35 |
+
|
36 |
+
$post_status_global = FeedWordPress::syndicated_status('post', /*default=*/ 'publish');
|
37 |
+
$thesePosts = $page->these_posts_phrase();
|
38 |
+
|
39 |
+
// Set up array for selector
|
40 |
+
$setting = array(
|
41 |
+
'publish' => array ('label' => "Publish %s immediately", 'checked' => ''),
|
42 |
+
'draft' => array('label' => "Save %s as drafts", 'checked' => ''),
|
43 |
+
'private' => array('label' => "Save %s as private posts", 'checked' => ''),
|
44 |
+
);
|
45 |
+
if (SyndicatedPost::use_api('post_status_pending')) :
|
46 |
+
$setting['pending'] = array('label' => "Hold %s for review; mark as Pending", 'checked' => '');
|
47 |
+
endif;
|
48 |
+
if ($page->for_feed_settings()) :
|
49 |
+
$href = $fwp_path.'/'.basename(__FILE__);
|
50 |
+
$currently = str_replace('%s', '', strtolower(strtok($setting[$post_status_global]['label'], ';')));
|
51 |
+
$setting['site-default'] = array('label' => "Use <a href=\"admin.php?page=${href}\">site-wide setting</a>", 'checked' => '');
|
52 |
+
$setting['site-default']['label'] .= " (currently: <strong>${currently}</strong>)";
|
53 |
+
|
54 |
+
$checked = $page->link->syndicated_status('post', 'site-default', /*fallback=*/ false);
|
55 |
+
else :
|
56 |
+
$checked = $post_status_global;
|
57 |
+
endif;
|
58 |
+
|
59 |
+
// Re-order appropriately
|
60 |
+
$selector = array();
|
61 |
+
$order = array(
|
62 |
+
'site-default',
|
63 |
+
'publish',
|
64 |
+
'pending',
|
65 |
+
'draft',
|
66 |
+
'private',
|
67 |
+
);
|
68 |
+
foreach ($order as $line) :
|
69 |
+
if (isset($setting[$line])) :
|
70 |
+
$selector[$line] = $setting[$line];
|
71 |
+
endif;
|
72 |
+
endforeach;
|
73 |
+
$selector[$checked]['checked'] = ' checked="checked"';
|
74 |
+
|
75 |
+
// Hey ho, let's go...
|
76 |
+
?>
|
77 |
+
<style type="text/css">
|
78 |
+
#syndicated-publication-form th { width: 27%; vertical-align: top; }
|
79 |
+
#syndicated-publication-form td { width: 73%; vertical-align: top; }
|
80 |
+
</style>
|
81 |
+
|
82 |
+
<table id="syndicated-publication-form" class="form-table" cellspacing="2" cellpadding="5">
|
83 |
+
<tr><th scope="row">Status for new posts:</th>
|
84 |
+
<td><ul class="options">
|
85 |
+
<?php foreach ($selector as $code => $li) : ?>
|
86 |
+
<li><label><input type="radio" name="feed_post_status"
|
87 |
+
value="<?php print $code; ?>"<?php print $li['checked']; ?> />
|
88 |
+
<?php print str_replace('%s', $thesePosts, $li['label']); ?></label></li>
|
89 |
+
<?php endforeach; ?>
|
90 |
+
</ul></td>
|
91 |
+
</tr>
|
92 |
+
</table>
|
93 |
+
|
94 |
+
<?php
|
95 |
+
} /* FeedWordPressPostsPage::publication_box () */
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Outputs "Formatting" settings box
|
99 |
+
*
|
100 |
+
* @since 2009.0713
|
101 |
+
* @param object $page of class FeedWordPressPostsPage tells us whether this is
|
102 |
+
* a page for one feed's settings or for global defaults
|
103 |
+
* @param array $box
|
104 |
+
*
|
105 |
+
* @uses fwp_option_box_opener()
|
106 |
+
* @uses fwp_option_box_closer()
|
107 |
+
*/
|
108 |
+
function formatting_box ($page, $box = NULL) {
|
109 |
+
$formatting_filters = get_option('feedwordpress_formatting_filters');
|
110 |
+
?>
|
111 |
+
<table class="form-table" cellspacing="2" cellpadding="5">
|
112 |
+
<tr><th scope="row">Formatting filters:</th>
|
113 |
+
<td><select name="formatting_filters" size="1">
|
114 |
+
<option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option>
|
115 |
+
<option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option>
|
116 |
+
</select>
|
117 |
+
<p class="setting-description">If you have trouble getting plugins to work that are supposed to insert
|
118 |
+
elements after posts (like relevant links or a social networking
|
119 |
+
<q>Share This</q> button), try changing this option to see if it fixes your
|
120 |
+
problem.</p>
|
121 |
+
</td></tr>
|
122 |
+
</table>
|
123 |
+
<?php
|
124 |
+
} /* FeedWordPressPostsPage::formatting_box() */
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Output "Links" settings box
|
128 |
+
*
|
129 |
+
* @since 2009.0713
|
130 |
+
* @param object $page of class FeedWordPressPostsPage tells us whether this is
|
131 |
+
* a page for one feed's settings or for global defaults
|
132 |
+
* @param array $box
|
133 |
+
*
|
134 |
+
* @uses fwp_option_box_opener()
|
135 |
+
* @uses fwp_option_box_closer()
|
136 |
+
*/
|
137 |
+
/*static*/ function links_box ($page, $box = NULL) {
|
138 |
+
$munge_permalink = get_option('feedwordpress_munge_permalink');
|
139 |
+
$use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
|
140 |
+
?>
|
141 |
+
<table class="form-table" cellspacing="2" cellpadding="5">
|
142 |
+
<tr><th scope="row">Permalinks:</th>
|
143 |
+
<td><select name="munge_permalink" size="1">
|
144 |
+
<option value="yes"<?php echo ($munge_permalink=='yes')?' selected="selected"':''; ?>>point to the copy on the original website</option>
|
145 |
+
<option value="no"<?php echo ($munge_permalink=='no')?' selected="selected"':''; ?>>point to the local copy on this website</option>
|
146 |
+
</select></td>
|
147 |
+
</tr>
|
148 |
+
|
149 |
+
<tr><th scope="row">Posts from aggregator feeds:</th>
|
150 |
+
<td><ul class="options">
|
151 |
+
<li><label><input type="radio" name="use_aggregator_source_data" value="no"<?php echo ($use_aggregator_source_data!="yes")?' checked="checked"':''; ?>> Give the aggregator itself as the source of posts from an aggregator feed.</label></li>
|
152 |
+
<li><label><input type="radio" name="use_aggregator_source_data" value="yes"<?php echo ($use_aggregator_source_data=="yes")?' checked="checked"':''; ?>> Give the original source of the post as the source, not the aggregator.</label></li>
|
153 |
+
</ul>
|
154 |
+
<p class="setting-description">Some feeds (for example, those produced by FeedWordPress) aggregate content from several different sources, and include information about the original source of the post.
|
155 |
+
This setting controls what FeedWordPress will give as the source of posts from
|
156 |
+
such an aggregator feed.</p>
|
157 |
+
</td></tr>
|
158 |
+
</table>
|
159 |
+
|
160 |
+
<?php
|
161 |
+
} /* FeedWordPressPostsPage::links_box() */
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Output "Comments & Pings" settings box
|
165 |
+
*
|
166 |
+
* @since 2009.0713
|
167 |
+
* @param object $page of class FeedWordPressPostsPage tells us whether this is
|
168 |
+
* a page for one feed's settings or for global defaults
|
169 |
+
* @param array $box
|
170 |
+
*
|
171 |
+
* @uses fwp_option_box_opener()
|
172 |
+
* @uses fwp_option_box_closer()
|
173 |
+
*/
|
174 |
+
/*static*/ function comments_and_pings_box ($page, $box = NULL) {
|
175 |
+
$setting = array();
|
176 |
+
$selector = array();
|
177 |
+
|
178 |
+
$whatsits = array(
|
179 |
+
'comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'),
|
180 |
+
'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'),
|
181 |
+
);
|
182 |
+
$onThesePosts = 'on '.$page->these_posts_phrase();
|
183 |
+
|
184 |
+
foreach ($whatsits as $what => $how) :
|
185 |
+
$whatsits[$what]['default'] = FeedWordPress::syndicated_status($what, /*default=*/ 'closed');
|
186 |
+
|
187 |
+
// Set up array for selector
|
188 |
+
$setting = array(
|
189 |
+
'open' => array ('label' => "{$how['accept']} %s", 'checked' => ''),
|
190 |
+
'closed' => array('label' => "Don't ".strtolower($how['accept'])." %s", 'checked' => ''),
|
191 |
+
);
|
192 |
+
if ($page->for_feed_settings()) :
|
193 |
+
$href = $fwp_path.'/'.basename(__FILE__);
|
194 |
+
$currently = trim(str_replace('%s', '', strtolower(strtok($setting[$whatsits[$what]['default']]['label'], ';'))));
|
195 |
+
$setting['site-default'] = array('label' => "Use <a href=\"admin.php?page=${href}\">site-wide setting</a>", 'checked' => '');
|
196 |
+
$setting['site-default']['label'] .= " (currently: <strong>${currently}</strong>)";
|
197 |
+
|
198 |
+
$checked = $page->link->syndicated_status($what, 'site-default', /*fallback=*/ false);
|
199 |
+
else :
|
200 |
+
$checked = $whatsits[$what]['default'];
|
201 |
+
endif;
|
202 |
+
|
203 |
+
// Re-order appropriately
|
204 |
+
$selector[$what] = array();
|
205 |
+
$order = array(
|
206 |
+
'site-default',
|
207 |
+
'open',
|
208 |
+
'closed',
|
209 |
+
);
|
210 |
+
foreach ($order as $line) :
|
211 |
+
if (isset($setting[$line])) :
|
212 |
+
$selector[$what][$line] = $setting[$line];
|
213 |
+
endif;
|
214 |
+
endforeach;
|
215 |
+
$selector[$what][$checked]['checked'] = ' checked="checked"';
|
216 |
+
endforeach;
|
217 |
+
|
218 |
+
// Hey ho, let's go...
|
219 |
+
?>
|
220 |
+
<table class="form-table" cellspacing="2" cellpadding="5">
|
221 |
+
<?php foreach ($whatsits as $what => $how) : ?>
|
222 |
+
<tr><th scope="row"><?php print $how['label']; ?>:</th>
|
223 |
+
<td><ul class="options">
|
224 |
+
<?php foreach ($selector[$what] as $code => $li) : ?>
|
225 |
+
<li><label><input type="radio" name="feed_<?php print $what; ?>_status"
|
226 |
+
value="<?php print $code; ?>"<?php print $li['checked']; ?> />
|
227 |
+
<?php print trim(str_replace('%s', $onThesePosts, $li['label'])); ?></label></li>
|
228 |
+
<?php endforeach; ?>
|
229 |
+
</ul></td></tr>
|
230 |
+
<?php endforeach; ?>
|
231 |
+
</table>
|
232 |
+
|
233 |
+
<?php
|
234 |
+
} /* FeedWordPressPostsPage::comments_and_pings_box() */
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Output "Custom Post Settings" settings box
|
238 |
+
*
|
239 |
+
* @since 2009.0713
|
240 |
+
* @param object $page of class FeedWordPressPostsPage tells us whether this is
|
241 |
+
* a page for one feed's settings or for global defaults
|
242 |
+
* @param array $box
|
243 |
+
*
|
244 |
+
* @uses fwp_option_box_opener()
|
245 |
+
* @uses fwp_option_box_closer()
|
246 |
+
*/
|
247 |
+
/*static*/ function custom_post_settings_box ($page, $box = NULL) {
|
248 |
+
if ($page->for_feed_settings()) :
|
249 |
+
$custom_settings = $page->link->settings["postmeta"];
|
250 |
+
if ($custom_settings and !is_array($custom_settings)) :
|
251 |
+
$custom_settings = unserialize($custom_settings);
|
252 |
+
endif;
|
253 |
+
|
254 |
+
if (!is_array($custom_settings)) :
|
255 |
+
$custom_settings = array();
|
256 |
+
endif;
|
257 |
+
else :
|
258 |
+
$custom_settings = get_option('feedwordpress_custom_settings');
|
259 |
+
if ($custom_settings and !is_array($custom_settings)) :
|
260 |
+
$custom_settings = unserialize($custom_settings);
|
261 |
+
endif;
|
262 |
+
|
263 |
+
if (!is_array($custom_settings)) :
|
264 |
+
$custom_settings = array();
|
265 |
+
endif;
|
266 |
+
endif;
|
267 |
+
|
268 |
+
?>
|
269 |
+
<div id="postcustomstuff">
|
270 |
+
<table id="meta-list" cellpadding="3">
|
271 |
+
<tr>
|
272 |
+
<th>Key</th>
|
273 |
+
<th>Value</th>
|
274 |
+
<th>Action</th>
|
275 |
+
</tr>
|
276 |
+
|
277 |
+
<?php
|
278 |
+
$i = 0;
|
279 |
+
foreach ($custom_settings as $key => $value) :
|
280 |
+
?>
|
281 |
+
<tr style="vertical-align:top">
|
282 |
+
<th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
|
283 |
+
<input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th>
|
284 |
+
<td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo wp_specialchars($value, 'both'); ?></textarea></td>
|
285 |
+
<td width="10%"><select name="notes[<?php echo $i; ?>][action]">
|
286 |
+
<option value="update">save changes</option>
|
287 |
+
<option value="delete">delete this setting</option>
|
288 |
+
</select></td>
|
289 |
+
</tr>
|
290 |
+
|
291 |
+
<?php
|
292 |
+
$i++;
|
293 |
+
endforeach;
|
294 |
+
?>
|
295 |
+
|
296 |
+
<tr>
|
297 |
+
<th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
|
298 |
+
<td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
|
299 |
+
<td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
|
300 |
+
</tr>
|
301 |
+
</table>
|
302 |
+
</div> <!-- id="postcustomstuff" -->
|
303 |
+
|
304 |
+
<?php
|
305 |
+
} /* FeedWordPressPostsPage::custom_post_settings_box() */
|
306 |
+
}
|
307 |
+
|
308 |
function fwp_posts_page () {
|
309 |
global $wpdb, $wp_db_version;
|
310 |
+
|
311 |
+
if (FeedWordPress::needs_upgrade()) :
|
312 |
+
fwp_upgrade_page();
|
313 |
+
return;
|
314 |
+
endif;
|
315 |
|
316 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links');
|
317 |
|
318 |
+
$link = FeedWordPressAdminPage::submitted_link();
|
319 |
+
$link_id = $link->id;
|
320 |
+
$postsPage = new FeedWordPressPostsPage($link);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
|
322 |
$mesg = null;
|
323 |
|
324 |
////////////////////////////////////////////////
|
325 |
// Process POST request, if any /////////////////
|
326 |
////////////////////////////////////////////////
|
327 |
+
if (isset($GLOBALS['fwp_post']['save']) or isset($GLOBALS['fwp_post']['submit'])) :
|
328 |
+
// custom post settings
|
329 |
foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
|
330 |
$mn['key0'] = trim($mn['key0']);
|
331 |
$mn['key1'] = trim($mn['key1']);
|
399 |
|
400 |
$updated_link = true;
|
401 |
endif;
|
402 |
+
|
403 |
+
do_action('feedwordpress_admin_page_posts_save', $GLOBALS['fwp_post'], $postsPage);
|
404 |
else :
|
405 |
$updated_link = false;
|
406 |
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
|
408 |
+
$postsPage->ajax_interface_js();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
|
410 |
+
if ($updated_link) : ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
<div class="updated"><p>Syndicated posts settings updated.</p></div>
|
412 |
<?php elseif (!is_null($mesg)) : ?>
|
413 |
<div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div>
|
414 |
<?php endif; ?>
|
415 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
<?php
|
417 |
+
$links = FeedWordPress::syndicated_links();
|
418 |
+
$postsPage->open_sheet('Syndicated Posts & Links');
|
419 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
<style type="text/css">
|
421 |
+
table.edit-form th, table.form-table th { width: 27%; vertical-align: top; }
|
422 |
+
table.edit-form td, table.form-table td { width: 73%; vertical-align: top; }
|
423 |
+
ul.options { margin: 0; padding: 0; list-style: none; }
|
424 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
425 |
<div id="post-body">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
<?php
|
427 |
+
$boxes_by_methods = array(
|
428 |
+
'publication_box' => __('Publication'),
|
429 |
+
'formatting_box' => __('Formatting'),
|
430 |
+
'links_box' => __('Links'),
|
431 |
+
'comments_and_pings_box' => __('Comments & Pings'),
|
432 |
+
'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'),
|
433 |
+
);
|
434 |
+
|
435 |
+
// Feed-level settings don't exist for these.
|
436 |
+
if ($postsPage->for_feed_settings()) :
|
437 |
+
unset($boxes_by_methods['formatting_box']);
|
438 |
+
unset($boxes_by_methods['links_box']);
|
439 |
endif;
|
440 |
|
441 |
+
foreach ($boxes_by_methods as $method => $title) :
|
442 |
+
fwp_add_meta_box(
|
443 |
+
/*id=*/ 'feedwordpress_'.$method,
|
444 |
+
/*title=*/ $title,
|
445 |
+
/*callback=*/ array('FeedWordPressPostsPage', $method),
|
446 |
+
/*page=*/ $postsPage->meta_box_context(),
|
447 |
+
/*context=*/ $postsPage->meta_box_context()
|
448 |
+
);
|
449 |
+
endforeach;
|
450 |
+
do_action('feedwordpress_admin_page_posts_meta_boxes', $postsPage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
?>
|
452 |
+
<div class="metabox-holder">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
<?php
|
454 |
+
fwp_do_meta_boxes($postsPage->meta_box_context(), $postsPage->meta_box_context(), $postsPage);
|
|
|
455 |
?>
|
456 |
+
</div> <!-- class="metabox-holder" -->
|
457 |
+
</div> <!-- id="post-body" -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
<?php
|
459 |
+
$postsPage->close_sheet();
|
460 |
} /* function fwp_posts_page () */
|
461 |
|
462 |
fwp_posts_page();
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== FeedWordPress ===
|
2 |
Contributors: Charles Johnson
|
3 |
-
Donate link: http://
|
4 |
Tags: syndication, aggregation, feed, atom, rss
|
5 |
Requires at least: 1.5
|
6 |
-
Tested up to: 2.8.
|
7 |
-
Stable tag: 2009.
|
8 |
|
9 |
FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
|
10 |
|
1 |
=== FeedWordPress ===
|
2 |
Contributors: Charles Johnson
|
3 |
+
Donate link: http://feedwordpress.radgeek.com/
|
4 |
Tags: syndication, aggregation, feed, atom, rss
|
5 |
Requires at least: 1.5
|
6 |
+
Tested up to: 2.8.4
|
7 |
+
Stable tag: 2009.1111
|
8 |
|
9 |
FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
|
10 |
|
syndicatedlink.class.php
CHANGED
@@ -192,9 +192,22 @@ class SyndicatedLink {
|
|
192 |
$this->settings['update/ttl'] = $ttl;
|
193 |
$this->settings['update/timed'] = 'feed';
|
194 |
else :
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
$this->settings['update/timed'] = 'automatically';
|
197 |
endif;
|
|
|
198 |
|
199 |
if (!isset($this->settings['update/hold']) or $this->settings['update/hold']!='ping') :
|
200 |
$this->settings['update/hold'] = 'scheduled';
|
@@ -255,6 +268,31 @@ class SyndicatedLink {
|
|
255 |
return $new_count;
|
256 |
} /* SyndicatedLink::poll() */
|
257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
function map_name_to_new_user ($name, $newuser_name) {
|
259 |
global $wpdb;
|
260 |
|
@@ -324,14 +362,48 @@ class SyndicatedLink {
|
|
324 |
return $notes;
|
325 |
} /* SyndicatedLink::settings_to_notes () */
|
326 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
327 |
function uri () {
|
328 |
return (is_object($this->link) ? $this->link->link_rss : NULL);
|
329 |
} /* SyndicatedLink::uri () */
|
330 |
|
331 |
-
function homepage () {
|
332 |
-
|
|
|
|
|
|
|
|
|
|
|
333 |
} /* SyndicatedLink::homepage () */
|
334 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
function ttl () {
|
336 |
if (is_object($this->magpie)) :
|
337 |
$channel = $this->magpie->channel;
|
@@ -417,15 +489,23 @@ class SyndicatedLink {
|
|
417 |
return $ret;
|
418 |
} /* SyndicatedLink::hardcode () */
|
419 |
|
420 |
-
function syndicated_status ($what, $default) {
|
421 |
global $wpdb;
|
422 |
|
423 |
-
|
424 |
if ( isset($this->settings["$what status"]) ) :
|
425 |
$ret = $this->settings["$what status"];
|
426 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
427 |
$ret = $default;
|
|
|
428 |
endif;
|
|
|
429 |
return $wpdb->escape(trim(strtolower($ret)));
|
430 |
} /* SyndicatedLink:syndicated_status () */
|
431 |
} // class SyndicatedLink
|
192 |
$this->settings['update/ttl'] = $ttl;
|
193 |
$this->settings['update/timed'] = 'feed';
|
194 |
else :
|
195 |
+
// spread out over a time interval for staggered updates
|
196 |
+
if (isset($this->settings['update/window'])) :
|
197 |
+
$updateWindow = $this->settings['update/window'];
|
198 |
+
else :
|
199 |
+
$updateWindow = get_option('feedwordpress_update_window');
|
200 |
+
endif;
|
201 |
+
|
202 |
+
if (!is_numeric($updateWindow) or ($updateWindow < 1)) :
|
203 |
+
$updateWindow = DEFAULT_UPDATE_PERIOD;
|
204 |
+
endif;
|
205 |
+
|
206 |
+
$fudgedInterval = $updateWindow+rand(0, 2*($updateWindow/3));
|
207 |
+
$this->settings['update/ttl'] = apply_filters('syndicated_feed_automatic_ttl', $fudgedInterval, $this);
|
208 |
$this->settings['update/timed'] = 'automatically';
|
209 |
endif;
|
210 |
+
$this->settings['update/ttl'] = apply_filters('syndicated_feed_ttl', $this->settings['update/ttl'], $this);
|
211 |
|
212 |
if (!isset($this->settings['update/hold']) or $this->settings['update/hold']!='ping') :
|
213 |
$this->settings['update/hold'] = 'scheduled';
|
268 |
return $new_count;
|
269 |
} /* SyndicatedLink::poll() */
|
270 |
|
271 |
+
/**
|
272 |
+
* Updates the URL for the feed syndicated by this link.
|
273 |
+
*
|
274 |
+
* @param string $url The new feed URL to use for this source.
|
275 |
+
* @return bool TRUE on success, FALSE on failure.
|
276 |
+
*/
|
277 |
+
function set_uri ($url) {
|
278 |
+
global $wpdb;
|
279 |
+
|
280 |
+
if ($this->found()) :
|
281 |
+
// Update link_rss
|
282 |
+
$result = $wpdb->query("
|
283 |
+
UPDATE $wpdb->links
|
284 |
+
SET
|
285 |
+
link_rss = '".$wpdb->escape($url)."'
|
286 |
+
WHERE link_id = '".$wpdb->escape($this->id)."'
|
287 |
+
");
|
288 |
+
|
289 |
+
$ret = ($result ? true : false);
|
290 |
+
else :
|
291 |
+
$ret = false;
|
292 |
+
endif;
|
293 |
+
return $ret;
|
294 |
+
} /* SyndicatedLink::set_uri () */
|
295 |
+
|
296 |
function map_name_to_new_user ($name, $newuser_name) {
|
297 |
global $wpdb;
|
298 |
|
362 |
return $notes;
|
363 |
} /* SyndicatedLink::settings_to_notes () */
|
364 |
|
365 |
+
function save_settings ($reload = false) {
|
366 |
+
global $wpdb;
|
367 |
+
|
368 |
+
$update_set = "link_notes = '".$wpdb->escape($this->settings_to_notes())."'";
|
369 |
+
|
370 |
+
// Update the properties of the link from the feed information
|
371 |
+
$result = $wpdb->query("
|
372 |
+
UPDATE $wpdb->links
|
373 |
+
SET $update_set
|
374 |
+
WHERE link_id='$this->id'
|
375 |
+
");
|
376 |
+
|
377 |
+
if ($reload) :
|
378 |
+
// reload link information from DB
|
379 |
+
if (function_exists('clean_bookmark_cache')) :
|
380 |
+
clean_bookmark_cache($this->id);
|
381 |
+
endif;
|
382 |
+
endif;
|
383 |
+
} /* SyndicatedLink::save_settings () */
|
384 |
+
|
385 |
function uri () {
|
386 |
return (is_object($this->link) ? $this->link->link_rss : NULL);
|
387 |
} /* SyndicatedLink::uri () */
|
388 |
|
389 |
+
function homepage ($fromFeed = true) {
|
390 |
+
if ($fromFeed) :
|
391 |
+
$url = (isset($this->settings['feed/link']) ? $this->settings['feed/link'] : NULL);
|
392 |
+
else :
|
393 |
+
$url = $this->link->link_url;
|
394 |
+
endif;
|
395 |
+
return $url;
|
396 |
} /* SyndicatedLink::homepage () */
|
397 |
|
398 |
+
function name ($fromFeed = true) {
|
399 |
+
if ($fromFeed) :
|
400 |
+
$name = (isset($this->settings['feed/title']) ? $this->settings['feed/title'] : NULL);
|
401 |
+
else :
|
402 |
+
$name = $this->link->link_name;
|
403 |
+
endif;
|
404 |
+
return $name;
|
405 |
+
} /* SyndicatedLink::name () */
|
406 |
+
|
407 |
function ttl () {
|
408 |
if (is_object($this->magpie)) :
|
409 |
$channel = $this->magpie->channel;
|
489 |
return $ret;
|
490 |
} /* SyndicatedLink::hardcode () */
|
491 |
|
492 |
+
function syndicated_status ($what, $default, $fallback = true) {
|
493 |
global $wpdb;
|
494 |
|
495 |
+
// Use local setting if we have it
|
496 |
if ( isset($this->settings["$what status"]) ) :
|
497 |
$ret = $this->settings["$what status"];
|
498 |
+
|
499 |
+
// Or fall back to global default if we can
|
500 |
+
elseif ($fallback) :
|
501 |
+
$ret = FeedWordPress::syndicated_status($what, $default);
|
502 |
+
|
503 |
+
// Or use default value if we can't.
|
504 |
+
else :
|
505 |
$ret = $default;
|
506 |
+
|
507 |
endif;
|
508 |
+
|
509 |
return $wpdb->escape(trim(strtolower($ret)));
|
510 |
} /* SyndicatedLink:syndicated_status () */
|
511 |
} // class SyndicatedLink
|
syndicatedpost.class.php
CHANGED
@@ -107,7 +107,7 @@ class SyndicatedPost {
|
|
107 |
|
108 |
// User-supplied custom settings to apply to each post. Do first so that FWP-generated custom settings will overwrite if necessary; thus preventing any munging
|
109 |
$default_custom_settings = get_option('feedwordpress_custom_settings');
|
110 |
-
if ($default_custom_settings) :
|
111 |
$default_custom_settings = unserialize($default_custom_settings);
|
112 |
endif;
|
113 |
if (!is_array($default_custom_settings)) :
|
@@ -115,7 +115,7 @@ class SyndicatedPost {
|
|
115 |
endif;
|
116 |
|
117 |
$custom_settings = (isset($this->link->settings['postmeta']) ? $this->link->settings['postmeta'] : null);
|
118 |
-
if ($custom_settings) :
|
119 |
$custom_settings = unserialize($custom_settings);
|
120 |
endif;
|
121 |
if (!is_array($custom_settings)) :
|
@@ -160,10 +160,25 @@ class SyndicatedPost {
|
|
160 |
if (isset($this->item['comments'])) :
|
161 |
$this->post['meta']['rss:comments'] = apply_filters('syndicated_item_comments', $this->item['comments']);
|
162 |
endif;
|
|
|
|
|
163 |
if (isset($this->item['wfw']['commentrss'])) :
|
164 |
$this->post['meta']['wfw:commentRSS'] = apply_filters('syndicated_item_commentrss', $this->item['wfw']['commentrss']);
|
165 |
endif;
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
// Store information to identify the feed that this came from
|
168 |
$this->post['meta']['syndication_feed'] = $this->feedmeta['link/uri'];
|
169 |
$this->post['meta']['syndication_feed_id'] = $this->feedmeta['link/id'];
|
@@ -173,7 +188,17 @@ class SyndicatedPost {
|
|
173 |
endif;
|
174 |
|
175 |
// In case you want to know the external permalink...
|
176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
// Store a hash of the post content for checking whether something needs to be updated
|
179 |
$this->post['meta']['syndication_item_hash'] = $this->update_hash();
|
@@ -222,7 +247,7 @@ class SyndicatedPost {
|
|
222 |
if (isset($this->feedmeta['tags']) and is_array($this->feedmeta['tags'])) :
|
223 |
$this->post['tags_input'] = array_merge($this->post['tags_input'], $this->feedmeta['tags']);
|
224 |
endif;
|
225 |
-
|
226 |
endif;
|
227 |
} // SyndicatedPost::SyndicatedPost()
|
228 |
|
@@ -680,6 +705,12 @@ class SyndicatedPost {
|
|
680 |
meta_key='$key',
|
681 |
meta_value='$value'
|
682 |
");
|
|
|
|
|
|
|
|
|
|
|
|
|
683 |
endforeach;
|
684 |
endforeach;
|
685 |
endif;
|
@@ -891,7 +922,7 @@ class SyndicatedPost {
|
|
891 |
endforeach;
|
892 |
elseif ('create'===$unfamiliar_category) :
|
893 |
if (function_exists('wp_insert_category')) :
|
894 |
-
$cat_id = wp_insert_category(array('cat_name' => $
|
895 |
// And into the database we go.
|
896 |
else :
|
897 |
$nice_kitty = sanitize_title($cat_name);
|
@@ -900,7 +931,7 @@ class SyndicatedPost {
|
|
900 |
SET
|
901 |
cat_name='%s',
|
902 |
category_nicename='%s'
|
903 |
-
", $
|
904 |
));
|
905 |
$cat_id = $wpdb->insert_id;
|
906 |
endif;
|
@@ -1105,7 +1136,60 @@ class SyndicatedPost {
|
|
1105 |
|
1106 |
return $author;
|
1107 |
} // SyndicatedPost::author()
|
1108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1109 |
var $uri_attrs = array (
|
1110 |
array('a', 'href'),
|
1111 |
array('applet', 'codebase'),
|
107 |
|
108 |
// User-supplied custom settings to apply to each post. Do first so that FWP-generated custom settings will overwrite if necessary; thus preventing any munging
|
109 |
$default_custom_settings = get_option('feedwordpress_custom_settings');
|
110 |
+
if ($default_custom_settings and !is_array($default_custom_settings)) :
|
111 |
$default_custom_settings = unserialize($default_custom_settings);
|
112 |
endif;
|
113 |
if (!is_array($default_custom_settings)) :
|
115 |
endif;
|
116 |
|
117 |
$custom_settings = (isset($this->link->settings['postmeta']) ? $this->link->settings['postmeta'] : null);
|
118 |
+
if ($custom_settings and !is_array($custom_settings)) :
|
119 |
$custom_settings = unserialize($custom_settings);
|
120 |
endif;
|
121 |
if (!is_array($custom_settings)) :
|
160 |
if (isset($this->item['comments'])) :
|
161 |
$this->post['meta']['rss:comments'] = apply_filters('syndicated_item_comments', $this->item['comments']);
|
162 |
endif;
|
163 |
+
|
164 |
+
// RSS 2.0 comment feeds extension
|
165 |
if (isset($this->item['wfw']['commentrss'])) :
|
166 |
$this->post['meta']['wfw:commentRSS'] = apply_filters('syndicated_item_commentrss', $this->item['wfw']['commentrss']);
|
167 |
endif;
|
168 |
|
169 |
+
// Atom 1.0 comment feeds link-rel
|
170 |
+
if (isset($this->item['link_replies'])) :
|
171 |
+
// There may be multiple <link rel="replies"> elements; feeds have a feed MIME type
|
172 |
+
$N = isset($this->item['link_replies#']) ? $this->item['link_replies#'] : 1;
|
173 |
+
for ($i = 1; $i <= $N; $i++) :
|
174 |
+
$currentElement = 'link_replies'.(($i > 1) ? '#'.$i : '');
|
175 |
+
if (isset($this->item[$currentElement.'@type'])
|
176 |
+
and preg_match("\007application/(atom|rss|rdf)\+xml\007i", $this->item[$currentElement.'@type'])) :
|
177 |
+
$this->post['meta']['wfw:commentRSS'] = apply_filters('syndicated_item_commentrss', $this->item[$currentElement]);
|
178 |
+
endif;
|
179 |
+
endfor;
|
180 |
+
endif;
|
181 |
+
|
182 |
// Store information to identify the feed that this came from
|
183 |
$this->post['meta']['syndication_feed'] = $this->feedmeta['link/uri'];
|
184 |
$this->post['meta']['syndication_feed_id'] = $this->feedmeta['link/id'];
|
188 |
endif;
|
189 |
|
190 |
// In case you want to know the external permalink...
|
191 |
+
if (isset($this->item['link'])) :
|
192 |
+
$permalink = $this->item['link'];
|
193 |
+
|
194 |
+
// No <link> element. See if this feed has <guid isPermalink="true"> ....
|
195 |
+
elseif (isset($this->item['guid'])) :
|
196 |
+
if (isset($this->item['guid@ispermalink']) and strtolower(trim($this->item['guid@ispermalink'])) != 'false') :
|
197 |
+
$permalink = $this->item['guid'];
|
198 |
+
endif;
|
199 |
+
endif;
|
200 |
+
|
201 |
+
$this->post['meta']['syndication_permalink'] = apply_filters('syndicated_item_link', $permalink);
|
202 |
|
203 |
// Store a hash of the post content for checking whether something needs to be updated
|
204 |
$this->post['meta']['syndication_item_hash'] = $this->update_hash();
|
247 |
if (isset($this->feedmeta['tags']) and is_array($this->feedmeta['tags'])) :
|
248 |
$this->post['tags_input'] = array_merge($this->post['tags_input'], $this->feedmeta['tags']);
|
249 |
endif;
|
250 |
+
$this->post['tags_input'] = apply_filters('syndicated_item_tags', $this->post['tags_input'], $this);
|
251 |
endif;
|
252 |
} // SyndicatedPost::SyndicatedPost()
|
253 |
|
705 |
meta_key='$key',
|
706 |
meta_value='$value'
|
707 |
");
|
708 |
+
if (!$result) :
|
709 |
+
$err = mysql_error();
|
710 |
+
if (FEEDWORDPRESS_DEBUG) :
|
711 |
+
echo "[DEBUG:".date('Y-m-d H:i:S')."][feedwordpress]: post metadata insertion FAILED for field '$key' := '$value': [$err]";
|
712 |
+
endif;
|
713 |
+
endif;
|
714 |
endforeach;
|
715 |
endforeach;
|
716 |
endif;
|
922 |
endforeach;
|
923 |
elseif ('create'===$unfamiliar_category) :
|
924 |
if (function_exists('wp_insert_category')) :
|
925 |
+
$cat_id = wp_insert_category(array('cat_name' => $esc));
|
926 |
// And into the database we go.
|
927 |
else :
|
928 |
$nice_kitty = sanitize_title($cat_name);
|
931 |
SET
|
932 |
cat_name='%s',
|
933 |
category_nicename='%s'
|
934 |
+
", $esc, $nice_kitty
|
935 |
));
|
936 |
$cat_id = $wpdb->insert_id;
|
937 |
endif;
|
1136 |
|
1137 |
return $author;
|
1138 |
} // SyndicatedPost::author()
|
1139 |
+
|
1140 |
+
/**
|
1141 |
+
* SyndicatedPost::isTaggedAs: Test whether a feed item is
|
1142 |
+
* tagged / categorized with a given string. Case and leading and
|
1143 |
+
* trailing whitespace are ignored.
|
1144 |
+
*
|
1145 |
+
* @param string $tag Tag to check for
|
1146 |
+
*
|
1147 |
+
* @return bool Whether or not at least one of the categories / tags on
|
1148 |
+
* $this->item is set to $tag (modulo case and leading and trailing
|
1149 |
+
* whitespace)
|
1150 |
+
*/
|
1151 |
+
function isTaggedAs ($tag) {
|
1152 |
+
$desiredTag = strtolower(trim($tag)); // Normalize case and whitespace
|
1153 |
+
|
1154 |
+
// Check to see if this is tagged with $tag
|
1155 |
+
$currentCategory = 'category';
|
1156 |
+
$currentCategoryNumber = 1;
|
1157 |
+
|
1158 |
+
// If we have the new MagpieRSS, the number of category elements
|
1159 |
+
// on this item is stored under index "category#".
|
1160 |
+
if (isset($this->item['category#'])) :
|
1161 |
+
$numberOfCategories = (int) $this->item['category#'];
|
1162 |
+
|
1163 |
+
// We REALLY shouldn't have the old and busted MagpieRSS, but in
|
1164 |
+
// case we do, it doesn't support multiple categories, but there
|
1165 |
+
// might still be a single value under the "category" index.
|
1166 |
+
elseif (isset($this->item['category'])) :
|
1167 |
+
$numberOfCategories = 1;
|
1168 |
+
|
1169 |
+
// No standard category or tag elements on this feed item.
|
1170 |
+
else :
|
1171 |
+
$numberOfCategories = 0;
|
1172 |
+
|
1173 |
+
endif;
|
1174 |
+
|
1175 |
+
$isSoTagged = false; // Innocent until proven guilty
|
1176 |
+
|
1177 |
+
// Loop through category elements; if there are multiple
|
1178 |
+
// elements, they are indexed as category, category#2,
|
1179 |
+
// category#3, ... category#N
|
1180 |
+
while ($currentCategoryNumber <= $numberOfCategories) :
|
1181 |
+
if ($desiredTag == strtolower(trim($this->item[$currentCategory]))) :
|
1182 |
+
$isSoTagged = true; // Got it!
|
1183 |
+
break;
|
1184 |
+
endif;
|
1185 |
+
|
1186 |
+
$currentCategoryNumber += 1;
|
1187 |
+
$currentCategory = 'category#'.$currentCategoryNumber;
|
1188 |
+
endwhile;
|
1189 |
+
|
1190 |
+
return $isSoTagged;
|
1191 |
+
} /* SyndicatedPost::isTaggedAs() */
|
1192 |
+
|
1193 |
var $uri_attrs = array (
|
1194 |
array('a', 'href'),
|
1195 |
array('applet', 'codebase'),
|
syndication-options.php
DELETED
@@ -1,243 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require_once(dirname(__FILE__) . '/admin-ui.php');
|
3 |
-
|
4 |
-
function fwp_syndication_options_page () {
|
5 |
-
global $wpdb, $wp_db_version, $fwp_path;
|
6 |
-
|
7 |
-
if (FeedWordPress::needs_upgrade()) :
|
8 |
-
fwp_upgrade_page();
|
9 |
-
return;
|
10 |
-
endif;
|
11 |
-
|
12 |
-
// If this is a POST, validate source and user credentials
|
13 |
-
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_options', /*capability=*/ 'manage_options');
|
14 |
-
|
15 |
-
if (isset($_POST['create_index'])) :
|
16 |
-
FeedWordPress::create_guid_index();
|
17 |
-
?>
|
18 |
-
<div class="updated">
|
19 |
-
<p><?php _e('Index created on database table.')?></p>
|
20 |
-
</div>
|
21 |
-
<?php
|
22 |
-
endif;
|
23 |
-
|
24 |
-
if (isset($_POST['submit']) or isset($_POST['create_index'])) :
|
25 |
-
update_option('feedwordpress_cat_id', $_REQUEST['syndication_category']);
|
26 |
-
update_option('feedwordpress_update_logging', $_REQUEST['update_logging']);
|
27 |
-
update_option('feedwordpress_debug', $_POST['feedwordpress_debug']);
|
28 |
-
update_option('feedwordpress_automatic_updates', ($_POST['automatic_updates']=='yes'));
|
29 |
-
update_option('feedwordpress_update_time_limit', ($_POST['update_time_limit']=='yes')?(int) $_POST['time_limit_seconds']:0);
|
30 |
-
|
31 |
-
$freshness_interval = (isset($_POST['freshness_interval']) ? (int) $_POST['freshness_interval'] : 10);
|
32 |
-
update_option('feedworidpress_freshness', $freshness_interval*60);
|
33 |
-
|
34 |
-
if (isset($_REQUEST['hardcode_name']) and ($_REQUEST['hardcode_name'] == 'no')) :
|
35 |
-
update_option('feedwordpress_hardcode_name', 'no');
|
36 |
-
else :
|
37 |
-
update_option('feedwordpress_hardcode_name', 'yes');
|
38 |
-
endif;
|
39 |
-
|
40 |
-
if (isset($_REQUEST['hardcode_description']) and ($_REQUEST['hardcode_description'] == 'no')) :
|
41 |
-
update_option('feedwordpress_hardcode_description', 'no');
|
42 |
-
else :
|
43 |
-
update_option('feedwordpress_hardcode_description', 'yes');
|
44 |
-
endif;
|
45 |
-
|
46 |
-
if (isset($_REQUEST['hardcode_url']) and ($_REQUEST['hardcode_url'] == 'no')) :
|
47 |
-
update_option('feedwordpress_hardcode_url', 'no');
|
48 |
-
else :
|
49 |
-
update_option('feedwordpress_hardcode_url', 'yes');
|
50 |
-
endif;
|
51 |
-
?>
|
52 |
-
<div class="updated">
|
53 |
-
<p><?php _e('Options saved.')?></p>
|
54 |
-
</div>
|
55 |
-
<?php
|
56 |
-
endif;
|
57 |
-
|
58 |
-
$cat_id = FeedWordPress::link_category_id();
|
59 |
-
$update_logging = get_option('feedwordpress_update_logging');
|
60 |
-
$feedwordpress_debug = (get_option('feedwordpress_debug')=='yes');
|
61 |
-
|
62 |
-
$update_time_limit = (int) get_option('feedwordpress_update_time_limit');
|
63 |
-
$automatic_updates = get_option('feedwordpress_automatic_updates');
|
64 |
-
|
65 |
-
$freshness_interval = get_option('feedwordpress_freshness');
|
66 |
-
if (false === $freshness_interval) :
|
67 |
-
$freshness_interval = FEEDWORDPRESS_FRESHNESS_INTERVAL;
|
68 |
-
endif;
|
69 |
-
$freshness_interval = $freshness_interval / 60; // convert to minutes
|
70 |
-
|
71 |
-
$hardcode_name = get_option('feedwordpress_hardcode_name');
|
72 |
-
$hardcode_description = get_option('feedwordpress_hardcode_description');
|
73 |
-
$hardcode_url = get_option('feedwordpress_hardcode_url');
|
74 |
-
|
75 |
-
if (isset($wp_db_version) and $wp_db_version >= 4772) :
|
76 |
-
$results = get_categories(array(
|
77 |
-
"type" => 'link',
|
78 |
-
"hide_empty" => false,
|
79 |
-
));
|
80 |
-
|
81 |
-
// Guarantee that the Contributors category will be in the drop-down chooser, even if it is empty.
|
82 |
-
$found_link_category_id = false;
|
83 |
-
foreach ($results as $row) :
|
84 |
-
if ($row->cat_id == $cat_id) : $found_link_category_id = true; endif;
|
85 |
-
endforeach;
|
86 |
-
|
87 |
-
if (!$found_link_category_id) : $results[] = get_category($cat_id); endif;
|
88 |
-
else :
|
89 |
-
$results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
|
90 |
-
endif;
|
91 |
-
|
92 |
-
$cats = array_map('trim',
|
93 |
-
preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_cats'))
|
94 |
-
);
|
95 |
-
$dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL);
|
96 |
-
|
97 |
-
$tags = array_map('trim',
|
98 |
-
preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_tags'))
|
99 |
-
);
|
100 |
-
|
101 |
-
if (fwp_test_wp_version(FWP_SCHEMA_27)) :
|
102 |
-
$icon = '<div class="icon32"><img src="'.htmlspecialchars(WP_PLUGIN_URL.'/'.$fwp_path.'/feedwordpress.png').'" alt="" /></div>';
|
103 |
-
else :
|
104 |
-
$icon = '';
|
105 |
-
endif;
|
106 |
-
|
107 |
-
if (fwp_test_wp_version(FWP_SCHEMA_26)) :
|
108 |
-
$options = __('Settings');
|
109 |
-
else :
|
110 |
-
$options = __('Options');
|
111 |
-
endif;
|
112 |
-
?>
|
113 |
-
<script type="text/javascript">
|
114 |
-
function contextual_appearance (item, appear, disappear, value, checkbox) {
|
115 |
-
var rollup=document.getElementById(item);
|
116 |
-
var newuser=document.getElementById(appear);
|
117 |
-
var sitewide=document.getElementById(disappear);
|
118 |
-
if (rollup) {
|
119 |
-
if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) {
|
120 |
-
if (newuser) newuser.style.display='block';
|
121 |
-
if (sitewide) sitewide.style.display='none';
|
122 |
-
} else {
|
123 |
-
if (newuser) newuser.style.display='none';
|
124 |
-
if (sitewide) sitewide.style.display='block';
|
125 |
-
}
|
126 |
-
}
|
127 |
-
}
|
128 |
-
</script>
|
129 |
-
|
130 |
-
<div class="wrap">
|
131 |
-
<?php print $icon; ?>
|
132 |
-
<h2>Syndication <?php print $options; ?></h2>
|
133 |
-
<div id="poststuff">
|
134 |
-
<form action="" method="post">
|
135 |
-
<?php
|
136 |
-
FeedWordPressCompatibility::stamp_nonce('feedwordpress_options');
|
137 |
-
fwp_linkedit_single_submit();
|
138 |
-
?>
|
139 |
-
<div id="post-body">
|
140 |
-
<?php fwp_option_box_opener('Syndicated Feeds', 'syndicatedfeedsdiv'); ?>
|
141 |
-
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
142 |
-
<tr>
|
143 |
-
<th width="33%" scope="row">Syndicated Link category:</th>
|
144 |
-
<td width="67%"><?php
|
145 |
-
echo "\n<select name=\"syndication_category\" size=\"1\">";
|
146 |
-
foreach ($results as $row) :
|
147 |
-
if (!isset($row->cat_id)) : $row->cat_id = $row->cat_ID; endif;
|
148 |
-
|
149 |
-
echo "\n\t<option value=\"$row->cat_id\"";
|
150 |
-
if ($row->cat_id == $cat_id) :
|
151 |
-
echo " selected='selected'";
|
152 |
-
endif;
|
153 |
-
echo ">$row->cat_id: ".wp_specialchars($row->cat_name);
|
154 |
-
if ('Y' == $row->auto_toggle) :
|
155 |
-
echo ' (auto toggle)';
|
156 |
-
endif;
|
157 |
-
echo "</option>\n";
|
158 |
-
endforeach;
|
159 |
-
echo "\n</select>\n";
|
160 |
-
?></td>
|
161 |
-
</tr>
|
162 |
-
|
163 |
-
<tr style="vertical-align: top">
|
164 |
-
<th width="33%" scope="row">Check for updates:</th>
|
165 |
-
<td width="67%"><select name="automatic_updates" size="1">
|
166 |
-
<option value="yes"<?php echo ($automatic_updates)?' selected="selected"':''; ?>>automatically</option>
|
167 |
-
<option value="no"<?php echo (!$automatic_updates)?' selected="selected"':''; ?>>only when I request</option>
|
168 |
-
</select>
|
169 |
-
</td>
|
170 |
-
</tr>
|
171 |
-
|
172 |
-
<tr style="vertical-align: top">
|
173 |
-
<th width="33%" scope="row"><?php print __('Time limit on updates'); ?>:</th>
|
174 |
-
<td width="67%"><select id="time-limit" name="update_time_limit" size="1" onchange="contextual_appearance('time-limit', 'time-limit-box', null, 'yes');">
|
175 |
-
<option value="no"<?php echo ($update_time_limit>0)?'':' selected="selected"'; ?>>no time limit on updates</option>
|
176 |
-
<option value="yes"<?php echo ($update_time_limit>0)?' selected="selected"':''; ?>>limit updates to no more than...</option>
|
177 |
-
</select>
|
178 |
-
<span id="time-limit-box"><label><input type="text" name="time_limit_seconds" value="<?php print $update_time_limit; ?>" size="5" /> seconds</label></span>
|
179 |
-
</tr>
|
180 |
-
|
181 |
-
<script type="text/javascript">
|
182 |
-
contextual_appearance('time-limit', 'time-limit-box', null, 'yes');
|
183 |
-
</script>
|
184 |
-
|
185 |
-
<tr><th width="33%" scope="row" style="vertical-align:top">Feed information:</th>
|
186 |
-
<td width="67%"><ul style="margin:0;padding:0;list-style:none">
|
187 |
-
<li><input type="checkbox" name="hardcode_name" value="no"<?php echo (($hardcode_name=='yes')?'':' checked="checked"');?>/> Update the contributor title when the feed title changes</li>
|
188 |
-
<li><input type="checkbox" name="hardcode_description" value="no"<?php echo (($hardcode_description=='yes')?'':' checked="checked"');?>/> Update when contributor description if the feed tagline changes</li>
|
189 |
-
<li><input type="checkbox" name="hardcode_url" value="no"<?php echo (($hardcode_url=='yes')?'':' checked="checked"');?>/> Update the contributor homepage when the feed link changes</li>
|
190 |
-
</ul></td></tr>
|
191 |
-
</table>
|
192 |
-
<?php fwp_linkedit_periodic_submit(); ?>
|
193 |
-
<?php fwp_option_box_closer(); ?>
|
194 |
-
|
195 |
-
<?php
|
196 |
-
FeedWordPressSettingsUI::instead_of_posts_box();
|
197 |
-
FeedWordPressSettingsUI::instead_of_authors_box();
|
198 |
-
FeedWordPressSettingsUI::instead_of_categories_box();
|
199 |
-
|
200 |
-
fwp_option_box_opener('Back End', 'backenddiv', 'postbox');
|
201 |
-
?>
|
202 |
-
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
203 |
-
<tr style="vertical-align: top">
|
204 |
-
<th width="33%" scope="row">Update notices:</th>
|
205 |
-
<td width="67%"><select name="update_logging" size="1">
|
206 |
-
<option value="yes"<?php echo (($update_logging=='yes')?' selected="selected"':''); ?>>write to PHP logs</option>
|
207 |
-
<option value="no"<?php echo (($update_logging!='yes')?' selected="selected"':''); ?>>don't write to PHP logs</option>
|
208 |
-
</select></td>
|
209 |
-
</tr>
|
210 |
-
<tr style="vertical-align: top">
|
211 |
-
<th width="33%" scope="row">Debugging mode:</th>
|
212 |
-
<td width="67%"><select name="feedwordpress_debug" size="1">
|
213 |
-
<option value="yes"<?php echo ($feedwordpress_debug ? ' selected="selected"' : ''); ?>>on</option>
|
214 |
-
<option value="no"<?php echo ($feedwordpress_debug ? '' : ' selected="selected"'); ?>>off</option>
|
215 |
-
</select>
|
216 |
-
<p>When debugging mode is <strong>ON</strong>, FeedWordPress displays many diagnostic error messages,
|
217 |
-
warnings, and notices that are ordinarily suppressed, and turns off all caching of feeds. Use with
|
218 |
-
caution: this setting is absolutely inappropriate for a production server.</p>
|
219 |
-
</td>
|
220 |
-
</tr>
|
221 |
-
|
222 |
-
<tr style="vertical-align: top">
|
223 |
-
<th width="33%" scope="row">Guid index:</th>
|
224 |
-
<td width="67%"><input class="button" type="submit" name="create_index" value="Create index on guid column in posts database table" />
|
225 |
-
<p>Creating this index may significantly improve performance on some large
|
226 |
-
FeedWordPress installations.</p></td>
|
227 |
-
</tr>
|
228 |
-
</table>
|
229 |
-
<?php
|
230 |
-
fwp_option_box_closer();
|
231 |
-
fwp_linkedit_periodic_submit();
|
232 |
-
fwp_linkedit_single_submit_closer();
|
233 |
-
?>
|
234 |
-
</div>
|
235 |
-
</form>
|
236 |
-
|
237 |
-
</div> <!-- id="poststuff" -->
|
238 |
-
</div> <!-- class="wrap" -->
|
239 |
-
<?php
|
240 |
-
}
|
241 |
-
|
242 |
-
fwp_syndication_options_page();
|
243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
syndication.php
CHANGED
@@ -1,48 +1,5 @@
|
|
1 |
<?php
|
2 |
require_once(dirname(__FILE__) . '/admin-ui.php');
|
3 |
-
require_once(dirname(__FILE__) . '/magpiemocklink.class.php');
|
4 |
-
require_once(dirname(__FILE__) . '/feedfinder.class.php');
|
5 |
-
|
6 |
-
$FeedWordPressHTTPStatusMessages = array (
|
7 |
-
200 => 'OK. FeedWordPress had no problems retrieving the content at this URL but the content does not seem to be a feed, and does not seem to include links to any feeds.',
|
8 |
-
201 => 'Created',
|
9 |
-
202 => 'Accepted',
|
10 |
-
203 => 'Non-Authoritative information',
|
11 |
-
204 => 'No Content',
|
12 |
-
205 => 'Reset Content',
|
13 |
-
206 => 'Partial Content',
|
14 |
-
300 => 'Multiple Choices',
|
15 |
-
301 => 'Moved Permanently',
|
16 |
-
302 => 'Found',
|
17 |
-
303 => 'See Other',
|
18 |
-
304 => 'Not Modified',
|
19 |
-
305 => 'Use Proxy',
|
20 |
-
307 => 'Temporary Redirect',
|
21 |
-
400 => 'Bad Request',
|
22 |
-
401 => 'Unauthorized. This URL probably needs a username and password for you to access it.',
|
23 |
-
402 => 'Payment Required',
|
24 |
-
403 => 'Forbidden. The URL is not made available for the machine that FeedWordPress is running on.',
|
25 |
-
404 => 'Not Found. There is nothing at this URL. Have you checked the address for typos?',
|
26 |
-
405 => 'Method Not Allowed',
|
27 |
-
406 => 'Not Acceptable',
|
28 |
-
407 => 'Proxy Authentication Required',
|
29 |
-
408 => 'Request Timeout',
|
30 |
-
409 => 'Conflict',
|
31 |
-
410 => 'Gone. This URL is no longer available on this server and no forwarding address is known.',
|
32 |
-
411 => 'Length Required',
|
33 |
-
412 => 'Precondition Failed',
|
34 |
-
413 => 'Request Entity Too Large',
|
35 |
-
414 => 'Request URI Too Long',
|
36 |
-
415 => 'Unsupported Media Type',
|
37 |
-
416 => 'Requested Range Not Satisfiable',
|
38 |
-
417 => 'Expectation Failed',
|
39 |
-
500 => 'Internal Server Error. Something unexpected went wrong with the configuration of the server that hosts this URL. You might try again later to see if this issue has been resolved.',
|
40 |
-
501 => 'Not Implemented',
|
41 |
-
502 => 'Bad Gateway',
|
42 |
-
503 => 'Service Unavailable. The server is currently unable to handle the request due to a temporary overloading or maintenance of the server that hosts this URL. This is probably a temporary condition and you should try again later to see if the issue has been resolved.',
|
43 |
-
504 => 'Gateway Timeout',
|
44 |
-
505 => 'HTTP Version Not Supported',
|
45 |
-
);
|
46 |
|
47 |
################################################################################
|
48 |
## ADMIN MENU ADD-ONS: implement Dashboard management pages ####################
|
@@ -51,29 +8,198 @@ $FeedWordPressHTTPStatusMessages = array (
|
|
51 |
if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
|
52 |
define('FWP_UPDATE_CHECKED', 'Update Checked Links');
|
53 |
define('FWP_UNSUB_CHECKED', 'Unsubscribe from Checked Links');
|
54 |
-
define('FWP_SYNDICATE_NEW', 'Syndicate
|
55 |
else :
|
56 |
define('FWP_UPDATE_CHECKED', 'Update Checked');
|
57 |
define('FWP_UNSUB_CHECKED', 'Unsubscribe');
|
58 |
-
define('FWP_SYNDICATE_NEW', 'Syndicate
|
59 |
endif;
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
function fwp_dashboard_update_if_requested () {
|
79 |
global $wpdb;
|
@@ -150,151 +276,78 @@ function fwp_dashboard_update_if_requested () {
|
|
150 |
echo "\n"; flush();
|
151 |
endif;
|
152 |
echo "</div> <!-- class=\"updated\" -->\n";
|
153 |
-
elseif (fwp_test_wp_version(FWP_SCHEMA_25)) :
|
154 |
-
?>
|
155 |
-
<p class="youare">Check currently scheduled feeds for new and updated posts.</p>
|
156 |
-
<?php
|
157 |
endif;
|
158 |
}
|
159 |
|
160 |
-
function
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
<?php
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
elseif ($_REQUEST['action'] == 'linkedit') : $cont = fwp_linkedit_page();
|
174 |
-
elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') : $cont = fwp_multidelete_page();
|
175 |
-
endif;
|
176 |
-
endif;
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
$
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
|
189 |
-
fwp_dashboard_update_if_requested();
|
190 |
endif;
|
191 |
|
192 |
-
if (
|
193 |
-
|
194 |
-
$hook_it = 'admin_footer';
|
195 |
-
else : // WordPress 2.8+
|
196 |
-
$hook_it = 'admin_footer-feedwordpress/syndication.php';
|
197 |
-
endif;
|
198 |
-
add_action($hook_it, 'feedwordpress_syndication_toggles', /*priority=*/ 10000);
|
199 |
-
echo "<form style='display: none' method='get' action=''>\n<p>\n";
|
200 |
-
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
201 |
-
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
202 |
-
echo "</p>\n</form>\n";
|
203 |
-
|
204 |
-
if ($links) :
|
205 |
-
add_meta_box(
|
206 |
-
/*id=*/ 'feedwordpress_update_box',
|
207 |
-
/*title=*/ __('Update feeds now'),
|
208 |
-
/*callback=*/ 'fwp_syndication_manage_page_update_box',
|
209 |
-
/*page=*/ 'feedwordpresssyndication',
|
210 |
-
/*context =*/ 'feedwordpresssyndication'
|
211 |
-
);
|
212 |
-
endif;
|
213 |
-
add_meta_box(
|
214 |
-
/*id=*/ 'feedwordpress_feeds_box',
|
215 |
-
/*title=*/ __('Syndicated sources'),
|
216 |
-
/*callback=*/ 'fwp_syndication_manage_page_links_box',
|
217 |
-
/*page=*/ 'feedwordpresssyndication',
|
218 |
-
/*context =*/ 'feedwordpresssyndication'
|
219 |
-
);
|
220 |
-
?>
|
221 |
-
<div class="metabox-holder">
|
222 |
-
<div id="feedwordpresssyndication-sortables" class="meta-box-sortables ui-sortable">
|
223 |
-
<?php
|
224 |
-
do_meta_boxes('feedwordpresssyndication', 'feedwordpresssyndication', NULL);
|
225 |
else :
|
226 |
-
|
227 |
-
|
228 |
-
endif;
|
229 |
-
fwp_syndication_manage_page_links_box();
|
230 |
?>
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
<h2>Add a new syndicated site:</h2>
|
238 |
-
<div>
|
239 |
-
<label for="add-uri">Website or feed:</label>
|
240 |
-
<input type="text" name="lookup" id="add-uri" value="URI" size="64" />
|
241 |
-
<input type="hidden" name="action" value="feedfinder" />
|
242 |
-
</div>
|
243 |
-
<div class="submit"><input type="submit" value="Syndicate »" /></div>
|
244 |
-
</form>
|
245 |
-
</div> <!-- class="wrap" -->
|
246 |
-
<?php endif; ?>
|
247 |
-
|
248 |
-
<div style="display: none">
|
249 |
-
<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
|
250 |
-
</div>
|
251 |
-
<?php
|
252 |
endif;
|
253 |
-
|
254 |
-
} /* function fwp_syndication_manage_page () */
|
255 |
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
|
|
260 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
|
261 |
-
|
262 |
-
<div id="rightnow">
|
263 |
-
<h3 class="reallynow"><span><?php print $updateFeedsNow; ?></span>
|
264 |
-
<input type="hidden" name="update_uri" value="*" /><input style="float: right; border: none;" class="rbutton" type="submit" name="update" value="Update" />
|
265 |
-
<br class="clear"/></h3>
|
266 |
-
<?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
|
267 |
-
<h2><?php print $updateFeedsNow; ?></h2>
|
268 |
-
<?php endif; ?>
|
269 |
|
270 |
-
<?php
|
271 |
-
|
272 |
-
fwp_dashboard_update_if_requested();
|
273 |
-
else :
|
274 |
-
?>
|
275 |
-
<p>Check currently scheduled feeds for new and updated posts.</p>
|
276 |
-
<?php endif; ?>
|
277 |
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
<?php
|
|
|
|
|
285 |
|
286 |
-
<?php if (!fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
|
287 |
<div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div>
|
288 |
-
<?php endif; ?>
|
289 |
|
290 |
<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
|
291 |
<br style="clear: both" />
|
292 |
-
<?php elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) :
|
293 |
</div> <!-- id="rightnow" -->
|
294 |
-
|
295 |
-
<?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
|
296 |
-
</div> <!-- class="wrap" -->
|
297 |
-
<?php endif; ?>
|
298 |
</form>
|
299 |
<?php
|
300 |
} /* function fwp_syndication_manage_page_update_box () */
|
@@ -302,11 +355,6 @@ function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
|
|
302 |
function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) {
|
303 |
$links = FeedWordPress::syndicated_links();
|
304 |
?>
|
305 |
-
<?php if (!fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
|
306 |
-
<div class="wrap">
|
307 |
-
<h2>Syndicated Sites</h2>
|
308 |
-
<?php endif; ?>
|
309 |
-
|
310 |
<form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
|
311 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
|
312 |
|
@@ -317,22 +365,7 @@ function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) {
|
|
317 |
<div class="alignright">
|
318 |
<label for="add-uri">Add new source:</label>
|
319 |
<input type="text" name="lookup" id="add-uri" value="Website or feed URI" />
|
320 |
-
|
321 |
-
jQuery(document).ready( function () {
|
322 |
-
var addUri = jQuery("#add-uri");
|
323 |
-
var box = addUri.get(0);
|
324 |
-
if (box.value==box.defaultValue) { addUri.addClass('form-input-tip'); }
|
325 |
-
addUri.focus(function() {
|
326 |
-
if ( this.value == this.defaultValue )
|
327 |
-
jQuery(this).val( '' ).removeClass( 'form-input-tip' );
|
328 |
-
});
|
329 |
-
addUri.blur(function() {
|
330 |
-
if ( this.value == '' )
|
331 |
-
jQuery(this).val( this.defaultValue ).addClass( 'form-input-tip' );
|
332 |
-
});
|
333 |
-
|
334 |
-
} );
|
335 |
-
</script>
|
336 |
|
337 |
<input type="hidden" name="action" value="feedfinder" />
|
338 |
<input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
|
@@ -376,12 +409,12 @@ jQuery(document).ready( function () {
|
|
376 |
endif;
|
377 |
?>
|
378 |
<td>
|
379 |
-
<strong><a href="admin.php?page=<?php print $GLOBALS['fwp_path']
|
380 |
<div class="row-actions"><div><strong>Settings ></strong>
|
381 |
-
<a href="admin.php?page=<?php print $GLOBALS['fwp_path']
|
382 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Posts'); ?></a>
|
383 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/authors-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Authors'); ?></a>
|
384 |
-
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php&link_id=<?php echo $link->link_id; ?>"><?php
|
385 |
<div><strong>Actions ></strong>
|
386 |
<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=feedfinder"><?php echo $caption; ?></a>
|
387 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=Unsubscribe"><?php _e('Unsubscribe'); ?></a>
|
@@ -419,6 +452,7 @@ jQuery(document).ready( function () {
|
|
419 |
if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') :
|
420 |
$next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60);
|
421 |
print fwp_time_elapsed($next);
|
|
|
422 |
else :
|
423 |
echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":"");
|
424 |
endif;
|
@@ -451,482 +485,56 @@ jQuery(document).ready( function () {
|
|
451 |
} /* function fwp_syndication_manage_page_links_box() */
|
452 |
|
453 |
function fwp_feedfinder_page () {
|
454 |
-
global $
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
$link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id='".$wpdb->escape($link_id)."'");
|
464 |
-
if (is_object($link)):
|
465 |
-
if (is_null($lookup)) $lookup = $link->link_url;
|
466 |
-
$name = wp_specialchars($link->link_name, 'both');
|
467 |
-
else:
|
468 |
-
die (__("Cheatin' uh ?"));
|
469 |
-
endif;
|
470 |
-
else:
|
471 |
-
$name = "<code>".htmlspecialchars($lookup)."</code>";
|
472 |
-
$link_id = 0;
|
473 |
-
endif;
|
474 |
-
?>
|
475 |
-
<div class="wrap">
|
476 |
-
<h2>Feed Finder: <?php echo $name; ?></h2>
|
477 |
-
<?php
|
478 |
-
$f =& new FeedFinder($lookup);
|
479 |
-
$feeds = $f->find();
|
480 |
-
if (count($feeds) > 0):
|
481 |
-
foreach ($feeds as $key => $f):
|
482 |
-
$rss = fetch_rss($f);
|
483 |
-
if ($rss):
|
484 |
-
$feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link'];
|
485 |
-
$feed_link = isset($rss->channel['link'])?$rss->channel['link']:'';
|
486 |
-
else :
|
487 |
-
// Give us some sucky defaults
|
488 |
-
$uri_bits = parse_url($lookup);
|
489 |
-
$uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
|
490 |
-
$display_uri =
|
491 |
-
(isset($uri_bits['user'])?$uri_bits['user'].'@':'')
|
492 |
-
.(isset($uri_bits['host'])?$uri_bits['host']:'')
|
493 |
-
.(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
|
494 |
-
.(isset($uri_bits['path'])?$uri_bits['path']:'')
|
495 |
-
.(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
|
496 |
-
if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'…'; endif;
|
497 |
-
|
498 |
-
$feed_title = $display_uri;
|
499 |
-
$feed_link = $lookup;
|
500 |
-
endif;
|
501 |
-
?>
|
502 |
-
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
|
503 |
-
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?></div>
|
504 |
-
<fieldset style="clear: both">
|
505 |
-
<legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend>
|
506 |
-
|
507 |
-
<?php if ($link_id===0): ?>
|
508 |
-
<input type="hidden" name="feed_title" value="<?php echo wp_specialchars($feed_title, 'both'); ?>" />
|
509 |
-
<input type="hidden" name="feed_link" value="<?php echo wp_specialchars($feed_link, 'both'); ?>" />
|
510 |
-
<?php endif; ?>
|
511 |
-
|
512 |
-
<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
|
513 |
-
<input type="hidden" name="feed" value="<?php echo wp_specialchars($f, 'both'); ?>" />
|
514 |
-
<input type="hidden" name="action" value="switchfeed" />
|
515 |
-
|
516 |
-
<div>
|
517 |
-
<div style="float:right; background-color:#D0D0D0; color: black; width:45%; font-size:70%; border-left: 1px dotted #A0A0A0; padding-left: 0.5em; margin-left: 1.0em">
|
518 |
-
<?php if (count($rss->items) > 0): ?>
|
519 |
-
<?php
|
520 |
-
// Prepare to display Sample Item
|
521 |
-
$link =& new MagpieMockLink($rss, $f);
|
522 |
-
$post =& new SyndicatedPost($rss->items[0], $link);
|
523 |
-
?>
|
524 |
-
<h3>Sample Item</h3>
|
525 |
-
<ul>
|
526 |
-
<li><strong>Title:</strong> <a href="<?php echo $post->post['meta']['syndication_permalink']; ?>"><?php echo $post->post['post_title']; ?></a></li>
|
527 |
-
<li><strong>Date:</strong> <?php print date('d-M-y g:i:s a', $post->published()); ?></li>
|
528 |
-
</ul>
|
529 |
-
<div class="entry">
|
530 |
-
<?php print $post->post['post_content']; ?>
|
531 |
-
</div>
|
532 |
-
<?php else: ?>
|
533 |
-
<h3>No Items</h3>
|
534 |
-
<p>FeedWordPress found no posts on this feed.</p>
|
535 |
-
<?php endif; ?>
|
536 |
-
</div>
|
537 |
-
|
538 |
-
<div>
|
539 |
-
<h3>Feed Information</h3>
|
540 |
-
<ul>
|
541 |
-
<li><strong>Website:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li>
|
542 |
-
<li><strong>Feed URI:</strong> <a href="<?php echo wp_specialchars($f, 'both'); ?>"><?php echo wp_specialchars($f, 'both'); ?></a> (<a title="Check feed <<?php echo wp_specialchars($f, 'both'); ?>> for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li>
|
543 |
-
<li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li>
|
544 |
-
<li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li>
|
545 |
-
</ul>
|
546 |
-
<div class="submit"><input type="submit" name="Use" value="« Use this feed" /></div>
|
547 |
-
<div class="submit"><input type="submit" name="Cancel" value="« Cancel" /></div>
|
548 |
-
</div>
|
549 |
-
</div>
|
550 |
-
</fieldset>
|
551 |
-
</form>
|
552 |
-
<?php
|
553 |
-
endforeach;
|
554 |
-
else:
|
555 |
-
print "<p><strong>".__('Error').":</strong> ".__("FeedWordPress couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>';
|
556 |
-
print ". ".__('Try another URL').".</p>";
|
557 |
-
|
558 |
-
// Diagnostics
|
559 |
-
$httpObject = _wp_http_get_object();
|
560 |
-
$transports = $httpObject->_getTransport();
|
561 |
-
print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n";
|
562 |
-
print "<h3>".__('Diagnostic information')."</h3>\n";
|
563 |
-
if (!is_null($f->error())) :
|
564 |
-
print "<h4>".__('HTTP request failure')."</h4>\n";
|
565 |
-
print "<p>".$f->error()."</p>\n";
|
566 |
-
else :
|
567 |
-
print "<h4>".__('HTTP request completed')."</h4>\n";
|
568 |
-
print "<p><strong>Status ".$f->status().":</strong> ".$FeedWordPressHTTPStatusMessages[$f->status()]."</p>\n";
|
569 |
-
endif;
|
570 |
-
print "<h4>".__('HTTP Transports available').":</h4>\n";
|
571 |
-
print "<ol>\n";
|
572 |
-
print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n";
|
573 |
-
print "</ol>\n";
|
574 |
-
print "</div>\n";
|
575 |
-
endif;
|
576 |
-
?>
|
577 |
-
</div>
|
578 |
-
|
579 |
-
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
|
580 |
-
<div><?php
|
581 |
-
FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds');
|
582 |
-
?></div>
|
583 |
-
<div class="wrap">
|
584 |
-
<h2>Use another feed</h2>
|
585 |
-
<div><label>Feed:</label>
|
586 |
-
<input type="text" name="lookup" value="URI" />
|
587 |
-
<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
|
588 |
-
<input type="hidden" name="action" value="feedfinder" /></div>
|
589 |
-
<div class="submit"><input type="submit" value="Use this feed »" /></div>
|
590 |
-
</div>
|
591 |
-
</form>
|
592 |
-
<?php
|
593 |
-
return false; // Don't continue
|
594 |
-
}
|
595 |
|
596 |
function fwp_switchfeed_page () {
|
597 |
global $wpdb, $wp_db_version;
|
|
|
598 |
|
599 |
// If this is a POST, validate source and user credentials
|
600 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
|
601 |
|
602 |
-
|
603 |
-
|
604 |
-
|
|
|
|
|
605 |
if ($link_id): ?>
|
606 |
-
<div class="updated"><p><a href="<?php
|
607 |
-
has been added as a contributing site, using the feed at
|
608 |
-
|
|
|
609 |
<?php else: ?>
|
610 |
<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div>
|
611 |
<?php endif;
|
612 |
-
elseif (isset($
|
613 |
-
|
614 |
-
$
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
SELECT link_name, link_url FROM $wpdb->links
|
624 |
-
WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."'
|
625 |
-
");
|
626 |
-
?>
|
627 |
-
<div class="updated"><p>Feed for <a href="<?php echo $result->link_url; ?>"><?php echo wp_specialchars($result->link_name, 'both'); ?></a>
|
628 |
-
updated to <<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>>.</p></div>
|
629 |
-
<?php else: ?>
|
630 |
-
<div class="updated"><p>Nothing was changed.</p></div>
|
631 |
-
<?php endif;
|
632 |
-
endif;
|
633 |
-
endif;
|
634 |
-
return true; // Continue
|
635 |
-
}
|
636 |
-
|
637 |
-
function fwp_linkedit_page () {
|
638 |
-
global $wpdb, $wp_db_version;
|
639 |
-
|
640 |
-
// If this is a POST, validate source and user credentials
|
641 |
-
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_linkedit', /*capability=*/ 'manage_links');
|
642 |
-
|
643 |
-
$special_settings = array ( /* Regular expression syntax is OK here */
|
644 |
-
'cats',
|
645 |
-
'cat_split',
|
646 |
-
'hardcode name',
|
647 |
-
'hardcode url',
|
648 |
-
'hardcode description',
|
649 |
-
'hardcode categories', /* Deprecated */
|
650 |
-
'post status',
|
651 |
-
'comment status',
|
652 |
-
'ping status',
|
653 |
-
'unfamiliar author',
|
654 |
-
'unfamliar categories', /* Deprecated */
|
655 |
-
'unfamiliar category',
|
656 |
-
'map authors',
|
657 |
-
'tags',
|
658 |
-
'update/.*',
|
659 |
-
'feed/.*',
|
660 |
-
'link/.*',
|
661 |
-
);
|
662 |
-
|
663 |
-
if (isset($_REQUEST['feedfinder'])) :
|
664 |
-
return fwp_feedfinder_page(); // re-route to Feed Finder page
|
665 |
-
else :
|
666 |
-
$link_id = (int) $_REQUEST['link_id'];
|
667 |
-
$link =& new SyndicatedLink($link_id);
|
668 |
-
|
669 |
-
if ($link->found()) :
|
670 |
-
if (isset($GLOBALS['fwp_post']['save'])) :
|
671 |
-
$alter = array ();
|
672 |
-
|
673 |
-
// custom feed settings first
|
674 |
-
foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
|
675 |
-
$mn['key0'] = trim($mn['key0']);
|
676 |
-
$mn['key1'] = trim($mn['key1']);
|
677 |
-
if (preg_match("\007^(("
|
678 |
-
.implode(')|(',$special_settings)
|
679 |
-
."))$\007i",
|
680 |
-
$mn['key1'])) :
|
681 |
-
$mn['key1'] = 'user/'.$mn['key1'];
|
682 |
-
endif;
|
683 |
-
|
684 |
-
if (strlen($mn['key0']) > 0) :
|
685 |
-
unset($link->settings[$mn['key0']]); // out with the old
|
686 |
-
endif;
|
687 |
-
|
688 |
-
if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
|
689 |
-
$link->settings[$mn['key1']] = $mn['value']; // in with the new
|
690 |
-
endif;
|
691 |
-
endforeach;
|
692 |
-
|
693 |
-
// now stuff through the web form
|
694 |
-
// hardcoded feed info
|
695 |
-
if (isset($GLOBALS['fwp_post']['hardcode_name'])) :
|
696 |
-
$link->settings['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name'];
|
697 |
-
if (FeedWordPress::affirmative($link->settings, 'hardcode name')) :
|
698 |
-
$alter[] = "link_name = '".$wpdb->escape($GLOBALS['fwp_post']['name'])."'";
|
699 |
-
endif;
|
700 |
-
endif;
|
701 |
-
if (isset($GLOBALS['fwp_post']['hardcode_description'])) :
|
702 |
-
$link->settings['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description'];
|
703 |
-
if (FeedWordPress::affirmative($link->settings, 'hardcode description')) :
|
704 |
-
$alter[] = "link_description = '".$wpdb->escape($GLOBALS['fwp_post']['description'])."'";
|
705 |
-
endif;
|
706 |
-
endif;
|
707 |
-
if (isset($GLOBALS['fwp_post']['hardcode_url'])) :
|
708 |
-
$link->settings['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url'];
|
709 |
-
if (FeedWordPress::affirmative($link->settings, 'hardcode url')) :
|
710 |
-
$alter[] = "link_url = '".$wpdb->escape($GLOBALS['fwp_post']['linkurl'])."'";
|
711 |
-
endif;
|
712 |
-
endif;
|
713 |
-
|
714 |
-
// Update scheduling
|
715 |
-
if (isset($GLOBALS['fwp_post']['update_schedule'])) :
|
716 |
-
$link->settings['update/hold'] = $GLOBALS['fwp_post']['update_schedule'];
|
717 |
-
endif;
|
718 |
-
|
719 |
-
$alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
|
720 |
-
|
721 |
-
$alter_set = implode(", ", $alter);
|
722 |
-
|
723 |
-
// issue update query
|
724 |
-
$result = $wpdb->query("
|
725 |
-
UPDATE $wpdb->links
|
726 |
-
SET $alter_set
|
727 |
-
WHERE link_id='$link_id'
|
728 |
-
");
|
729 |
-
$updated_link = true;
|
730 |
-
|
731 |
-
// reload link information from DB
|
732 |
-
if (function_exists('clean_bookmark_cache')) :
|
733 |
-
clean_bookmark_cache($link_id);
|
734 |
-
endif;
|
735 |
-
$link =& new SyndicatedLink($link_id);
|
736 |
-
else :
|
737 |
-
$updated_link = false;
|
738 |
endif;
|
739 |
-
|
740 |
-
$db_link = $link->link;
|
741 |
-
$link_url = wp_specialchars($db_link->link_url, 1);
|
742 |
-
$link_name = wp_specialchars($db_link->link_name, 1);
|
743 |
-
$link_description = wp_specialchars($db_link->link_description, 'both');
|
744 |
-
$link_rss_uri = wp_specialchars($db_link->link_rss, 'both');
|
745 |
-
else :
|
746 |
-
die( __('Link not found.') );
|
747 |
-
endif;
|
748 |
-
|
749 |
-
?>
|
750 |
-
<script type="text/javascript">
|
751 |
-
function flip_hardcode (item) {
|
752 |
-
ed=document.getElementById('basics-'+item+'-edit');
|
753 |
-
view=document.getElementById('basics-'+item+'-view');
|
754 |
-
|
755 |
-
o = document.getElementById('basics-hardcode-'+item);
|
756 |
-
if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; }
|
757 |
-
else { ed.style.display='none'; view.style.display='inline'; }
|
758 |
-
}
|
759 |
-
</script>
|
760 |
-
|
761 |
-
<?php if ($updated_link) : ?>
|
762 |
-
<div class="updated"><p>Syndicated feed settings updated.</p></div>
|
763 |
-
<?php endif; ?>
|
764 |
-
|
765 |
-
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
|
766 |
-
<div class="wrap">
|
767 |
-
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_linkedit'); ?>
|
768 |
-
<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
|
769 |
-
<input type="hidden" name="action" value="linkedit" />
|
770 |
-
<input type="hidden" name="save" value="link" />
|
771 |
-
|
772 |
-
<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
|
773 |
-
<div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
|
774 |
-
<?php endif; ?>
|
775 |
-
|
776 |
-
<h2><?php _e('Feed settings'); ?><?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2>
|
777 |
-
|
778 |
-
<div id="poststuff">
|
779 |
-
<?php fwp_linkedit_single_submit($status); ?>
|
780 |
-
|
781 |
-
<div id="post-body">
|
782 |
-
<?php fwp_option_box_opener('Feed Information', 'feedinformationdiv'); ?>
|
783 |
-
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
|
784 |
-
<tr>
|
785 |
-
<th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
|
786 |
-
<td width="60%"><a href="<?php echo wp_specialchars($link_rss_uri, 'both'); ?>"><?php echo $link_rss_uri; ?></a>
|
787 |
-
(<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>"
|
788 |
-
title="Check feed <<?php echo wp_specialchars($link_rss_uri, 'both'); ?>> for validity">validate</a>)
|
789 |
-
</td>
|
790 |
-
<td width="20%"><input type="submit" name="feedfinder" value="switch →" style="font-size:smaller" /></td>
|
791 |
-
</tr>
|
792 |
-
<tr>
|
793 |
-
<th scope="row" width="20%"><?php _e('Link Name:') ?></th>
|
794 |
-
<td width="60%"><input type="text" id="basics-name-edit" name="name"
|
795 |
-
value="<?php echo $link_name; ?>" style="width: 95%" />
|
796 |
-
<span id="basics-name-view"><strong><?php echo $link_name; ?></strong></span>
|
797 |
-
</td>
|
798 |
-
<td>
|
799 |
-
<select id="basics-hardcode-name" onchange="flip_hardcode('name')" name="hardcode_name">
|
800 |
-
<option value="no" <?php echo $link->hardcode('name')?'':'selected="selected"'; ?>>update automatically</option>
|
801 |
-
<option value="yes" <?php echo $link->hardcode('name')?'selected="selected"':''; ?>>edit manually</option>
|
802 |
-
</select>
|
803 |
-
</td>
|
804 |
-
</tr>
|
805 |
-
<tr>
|
806 |
-
<th scope="row" width="20%"><?php _e('Short description:') ?></th>
|
807 |
-
<td width="60%">
|
808 |
-
<input id="basics-description-edit" type="text" name="description" value="<?php echo $link_description; ?>" style="width: 95%" />
|
809 |
-
<span id="basics-description-view"><strong><?php echo $link_description; ?></strong></span>
|
810 |
-
</td>
|
811 |
-
<td>
|
812 |
-
<select id="basics-hardcode-description" onchange="flip_hardcode('description')"
|
813 |
-
name="hardcode_description">
|
814 |
-
<option value="no" <?php echo $link->hardcode('description')?'':'selected="selected"'; ?>>update automatically</option>
|
815 |
-
<option value="yes" <?php echo $link->hardcode('description')?'selected="selected"':''; ?>>edit manually</option>
|
816 |
-
</select></td>
|
817 |
-
</tr>
|
818 |
-
<tr>
|
819 |
-
<th width="20%" scope="row"><?php _e('Homepage:') ?></th>
|
820 |
-
<td width="60%">
|
821 |
-
<input id="basics-url-edit" type="text" name="linkurl" value="<?php echo $link_url; ?>" style="width: 95%;" />
|
822 |
-
<a id="basics-url-view" href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td>
|
823 |
-
<td>
|
824 |
-
<select id="basics-hardcode-url" onchange="flip_hardcode('url')" name="hardcode_url">
|
825 |
-
<option value="no"<?php echo $link->hardcode('url')?'':' selected="selected"'; ?>>update automatically</option>
|
826 |
-
<option value="yes"<?php echo $link->hardcode('url')?' selected="selected"':''; ?>>edit manually</option>
|
827 |
-
</select></td></tr>
|
828 |
-
|
829 |
-
<tr>
|
830 |
-
<th width="20%"><?php _e('Last update') ?>:</th>
|
831 |
-
<td colspan="2"><?php
|
832 |
-
if (isset($link->settings['update/last'])) :
|
833 |
-
echo fwp_time_elapsed($link->settings['update/last'])." ";
|
834 |
-
else :
|
835 |
-
echo " none yet";
|
836 |
endif;
|
837 |
-
|
838 |
-
<tr><th width="20%">Next update:</th>
|
839 |
-
<td colspan="2"><?php
|
840 |
-
$holdem = (isset($link->settings['update/hold']) ? $link->settings['update/hold'] : 'scheduled');
|
841 |
-
?>
|
842 |
-
<select name="update_schedule">
|
843 |
-
<option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
|
844 |
-
echo " (";
|
845 |
-
if (isset($link->settings['update/ttl']) and is_numeric($link->settings['update/ttl'])) :
|
846 |
-
if (isset($link->settings['update/timed']) and $link->settings['update/timed']=='automatically') :
|
847 |
-
echo 'next: ';
|
848 |
-
$next = $link->settings['update/last'] + ((int) $link->settings['update/ttl'] * 60);
|
849 |
-
if (strftime('%x', time()) != strftime('%x', $next)) :
|
850 |
-
echo strftime('%x', $next)." ";
|
851 |
-
endif;
|
852 |
-
echo strftime('%X', $link->settings['update/last']+((int) $link->settings['update/ttl']*60));
|
853 |
-
else :
|
854 |
-
echo "every ".$link->settings['update/ttl']." minute".(($link->settings['update/ttl']!=1)?"s":"");
|
855 |
-
endif;
|
856 |
-
else:
|
857 |
-
echo "next scheduled update";
|
858 |
-
endif;
|
859 |
-
echo ")";
|
860 |
-
?></option>
|
861 |
-
<option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option>
|
862 |
-
<option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option>
|
863 |
-
</select></tr>
|
864 |
-
</table>
|
865 |
-
<?php fwp_option_box_closer(); ?>
|
866 |
-
|
867 |
-
<script type="text/javascript">
|
868 |
-
flip_hardcode('name');
|
869 |
-
flip_hardcode('description');
|
870 |
-
flip_hardcode('url');
|
871 |
-
</script>
|
872 |
-
|
873 |
-
<?php fwp_linkedit_periodic_submit(); ?>
|
874 |
-
|
875 |
-
<?php
|
876 |
-
FeedWordPressSettingsUI::instead_of_posts_box($link_id);
|
877 |
-
FeedWordPressSettingsUI::instead_of_authors_box($link_id);
|
878 |
-
FeedWordPressSettingsUI::instead_of_categories_box($link_id);
|
879 |
-
|
880 |
-
fwp_option_box_opener('Custom Feed Settings (for use in templates)', 'postcustom', 'postbox');
|
881 |
-
?>
|
882 |
-
<p class="setting-description">These custom settings are special fields for the <strong>feed</strong> you are
|
883 |
-
syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create
|
884 |
-
custom fields on syndicated <strong>posts</strong>. If you want to create custom fields that are applied to each
|
885 |
-
individual post from this feed, set up the settings in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&link_id=<?php print $link_id; ?>">Syndicated Posts</a>.</p>
|
886 |
-
|
887 |
-
<div id="postcustomstuff">
|
888 |
-
<table id="meta-list" cellpadding="3">
|
889 |
-
<tr>
|
890 |
-
<th>Key</th>
|
891 |
-
<th>Value</th>
|
892 |
-
<th>Action</th>
|
893 |
-
</tr>
|
894 |
-
|
895 |
-
<?php
|
896 |
-
$i = 0;
|
897 |
-
foreach ($link->settings as $key => $value) :
|
898 |
-
if (!preg_match("\007^((".implode(')|(', $special_settings)."))$\007i", $key)) :
|
899 |
-
?>
|
900 |
-
<tr style="vertical-align:top">
|
901 |
-
<th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
|
902 |
-
<input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th>
|
903 |
-
<td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo wp_specialchars($value, 'both'); ?></textarea></td>
|
904 |
-
<td width="10%"><select name="notes[<?php echo $i; ?>][action]">
|
905 |
-
<option value="update">save changes</option>
|
906 |
-
<option value="delete">delete this setting</option>
|
907 |
-
</select></td>
|
908 |
-
</tr>
|
909 |
-
<?php
|
910 |
-
$i++;
|
911 |
-
endif;
|
912 |
-
endforeach;
|
913 |
-
?>
|
914 |
-
<tr>
|
915 |
-
<th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
|
916 |
-
<td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
|
917 |
-
<td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
|
918 |
-
</tr>
|
919 |
-
</table>
|
920 |
-
<?php fwp_option_box_closer(); ?>
|
921 |
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
</div>
|
927 |
-
<?php
|
928 |
endif;
|
929 |
-
return
|
930 |
}
|
931 |
|
932 |
function fwp_multidelete_page () {
|
@@ -939,7 +547,13 @@ function fwp_multidelete_page () {
|
|
939 |
if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
|
940 |
|
941 |
if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
|
942 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
943 |
$do_it[$what][] = $link_id;
|
944 |
endforeach;
|
945 |
|
@@ -1076,5 +690,6 @@ my mind.</label></li>
|
|
1076 |
endif;
|
1077 |
}
|
1078 |
|
1079 |
-
|
|
|
1080 |
|
1 |
<?php
|
2 |
require_once(dirname(__FILE__) . '/admin-ui.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
################################################################################
|
5 |
## ADMIN MENU ADD-ONS: implement Dashboard management pages ####################
|
8 |
if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
|
9 |
define('FWP_UPDATE_CHECKED', 'Update Checked Links');
|
10 |
define('FWP_UNSUB_CHECKED', 'Unsubscribe from Checked Links');
|
11 |
+
define('FWP_SYNDICATE_NEW', 'Syndicate ...');
|
12 |
else :
|
13 |
define('FWP_UPDATE_CHECKED', 'Update Checked');
|
14 |
define('FWP_UNSUB_CHECKED', 'Unsubscribe');
|
15 |
+
define('FWP_SYNDICATE_NEW', 'Syndicate ...');
|
16 |
endif;
|
17 |
|
18 |
+
class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
|
19 |
+
function FeedWordPressSyndicationPage () {
|
20 |
+
FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresssyndication', /*link=*/ NULL);
|
21 |
+
|
22 |
+
// No over-arching form element
|
23 |
+
$this->dispatch = NULL;
|
24 |
+
$this->filename = __FILE__;
|
25 |
+
} /* FeedWordPressSyndicationPage constructor */
|
26 |
+
|
27 |
+
function has_link () { return false; }
|
28 |
+
|
29 |
+
function display () {
|
30 |
+
global $wpdb;
|
31 |
+
|
32 |
+
if (FeedWordPress::needs_upgrade()) :
|
33 |
+
fwp_upgrade_page();
|
34 |
+
return;
|
35 |
+
endif;
|
36 |
+
|
37 |
+
?>
|
38 |
+
<?php $cont = true;
|
39 |
+
if (isset($_REQUEST['action'])):
|
40 |
+
if ($_REQUEST['action'] == 'feedfinder' or $_REQUEST['action']==FWP_SYNDICATE_NEW) : $cont = fwp_feedfinder_page();
|
41 |
+
elseif ($_REQUEST['action'] == 'switchfeed') : $cont = fwp_switchfeed_page();
|
42 |
+
elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') : $cont = fwp_multidelete_page();
|
43 |
+
endif;
|
44 |
+
endif;
|
45 |
+
|
46 |
+
if ($cont):
|
47 |
+
?>
|
48 |
+
<style type="text/css">
|
49 |
+
.heads-up {
|
50 |
+
background-color: #d0d0d0;
|
51 |
+
color: black;
|
52 |
+
padding: 1.0em;
|
53 |
+
margin: 0.5em 4.0em !important;
|
54 |
+
}
|
55 |
+
.update-form.with-donation {
|
56 |
+
margin-right: 50%;
|
57 |
+
min-height: 255px;
|
58 |
+
}
|
59 |
+
.donation-form, .donation-thanks {
|
60 |
+
background-color: #ffffcc;
|
61 |
+
text-align: left;
|
62 |
+
padding: 0.5em 0.5em;
|
63 |
+
border-left: thin dashed #777777;
|
64 |
+
font-size: 70%;
|
65 |
+
position: absolute;
|
66 |
+
top: 0; bottom: 0; right: 0; left: auto;
|
67 |
+
width: 50%;
|
68 |
+
}
|
69 |
+
.donation-thanks {
|
70 |
+
background-color: #ccffcc;
|
71 |
+
}
|
72 |
+
.donation-thanks .signature {
|
73 |
+
text-align: right;
|
74 |
+
font-style: italic;
|
75 |
+
}
|
76 |
+
.donation-form h4, .donation-thanks h4 {
|
77 |
+
font-size: 10px;
|
78 |
+
text-align: center;
|
79 |
+
border-bottom: 1px solid #777777;
|
80 |
+
margin: 0px;
|
81 |
+
}
|
82 |
+
.donation-form .donate {
|
83 |
+
text-align: center;
|
84 |
+
}
|
85 |
+
.donation-form .sod-off {
|
86 |
+
padding-top: 0.5em;
|
87 |
+
margin-top: 0.5em;
|
88 |
+
border-top: thin solid #777777;
|
89 |
+
}
|
90 |
+
</style>
|
91 |
+
<?php
|
92 |
+
$links = FeedWordPress::syndicated_links();
|
93 |
+
$this->open_sheet('Syndicated Sites');
|
94 |
+
?>
|
95 |
+
<div id="post-body">
|
96 |
+
<?php
|
97 |
+
if ($links) :
|
98 |
+
fwp_add_meta_box(
|
99 |
+
/*id=*/ 'feedwordpress_update_box',
|
100 |
+
/*title=*/ __('Update feeds now'),
|
101 |
+
/*callback=*/ 'fwp_syndication_manage_page_update_box',
|
102 |
+
/*page=*/ $this->meta_box_context(),
|
103 |
+
/*context =*/ $this->meta_box_context()
|
104 |
+
);
|
105 |
+
endif;
|
106 |
+
fwp_add_meta_box(
|
107 |
+
/*id=*/ 'feedwordpress_feeds_box',
|
108 |
+
/*title=*/ __('Syndicated sources'),
|
109 |
+
/*callback=*/ 'fwp_syndication_manage_page_links_box',
|
110 |
+
/*page=*/ $this->meta_box_context(),
|
111 |
+
/*context =*/ $this->meta_box_context()
|
112 |
+
);
|
113 |
+
if (FeedWordPressCompatibility::test_version(0, FWP_SCHEMA_25)) :
|
114 |
+
fwp_add_meta_box(
|
115 |
+
/*id=*/ 'feedwordpress_add_feed_box',
|
116 |
+
/*title=*/ 'Add a new syndicated source',
|
117 |
+
/*callback=*/ 'fwp_syndication_manage_page_add_feed_box',
|
118 |
+
/*page=*/ $this->meta_box_context(),
|
119 |
+
/*context=*/ $this->meta_box_context()
|
120 |
+
);
|
121 |
+
endif;
|
122 |
+
|
123 |
+
do_action('feedwordpress_admin_page_syndication_meta_boxes', $this);
|
124 |
+
?>
|
125 |
+
<div class="metabox-holder">
|
126 |
+
<?php
|
127 |
+
fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
|
128 |
+
?>
|
129 |
+
</div> <!-- class="metabox-holder" -->
|
130 |
+
</div> <!-- id="post-body" -->
|
131 |
+
|
132 |
+
<?php $this->close_sheet(/*dispatch=*/ NULL); ?>
|
133 |
+
|
134 |
+
<div style="display: none">
|
135 |
+
<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
|
136 |
+
</div>
|
137 |
+
<?php
|
138 |
+
endif;
|
139 |
+
} /* FeedWordPressSyndicationPage::display () */
|
140 |
+
|
141 |
+
function bleg_thanks ($page, $box = NULL) {
|
142 |
+
?>
|
143 |
+
<div class="donation-thanks">
|
144 |
+
<h4>Thank you!</h4>
|
145 |
+
<p><strong>Thank you</strong> for your contribution to <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> development.
|
146 |
+
Your generous gifts make ongoing support and development for
|
147 |
+
FeedWordPress possible.</p>
|
148 |
+
<p>If you have any questions about FeedWordPress, or if there
|
149 |
+
is anything I can do to help make FeedWordPress more useful for
|
150 |
+
you, please <a href="http://feedwordpress.radgeek.com/contact">contact me</a>
|
151 |
+
and let me know what you're thinking about.</p>
|
152 |
+
<p class="signature">—<a href="http://radgeek.com/">Charles Johnson</a>, Developer, <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a>.</p>
|
153 |
+
</div>
|
154 |
+
<?php
|
155 |
+
} /* FeedWordPressSyndicationPage::bleg_thanks () */
|
156 |
+
|
157 |
+
function bleg_box ($page, $box = NULL) {
|
158 |
+
?>
|
159 |
+
<div class="donation-form">
|
160 |
+
<h4>Keep FeedWordPress improving</h4>
|
161 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" accept-charset="UTF-8" method="post"><div>
|
162 |
+
<p><a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> makes syndication
|
163 |
+
simple and empowers you to stream content from all over the web into your
|
164 |
+
WordPress hub. That's got to be worth a few lattes. If you're finding FWP useful,
|
165 |
+
<a href="http://feedwordpress.radgeek.com/donation/">a modest gift</a>
|
166 |
+
is the best way to support steady progress on development, enhancements,
|
167 |
+
support, and documentation.</p>
|
168 |
+
<div class="donate">
|
169 |
+
<input type="hidden" name="business" value="commerce@radgeek.com" />
|
170 |
+
<input type="hidden" name="cmd" value="_xclick" />
|
171 |
+
<input type="hidden" name="item_name" value="FeedWordPress donation" />
|
172 |
+
<input type="hidden" name="no_shipping" value="1" />
|
173 |
+
<input type="hidden" name="return" value="<?php bloginfo('url'); ?>/wp-admin/admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>&paid=yes" />
|
174 |
+
<input type="hidden" name="currency_code" value="USD" />
|
175 |
+
<input type="hidden" name="notify_url" value="http://feedwordpress.radgeek.com/ipn/donation" />
|
176 |
+
<input type="hidden" name="custom" value="1" />
|
177 |
+
<input type="image" name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" alt="Donate through PayPal" />
|
178 |
+
</div>
|
179 |
+
</div></form>
|
180 |
+
|
181 |
+
<p>You can make a gift online (or
|
182 |
+
<a href="http://feedwordpress.radgeek.com/donation">set up an automatic
|
183 |
+
regular donation</a>) using an existing PayPal account or any major credit card.</p>
|
184 |
+
|
185 |
+
<div class="sod-off">
|
186 |
+
<form style="text-align: center" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>" method="POST"><div>
|
187 |
+
<input class="button-primary" type="submit" name="maybe_later" value="Maybe Later" />
|
188 |
+
<input class="button-secondary" type="submit" name="go_away" value="Dismiss" />
|
189 |
+
</div></form>
|
190 |
+
</div>
|
191 |
+
</div> <!-- class="donation-form" -->
|
192 |
+
<?php
|
193 |
+
} /* FeedWordPressSyndicationPage::bleg_box () */
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Override the default display of a save-settings button and replace
|
197 |
+
* it with nothing.
|
198 |
+
*/
|
199 |
+
function interstitial () {
|
200 |
+
/* NOOP */
|
201 |
+
} /* FeedWordPressSyndicationPage::interstitial() */
|
202 |
+
} /* class FeedWordPressSyndicationPage */
|
203 |
|
204 |
function fwp_dashboard_update_if_requested () {
|
205 |
global $wpdb;
|
276 |
echo "\n"; flush();
|
277 |
endif;
|
278 |
echo "</div> <!-- class=\"updated\" -->\n";
|
|
|
|
|
|
|
|
|
279 |
endif;
|
280 |
}
|
281 |
|
282 |
+
function fwp_syndication_manage_page_add_feed_box ($object = NULL, $box = NULL) {
|
283 |
+
?>
|
284 |
+
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>" method="post">
|
285 |
+
<div>
|
286 |
+
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
|
287 |
+
<label for="add-uri">Website or feed:</label>
|
288 |
+
<input type="text" name="lookup" id="add-uri" value="URI" size="64" />
|
289 |
+
<input type="hidden" name="action" value="feedfinder" />
|
290 |
+
</div>
|
291 |
+
<div class="submit"><input type="submit" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
|
292 |
+
</form>
|
293 |
+
<?php
|
294 |
+
}
|
|
|
|
|
|
|
|
|
295 |
|
296 |
+
define('FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 31 /*days*/));
|
297 |
+
define('FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 183 /*days*/));
|
298 |
+
function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
|
299 |
+
$bleg_box_hidden = null;
|
300 |
+
if (isset($_POST['maybe_later'])) :
|
301 |
+
$bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET;
|
302 |
+
elseif (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
|
303 |
+
$bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET;
|
304 |
+
elseif (isset($_POST['go_away'])) :
|
305 |
+
$bleg_box_hidden = 'permanent';
|
|
|
|
|
306 |
endif;
|
307 |
|
308 |
+
if (!is_null($bleg_box_hidden)) :
|
309 |
+
update_option('feedwordpress_bleg_box_hidden', $bleg_box_hidden);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
else :
|
311 |
+
$bleg_box_hidden = get_option('feedwordpress_bleg_box_hidden');
|
312 |
+
endif;
|
|
|
|
|
313 |
?>
|
314 |
+
<?php
|
315 |
+
$bleg_box_ready = (!$bleg_box_hidden or (is_numeric($bleg_box_hidden) and $bleg_box_hidden < time()));
|
316 |
+
if (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
|
317 |
+
$object->bleg_thanks($subject, $box);
|
318 |
+
elseif ($bleg_box_ready) :
|
319 |
+
$object->bleg_box($object, $box);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
endif;
|
321 |
+
?>
|
|
|
322 |
|
323 |
+
<form
|
324 |
+
action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>"
|
325 |
+
method="POST"
|
326 |
+
class="update-form<?php if ($bleg_box_ready) : ?> with-donation<?php endif; ?>"
|
327 |
+
>
|
328 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
|
329 |
+
<p>Check currently scheduled feeds for new and updated posts.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
|
331 |
+
<?php
|
332 |
+
fwp_dashboard_update_if_requested();
|
|
|
|
|
|
|
|
|
|
|
333 |
|
334 |
+
if (!get_option('feedwordpress_automatic_updates')) :
|
335 |
+
?>
|
336 |
+
<p class="heads-up"><strong>Note:</strong> Automatic updates are currently turned
|
337 |
+
<strong>off</strong>. New posts from your feeds will not be syndicated
|
338 |
+
until you manually check for them here. You can turn on automatic
|
339 |
+
updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/feeds-page.php">Feed & Update Settings<a></a>.</p>
|
340 |
+
<?php
|
341 |
+
endif;
|
342 |
+
?>
|
343 |
|
|
|
344 |
<div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div>
|
|
|
345 |
|
346 |
<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
|
347 |
<br style="clear: both" />
|
348 |
+
<?php /* elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) :
|
349 |
</div> <!-- id="rightnow" -->
|
350 |
+
<?php */ endif; ?>
|
|
|
|
|
|
|
351 |
</form>
|
352 |
<?php
|
353 |
} /* function fwp_syndication_manage_page_update_box () */
|
355 |
function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) {
|
356 |
$links = FeedWordPress::syndicated_links();
|
357 |
?>
|
|
|
|
|
|
|
|
|
|
|
358 |
<form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
|
359 |
<div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
|
360 |
|
365 |
<div class="alignright">
|
366 |
<label for="add-uri">Add new source:</label>
|
367 |
<input type="text" name="lookup" id="add-uri" value="Website or feed URI" />
|
368 |
+
<?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
|
370 |
<input type="hidden" name="action" value="feedfinder" />
|
371 |
<input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
|
409 |
endif;
|
410 |
?>
|
411 |
<td>
|
412 |
+
<strong><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&link_id=<?php echo $link->link_id; ?>"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></strong>
|
413 |
<div class="row-actions"><div><strong>Settings ></strong>
|
414 |
+
<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Feed'); ?></a>
|
415 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Posts'); ?></a>
|
416 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/authors-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Authors'); ?></a>
|
417 |
+
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php&link_id=<?php echo $link->link_id; ?>"><?php print htmlspecialchars(__('Categories'.FEEDWORDPRESS_AND_TAGS)); ?></a></div>
|
418 |
<div><strong>Actions ></strong>
|
419 |
<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=feedfinder"><?php echo $caption; ?></a>
|
420 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=Unsubscribe"><?php _e('Unsubscribe'); ?></a>
|
452 |
if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') :
|
453 |
$next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60);
|
454 |
print fwp_time_elapsed($next);
|
455 |
+
if (FEEDWORDPRESS_DEBUG) : print " [".(($next-time())/60)." minutes]"; endif;
|
456 |
else :
|
457 |
echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":"");
|
458 |
endif;
|
485 |
} /* function fwp_syndication_manage_page_links_box() */
|
486 |
|
487 |
function fwp_feedfinder_page () {
|
488 |
+
global $post_source;
|
489 |
+
|
490 |
+
$post_source = 'feedwordpress_feeds';
|
491 |
+
|
492 |
+
// With action=feedfinder, this goes directly to the feedfinder page
|
493 |
+
include_once(dirname(__FILE__) . '/feeds-page.php');
|
494 |
+
return false;
|
495 |
+
} /* function fwp_feedfinder_page () */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
|
497 |
function fwp_switchfeed_page () {
|
498 |
global $wpdb, $wp_db_version;
|
499 |
+
global $fwp_post;
|
500 |
|
501 |
// If this is a POST, validate source and user credentials
|
502 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
|
503 |
|
504 |
+
$changed = false;
|
505 |
+
if (!isset($fwp_post['Cancel'])):
|
506 |
+
if (isset($fwp_post['save_link_id']) and ($fwp_post['save_link_id']=='*')) :
|
507 |
+
$changed = true;
|
508 |
+
$link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']);
|
509 |
if ($link_id): ?>
|
510 |
+
<div class="updated"><p><a href="<?php print $fwp_post['feed_link']; ?>"><?php print wp_specialchars($fwp_post['feed_title'], 'both'); ?></a>
|
511 |
+
has been added as a contributing site, using the feed at
|
512 |
+
<<a href="<?php print $fwp_post['feed']; ?>"><?php print wp_specialchars($fwp_post['feed'], 'both'); ?></a>>.
|
513 |
+
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&link_id=<?php print $link_id; ?>">Configure settings</a>.</p></div>
|
514 |
<?php else: ?>
|
515 |
<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div>
|
516 |
<?php endif;
|
517 |
+
elseif (isset($fwp_post['save_link_id'])):
|
518 |
+
$existingLink = new SyndicatedLink($fwp_post['save_link_id']);
|
519 |
+
$changed = $existingLink->set_uri($fwp_post['feed']);
|
520 |
+
|
521 |
+
if ($changed):
|
522 |
+
$home = $existingLink->homepage(/*from feed=*/ false);
|
523 |
+
$name = $existingLink->name(/*from feed=*/ false);
|
524 |
+
?>
|
525 |
+
<div class="updated"><p>Feed for <a href="<?php echo wp_specialchars($home, 'both'); ?>"><?php echo wp_specialchars($name, 'both'); ?></a>
|
526 |
+
updated to <<a href="<?php echo wp_specialchars($fwp_post['feed'], 'both'); ?>"><?php echo wp_specialchars($fwp_post['feed'], 'both'); ?></a>>.</p></div>
|
527 |
+
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
528 |
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
endif;
|
530 |
+
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
531 |
|
532 |
+
if (!$changed) :
|
533 |
+
?>
|
534 |
+
<div class="updated"><p>Nothing was changed.</p></div>
|
535 |
+
<?php
|
|
|
|
|
536 |
endif;
|
537 |
+
return true; // Continue
|
538 |
}
|
539 |
|
540 |
function fwp_multidelete_page () {
|
547 |
if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
|
548 |
|
549 |
if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
|
550 |
+
if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) :
|
551 |
+
$actions = $GLOBALS['fwp_post']['link_action'];
|
552 |
+
else :
|
553 |
+
$actions = array();
|
554 |
+
endif;
|
555 |
+
|
556 |
+
foreach ($actions as $link_id => $what) :
|
557 |
$do_it[$what][] = $link_id;
|
558 |
endforeach;
|
559 |
|
690 |
endif;
|
691 |
}
|
692 |
|
693 |
+
$syndicationPage = new FeedWordPressSyndicationPage;
|
694 |
+
$syndicationPage->display();
|
695 |
|