Version: 0.1 Author URI: http://www.robertopolli.it License: GPL v.2 Thanks to: www.petitiononline.com Pixline: http://pixline.net/2006/10/anatomia-di-un-plugin-wordpress/ DigitalRamble: http://www.digitalramble.com/2006/06/06/34/ * HOWTO: * simply put me into the plugin folder, then activate me thru the menu. * put "do_petitions();" into the code to show the configured petitions. */ require_once(ABSPATH . WPINC . '/rss-functions.php'); function get_petition($petition) { $url = "http://www.petitiononline.com/mod_perl/signed.cgi?$petition"; $news = wp_cache_get("petition_".$petition); if($news == false) { $snoopy = new Snoopy; $snoopy->fetch($url); $text = $snoopy->results; $regexp="/.*We endorse the () Petition to (.*?)\..*>(\d+) Total Sign/"; preg_match("/.*We endorse the () Petition to (.*?)\./",$text, $matches); preg_match("/>(\d+) Total Signatures

'.$a_petition[0].'

'.$a_petition[2].' firme'."\n"; } function do_petitions() { $fm_petition_name = get_option('fm_petition_name'); foreach ( explode(",",$fm_petition_name ) as $p) { show_petition($p); } } // foreach (array('acquasms','l4tin4') as $p ) { // show_petition($p); // } // options menu // add the saved items to the database if not already there function petitiononline_mgr_add_options() { add_option('fm_petition_name', ''); } // call to actually set up petitiononline_mgr_add_options(); // create hook for new submenu add_action('admin_menu', 'petitiononline_mgr_admin_menu'); function petitiononline_mgr_admin_menu() { add_options_page(__('PetitionOnLine Manager Options'), __('PetitionOnLine'), 5, basename(__FILE__), 'petitiononline_mgr_options_page'); } function petitiononline_mgr_options_page() { $updated = false; if (isset($_POST['fm_petition_name'])) { $fm_petition_name = $_POST['fm_petition_name']; update_option('fm_petition_name', $fm_petition_name); $updated = true; } $fm_petition_name = get_option('fm_petition_name'); if ($updated) { ?>
Options saved.

PetitionOnLine Settings

PetitionOnLine in WordPress Pages
Petitions:
Enter a comma separed list of the petitiononline petitions you want to display: