Version Description
-
WORDPRSS BACKWARD COMPATIBILITY FOR VERSIONS [4.5, 4.7]: This change fixes a fatal PHP error (on some web server configurations you'd see the message "Fatal error: require_once(): Failed opening required '[...]/wp-includes/class-wp-feed-cache.php'" on others, you might just see an HTTP 500 Internal Server Error or a blank page) when using FeedWordPress with versions of WordPress before 4.7. A change that I introduced to avoid a code module that had been deprecated in version 4.7 ended up relying on code modules that were only introduced as of version 4.7; so now, instead, FeedWordPress attempts to detect which modules the current version of the WordPress core makes available, and load the right modules depending on your WordPress version.
In theory, up to this point, FeedWordPress supported any version of WordPress from version 3.0 onward. In practice, version 3.0 was released over 6 years ago, and I can realistically commit only to testing out new releases of FeedWordPress with a few prior versions of WordPress; so I've updated the "Requires at least" field to version 4.5, the first major release issued in 2016. If you've really got to use FeedWordPress with older versions of WordPress, it will probably still work with any moderately modern release of WordPress, but I won't promise to keep it working with releases of WordPress that are more than about a year old.
Release Info
Developer | radgeek |
Plugin | FeedWordPress |
Version | 2016.1213 |
Comparing to | |
See all releases |
Code changes from version 2016.1211 to 2016.1213
- admin-ui.php +50 -45
- authors-page.php +1 -1
- feeds-page.php +1 -1
- feedwordpress.php +39 -21
- posts-page.php +1 -1
- readme.txt +25 -2
- syndicatedlink.class.php +85 -59
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
class FeedWordPressAdminPage {
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
|
7 |
var $link = NULL;
|
8 |
var $dispatch = NULL;
|
@@ -24,12 +24,12 @@ class FeedWordPressAdminPage {
|
|
24 |
endif;
|
25 |
} /* FeedWordPressAdminPage constructor */
|
26 |
|
27 |
-
function pageslug () {
|
28 |
$slug = preg_replace('/FeedWordPress(.*)Page/', '$1', get_class($this));
|
29 |
return strtolower($slug);
|
30 |
}
|
31 |
|
32 |
-
function pagename ($context = NULL) {
|
33 |
if (is_null($context)) :
|
34 |
$context = 'default';
|
35 |
endif;
|
@@ -44,7 +44,7 @@ class FeedWordPressAdminPage {
|
|
44 |
return __($name);
|
45 |
} /* FeedWordPressAdminPage::pagename () */
|
46 |
|
47 |
-
function accept_POST ($post) {
|
48 |
if ($this->for_feed_settings() and $this->update_requested_in($post)) :
|
49 |
$this->update_feed();
|
50 |
elseif ($this->save_requested_in($post)) : // User mashed Save Changes
|
@@ -53,7 +53,7 @@ class FeedWordPressAdminPage {
|
|
53 |
do_action($this->dispatch.'_post', $post, $this);
|
54 |
}
|
55 |
|
56 |
-
function update_feed () {
|
57 |
global $feedwordpress;
|
58 |
|
59 |
add_action('feedwordpress_check_feed', 'update_feeds_mention');
|
@@ -85,7 +85,7 @@ class FeedWordPressAdminPage {
|
|
85 |
remove_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
|
86 |
}
|
87 |
|
88 |
-
function save_settings ($post) {
|
89 |
do_action($this->dispatch.'_save', $post, $this);
|
90 |
|
91 |
if ($this->for_feed_settings()) :
|
@@ -102,10 +102,10 @@ class FeedWordPressAdminPage {
|
|
102 |
endif;
|
103 |
} /* FeedWordPressAdminPage::save_settings () */
|
104 |
|
105 |
-
function for_feed_settings () { return (is_object($this->link) and method_exists($this->link, 'found') and $this->link->found()); }
|
106 |
-
function for_default_settings () { return !$this->for_feed_settings(); }
|
107 |
|
108 |
-
function setting ($names, $fallback_value = NULL, $params = array()) {
|
109 |
if (!is_array($params)) :
|
110 |
$params = array('default' => $params);
|
111 |
endif;
|
@@ -131,7 +131,7 @@ class FeedWordPressAdminPage {
|
|
131 |
return $ret;
|
132 |
}
|
133 |
|
134 |
-
function update_setting ($names, $value, $default = 'default') {
|
135 |
if (is_string($names)) :
|
136 |
$feed_name = $names;
|
137 |
$global_name = 'feedwordpress_'.preg_replace('![\s/]+!', '_', $names);
|
@@ -147,14 +147,14 @@ class FeedWordPressAdminPage {
|
|
147 |
endif;
|
148 |
} /* FeedWordPressAdminPage::update_setting () */
|
149 |
|
150 |
-
function save_requested_in ($post) {
|
151 |
return (isset($post['save']) or isset($post['submit']));
|
152 |
}
|
153 |
-
function update_requested_in ($post) {
|
154 |
return (isset($post['update']) and (strlen($post['update']) > 0));
|
155 |
}
|
156 |
|
157 |
-
|
158 |
global $fwp_post;
|
159 |
|
160 |
// Presume global unless we get a specific link ID
|
@@ -179,8 +179,8 @@ class FeedWordPressAdminPage {
|
|
179 |
return $link_id;
|
180 |
} /* FeedWordPressAdminPage::submitted_link_id() */
|
181 |
|
182 |
-
|
183 |
-
$link_id =
|
184 |
if (is_numeric($link_id) and $link_id) :
|
185 |
$link = new SyndicatedLink($link_id);
|
186 |
else :
|
@@ -189,14 +189,14 @@ class FeedWordPressAdminPage {
|
|
189 |
return $link;
|
190 |
} /* FeedWordPressAdminPage::submitted_link () */
|
191 |
|
192 |
-
function stamp_link_id ($field = null) {
|
193 |
if (is_null($field)) : $field = 'save_link_id'; endif;
|
194 |
?>
|
195 |
<input type="hidden" name="<?php print esc_attr($field); ?>" value="<?php print ($this->for_feed_settings() ? $this->link->id : '*'); ?>" />
|
196 |
<?php
|
197 |
} /* FeedWordPressAdminPage::stamp_link_id () */
|
198 |
|
199 |
-
function these_posts_phrase () {
|
200 |
if ($this->for_feed_settings()) :
|
201 |
$phrase = __('posts from this feed');
|
202 |
else :
|
@@ -214,7 +214,7 @@ class FeedWordPressAdminPage {
|
|
214 |
* @see add_meta_box()
|
215 |
* @see do_meta_boxes()
|
216 |
*/
|
217 |
-
function meta_box_context () {
|
218 |
return $this->context;
|
219 |
} /* FeedWordPressAdminPage::meta_box_context () */
|
220 |
|
@@ -223,11 +223,11 @@ class FeedWordPressAdminPage {
|
|
223 |
*
|
224 |
* @uses FeedWordPressAdminPage::meta_box_context()
|
225 |
*/
|
226 |
-
function fix_toggles () {
|
227 |
FeedWordPressSettingsUI::fix_toggles_js($this->meta_box_context());
|
228 |
} /* FeedWordPressAdminPage::fix_toggles() */
|
229 |
|
230 |
-
function ajax_interface_js () {
|
231 |
?>
|
232 |
function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) {
|
233 |
if (typeof(visibleStyle)=='undefined') visibleStyle = 'block';
|
@@ -246,7 +246,7 @@ class FeedWordPressAdminPage {
|
|
246 |
<?php
|
247 |
} /* FeedWordPressAdminPage::ajax_interface_js () */
|
248 |
|
249 |
-
function admin_page_href ($page, $params = array(), $link = NULL) {
|
250 |
global $fwp_path;
|
251 |
|
252 |
// Merge in the page's filename
|
@@ -278,7 +278,7 @@ class FeedWordPressAdminPage {
|
|
278 |
return MyPHP::url(admin_url('admin.php'), $params);
|
279 |
} /* FeedWordPressAdminPage::admin_page_href () */
|
280 |
|
281 |
-
function display_feed_settings_page_links ($params = array()) {
|
282 |
global $fwp_path;
|
283 |
|
284 |
$params = wp_parse_args($params, array(
|
@@ -338,7 +338,7 @@ class FeedWordPressAdminPage {
|
|
338 |
print $params['after'];
|
339 |
} /* FeedWordPressAdminPage::display_feed_settings_page_links */
|
340 |
|
341 |
-
function display_feed_select_dropdown() {
|
342 |
$links = FeedWordPress::syndicated_links();
|
343 |
|
344 |
?>
|
@@ -370,7 +370,7 @@ class FeedWordPressAdminPage {
|
|
370 |
<?php
|
371 |
} /* FeedWordPressAdminPage::display_feed_select_dropdown() */
|
372 |
|
373 |
-
function display_sheet_header ($pagename = 'Syndication', $all = false) {
|
374 |
global $fwp_path;
|
375 |
?>
|
376 |
<div class="icon32"><img src="<?php print esc_html( plugins_url( '/'.$fwp_path.'/feedwordpress.png') ); ?>" alt="" /></div>
|
@@ -378,7 +378,7 @@ class FeedWordPressAdminPage {
|
|
378 |
<?php
|
379 |
}
|
380 |
|
381 |
-
function display_update_notice_if_updated ($pagename = 'Syndication', $mesg = NULL) {
|
382 |
if (!is_null($mesg)) :
|
383 |
$this->mesg = $mesg;
|
384 |
endif;
|
@@ -400,7 +400,7 @@ class FeedWordPressAdminPage {
|
|
400 |
endif;
|
401 |
} /* FeedWordPressAdminPage::display_update_notice_if_updated() */
|
402 |
|
403 |
-
function display_settings_scope_message () {
|
404 |
if ($this->for_feed_settings()) :
|
405 |
?>
|
406 |
<p>These settings only affect posts syndicated from
|
@@ -416,7 +416,7 @@ class FeedWordPressAdminPage {
|
|
416 |
|
417 |
/*static*/ function has_link () { return true; }
|
418 |
|
419 |
-
function form_action ($filename = NULL) {
|
420 |
global $fwp_path;
|
421 |
|
422 |
if (is_null($filename)) :
|
@@ -425,11 +425,11 @@ class FeedWordPressAdminPage {
|
|
425 |
return $this->admin_page_href($filename);
|
426 |
} /* FeedWordPressAdminPage::form_action () */
|
427 |
|
428 |
-
function update_message () {
|
429 |
return $this->mesg;
|
430 |
}
|
431 |
|
432 |
-
function display () {
|
433 |
global $fwp_post;
|
434 |
|
435 |
if (FeedWordPress::needs_upgrade()) :
|
@@ -490,7 +490,7 @@ class FeedWordPressAdminPage {
|
|
490 |
<?php
|
491 |
}
|
492 |
|
493 |
-
function open_sheet ($header) {
|
494 |
// Set up prepatory AJAX stuff
|
495 |
?>
|
496 |
<script type="text/javascript">
|
@@ -545,7 +545,7 @@ class FeedWordPressAdminPage {
|
|
545 |
<?php
|
546 |
} /* FeedWordPressAdminPage::open_sheet () */
|
547 |
|
548 |
-
function close_sheet () {
|
549 |
?>
|
550 |
|
551 |
</div> <!-- id="poststuff" -->
|
@@ -560,7 +560,7 @@ class FeedWordPressAdminPage {
|
|
560 |
<?php
|
561 |
} /* FeedWordPressAdminPage::close_sheet () */
|
562 |
|
563 |
-
function setting_radio_control ($localName, $globalName, $options, $params = array()) {
|
564 |
global $fwp_path;
|
565 |
|
566 |
if (isset($params['filename'])) : $filename = $params['filename'];
|
@@ -727,7 +727,7 @@ class FeedWordPressAdminPage {
|
|
727 |
endif;
|
728 |
} /* FeedWordPressAdminPage::setting_radio_control () */
|
729 |
|
730 |
-
function save_button ($caption = NULL) {
|
731 |
if (is_null($caption)) : $caption = __('Save Changes'); endif;
|
732 |
?>
|
733 |
<p class="submit">
|
@@ -793,8 +793,11 @@ function fwp_tags_box ($tags, $object, $params = array()) {
|
|
793 |
if (!is_array($tags)) : $tags = array(); endif;
|
794 |
|
795 |
$tax_name = $params['taxonomy'];
|
796 |
-
|
797 |
-
$
|
|
|
|
|
|
|
798 |
|
799 |
$desc = "<p style=\"font-size:smaller;font-style:bold;margin:0\">Tag $object as...</p>";
|
800 |
|
@@ -822,24 +825,24 @@ function fwp_tags_box ($tags, $object, $params = array()) {
|
|
822 |
<div class="tagsdiv" id="<?php echo $params['id']; ?>">
|
823 |
<div class="jaxtag">
|
824 |
<div class="nojs-tags hide-if-js">
|
825 |
-
<p><?php echo $
|
826 |
<textarea name="<?php echo $params['textarea_name']; ?>" class="the-tags" id="<?php echo $params['textarea_id']; ?>"><?php echo esc_attr(implode(",", $tags)); ?></textarea></div>
|
827 |
|
828 |
-
<?php if ( current_user_can($
|
829 |
<div class="ajaxtag hide-if-no-js">
|
830 |
<label class="screen-reader-text" for="<?php echo $params['input_id']; ?>"><?php echo $params['box_title']; ?></label>
|
831 |
-
<div class="taghint"><?php echo $
|
832 |
<p><input type="text" id="<?php print $params['input_id']; ?>" name="<?php print $params['input_name']; ?>" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
|
833 |
<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" /></p>
|
834 |
</div>
|
835 |
-
<p class="howto"><?php echo esc_attr( $
|
836 |
<?php endif; ?>
|
837 |
</div>
|
838 |
|
839 |
<div class="tagchecklist"></div>
|
840 |
</div>
|
841 |
-
<?php if ( current_user_can($
|
842 |
-
<p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $
|
843 |
<?php endif;
|
844 |
|
845 |
}
|
@@ -854,7 +857,9 @@ function fwp_category_box ($checked, $object, $tags = array(), $params = array()
|
|
854 |
$prefix = (isset($params['prefix']) ? $params['prefix'] : '');
|
855 |
$taxonomy = (isset($params['taxonomy']) ? $params['taxonomy'] : 'category');
|
856 |
endif;
|
857 |
-
|
|
|
|
|
858 |
|
859 |
if (strlen($prefix) > 0) :
|
860 |
$idPrefix = $prefix.'-';
|
@@ -870,7 +875,7 @@ function fwp_category_box ($checked, $object, $tags = array(), $params = array()
|
|
870 |
<div id="<?php print $idPrefix; ?>taxonomy-<?php print $taxonomy; ?>" class="feedwordpress-category-div">
|
871 |
<ul id="<?php print $idPrefix; ?><?php print $taxonomy; ?>-tabs" class="category-tabs">
|
872 |
<li class="ui-tabs-selected tabs"><a href="#<?php print $idPrefix; ?><?php print $taxonomy; ?>-all" tabindex="3"><?php _e( 'All posts' ); ?></a>
|
873 |
-
<p style="font-size:smaller;font-style:bold;margin:0">Give <?php print $object; ?> these <?php print $
|
874 |
</li>
|
875 |
</ul>
|
876 |
|
1 |
<?php
|
2 |
class FeedWordPressAdminPage {
|
3 |
+
protected $context;
|
4 |
+
protected $updated = false;
|
5 |
+
protected $mesg = NULL;
|
6 |
|
7 |
var $link = NULL;
|
8 |
var $dispatch = NULL;
|
24 |
endif;
|
25 |
} /* FeedWordPressAdminPage constructor */
|
26 |
|
27 |
+
public function pageslug () {
|
28 |
$slug = preg_replace('/FeedWordPress(.*)Page/', '$1', get_class($this));
|
29 |
return strtolower($slug);
|
30 |
}
|
31 |
|
32 |
+
public function pagename ($context = NULL) {
|
33 |
if (is_null($context)) :
|
34 |
$context = 'default';
|
35 |
endif;
|
44 |
return __($name);
|
45 |
} /* FeedWordPressAdminPage::pagename () */
|
46 |
|
47 |
+
public function accept_POST ($post) {
|
48 |
if ($this->for_feed_settings() and $this->update_requested_in($post)) :
|
49 |
$this->update_feed();
|
50 |
elseif ($this->save_requested_in($post)) : // User mashed Save Changes
|
53 |
do_action($this->dispatch.'_post', $post, $this);
|
54 |
}
|
55 |
|
56 |
+
public function update_feed () {
|
57 |
global $feedwordpress;
|
58 |
|
59 |
add_action('feedwordpress_check_feed', 'update_feeds_mention');
|
85 |
remove_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
|
86 |
}
|
87 |
|
88 |
+
public function save_settings ($post) {
|
89 |
do_action($this->dispatch.'_save', $post, $this);
|
90 |
|
91 |
if ($this->for_feed_settings()) :
|
102 |
endif;
|
103 |
} /* FeedWordPressAdminPage::save_settings () */
|
104 |
|
105 |
+
public function for_feed_settings () { return (is_object($this->link) and method_exists($this->link, 'found') and $this->link->found()); }
|
106 |
+
public function for_default_settings () { return !$this->for_feed_settings(); }
|
107 |
|
108 |
+
public function setting ($names, $fallback_value = NULL, $params = array()) {
|
109 |
if (!is_array($params)) :
|
110 |
$params = array('default' => $params);
|
111 |
endif;
|
131 |
return $ret;
|
132 |
}
|
133 |
|
134 |
+
public function update_setting ($names, $value, $default = 'default') {
|
135 |
if (is_string($names)) :
|
136 |
$feed_name = $names;
|
137 |
$global_name = 'feedwordpress_'.preg_replace('![\s/]+!', '_', $names);
|
147 |
endif;
|
148 |
} /* FeedWordPressAdminPage::update_setting () */
|
149 |
|
150 |
+
public function save_requested_in ($post) {
|
151 |
return (isset($post['save']) or isset($post['submit']));
|
152 |
}
|
153 |
+
public function update_requested_in ($post) {
|
154 |
return (isset($post['update']) and (strlen($post['update']) > 0));
|
155 |
}
|
156 |
|
157 |
+
public function submitted_link_id () {
|
158 |
global $fwp_post;
|
159 |
|
160 |
// Presume global unless we get a specific link ID
|
179 |
return $link_id;
|
180 |
} /* FeedWordPressAdminPage::submitted_link_id() */
|
181 |
|
182 |
+
public function submitted_link () {
|
183 |
+
$link_id = $this->submitted_link_id();
|
184 |
if (is_numeric($link_id) and $link_id) :
|
185 |
$link = new SyndicatedLink($link_id);
|
186 |
else :
|
189 |
return $link;
|
190 |
} /* FeedWordPressAdminPage::submitted_link () */
|
191 |
|
192 |
+
public function stamp_link_id ($field = null) {
|
193 |
if (is_null($field)) : $field = 'save_link_id'; endif;
|
194 |
?>
|
195 |
<input type="hidden" name="<?php print esc_attr($field); ?>" value="<?php print ($this->for_feed_settings() ? $this->link->id : '*'); ?>" />
|
196 |
<?php
|
197 |
} /* FeedWordPressAdminPage::stamp_link_id () */
|
198 |
|
199 |
+
public function these_posts_phrase () {
|
200 |
if ($this->for_feed_settings()) :
|
201 |
$phrase = __('posts from this feed');
|
202 |
else :
|
214 |
* @see add_meta_box()
|
215 |
* @see do_meta_boxes()
|
216 |
*/
|
217 |
+
public function meta_box_context () {
|
218 |
return $this->context;
|
219 |
} /* FeedWordPressAdminPage::meta_box_context () */
|
220 |
|
223 |
*
|
224 |
* @uses FeedWordPressAdminPage::meta_box_context()
|
225 |
*/
|
226 |
+
public function fix_toggles () {
|
227 |
FeedWordPressSettingsUI::fix_toggles_js($this->meta_box_context());
|
228 |
} /* FeedWordPressAdminPage::fix_toggles() */
|
229 |
|
230 |
+
public function ajax_interface_js () {
|
231 |
?>
|
232 |
function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) {
|
233 |
if (typeof(visibleStyle)=='undefined') visibleStyle = 'block';
|
246 |
<?php
|
247 |
} /* FeedWordPressAdminPage::ajax_interface_js () */
|
248 |
|
249 |
+
public function admin_page_href ($page, $params = array(), $link = NULL) {
|
250 |
global $fwp_path;
|
251 |
|
252 |
// Merge in the page's filename
|
278 |
return MyPHP::url(admin_url('admin.php'), $params);
|
279 |
} /* FeedWordPressAdminPage::admin_page_href () */
|
280 |
|
281 |
+
public function display_feed_settings_page_links ($params = array()) {
|
282 |
global $fwp_path;
|
283 |
|
284 |
$params = wp_parse_args($params, array(
|
338 |
print $params['after'];
|
339 |
} /* FeedWordPressAdminPage::display_feed_settings_page_links */
|
340 |
|
341 |
+
public function display_feed_select_dropdown() {
|
342 |
$links = FeedWordPress::syndicated_links();
|
343 |
|
344 |
?>
|
370 |
<?php
|
371 |
} /* FeedWordPressAdminPage::display_feed_select_dropdown() */
|
372 |
|
373 |
+
public function display_sheet_header ($pagename = 'Syndication', $all = false) {
|
374 |
global $fwp_path;
|
375 |
?>
|
376 |
<div class="icon32"><img src="<?php print esc_html( plugins_url( '/'.$fwp_path.'/feedwordpress.png') ); ?>" alt="" /></div>
|
378 |
<?php
|
379 |
}
|
380 |
|
381 |
+
public function display_update_notice_if_updated ($pagename = 'Syndication', $mesg = NULL) {
|
382 |
if (!is_null($mesg)) :
|
383 |
$this->mesg = $mesg;
|
384 |
endif;
|
400 |
endif;
|
401 |
} /* FeedWordPressAdminPage::display_update_notice_if_updated() */
|
402 |
|
403 |
+
public function display_settings_scope_message () {
|
404 |
if ($this->for_feed_settings()) :
|
405 |
?>
|
406 |
<p>These settings only affect posts syndicated from
|
416 |
|
417 |
/*static*/ function has_link () { return true; }
|
418 |
|
419 |
+
public function form_action ($filename = NULL) {
|
420 |
global $fwp_path;
|
421 |
|
422 |
if (is_null($filename)) :
|
425 |
return $this->admin_page_href($filename);
|
426 |
} /* FeedWordPressAdminPage::form_action () */
|
427 |
|
428 |
+
public function update_message () {
|
429 |
return $this->mesg;
|
430 |
}
|
431 |
|
432 |
+
public function display () {
|
433 |
global $fwp_post;
|
434 |
|
435 |
if (FeedWordPress::needs_upgrade()) :
|
490 |
<?php
|
491 |
}
|
492 |
|
493 |
+
public function open_sheet ($header) {
|
494 |
// Set up prepatory AJAX stuff
|
495 |
?>
|
496 |
<script type="text/javascript">
|
545 |
<?php
|
546 |
} /* FeedWordPressAdminPage::open_sheet () */
|
547 |
|
548 |
+
public function close_sheet () {
|
549 |
?>
|
550 |
|
551 |
</div> <!-- id="poststuff" -->
|
560 |
<?php
|
561 |
} /* FeedWordPressAdminPage::close_sheet () */
|
562 |
|
563 |
+
public function setting_radio_control ($localName, $globalName, $options, $params = array()) {
|
564 |
global $fwp_path;
|
565 |
|
566 |
if (isset($params['filename'])) : $filename = $params['filename'];
|
727 |
endif;
|
728 |
} /* FeedWordPressAdminPage::setting_radio_control () */
|
729 |
|
730 |
+
public function save_button ($caption = NULL) {
|
731 |
if (is_null($caption)) : $caption = __('Save Changes'); endif;
|
732 |
?>
|
733 |
<p class="submit">
|
793 |
if (!is_array($tags)) : $tags = array(); endif;
|
794 |
|
795 |
$tax_name = $params['taxonomy'];
|
796 |
+
|
797 |
+
$oTax = get_taxonomy($params['taxonomy']);
|
798 |
+
$oTaxLabels = get_taxonomy_labels($oTax);
|
799 |
+
|
800 |
+
$disabled = (!current_user_can($oTax->cap->assign_terms) ? 'disabled="disabled"' : '');
|
801 |
|
802 |
$desc = "<p style=\"font-size:smaller;font-style:bold;margin:0\">Tag $object as...</p>";
|
803 |
|
825 |
<div class="tagsdiv" id="<?php echo $params['id']; ?>">
|
826 |
<div class="jaxtag">
|
827 |
<div class="nojs-tags hide-if-js">
|
828 |
+
<p><?php echo $oTaxLabels->add_or_remove_items; ?></p>
|
829 |
<textarea name="<?php echo $params['textarea_name']; ?>" class="the-tags" id="<?php echo $params['textarea_id']; ?>"><?php echo esc_attr(implode(",", $tags)); ?></textarea></div>
|
830 |
|
831 |
+
<?php if ( current_user_can($oTax->cap->assign_terms) ) :?>
|
832 |
<div class="ajaxtag hide-if-no-js">
|
833 |
<label class="screen-reader-text" for="<?php echo $params['input_id']; ?>"><?php echo $params['box_title']; ?></label>
|
834 |
+
<div class="taghint"><?php echo $oTaxLabels->add_new_item; ?></div>
|
835 |
<p><input type="text" id="<?php print $params['input_id']; ?>" name="<?php print $params['input_name']; ?>" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
|
836 |
<input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" /></p>
|
837 |
</div>
|
838 |
+
<p class="howto"><?php echo esc_attr( $oTaxLabels->separate_items_with_commas ); ?></p>
|
839 |
<?php endif; ?>
|
840 |
</div>
|
841 |
|
842 |
<div class="tagchecklist"></div>
|
843 |
</div>
|
844 |
+
<?php if ( current_user_can($oTax->cap->assign_terms) ) : ?>
|
845 |
+
<p class="hide-if-no-js"><a href="#titlediv" class="tagcloud-link" id="link-<?php echo $tax_name; ?>"><?php echo $oTaxLabels->choose_from_most_used; ?></a></p>
|
846 |
<?php endif;
|
847 |
|
848 |
}
|
857 |
$prefix = (isset($params['prefix']) ? $params['prefix'] : '');
|
858 |
$taxonomy = (isset($params['taxonomy']) ? $params['taxonomy'] : 'category');
|
859 |
endif;
|
860 |
+
|
861 |
+
$oTax = get_taxonomy($taxonomy);
|
862 |
+
$oTaxLabels = get_taxonomy_labels($oTax);
|
863 |
|
864 |
if (strlen($prefix) > 0) :
|
865 |
$idPrefix = $prefix.'-';
|
875 |
<div id="<?php print $idPrefix; ?>taxonomy-<?php print $taxonomy; ?>" class="feedwordpress-category-div">
|
876 |
<ul id="<?php print $idPrefix; ?><?php print $taxonomy; ?>-tabs" class="category-tabs">
|
877 |
<li class="ui-tabs-selected tabs"><a href="#<?php print $idPrefix; ?><?php print $taxonomy; ?>-all" tabindex="3"><?php _e( 'All posts' ); ?></a>
|
878 |
+
<p style="font-size:smaller;font-style:bold;margin:0">Give <?php print $object; ?> these <?php print $oTaxLabels->name; ?></p>
|
879 |
</li>
|
880 |
</ul>
|
881 |
|
@@ -7,7 +7,7 @@ class FeedWordPressAuthorsPage extends FeedWordPressAdminPage {
|
|
7 |
|
8 |
public function __construct( $link = -1 ) {
|
9 |
if (is_numeric($link) and -1 == $link) :
|
10 |
-
$link =
|
11 |
endif;
|
12 |
|
13 |
parent::__construct('feedwordpressauthors', $link);
|
7 |
|
8 |
public function __construct( $link = -1 ) {
|
9 |
if (is_numeric($link) and -1 == $link) :
|
10 |
+
$link = $this->submitted_link();
|
11 |
endif;
|
12 |
|
13 |
parent::__construct('feedwordpressauthors', $link);
|
@@ -85,7 +85,7 @@ class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
|
|
85 |
*/
|
86 |
public function __construct( $link = -1 ) {
|
87 |
if (is_numeric($link) and -1 == $link) :
|
88 |
-
$link =
|
89 |
endif;
|
90 |
|
91 |
parent::__construct('feedwordpressfeeds', $link);
|
85 |
*/
|
86 |
public function __construct( $link = -1 ) {
|
87 |
if (is_numeric($link) and -1 == $link) :
|
88 |
+
$link = $this->submitted_link();
|
89 |
endif;
|
90 |
|
91 |
parent::__construct('feedwordpressfeeds', $link);
|
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: FeedWordPress
|
4 |
Plugin URI: http://feedwordpress.radgeek.com/
|
5 |
Description: simple and flexible Atom/RSS syndication for WordPress
|
6 |
-
Version: 2016.
|
7 |
Author: Charles Johnson
|
8 |
Author URI: http://radgeek.com/
|
9 |
License: GPL
|
@@ -11,7 +11,7 @@ License: GPL
|
|
11 |
|
12 |
/**
|
13 |
* @package FeedWordPress
|
14 |
-
* @version 2016.
|
15 |
*/
|
16 |
|
17 |
# This uses code derived from:
|
@@ -32,7 +32,7 @@ License: GPL
|
|
32 |
|
33 |
# -- Don't change these unless you know what you're doing...
|
34 |
|
35 |
-
define ('FEEDWORDPRESS_VERSION', '2016.
|
36 |
define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
|
37 |
|
38 |
if (!defined('FEEDWORDPRESS_BLEG')) :
|
@@ -91,21 +91,39 @@ endif;
|
|
91 |
// Use our the cache settings that we want.
|
92 |
add_filter('wp_feed_cache_transient_lifetime', array('FeedWordPress', 'cache_lifetime'));
|
93 |
|
94 |
-
//
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
-
|
106 |
-
|
|
|
107 |
endif;
|
108 |
|
|
|
109 |
$dir = dirname(__FILE__);
|
110 |
require_once("${dir}/externals/myphp/myphp.class.php");
|
111 |
require_once("${dir}/admin-ui.php");
|
@@ -1804,7 +1822,7 @@ class FeedWordPress {
|
|
1804 |
global $wpdb;
|
1805 |
|
1806 |
// Explicit update request in the HTTP request (e.g. from a cron job)
|
1807 |
-
if (
|
1808 |
|
1809 |
$this->update_hooked = "Initiating a CRON JOB CHECK-IN ON UPDATE SCHEDULE due to URL parameter = ".trim($this->val($_REQUEST['update_feedwordpress']));
|
1810 |
|
@@ -1837,7 +1855,7 @@ class FeedWordPress {
|
|
1837 |
endif;
|
1838 |
} /* FeedWordPress::update_magic_url () */
|
1839 |
|
1840 |
-
public function update_requested () {
|
1841 |
return MyPHP::request('update_feedwordpress');
|
1842 |
} /* FeedWordPress::update_requested() */
|
1843 |
|
@@ -2310,24 +2328,24 @@ class FeedWordPress {
|
|
2310 |
|
2311 |
$diagnostic_nesting = count(explode(":", $level));
|
2312 |
|
2313 |
-
if (
|
2314 |
foreach ($output as $method) :
|
2315 |
switch ($method) :
|
2316 |
case 'echo' :
|
2317 |
-
if (!
|
2318 |
echo "<div><pre><strong>Diag".str_repeat('====', $diagnostic_nesting-1).'|</strong> '.$out."</pre></div>\n";
|
2319 |
endif;
|
2320 |
break;
|
2321 |
case 'echo_in_cronjob' :
|
2322 |
-
if (
|
2323 |
-
echo
|
2324 |
endif;
|
2325 |
break;
|
2326 |
case 'admin_footer' :
|
2327 |
$feedwordpress_admin_footer[] = $out;
|
2328 |
break;
|
2329 |
case 'error_log' :
|
2330 |
-
error_log(
|
2331 |
break;
|
2332 |
case 'email' :
|
2333 |
|
3 |
Plugin Name: FeedWordPress
|
4 |
Plugin URI: http://feedwordpress.radgeek.com/
|
5 |
Description: simple and flexible Atom/RSS syndication for WordPress
|
6 |
+
Version: 2016.1213
|
7 |
Author: Charles Johnson
|
8 |
Author URI: http://radgeek.com/
|
9 |
License: GPL
|
11 |
|
12 |
/**
|
13 |
* @package FeedWordPress
|
14 |
+
* @version 2016.1213
|
15 |
*/
|
16 |
|
17 |
# This uses code derived from:
|
32 |
|
33 |
# -- Don't change these unless you know what you're doing...
|
34 |
|
35 |
+
define ('FEEDWORDPRESS_VERSION', '2016.1213');
|
36 |
define ('FEEDWORDPRESS_AUTHOR_CONTACT', 'http://radgeek.com/contact');
|
37 |
|
38 |
if (!defined('FEEDWORDPRESS_BLEG')) :
|
91 |
// Use our the cache settings that we want.
|
92 |
add_filter('wp_feed_cache_transient_lifetime', array('FeedWordPress', 'cache_lifetime'));
|
93 |
|
94 |
+
// Dependencies: modules packaged with WordPress core
|
95 |
+
$wpCoreDependencies = array(
|
96 |
+
"class:SimplePie" => "class-simplepie",
|
97 |
+
"class:WP_Feed_Cache" => "class-wp-feed-cache",
|
98 |
+
"class:WP_Feed_Cache_Transient" => "class-wp-feed-cache-transient",
|
99 |
+
"class:WP_SimplePie_File" => "class-wp-simplepie-file",
|
100 |
+
"class:WP_SimplePie_Sanitize_KSES" => "class-wp-simplepie-sanitize-kses",
|
101 |
+
"function:wp_insert_user" => "registration",
|
102 |
+
);
|
103 |
|
104 |
+
// Ensure that we have SimplePie loaded up and ready to go
|
105 |
+
// along with the WordPress auxiliary classes.
|
106 |
+
$unmetCoreDependencies = array();
|
107 |
+
foreach ($wpCoreDependencies as $unit => $fileSlug) :
|
108 |
+
list($unitType, $unitName) = explode(":", $unit, 2);
|
109 |
+
|
110 |
+
$dependencyMet = (('class'==$unitType) ? class_exists($unitName) : function_exists($unitName));
|
111 |
+
if (!$dependencyMet) :
|
112 |
+
$phpFileName = ABSPATH . WPINC . "/${fileSlug}.php";
|
113 |
+
if (file_exists($phpFileName)) :
|
114 |
+
require_once($phpFileName);
|
115 |
+
else :
|
116 |
+
$unmetCoreDependencies[] = $unitName;
|
117 |
+
endif;
|
118 |
+
endif;
|
119 |
+
endforeach;
|
120 |
|
121 |
+
// Fallback garbage-pail module used in WP < 4.7 which may meet our dependencies
|
122 |
+
if (count($unmetCoreDependencies) > 0) :
|
123 |
+
require_once(ABSPATH . WPINC . "/class-feed.php");
|
124 |
endif;
|
125 |
|
126 |
+
// Dependences: modules packaged with FeedWordPress plugin
|
127 |
$dir = dirname(__FILE__);
|
128 |
require_once("${dir}/externals/myphp/myphp.class.php");
|
129 |
require_once("${dir}/admin-ui.php");
|
1822 |
global $wpdb;
|
1823 |
|
1824 |
// Explicit update request in the HTTP request (e.g. from a cron job)
|
1825 |
+
if (self::update_requested()) :
|
1826 |
|
1827 |
$this->update_hooked = "Initiating a CRON JOB CHECK-IN ON UPDATE SCHEDULE due to URL parameter = ".trim($this->val($_REQUEST['update_feedwordpress']));
|
1828 |
|
1855 |
endif;
|
1856 |
} /* FeedWordPress::update_magic_url () */
|
1857 |
|
1858 |
+
public static function update_requested () {
|
1859 |
return MyPHP::request('update_feedwordpress');
|
1860 |
} /* FeedWordPress::update_requested() */
|
1861 |
|
2328 |
|
2329 |
$diagnostic_nesting = count(explode(":", $level));
|
2330 |
|
2331 |
+
if (self::diagnostic_on($level)) :
|
2332 |
foreach ($output as $method) :
|
2333 |
switch ($method) :
|
2334 |
case 'echo' :
|
2335 |
+
if (!self::update_requested()) :
|
2336 |
echo "<div><pre><strong>Diag".str_repeat('====', $diagnostic_nesting-1).'|</strong> '.$out."</pre></div>\n";
|
2337 |
endif;
|
2338 |
break;
|
2339 |
case 'echo_in_cronjob' :
|
2340 |
+
if (self::update_requested()) :
|
2341 |
+
echo self::log_prefix()." ".$out."\n";
|
2342 |
endif;
|
2343 |
break;
|
2344 |
case 'admin_footer' :
|
2345 |
$feedwordpress_admin_footer[] = $out;
|
2346 |
break;
|
2347 |
case 'error_log' :
|
2348 |
+
error_log(self::log_prefix().' '.$out);
|
2349 |
break;
|
2350 |
case 'email' :
|
2351 |
|
@@ -13,7 +13,7 @@ class FeedWordPressPostsPage extends FeedWordPressAdminPage {
|
|
13 |
*/
|
14 |
public function __construct( $link = -1 ) {
|
15 |
if (is_numeric($link) and -1 == $link) :
|
16 |
-
$link =
|
17 |
endif;
|
18 |
|
19 |
parent::__construct('feedwordpresspostspage', $link);
|
13 |
*/
|
14 |
public function __construct( $link = -1 ) {
|
15 |
if (is_numeric($link) and -1 == $link) :
|
16 |
+
$link = $this->submitted_link();
|
17 |
endif;
|
18 |
|
19 |
parent::__construct('feedwordpresspostspage', $link);
|
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: Charles Johnson
|
3 |
Donate link: http://feedwordpress.radgeek.com/
|
4 |
Tags: syndication, aggregation, feed, atom, rss
|
5 |
-
Requires at least:
|
6 |
Tested up to: 4.7
|
7 |
-
Stable tag: 2016.
|
8 |
|
9 |
FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
|
10 |
|
@@ -93,6 +93,29 @@ outs, see the documentation at the [FeedWordPress project homepage][].
|
|
93 |
|
94 |
== Changelog ==
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
= 2016.1211 =
|
97 |
|
98 |
* WORDPRESS COMPATIBILITY: Tested with new versions of WordPress up to 4.7.
|
2 |
Contributors: Charles Johnson
|
3 |
Donate link: http://feedwordpress.radgeek.com/
|
4 |
Tags: syndication, aggregation, feed, atom, rss
|
5 |
+
Requires at least: 4.5
|
6 |
Tested up to: 4.7
|
7 |
+
Stable tag: 2016.1213
|
8 |
|
9 |
FeedWordPress syndicates content from feeds you choose into your WordPress weblog.
|
10 |
|
93 |
|
94 |
== Changelog ==
|
95 |
|
96 |
+
= 2016.1213 =
|
97 |
+
|
98 |
+
* WORDPRSS BACKWARD COMPATIBILITY FOR VERSIONS [4.5, 4.7]: This change fixes
|
99 |
+
a fatal PHP error (on some web server configurations you'd see the message
|
100 |
+
"Fatal error: require_once(): Failed opening required '[...]/wp-includes/class-wp-feed-cache.php'"
|
101 |
+
on others, you might just see an HTTP 500 Internal Server Error or a blank
|
102 |
+
page) when using FeedWordPress with versions of WordPress before 4.7. A
|
103 |
+
change that I introduced to avoid a code module that had been deprecated in
|
104 |
+
version 4.7 ended up relying on code modules that were only introduced as
|
105 |
+
of version 4.7; so now, instead, FeedWordPress attempts to detect which
|
106 |
+
modules the current version of the WordPress core makes available, and load
|
107 |
+
the right modules depending on your WordPress version.
|
108 |
+
|
109 |
+
In theory, up to this point, FeedWordPress supported any version of
|
110 |
+
WordPress from version 3.0 onward. In practice, version 3.0 was released
|
111 |
+
over 6 years ago, and I can realistically commit only to testing out new
|
112 |
+
releases of FeedWordPress with a few prior versions of WordPress; so I've
|
113 |
+
updated the "Requires at least" field to version 4.5, the first major
|
114 |
+
release issued in 2016. If you've really got to use FeedWordPress with
|
115 |
+
older versions of WordPress, it will probably still work with any moderately
|
116 |
+
modern release of WordPress, but I won't promise to keep it working with
|
117 |
+
releases of WordPress that are more than about a year old.
|
118 |
+
|
119 |
= 2016.1211 =
|
120 |
|
121 |
* WORDPRESS COMPATIBILITY: Tested with new versions of WordPress up to 4.7.
|
@@ -43,7 +43,7 @@ class SyndicatedLink {
|
|
43 |
public $simplepie = null;
|
44 |
var $magpie = null;
|
45 |
|
46 |
-
function __construct( $link ) {
|
47 |
global $wpdb;
|
48 |
|
49 |
if (is_object($link)) :
|
@@ -54,26 +54,24 @@ class SyndicatedLink {
|
|
54 |
$this->link = get_bookmark($link);
|
55 |
endif;
|
56 |
|
57 |
-
if (
|
58 |
-
$this->
|
|
|
|
|
59 |
endif;
|
60 |
|
61 |
add_filter('feedwordpress_update_complete', array($this, 'process_retirements'), 1000, 1);
|
62 |
-
} /* SyndicatedLink::
|
63 |
-
|
64 |
-
function SyndicatedLink( $link ) {
|
65 |
-
self::__construct( $link );
|
66 |
-
}
|
67 |
|
68 |
-
function found () {
|
69 |
return is_object($this->link) and !is_wp_error($this->link);
|
70 |
} /* SyndicatedLink::found () */
|
71 |
|
72 |
-
function id () {
|
73 |
return (is_object($this->link) ? $this->link->link_id : NULL);
|
74 |
}
|
75 |
|
76 |
-
function stale () {
|
77 |
global $feedwordpress;
|
78 |
|
79 |
$stale = true;
|
@@ -96,7 +94,7 @@ class SyndicatedLink {
|
|
96 |
return $stale;
|
97 |
} /* SyndicatedLink::stale () */
|
98 |
|
99 |
-
function fetch () {
|
100 |
$timeout = $this->setting('fetch timeout', 'feedwordpress_fetch_timeout', FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT);
|
101 |
|
102 |
$this->simplepie = apply_filters(
|
@@ -111,8 +109,9 @@ class SyndicatedLink {
|
|
111 |
else :
|
112 |
$this->magpie = new MagpieFromSimplePie($this->simplepie, NULL);
|
113 |
endif;
|
114 |
-
}
|
115 |
-
|
|
|
116 |
if (!is_object($this->simplepie)) :
|
117 |
$this->fetch();
|
118 |
endif;
|
@@ -127,9 +126,9 @@ class SyndicatedLink {
|
|
127 |
$ret = $this->simplepie;
|
128 |
endif;
|
129 |
return $ret;
|
130 |
-
}
|
131 |
|
132 |
-
function poll ($crash_ts = NULL) {
|
133 |
global $wpdb;
|
134 |
|
135 |
$url = $this->uri(array('add_params' => true, 'fetch' => true));
|
@@ -365,7 +364,7 @@ class SyndicatedLink {
|
|
365 |
return $new_count;
|
366 |
} /* SyndicatedLink::poll() */
|
367 |
|
368 |
-
function process_retirements ($delta) {
|
369 |
global $post;
|
370 |
|
371 |
$q = new WP_Query(array(
|
@@ -386,7 +385,7 @@ class SyndicatedLink {
|
|
386 |
endif;
|
387 |
|
388 |
return $delta;
|
389 |
-
}
|
390 |
|
391 |
/**
|
392 |
* Updates the URL for the feed syndicated by this link.
|
@@ -394,7 +393,7 @@ class SyndicatedLink {
|
|
394 |
* @param string $url The new feed URL to use for this source.
|
395 |
* @return bool TRUE on success, FALSE on failure.
|
396 |
*/
|
397 |
-
function set_uri ($url) {
|
398 |
global $wpdb;
|
399 |
|
400 |
if ($this->found()) :
|
@@ -413,7 +412,7 @@ class SyndicatedLink {
|
|
413 |
return $ret;
|
414 |
} /* SyndicatedLink::set_uri () */
|
415 |
|
416 |
-
function deactivate () {
|
417 |
global $wpdb;
|
418 |
|
419 |
$wpdb->query($wpdb->prepare("
|
@@ -421,7 +420,18 @@ class SyndicatedLink {
|
|
421 |
", (int) $this->id));
|
422 |
} /* SyndicatedLink::deactivate () */
|
423 |
|
424 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
425 |
global $wpdb;
|
426 |
|
427 |
$wpdb->query($wpdb->prepare("
|
@@ -436,7 +446,16 @@ class SyndicatedLink {
|
|
436 |
$this->id = NULL;
|
437 |
} /* SyndicatedLink::delete () */
|
438 |
|
439 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
global $wpdb;
|
441 |
|
442 |
// Make a list of the items syndicated from this feed...
|
@@ -461,7 +480,7 @@ class SyndicatedLink {
|
|
461 |
$this->delete();
|
462 |
} /* SyndicatedLink::nuke () */
|
463 |
|
464 |
-
function map_name_to_new_user ($name, $newuser_name) {
|
465 |
global $wpdb;
|
466 |
|
467 |
if (strlen($newuser_name) > 0) :
|
@@ -482,11 +501,11 @@ class SyndicatedLink {
|
|
482 |
endif;
|
483 |
} /* SyndicatedLink::map_name_to_new_user () */
|
484 |
|
485 |
-
function imploded_settings () {
|
486 |
return array('cats', 'tags', 'match/cats', 'match/tags', 'match/filter');
|
487 |
-
}
|
488 |
|
489 |
-
function get_settings_from_notes () {
|
490 |
// Read off feed settings from link_notes
|
491 |
$notes = explode("\n", $this->link->link_notes);
|
492 |
foreach ($notes as $note):
|
@@ -587,7 +606,7 @@ class SyndicatedLink {
|
|
587 |
|
588 |
} /* SyndicatedLink::get_settings_from_notes () */
|
589 |
|
590 |
-
function settings_to_notes () {
|
591 |
$to_notes = $this->settings;
|
592 |
|
593 |
unset($to_notes['link/id']); // Magic setting; don't save
|
@@ -633,7 +652,7 @@ class SyndicatedLink {
|
|
633 |
return $notes;
|
634 |
} /* SyndicatedLink::settings_to_notes () */
|
635 |
|
636 |
-
function save_settings ($reload = false) {
|
637 |
global $wpdb;
|
638 |
|
639 |
// Save channel-level meta-data
|
@@ -670,7 +689,7 @@ class SyndicatedLink {
|
|
670 |
* @param mixed $fallback_value If the link setting and the global setting are nonexistent or marked as a use-default value, fall back to this constant value.
|
671 |
* @return bool TRUE on success, FALSE on failure.
|
672 |
*/
|
673 |
-
function setting ($name, $fallback_global = NULL, $fallback_value = NULL, $default = 'default') {
|
674 |
$ret = NULL;
|
675 |
if (isset($this->settings[$name])) :
|
676 |
$ret = $this->settings[$name];
|
@@ -704,12 +723,12 @@ class SyndicatedLink {
|
|
704 |
return $ret;
|
705 |
} /* SyndicatedLink::setting () */
|
706 |
|
707 |
-
function merge_settings ($data, $prefix, $separator = '/') {
|
708 |
$dd = $this->flatten_array($data, $prefix, $separator);
|
709 |
$this->settings = array_merge($this->settings, $dd);
|
710 |
} /* SyndicatedLink::merge_settings () */
|
711 |
|
712 |
-
function update_setting ($name, $value, $default = 'default') {
|
713 |
if (!is_null($value) and $value != $default) :
|
714 |
$this->settings[$name] = $value;
|
715 |
else : // Zap it.
|
@@ -717,11 +736,11 @@ class SyndicatedLink {
|
|
717 |
endif;
|
718 |
} /* SyndicatedLink::update_setting () */
|
719 |
|
720 |
-
function is_non_incremental () {
|
721 |
return ('complete'==$this->setting('update_incremental', 'update_incremental', 'incremental'));
|
722 |
} /* SyndicatedLink::is_non_incremental () */
|
723 |
|
724 |
-
function uri ($params = array()) {
|
725 |
$params = wp_parse_args($params, array(
|
726 |
'add_params' => false,
|
727 |
'fetch' => false,
|
@@ -763,15 +782,15 @@ class SyndicatedLink {
|
|
763 |
return $uri;
|
764 |
} /* SyndicatedLink::uri () */
|
765 |
|
766 |
-
function username () {
|
767 |
return $this->setting('http username', 'http_username', NULL);
|
768 |
} /* SyndicatedLink::username () */
|
769 |
|
770 |
-
function password () {
|
771 |
return $this->setting('http password', 'http_password', NULL);
|
772 |
} /* SyndicatedLink::password () */
|
773 |
|
774 |
-
function authentication_method () {
|
775 |
$auth = $this->setting('http auth method', NULL);
|
776 |
if (('-' == $auth) or (strlen($auth)==0)) :
|
777 |
$auth = NULL;
|
@@ -780,7 +799,7 @@ class SyndicatedLink {
|
|
780 |
} /* SyndicatedLink::authentication_method () */
|
781 |
|
782 |
var $postmeta = array();
|
783 |
-
function postmeta ($params = array()) {
|
784 |
$params = wp_parse_args($params, /*defaults=*/ array(
|
785 |
"field" => NULL,
|
786 |
"parsed" => false,
|
@@ -824,7 +843,7 @@ class SyndicatedLink {
|
|
824 |
return $ret;
|
825 |
} /* SyndicatedLink::postmeta () */
|
826 |
|
827 |
-
function property_cascade ($fromFeed, $link_field, $setting, $method) {
|
828 |
$value = NULL;
|
829 |
if ($fromFeed) :
|
830 |
$value = $this->setting($setting, NULL, NULL, NULL);
|
@@ -840,15 +859,15 @@ class SyndicatedLink {
|
|
840 |
return $value;
|
841 |
} /* SyndicatedLink::property_cascade () */
|
842 |
|
843 |
-
function homepage ($fromFeed = true) {
|
844 |
return $this->property_cascade($fromFeed, 'link_url', 'feed/link', 'get_link');
|
845 |
} /* SyndicatedLink::homepage () */
|
846 |
|
847 |
-
function name ($fromFeed = true) {
|
848 |
return $this->property_cascade($fromFeed, 'link_name', 'feed/title', 'get_title');
|
849 |
} /* SyndicatedLink::name () */
|
850 |
|
851 |
-
function guid () {
|
852 |
$ret = $this->setting('feed/id', NULL, $this->uri());
|
853 |
|
854 |
// If we can get it live from the feed, do so.
|
@@ -875,7 +894,7 @@ class SyndicatedLink {
|
|
875 |
return $ret;
|
876 |
}
|
877 |
|
878 |
-
function links ($params = array()) {
|
879 |
$params = wp_parse_args($params, array(
|
880 |
"rel" => NULL,
|
881 |
));
|
@@ -929,7 +948,7 @@ class SyndicatedLink {
|
|
929 |
return $ret;
|
930 |
}
|
931 |
|
932 |
-
function ttl ($return_element = false) {
|
933 |
if (is_object($this->magpie)) :
|
934 |
$channel = $this->magpie->channel;
|
935 |
else :
|
@@ -986,7 +1005,7 @@ class SyndicatedLink {
|
|
986 |
return ($return_element ? array($ret, $xml) : $ret);
|
987 |
} /* SyndicatedLink::ttl() */
|
988 |
|
989 |
-
function automatic_ttl () {
|
990 |
// spread out over a time interval for staggered updates
|
991 |
$updateWindow = $this->setting('update/window', 'update_window', DEFAULT_UPDATE_PERIOD);
|
992 |
if (!is_numeric($updateWindow) or ($updateWindow < 1)) :
|
@@ -999,16 +1018,23 @@ class SyndicatedLink {
|
|
999 |
return apply_filters('syndicated_feed_automatic_ttl', $fudgedInterval, $this);
|
1000 |
} /* SyndicatedLink::automatic_ttl () */
|
1001 |
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1012 |
$ret = array ();
|
1013 |
if (is_array($arr)) :
|
1014 |
foreach ($arr as $key => $value) :
|
@@ -1022,7 +1048,7 @@ class SyndicatedLink {
|
|
1022 |
return $ret;
|
1023 |
} /* SyndicatedLink::flatten_array () */
|
1024 |
|
1025 |
-
function hardcode ($what) {
|
1026 |
|
1027 |
$ret = $this->setting('hardcode '.$what, 'hardcode_'.$what, NULL);
|
1028 |
|
@@ -1034,7 +1060,7 @@ class SyndicatedLink {
|
|
1034 |
return $ret;
|
1035 |
} /* SyndicatedLink::hardcode () */
|
1036 |
|
1037 |
-
function syndicated_status ($what, $default, $fallback = true) {
|
1038 |
global $wpdb;
|
1039 |
|
1040 |
$g_set = ($fallback ? 'syndicated_' . $what . '_status' : NULL);
|
@@ -1043,7 +1069,7 @@ class SyndicatedLink {
|
|
1043 |
return esc_sql(trim(strtolower($ret)));
|
1044 |
} /* SyndicatedLink:syndicated_status () */
|
1045 |
|
1046 |
-
function taxonomies () {
|
1047 |
$post_type = $this->setting('syndicated post type', 'syndicated_post_type', 'post');
|
1048 |
return get_object_taxonomies(array('object_type' => $post_type), 'names');
|
1049 |
} /* SyndicatedLink::taxonomies () */
|
@@ -1057,7 +1083,7 @@ class SyndicatedLink {
|
|
1057 |
* @param array|null $taxonomies
|
1058 |
* @return array
|
1059 |
*/
|
1060 |
-
function category_ids ($post, $cats, $unfamiliar_category = 'create', $taxonomies = NULL, $params = array()) {
|
1061 |
$singleton = (isset($params['singleton']) ? $params['singleton'] : true);
|
1062 |
$allowFilters = (isset($params['filters']) ? $params['filters'] : false);
|
1063 |
|
@@ -1154,5 +1180,5 @@ class SyndicatedLink {
|
|
1154 |
);
|
1155 |
return $terms;
|
1156 |
} /* SyndicatedLink::category_ids () */
|
1157 |
-
}
|
1158 |
|
43 |
public $simplepie = null;
|
44 |
var $magpie = null;
|
45 |
|
46 |
+
public function __construct( $link ) {
|
47 |
global $wpdb;
|
48 |
|
49 |
if (is_object($link)) :
|
54 |
$this->link = get_bookmark($link);
|
55 |
endif;
|
56 |
|
57 |
+
if (is_object($this->link)) :
|
58 |
+
if (strlen($this->link->link_rss) > 0) :
|
59 |
+
$this->get_settings_from_notes();
|
60 |
+
endif;
|
61 |
endif;
|
62 |
|
63 |
add_filter('feedwordpress_update_complete', array($this, 'process_retirements'), 1000, 1);
|
64 |
+
} /* SyndicatedLink::__construct () */
|
|
|
|
|
|
|
|
|
65 |
|
66 |
+
public function found () {
|
67 |
return is_object($this->link) and !is_wp_error($this->link);
|
68 |
} /* SyndicatedLink::found () */
|
69 |
|
70 |
+
public function id () {
|
71 |
return (is_object($this->link) ? $this->link->link_id : NULL);
|
72 |
}
|
73 |
|
74 |
+
public function stale () {
|
75 |
global $feedwordpress;
|
76 |
|
77 |
$stale = true;
|
94 |
return $stale;
|
95 |
} /* SyndicatedLink::stale () */
|
96 |
|
97 |
+
public function fetch () {
|
98 |
$timeout = $this->setting('fetch timeout', 'feedwordpress_fetch_timeout', FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT);
|
99 |
|
100 |
$this->simplepie = apply_filters(
|
109 |
else :
|
110 |
$this->magpie = new MagpieFromSimplePie($this->simplepie, NULL);
|
111 |
endif;
|
112 |
+
} /* SyndicatedLink::fetch () */
|
113 |
+
|
114 |
+
public function live_posts () {
|
115 |
if (!is_object($this->simplepie)) :
|
116 |
$this->fetch();
|
117 |
endif;
|
126 |
$ret = $this->simplepie;
|
127 |
endif;
|
128 |
return $ret;
|
129 |
+
} /* SyndicatedLink::live_posts () */
|
130 |
|
131 |
+
public function poll ($crash_ts = NULL) {
|
132 |
global $wpdb;
|
133 |
|
134 |
$url = $this->uri(array('add_params' => true, 'fetch' => true));
|
364 |
return $new_count;
|
365 |
} /* SyndicatedLink::poll() */
|
366 |
|
367 |
+
public function process_retirements ($delta) {
|
368 |
global $post;
|
369 |
|
370 |
$q = new WP_Query(array(
|
385 |
endif;
|
386 |
|
387 |
return $delta;
|
388 |
+
} /* SyndicatedLink::process_retirements () */
|
389 |
|
390 |
/**
|
391 |
* Updates the URL for the feed syndicated by this link.
|
393 |
* @param string $url The new feed URL to use for this source.
|
394 |
* @return bool TRUE on success, FALSE on failure.
|
395 |
*/
|
396 |
+
public function set_uri ($url) {
|
397 |
global $wpdb;
|
398 |
|
399 |
if ($this->found()) :
|
412 |
return $ret;
|
413 |
} /* SyndicatedLink::set_uri () */
|
414 |
|
415 |
+
public function deactivate () {
|
416 |
global $wpdb;
|
417 |
|
418 |
$wpdb->query($wpdb->prepare("
|
420 |
", (int) $this->id));
|
421 |
} /* SyndicatedLink::deactivate () */
|
422 |
|
423 |
+
/**
|
424 |
+
* SyndicatedLink::delete() deletes a subscription from the WordPress links
|
425 |
+
* table. Any posts that were syndicated through that subscription will still
|
426 |
+
* be present in the wp_posts table; but postmeta fields that refer to the
|
427 |
+
* syndication feed's numeric id (which will no longer be valid) will be
|
428 |
+
* deleted. For most purposes, the posts remaining will be treated as if they
|
429 |
+
* were locally authored posts rather than syndicated posts.
|
430 |
+
*
|
431 |
+
* @global $wpdb
|
432 |
+
* @uses wpdb::query
|
433 |
+
*/
|
434 |
+
public function delete () {
|
435 |
global $wpdb;
|
436 |
|
437 |
$wpdb->query($wpdb->prepare("
|
446 |
$this->id = NULL;
|
447 |
} /* SyndicatedLink::delete () */
|
448 |
|
449 |
+
/**
|
450 |
+
* SyndicatedLink::nuke() deletes a subscription AND all of the
|
451 |
+
* posts syndicated through that subscription.
|
452 |
+
*
|
453 |
+
* @global $wpdb
|
454 |
+
* @uses wpdb::get_col
|
455 |
+
* @uses wp_delete_post
|
456 |
+
* @uses SyndicatedLink::delete
|
457 |
+
*/
|
458 |
+
public function nuke () {
|
459 |
global $wpdb;
|
460 |
|
461 |
// Make a list of the items syndicated from this feed...
|
480 |
$this->delete();
|
481 |
} /* SyndicatedLink::nuke () */
|
482 |
|
483 |
+
public function map_name_to_new_user ($name, $newuser_name) {
|
484 |
global $wpdb;
|
485 |
|
486 |
if (strlen($newuser_name) > 0) :
|
501 |
endif;
|
502 |
} /* SyndicatedLink::map_name_to_new_user () */
|
503 |
|
504 |
+
protected function imploded_settings () {
|
505 |
return array('cats', 'tags', 'match/cats', 'match/tags', 'match/filter');
|
506 |
+
} /* SyndicatedLink::imploded_settings () */
|
507 |
|
508 |
+
protected function get_settings_from_notes () {
|
509 |
// Read off feed settings from link_notes
|
510 |
$notes = explode("\n", $this->link->link_notes);
|
511 |
foreach ($notes as $note):
|
606 |
|
607 |
} /* SyndicatedLink::get_settings_from_notes () */
|
608 |
|
609 |
+
protected function settings_to_notes () {
|
610 |
$to_notes = $this->settings;
|
611 |
|
612 |
unset($to_notes['link/id']); // Magic setting; don't save
|
652 |
return $notes;
|
653 |
} /* SyndicatedLink::settings_to_notes () */
|
654 |
|
655 |
+
public function save_settings ($reload = false) {
|
656 |
global $wpdb;
|
657 |
|
658 |
// Save channel-level meta-data
|
689 |
* @param mixed $fallback_value If the link setting and the global setting are nonexistent or marked as a use-default value, fall back to this constant value.
|
690 |
* @return bool TRUE on success, FALSE on failure.
|
691 |
*/
|
692 |
+
public function setting ($name, $fallback_global = NULL, $fallback_value = NULL, $default = 'default') {
|
693 |
$ret = NULL;
|
694 |
if (isset($this->settings[$name])) :
|
695 |
$ret = $this->settings[$name];
|
723 |
return $ret;
|
724 |
} /* SyndicatedLink::setting () */
|
725 |
|
726 |
+
public function merge_settings ($data, $prefix, $separator = '/') {
|
727 |
$dd = $this->flatten_array($data, $prefix, $separator);
|
728 |
$this->settings = array_merge($this->settings, $dd);
|
729 |
} /* SyndicatedLink::merge_settings () */
|
730 |
|
731 |
+
public function update_setting ($name, $value, $default = 'default') {
|
732 |
if (!is_null($value) and $value != $default) :
|
733 |
$this->settings[$name] = $value;
|
734 |
else : // Zap it.
|
736 |
endif;
|
737 |
} /* SyndicatedLink::update_setting () */
|
738 |
|
739 |
+
public function is_non_incremental () {
|
740 |
return ('complete'==$this->setting('update_incremental', 'update_incremental', 'incremental'));
|
741 |
} /* SyndicatedLink::is_non_incremental () */
|
742 |
|
743 |
+
public function uri ($params = array()) {
|
744 |
$params = wp_parse_args($params, array(
|
745 |
'add_params' => false,
|
746 |
'fetch' => false,
|
782 |
return $uri;
|
783 |
} /* SyndicatedLink::uri () */
|
784 |
|
785 |
+
public function username () {
|
786 |
return $this->setting('http username', 'http_username', NULL);
|
787 |
} /* SyndicatedLink::username () */
|
788 |
|
789 |
+
public function password () {
|
790 |
return $this->setting('http password', 'http_password', NULL);
|
791 |
} /* SyndicatedLink::password () */
|
792 |
|
793 |
+
public function authentication_method () {
|
794 |
$auth = $this->setting('http auth method', NULL);
|
795 |
if (('-' == $auth) or (strlen($auth)==0)) :
|
796 |
$auth = NULL;
|
799 |
} /* SyndicatedLink::authentication_method () */
|
800 |
|
801 |
var $postmeta = array();
|
802 |
+
public function postmeta ($params = array()) {
|
803 |
$params = wp_parse_args($params, /*defaults=*/ array(
|
804 |
"field" => NULL,
|
805 |
"parsed" => false,
|
843 |
return $ret;
|
844 |
} /* SyndicatedLink::postmeta () */
|
845 |
|
846 |
+
public function property_cascade ($fromFeed, $link_field, $setting, $method) {
|
847 |
$value = NULL;
|
848 |
if ($fromFeed) :
|
849 |
$value = $this->setting($setting, NULL, NULL, NULL);
|
859 |
return $value;
|
860 |
} /* SyndicatedLink::property_cascade () */
|
861 |
|
862 |
+
public function homepage ($fromFeed = true) {
|
863 |
return $this->property_cascade($fromFeed, 'link_url', 'feed/link', 'get_link');
|
864 |
} /* SyndicatedLink::homepage () */
|
865 |
|
866 |
+
public function name ($fromFeed = true) {
|
867 |
return $this->property_cascade($fromFeed, 'link_name', 'feed/title', 'get_title');
|
868 |
} /* SyndicatedLink::name () */
|
869 |
|
870 |
+
public function guid () {
|
871 |
$ret = $this->setting('feed/id', NULL, $this->uri());
|
872 |
|
873 |
// If we can get it live from the feed, do so.
|
894 |
return $ret;
|
895 |
}
|
896 |
|
897 |
+
public function links ($params = array()) {
|
898 |
$params = wp_parse_args($params, array(
|
899 |
"rel" => NULL,
|
900 |
));
|
948 |
return $ret;
|
949 |
}
|
950 |
|
951 |
+
public function ttl ($return_element = false) {
|
952 |
if (is_object($this->magpie)) :
|
953 |
$channel = $this->magpie->channel;
|
954 |
else :
|
1005 |
return ($return_element ? array($ret, $xml) : $ret);
|
1006 |
} /* SyndicatedLink::ttl() */
|
1007 |
|
1008 |
+
public function automatic_ttl () {
|
1009 |
// spread out over a time interval for staggered updates
|
1010 |
$updateWindow = $this->setting('update/window', 'update_window', DEFAULT_UPDATE_PERIOD);
|
1011 |
if (!is_numeric($updateWindow) or ($updateWindow < 1)) :
|
1018 |
return apply_filters('syndicated_feed_automatic_ttl', $fudgedInterval, $this);
|
1019 |
} /* SyndicatedLink::automatic_ttl () */
|
1020 |
|
1021 |
+
/**
|
1022 |
+
* SyndicatedLink::flatten_array (): flatten an array. Useful for
|
1023 |
+
* hierarchical and namespaced elements.
|
1024 |
+
*
|
1025 |
+
* Given an array which may contain array or object elements in it,
|
1026 |
+
* return a "flattened" array: a one-dimensional array of scalars
|
1027 |
+
* containing each of the scalar elements contained within the array
|
1028 |
+
* structure. Thus, for example, if $a['b']['c']['d'] == 'e', then the
|
1029 |
+
* returned array for FeedWordPress::flatten_array($a) will contain a key
|
1030 |
+
* $a['feed/b/c/d'] with value 'e'.
|
1031 |
+
*
|
1032 |
+
* @param array $arr
|
1033 |
+
* @param string $prefix
|
1034 |
+
* @param string $separator
|
1035 |
+
* @return array
|
1036 |
+
*/
|
1037 |
+
public function flatten_array ($arr, $prefix = 'feed/', $separator = '/') {
|
1038 |
$ret = array ();
|
1039 |
if (is_array($arr)) :
|
1040 |
foreach ($arr as $key => $value) :
|
1048 |
return $ret;
|
1049 |
} /* SyndicatedLink::flatten_array () */
|
1050 |
|
1051 |
+
public function hardcode ($what) {
|
1052 |
|
1053 |
$ret = $this->setting('hardcode '.$what, 'hardcode_'.$what, NULL);
|
1054 |
|
1060 |
return $ret;
|
1061 |
} /* SyndicatedLink::hardcode () */
|
1062 |
|
1063 |
+
public function syndicated_status ($what, $default, $fallback = true) {
|
1064 |
global $wpdb;
|
1065 |
|
1066 |
$g_set = ($fallback ? 'syndicated_' . $what . '_status' : NULL);
|
1069 |
return esc_sql(trim(strtolower($ret)));
|
1070 |
} /* SyndicatedLink:syndicated_status () */
|
1071 |
|
1072 |
+
public function taxonomies () {
|
1073 |
$post_type = $this->setting('syndicated post type', 'syndicated_post_type', 'post');
|
1074 |
return get_object_taxonomies(array('object_type' => $post_type), 'names');
|
1075 |
} /* SyndicatedLink::taxonomies () */
|
1083 |
* @param array|null $taxonomies
|
1084 |
* @return array
|
1085 |
*/
|
1086 |
+
public function category_ids ($post, $cats, $unfamiliar_category = 'create', $taxonomies = NULL, $params = array()) {
|
1087 |
$singleton = (isset($params['singleton']) ? $params['singleton'] : true);
|
1088 |
$allowFilters = (isset($params['filters']) ? $params['filters'] : false);
|
1089 |
|
1180 |
);
|
1181 |
return $terms;
|
1182 |
} /* SyndicatedLink::category_ids () */
|
1183 |
+
} /* class SyndicatedLink */
|
1184 |
|