Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 3 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
6 admin-ui.php
@@ -163,12 +163,12 @@ function update_requested_in ($post) {
);
foreach ($submit_buttons as $field) :
if (isset($fwp_post[$field])) :
- $link_id = $_REQUEST['save_link_id'];
+ $link_id = MyPHP::request('save_link_id');
endif;
endforeach;
if (is_null($link_id) and isset($_REQUEST['link_id'])) :
- $link_id = $_REQUEST['link_id'];
+ $link_id = MyPHP::request('link_id');
endif;
return $link_id;
@@ -187,7 +187,7 @@ function update_requested_in ($post) {
function stamp_link_id ($field = null) {
if (is_null($field)) : $field = 'save_link_id'; endif;
?>
- <input type="hidden" name="<?php print esc_html($field); ?>" value="<?php print ($this->for_feed_settings() ? $this->link->id : '*'); ?>" />
+ <input type="hidden" name="<?php print esc_attr($field); ?>" value="<?php print ($this->for_feed_settings() ? $this->link->id : '*'); ?>" />
<?php
} /* FeedWordPressAdminPage::stamp_link_id () */
View
6 feeds-page.php
@@ -775,9 +775,9 @@ function display_feedfinder () {
$lookup = (isset($_REQUEST['lookup']) ? $_REQUEST['lookup'] : NULL);
- $auth = FeedWordPress::param('link_rss_auth_method');
- $username = FeedWordPress::param('link_rss_username');
- $password = FeedWordPress::param('link_rss_password');
+ $auth = MyPHP::request('link_rss_auth_method');
+ $username = MyPHP::request('link_rss_username');
+ $password = MyPHP::request('link_rss_password');
$credentials = array(
"authentication" => $auth,
"username" => $username,
View
40 feedwordpress-elements.css
@@ -429,3 +429,43 @@ table.twofer td.secondary { padding-left: 10px; width: 30%; }
#feedwordpress-admin-feeds #link-rss-params td { width: auto !important; }
+/* Feed Contents picker & XPath test results widgets */
+
+.fwp-xpath-test-results {
+ position: absolute;
+ top: auto; left: auto;
+ z-index: 9999999;
+ overflow: auto;
+ max-height: 100px; max-width: 400px;
+ background-color: #ccffcc;
+ padding: 10px;
+}
+.fwp-xpath-test-results-close {
+ position: absolute;
+ top: 10px; right: 10px;
+
+}
+.fwp-xpath-test-setting {
+ font-size: smaller;
+}
+
+.fwp-feed-contents-picker h4, .fwp-xpath-test-results h4 {
+ margin-top: 0;
+ margin-bottom: 5px;
+ border-bottom: 1px dotted black;
+}
+.fwp-feed-contents-picker-close {
+ position: absolute;
+ top: 10px; right: 10px;
+}
+.fwp-feed-contents-picker, .fwp-feeds-picker {
+ position: absolute;
+ top: auto; left: auto;
+ z-index: 9999999;
+ overflow: auto;
+ max-height: 100px; max-width: 400px;
+ background-color: #ccffcc;
+ padding: 10px;
+}
+
+
View
245 feedwordpress-elements.js
@@ -486,7 +486,252 @@ jQuery(document).ready( function($) {
} ); /* $('.feedwordpress-category-div').each() */
} ); /* jQuery(document).ready() */
+
+function fwp_feedspiper () {
+ var data = {
+ action: 'fwp_feeds'
+ };
+
+ return jQuery.ajax({
+ type: "POST",
+ url: ajaxurl,
+ data: data
+ });
+}
+
+function fwp_feedcontentspiper (feed_id, callbackOK, callbackFail) {
+ var data = {
+ action: 'fwp_feedcontents',
+ feed_id: feed_id
+ };
+
+ jQuery.ajax({
+ type: "POST",
+ url: ajaxurl,
+ data: data
+ })
+ .done(function (response) { callbackOK(response); })
+ .fail(function (response) { callbackFail(response); });
+}
+
+function fwp_feedcontentspicker (feed_id, destination, pickCallback, closeCallback) {
+ var picker_id = 'fwp-feed-contents-picker-' + feed_id;
+
+ jQuery('<div class="fwp-feed-contents-picker" style="display: none;" id="'+picker_id+'"><p>Loading...</p></div>').insertAfter(destination);
+ jQuery('#'+picker_id).show(500);
+
+ fwp_feedcontentspiper(feed_id, function (response) {
+ var ul = '<h4>Using post...</h4><ul>';
+ for (var i=0; i < response.length; i++) {
+ ul += '<li><a class="fwp-feed-contents-picker-pick-'+feed_id+'" href="'
+ +response[i].guid
+ +'">' + response[i].post_title + '</a></li>';
+ }
+ ul += '</ul>';
+ ul += '<a class="fwp-feed-contents-picker-close" href="#" id="fwp-feed-contents-picker-' + feed_id + '-close">x</a>';
+
+ jQuery('#fwp-feed-contents-picker-' + feed_id).html(ul);
+
+ // Set up event handlers.
+ jQuery('#fwp-feed-contents-picker-' + feed_id + '-close').click(function (e) {
+ jQuery('#fwp-feed-contents-picker-' + feed_id).hide(500, function () { jQuery('#fwp-feed-contents-picker-' + feed_id).remove(); });
+ if (typeof(closeCallback)=='function') {
+ closeCallback(feed_id);
+ }
+ e.preventDefault();
+ return false;
+ });
+ jQuery('.fwp-feed-contents-picker-pick-' + feed_id).click(function (e) {
+ jQuery('#fwp-feed-contents-picker-' + feed_id).hide(500, function () { jQuery('#fwp-feed-contents-picker-' + feed_id).remove(); });
+ if (typeof(pickCallback)=='function') {
+ pickCallback(feed_id, jQuery(this).attr('href'));
+ }
+ e.preventDefault();
+ return false;
+ });
+ },
+ function (response) {
+ jQuery('#' + picker_id).addClass('error').html('There was a problem getting a listing of the feed. Sorry!').delay(5000).hide(500, function () { jQuery(this).remove(); });
+ });
+}
+
+function fwp_feedspicker (destination, pickCallback, closeCallback) {
+ var dabber = jQuery(destination).attr('id');
+ var picker_id = 'fwp-feeds-picker-' + dabber;
+
+ jQuery('<div class="fwp-feeds-picker" style="display: none;" id="'+picker_id+'"><p>Loading...</p></div>').insertAfter(destination);
+ jQuery('#'+picker_id).show(500);
+
+ fwp_feedspiper()
+ .done(function (response) {
+ var ul = '<h4>Using subscription...</h4><ul>';
+ for (var i=0; i < response.length; i++) {
+ ul += '<li><a class="fwp-feeds-picker-pick-'+dabber+'" href="#feed-'
+ +response[i].id
+ +'">' + response[i].name + '</a></li>';
+ }
+ ul += '</ul>';
+ ul += '<a class="fwp-feeds-picker-close" href="#" id="fwp-feeds-picker-' + dabber + '-close">x</a>';
+
+ jQuery('#fwp-feeds-picker-' + dabber).html(ul);;
+
+ // Set up event handlers.
+ jQuery('#fwp-feeds-picker-' + dabber + '-close').click(function (e) {
+ jQuery('#fwp-feeds-picker-' + dabber).hide(500, function () { jQuery('#fwp-feeds-picker-' + dabber).remove(); });
+ if (typeof(closeCallback)=='function') {
+ closeCallback(destination);
+ }
+ e.preventDefault();
+ return false;
+ });
+ jQuery('.fwp-feeds-picker-pick-' + dabber).click(function (e) {
+ jQuery('#fwp-feeds-picker-' + dabber).hide(500, function () {
+ jQuery('#fwp-feeds-picker-' + dabber).remove();
+ });
+
+ var feed_id = jQuery(this).attr('href').replace(/^#feed-/, '');
+
+ if (typeof(pickCallback)=='function') {
+ pickCallback(feed_id, jQuery(this));
+ }
+ e.preventDefault();
+ return false;
+ });
+ })
+ .fail(function (response) {
+ jQuery('#' + picker_id).addClass('error').html('There was a problem getting a listing of your subscriptions. Sorry!').delay(5000).hide(500, function () { jQuery(this).remove(); });
+ });
+}
+
+function fwp_xpathtest_ajax (expression, feed_id, post_id) {
+ var data = {
+ action: 'fwp_xpathtest',
+ xpath: expression,
+ feed_id: feed_id,
+ post_id: post_id
+ };
+
+ return jQuery.ajax({
+ type: "GET",
+ url: ajaxurl,
+ data: data
+ });
+}
+
+function fwp_xpathtest_fail (response, result_id, destination) {
+ jQuery('<div class="fwp-xpath-test-results error" style="display: none;" id="'+result_id+'">There was a problem communicating with the server.<p>result = <code>'+response+'</code></p></div>').insertAfter(destination);
+ jQuery('#'+result_id).show(500).delay(3000).hide(500, function () { jQuery(this).remove(); });
+}
+
+function fwp_xpathtest_ok (response, result_id, destination) {
+ var dabber = jQuery(destination).attr('id');
+ var resultsHtml = '<ul>';
+
+ if (response.results instanceof Array) {
+ for (var i = 0; i < response.results.length; i++) {
+ resultsHtml += '<li>result['+i.toString()+'] = <code>'+response.results[i]+'</code></li>';
+ }
+ } else {
+ resultsHtml += '<li>result = <code>' + response.results + '</code></li>';
+ } /* if */
+ resultsHtml += '</ul>';
+
+ jQuery('<div class="fwp-xpath-test-results" style="display: none;" id="'+result_id+'"><h4>'+response.expression+'</h4>'+resultsHtml+'</code> <a class="fwp-xpath-test-results-close">x</a></div>').insertAfter(destination);
+
+ var link_id = 'fwp-xpath-test-results-post-'+dabber;
+ if (jQuery('#'+link_id).length > 0) {
+ jQuery('#'+link_id).attr('href', response.guid).html(response.post_title);
+ } else {
+ jQuery('<div id="contain-'+link_id+'" class="fwp-xpath-test-results-post fwp-xpath-test-setting">Using post: <a id="'+link_id+'" href="'+response.guid+'"> '+response.post_title+'</a> (<a href="#" class="fwp-xpath-test-results-post-change">reset</a>)</div>').insertAfter('#'+result_id);
+ } /* if */
+
+ jQuery('#'+result_id).find('.fwp-xpath-test-results-close').click(function (e) {
+ e.preventDefault();
+
+ jQuery('#'+result_id).hide(500, function () { jQuery(this).remove(); });
+ return false;
+ });
+ jQuery('#contain-'+link_id).find('.fwp-xpath-test-results-post-change').click(function (e) {
+ e.preventDefault();
+ jQuery('#contain-'+link_id).remove();
+
+ return false;
+ });
+ jQuery('#'+result_id).show(500);
+}
+
+function fwp_xpathtest (expression, destination, feed_id) {
+ var dabber = jQuery(destination).attr('id');
+ var result_id = 'fwp-xpath-test-results-'+dabber;
+ var preset_post_id = 'fwp-xpath-test-results-post-'+dabber;
+ var post_id = jQuery('#'+preset_post_id).attr('href');
+
+ // Clear out any previous results.
+ jQuery('#'+result_id).remove();
+
+ if (jQuery('#xpath-test-feed-id-'+dabber).length > 0) {
+ feed_id = jQuery('#xpath-test-feed-id-'+dabber).val();
+ }
+
+ if ('*' == feed_id) {
+
+ fwp_feedspicker(destination, function (feed_id, a) {
+ var href = a.attr('href');
+ var text = a.text();
+
+ jQuery('<div class="fwp-xpath-test-feed-id fwp-xpath-test-setting" id="contain-xpath-test-feed-id-'+dabber+'">Using sub: <a href="'+href+'">'+text+'</a><input type="hidden" id="xpath-test-feed-id-'+dabber+'" name="xpath_test_feed_id" value="'+feed_id+'" /> (<a href="#" class="fwp-xpath-test-feed-id-change">reset</a>)</div>').insertAfter(destination);
+
+ jQuery('#contain-xpath-test-feed-id-'+dabber).find('.fwp-xpath-test-feed-id-change').click(function (e) {
+ e.preventDefault();
+
+ // If there is a post set, we need to reset that
+ console.log(('#contain-fwp-xpath-test-results-post-'+dabber), jQuery('#contain-fwp-xpath-test-results-post-'+dabber));
+ jQuery('#contain-fwp-xpath-test-results-post-'+dabber).remove();
+
+ // Show yourself out.
+ jQuery('#contain-xpath-test-feed-id-'+dabber).remove();
+ return false;
+ });
+
+ // Now recursively call the function in order to force
+ // a post-picker.
+ fwp_xpathtest(expression, destination, feed_id);
+ });
+ }
+
+ // Check for a pre-selected post GUID.
+ else if (post_id) {
+ fwp_xpathtest_ajax(expression, feed_id, post_id)
+ .done( function (response) { fwp_xpathtest_ok(response, result_id, destination); } )
+ .fail( function (response) { fwp_xpathtest_fail(response, result_id, destination); } );
+ }
+ else {
+ // Pop up the feed content picker
+ fwp_feedcontentspicker(feed_id, destination, function (feed_id, post_id) {
+ fwp_xpathtest_ajax(expression, feed_id, post_id)
+ .done( function (response) { fwp_xpathtest_ok(response, result_id, destination); } )
+ .fail( function (response) { fwp_xpathtest_fail(response, result_id, destination); } );
+ });
+ }
+
+}
+
jQuery(document).ready(function($){
+ if ( $('.xpath-test').length ) {
+ $('.xpath-test').click ( function (e) {
+ e.preventDefault();
+
+ // Pull the local expression from the text box
+ var expr = jQuery(this).closest('tr').find('textarea').val();
+
+ // Check to see if we are on a Feed settings page or
+ // on the global settings page;
+ var feed_id = jQuery('input[name="save_link_id"]').val();
+
+ fwp_xpathtest(expr, jQuery(this), feed_id);
+ return false;
+ });
+ }
if ( $('.jaxtag').length ) {
tagBox.init();
}
View
189 feedwordpress.php
@@ -104,6 +104,7 @@
endif;
$dir = dirname(__FILE__);
+require_once("${dir}/myphp.class.php");
require_once("${dir}/admin-ui.php");
require_once("${dir}/feedwordpresssyndicationpage.class.php");
require_once("${dir}/compatability.php"); // Legacy API
@@ -224,6 +225,7 @@
add_filter('syndicated_item_content', array('SyndicatedPost', 'resolve_relative_uris'), 0, 2);
add_filter('syndicated_item_content', array('SyndicatedPost', 'sanitize_content'), 0, 2);
+ add_action('plugins_loaded', array('FeedWordPress', 'admin_api'));
else :
# Hook in the menus, which will just point to the upgrade interface
add_action('admin_menu', 'fwp_add_pages');
@@ -653,6 +655,8 @@ function syndication_comments_feed_link ($link) {
################################################################################
function fwp_add_pages () {
+ global $feedwordpress;
+
$menu_cap = FeedWordPress::menu_cap();
$settings_cap = FeedWordPress::menu_cap(/*sub=*/ true);
$syndicationMenu = FeedWordPress::path('syndication.php');
@@ -706,6 +710,9 @@ function fwp_add_pages () {
$syndicationMenu, 'FeedWordPress Diagnostics', 'Diagnostics',
$settings_cap, FeedWordPress::path('diagnostics-page.php')
);
+
+ add_filter('page_row_actions', array($feedwordpress, 'row_actions'), 10, 2);
+ add_filter('post_row_actions', array($feedwordpress, 'row_actions'), 10, 2);
} /* function fwp_add_pages () */
function fwp_check_debug () {
@@ -946,7 +953,7 @@ function subscription ($which) {
endif;
return $sub;
- } /* FeedWordPress::subscriptions () */
+ } /* FeedWordPress::subscription () */
# function update (): polls for updates on one or more Contributor feeds
#
@@ -1207,6 +1214,29 @@ static function admin_init () {
endif;
} /* FeedWordPress::admin_init() */
+ function admin_api () {
+ // This sucks, but WordPress doesn't give us any other way to
+ // easily invoke a permanent-delete from a plugged in post
+ // actions link. So we create a magic parameter, and when this
+ // magic parameter is activated, the WordPress trashcan is
+ // temporarily de-activated.
+
+ if (MyPHP::request('fwp_post_delete')=='nuke') :
+ // Get post ID #
+ $post_id = MyPHP::request('post');
+ if (!$post_id) :
+ $post_id = MyPHP::request('post_ID');
+ endif;
+
+ // Make sure we've got the right nonce and all that.
+ check_admin_referer('delete-post_' . $post_id);
+
+ // If so, disable the trashcan.
+ define('EMPTY_TRASH_DAYS', 0);
+ endif;
+
+ }
+
function init () {
global $fwp_path;
@@ -1245,10 +1275,118 @@ function init () {
/*priority=*/ -100
);
+ add_action('wp_ajax_fwp_feeds', array($this, 'fwp_feeds'));
+ add_action('wp_ajax_fwp_feedcontents', array($this, 'fwp_feedcontents'));
+ add_action('wp_ajax_fwp_xpathtest', array($this, 'fwp_xpathtest'));
+
$this->clear_cache_magic_url();
$this->update_magic_url();
} /* FeedWordPress::init() */
+ function fwp_feeds () {
+ $feeds = array();
+ $feed_ids = $this->feeds;
+
+ foreach ($feed_ids as $id) :
+ $sub = $this->subscription($id);
+ $feeds[] = array(
+ "id" => $id,
+ "url" => $sub->uri(),
+ "name" => $sub->name(/*fromFeed=*/ false),
+ );
+ endforeach;
+
+ header("Content-Type: application/json");
+ echo json_encode($feeds);
+ exit;
+ }
+
+ function fwp_feedcontents () {
+ $feed_id = MyPHP::request('feed_id');
+
+ // Let's load up some data from the feed . . .
+ $feed = $this->subscription($feed_id);
+ $posts = $feed->live_posts();
+
+ if (is_wp_error($posts)) :
+ header("HTTP/1.1 502 Bad Gateway");
+ $result = $posts;
+ else :
+ $result = array();
+
+ foreach ($posts as $post) :
+ $p = new SyndicatedPost($post, $feed);
+
+ $result[] = array(
+ "post_title" => $p->entry->get_title(),
+ "post_link" => $p->permalink(),
+ "guid" => $p->guid(),
+ "post_date" => $p->published(),
+ );
+ endforeach;
+ endif;
+
+ header("Content-Type: application/json");
+
+ echo json_encode($result);
+
+ // This is an AJAX request, so close it out thus.
+ die;
+ } /* FeedWordPress::fwp_feedcontents () */
+
+ function fwp_xpathtest () {
+ $xpath = MyPHP::request('xpath');
+ $feed_id = MyPHP::request('feed_id');
+ $post_id = MyPHP::request('post_id');
+
+ $expr = new FeedWordPressParsedPostMeta($xpath);
+
+ // Let's load up some data from the feed . . .
+ $feed = $this->subscription($feed_id);
+ $posts = $feed->live_posts();
+
+ if (!is_wp_error($posts)) :
+ if (strlen($post_id) == 0) :
+ $post = $posts[0];
+ else :
+ $post = null;
+
+ foreach ($posts as $p) :
+ if ($p->get_id() == $post_id) :
+ $post = $p;
+ endif;
+ endforeach;
+ endif;
+
+ $post = new SyndicatedPost($post, $feed);
+ $meta = $expr->do_substitutions($post);
+
+ $result = array(
+ "post_title" => $post->entry->get_title(),
+ "post_link" => $post->permalink(),
+ "guid" => $post->guid(),
+ "expression" => $xpath,
+ "results" => $meta
+ );
+ else :
+ $result = array(
+ "expression" => $xpath,
+ "feed_id" => $feed_id,
+ "post_id" => $post_id,
+ "results" => $posts
+ );
+
+ header("HTTP/1.1 503 Bad Gateway");
+ endif;
+
+ header("Content-Type: application/json");
+
+ echo json_encode($result);
+
+ // This is an AJAX request, so close it out thus.
+ die;
+ } /* FeedWordPress::fwp_xpathtest () */
+
function redirect_retired () {
global $wp_query;
if (is_singular()) :
@@ -1267,6 +1405,34 @@ function redirect_retired () {
endif;
}
+ function row_actions ($actions, $post) {
+ if (is_syndicated($post->ID)) :
+ $link = get_delete_post_link($post->ID, '', true);
+ $link = MyPHP::url($link, array("fwp_post_delete" => "nuke"));
+
+ $caption = 'Erase the record of this post (will be re-syndicated if it still appears on the feed).';
+ $linktext = 'Erase/Resyndicate';
+
+ $keys = array_keys($actions);
+ $links = array();
+ foreach ($keys as $key) :
+ $links[$key] = $actions[$key];
+
+ if ('trash'==$key) :
+ $links[$key] = "<a class='submitdelete' title='" . esc_attr( __( 'Move this item to the Trash (will NOT be re-syndicated)' ) ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash/Don&#8217;t Resyndicate' ) . "</a>";
+
+ // Placeholder.
+ $links['delete'] = '';
+ endif;
+ endforeach;
+
+ $links['delete'] = '<a class="submitdelete" title="'.esc_attr(__($caption)).'" href="' . $link . '">' . __($linktext) . '</a>';
+
+ $actions = $links;
+ endif;
+ return $actions;
+ }
+
function dashboard_setup () {
$see_it = FeedWordPress::menu_cap();
@@ -1385,10 +1551,7 @@ function clear_cache_magic_url () {
} /* FeedWordPress::clear_cache_magic_url() */
function clear_cache_requested () {
- return (
- isset($_GET['clear_cache'])
- and $_GET['clear_cache']
- );
+ return MyPHP::request('clear_cache');
} /* FeedWordPress::clear_cache_requested() */
function update_requested () {
@@ -2077,21 +2240,13 @@ function path ($filename = '') {
return $path;
}
+ // These are superceded by MyPHP::param/post/get/request, but kept
+ // here for backward compatibility.
function param ($key, $type = 'REQUEST', $default = NULL) {
- $where = '_'.strtoupper($type);
- $ret = $default;
- if (isset($GLOBALS[$where]) and is_array($GLOBALS[$where])) :
- if (isset($GLOBALS[$where][$key])) :
- $ret = $GLOBALS[$where][$key];
- if (get_magic_quotes_gpc()) :
- $ret = stripslashes_deep($ret);
- endif;
- endif;
- endif;
- return $ret;
+ return MyPHP::param($key, $default, $type);
}
function post ($key, $default = NULL) {
- return FeedWordPress::param($key, 'POST');
+ return MyPHP::post($key, $default);
}
} // class FeedWordPress
View
16 feedwordpresssyndicationpage.class.php
@@ -82,8 +82,8 @@ function updates_requested () {
$update_set = array();
if ($fwp_update_invoke != 'get') :
- if (is_array(FeedWordPress::post('link_ids'))
- and (FeedWordPress::post('action')==FWP_UPDATE_CHECKED)) :
+ if (is_array(MyPHP::post('link_ids'))
+ and (MyPHP::post('action')==FWP_UPDATE_CHECKED)) :
$targets = $wpdb->get_results("
SELECT * FROM $wpdb->links
WHERE link_id IN (".implode(",",$_POST['link_ids']).")
@@ -95,8 +95,8 @@ function updates_requested () {
else : // This should never happen
FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__, __FILE__);
endif;
- elseif (!is_null(FeedWordPress::post('update_uri'))) :
- $targets = FeedWordPress::post('update_uri');
+ elseif (!is_null(MyPHP::post('update_uri'))) :
+ $targets = MyPHP::post('update_uri');
if (!is_array($targets)) :
$targets = array($targets);
endif;
@@ -351,7 +351,7 @@ function display () {
FWP_RESUB_CHECKED => 'multiundelete_page',
);
- $act = FeedWordPress::param('action');
+ $act = MyPHP::request('action');
if (isset($dispatcher[$act])) :
$method = $dispatcher[$act];
if (method_exists($this, $method)) :
@@ -1141,14 +1141,14 @@ function fwp_switchfeed_page () {
endif;
if (isset($existingLink)) :
- $auth = FeedWordPress::post('link_rss_auth_method');
+ $auth = MyPHP::post('link_rss_auth_method');
if (!is_null($auth) and (strlen($auth) > 0) and ($auth != '-')) :
$existingLink->update_setting('http auth method', $auth);
$existingLink->update_setting('http username',
- FeedWordPress::post('link_rss_username')
+ MyPHP::post('link_rss_username')
);
$existingLink->update_setting('http password',
- FeedWordPress::post('link_rss_password')
+ MyPHP::post('link_rss_password')
);
else :
$existingLink->update_setting('http auth method', NULL);
View
80 myphp.class.php
@@ -0,0 +1,80 @@
+<?php
+if (!class_exists('MyPHP')) :
+ class MyPHP {
+ // For dealing with HTTP GET/POST parameters sent to us as input
+ static public function param ($key, $default = NULL, $type = 'REQUEST') {
+ $where = '_'.strtoupper($type);
+ $ret = $default;
+ if (isset($GLOBALS[$where]) and is_array($GLOBALS[$where])) :
+ if (isset($GLOBALS[$where][$key])) :
+ $ret = $GLOBALS[$where][$key];
+
+ // Magic quotes are like the stupidest
+ // thing ever.
+ if (get_magic_quotes_gpc()) :
+ $ret = self::stripslashes_deep($ret);
+ endif;
+ endif;
+ endif;
+ return $ret;
+ } /* MyPHP::param () */
+
+ static function post ($key, $default = NULL) {
+ return self::param($key, $default, 'POST');
+ } /*MyPHP::post () */
+
+ static function get ($key, $default = NULL) {
+ return self::param($key, $default, "GET");
+ } /* MyPHP::get () */
+
+ static function request ($key, $default = NULL) {
+ return self::param($key, $default, "REQUEST");
+ } /* MyPHP::request () */
+
+ static function stripslashes_deep ($value) {
+ if ( is_array($value) ) {
+ $value = array_map(array(__CLASS__, 'stripslashes_deep'), $value);
+ } elseif ( is_object($value) ) {
+ $vars = get_object_vars( $value );
+ foreach ($vars as $key=>$data) {
+ $value->{$key} = stripslashes_deep( $data );
+ }
+ } else {
+ $value = stripslashes($value);
+ }
+ return $value;
+ } /* MyPHP::stripslashes_deep () */
+
+ static function url ($url, $params = array()) {
+ $sep = '?';
+ if (strpos($url, '?') !== false) :
+ $sep = '&';
+ endif;
+ $url .= $sep . self::to_http_post($params);
+
+ return $url;
+ } /* MyPHP::url () */
+
+ /**
+ * MyPHP::to_http_post () -- convert a hash table or object into
+ * an application/x-www-form-urlencoded query string
+ */
+ static function to_http_post ($params) {
+ $getQuery = array();
+ foreach ($params as $key => $value) :
+ if (is_scalar($value)) :
+ $getQuery[] = urlencode($key) . '=' . urlencode($value);
+ else :
+ // Make some attempt to deal with array and
+ // object members. Really we should descend
+ // recursively to get the whole thing....
+ foreach ((array) $value as $k => $v) :
+ $getQuery[] = urlencode($key.'['.$k.']') . '=' . urlencode($v);
+ endforeach;
+ endif;
+ endforeach;
+ return implode("&", $getQuery);
+ } /* MyPHP::to_http_post () */
+ }
+endif;
+
View
10 posts-page.php
@@ -418,12 +418,16 @@ function formatting_box ($page, $box = NULL) {
<?php
$i = 0;
- foreach ($custom_settings as $key => $value) :
+ $testerButton = '<br/><button id="xpath-test-%d"'
+ .'class="xpath-test"'
+ .'>test expression</button>';
+ foreach ($custom_settings as $key => $value) :
?>
<tr style="vertical-align:top">
<th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo esc_html($key); ?>" />
<input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo esc_html($key); ?>" /></th>
- <td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo esc_html($value); ?></textarea></td>
+ <td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo esc_html($value); ?></textarea>
+ <?php print sprintf($testerButton, $i); ?></td>
<td width="10%"><select name="notes[<?php echo $i; ?>][action]">
<option value="update">save changes</option>
<option value="delete">delete this setting</option>
@@ -437,7 +441,7 @@ function formatting_box ($page, $box = NULL) {
<tr style="vertical-align: top">
<th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
- <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea>
+ <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea><?php print sprintf($testerButton, $i); ?>
<p>Enter a text value, or a path to a data element from the syndicated item.<br/>
For data elements, you can use an XPath-like syntax wrapped in <code>$( ... )</code>.<br/>
<code>hello</code> = the text value <code><span style="background-color: #30FFA0;">hello</span></code><br/>
View
38 syndicatedlink.class.php
@@ -92,12 +92,7 @@ function stale () {
return $stale;
} /* SyndicatedLink::stale () */
- function poll ($crash_ts = NULL) {
- global $wpdb;
-
- $url = $this->uri(array('add_params' => true));
- FeedWordPress::diagnostic('updated_feeds', 'Polling feed ['.$url.']');
-
+ function fetch () {
$timeout = $this->setting('fetch timeout', 'feedwordpress_fetch_timeout', FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT);
$this->simplepie = apply_filters(
@@ -112,6 +107,31 @@ function poll ($crash_ts = NULL) {
else :
$this->magpie = new MagpieFromSimplePie($this->simplepie, NULL);
endif;
+ }
+ function live_posts () {
+ if (!is_object($this->simplepie)) :
+ $this->fetch();
+ endif;
+
+ if (is_object($this->simplepie) and method_exists($this->simplepie, 'get_items')) :
+ $ret = apply_filters(
+ 'syndicated_feed_items',
+ $this->simplepie->get_items(),
+ $this
+ );
+ else :
+ $ret = $this->simplepie;
+ endif;
+ return $ret;
+ }
+
+ function poll ($crash_ts = NULL) {
+ global $wpdb;
+
+ $url = $this->uri(array('add_params' => true));
+ FeedWordPress::diagnostic('updated_feeds', 'Polling feed ['.$url.']');
+
+ $this->fetch();
$new_count = NULL;
@@ -230,11 +250,7 @@ function poll ($crash_ts = NULL) {
# -- Add new posts from feed and update any updated posts
$crashed = false;
- $posts = apply_filters(
- 'syndicated_feed_items',
- $this->simplepie->get_items(),
- $this
- );
+ $posts = $this->live_posts();
$this->magpie->originals = $posts;

No commit comments for this range

Something went wrong with that request. Please try again.