Monday

Hacking FeedWordPress for Self Auto Update

FeedWordPress is an Atom/RSS aggregator for WordPress. It syndicates content from newsfeeds that you choose into your WordPress blog; if you syndicate several newsfeeds then you can WordPress’s posts database and templating engine as the back-end of an aggregation (”planet”) website.

No Cron?


If you do not have cron-facilities at your hosting provider, you have a bit of a problem. The latest version of WordPress have built in WP-cron facilities now,
but it is extremely badly documented, and apart from the developers, no-one really seems to know how to use the functionality.

With the lack of cron-support on our host, we would have to go to the manual update file a couple of times per day, and that would be annoying even by the end of the day.

http://www.yoursite.com/wp-content/update-feeds.php


Here is the fix


This little hack involves a bit of editing of the update-feeds.php file in your wp-content/-folder, and then subscribing to www.WebCron.org.
Its free, and it gives you the option to run specific urls every hour, or however you want to time it.

Webcron allows you to do tasks at set hours by looking for a page on your website.

The system allows you to enter a username and password, which would prevent improper use of the system, but it does not word with the FWP update script. The webcron service uses GET to contact the url, and FWP accepts only POSTs.

Our first task is to make sure the script is not forwarded to the login page. Open up your editor, and load the update-feeds.php file.


Now, we do want to ensure that the script can still talk to the WP backend, so we do not want to remove the login check, but simply by-pass it by adding the variables above the check function, with the correct values, like this:




It could be seen as a breach of security to put your login and password in the .php file, but who is going to be looking at it? Only people who already have access to your FTP, thats who.


We now have secured that the script is always logged in, and ready to communicate with the WordPress backend. But the script usually requires an layer of interactivity, where you as the user select which feeds (if not all) to update from a pulldown.

Here is where some additional editing comes into play. You simply add the variable to the beginning of the script, like this:



$_POST['update']='silent'; would work as well, but I left the verbose option there for debugging, and there is no reason to not leave it there.

There you have it. Its not a beautiful hack in its layout, but its effective. I wish the functionality of automated tasks were more better documented, so there would be no need for hacks like this, editing source .php-files and relying on 3rd party homepages.