function multidelete_page() { global $wpdb; // If this is a POST, validate source and user credentials FeedWordPressCompatibility::validate_http_request('feedwordpress_feeds', 'manage_links'); if (MyPHP::post('submit') == FWP_CANCEL_BUTTON) { return true; // Continue without further ado. } // Get single link ID or multiple link IDs from REQUEST parameters // if available. Sanitize values for MySQL. $link_list = $this->requested_link_ids_sql(); if (MyPHP::post('confirm') == 'Delete') { if (is_array(MyPHP::post('link_action'))) { $actions = MyPHP::post('link_action'); } else { $actions = array(); } $do_it = array('hide' => array(), 'nuke' => array(), 'delete' => array()); foreach ($actions as $link_id => $what) { $do_it[$what][] = $link_id; } $alter = array(); if (count($do_it['hide']) > 0) { $hidem = "(" . implode(', ', $do_it['hide']) . ")"; $alter[] = "\n\t\t\t\tUPDATE {$wpdb->links}\n\t\t\t\tSET link_visible = 'N'\n\t\t\t\tWHERE link_id IN {$hidem}\n\t\t\t\t"; } if (count($do_it['nuke']) > 0) { $nukem = "(" . implode(', ', $do_it['nuke']) . ")"; // Make a list of the items syndicated from this feed... $post_ids = $wpdb->get_col("\n\t\t\t\t\tSELECT post_id FROM {$wpdb->postmeta}\n\t\t\t\t\tWHERE meta_key = 'syndication_feed_id'\n\t\t\t\t\tAND meta_value IN {$nukem}\n\t\t\t\t"); // ... and kill them all if (count($post_ids) > 0) { foreach ($post_ids as $post_id) { // Force scrubbing of deleted post // rather than sending to Trashcan wp_delete_post($post_id, true); } } $alter[] = "\n\t\t\t\tDELETE FROM {$wpdb->links}\n\t\t\t\tWHERE link_id IN {$nukem}\n\t\t\t\t"; } if (count($do_it['delete']) > 0) { $deletem = "(" . implode(', ', $do_it['delete']) . ")"; // Make the items syndicated from this feed appear to be locally-authored $alter[] = "\n\t\t\t\t\tDELETE FROM {$wpdb->postmeta}\n\t\t\t\t\tWHERE meta_key = 'syndication_feed_id'\n\t\t\t\t\tAND meta_value IN {$deletem}\n\t\t\t\t"; // ... and delete the links themselves. $alter[] = "\n\t\t\t\tDELETE FROM {$wpdb->links}\n\t\t\t\tWHERE link_id IN {$deletem}\n\t\t\t\t"; } $errs = array(); $success = array(); foreach ($alter as $sql) { $result = $wpdb->query($sql); if (!$result) { $errs[] = mysql_error(); } } if (count($alter) > 0) { echo "<div class=\"updated\">\n"; if (count($errs) > 0) { echo "There were some problems processing your "; echo "unsubscribe request. [SQL: " . implode('; ', $errs) . "]"; } else { echo "Your unsubscribe request(s) have been processed."; } echo "</div>\n"; } return true; // Continue on to Syndicated Sites listing } else { // $link_list has previously been sanitized for html by self::requested_link_ids_sql $targets = $wpdb->get_results("\n\t\t\t\tSELECT * FROM {$wpdb->links}\n\t\t\t\tWHERE link_id IN {$link_list}\n\t\t\t\t"); ?> <form action="<?php print $this->form_action(); ?> " method="post"> <div class="wrap"> <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> <input type="hidden" name="action" value="Unsubscribe" /> <input type="hidden" name="confirm" value="Delete" /> <h2>Unsubscribe from Syndicated Links:</h2> <?php foreach ($targets as $link) { $subscribed = 'Y' == strtoupper($link->link_visible); $link_url = esc_html($link->link_url); $link_name = esc_html($link->link_name); $link_description = esc_html($link->link_description); $link_rss = esc_html($link->link_rss); ?> <fieldset> <legend><?php echo $link_name; ?> </legend> <table class="editform" width="100%" cellspacing="2" cellpadding="5"> <tr><th scope="row" width="20%"><?php _e('Feed URI:'); ?> </th> <td width="80%"><a href="<?php echo $link_rss; ?> "><?php echo $link_rss; ?> </a></td></tr> <tr><th scope="row" width="20%"><?php _e('Short description:'); ?> </th> <td width="80%"><?php echo $link_description; ?> </span></td></tr> <tr><th width="20%" scope="row"><?php _e('Homepage:'); ?> </th> <td width="80%"><a href="<?php echo $link_url; ?> "><?php echo $link_url; ?> </a></td></tr> <tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options'); ?> :</th> <td width="80%"><ul style="margin:0; padding: 0; list-style: none"> <?php if ($subscribed) { ?> <li><input type="radio" id="hide-<?php echo $link->link_id; ?> " name="link_action[<?php echo $link->link_id; ?> ]" value="hide" checked="checked" /> <label for="hide-<?php echo $link->link_id; ?> ">Turn off the subscription for this syndicated link<br/><span style="font-size:smaller">(Keep the feed information and all the posts from this feed in the database, but don't syndicate any new posts from the feed.)</span></label></li> <?php } ?> <li><input type="radio" id="nuke-<?php echo $link->link_id; ?> "<?php if (!$subscribed) { ?> checked="checked"<?php } ?> name="link_action[<?php echo $link->link_id; ?> ]" value="nuke" /> <label for="nuke-<?php echo $link->link_id; ?> ">Delete this syndicated link and all the posts that were syndicated from it</label></li> <li><input type="radio" id="delete-<?php echo $link->link_id; ?> " name="link_action[<?php echo $link->link_id; ?> ]" value="delete" /> <label for="delete-<?php echo $link->link_id; ?> ">Delete this syndicated link, but <em>keep</em> posts that were syndicated from it (as if they were authored locally).</label></li> <li><input type="radio" id="nothing-<?php echo $link->link_id; ?> " name="link_action[<?php echo $link->link_id; ?> ]" value="nothing" /> <label for="nothing-<?php echo $link->link_id; ?> ">Keep this feed as it is. I changed my mind.</label></li> </ul> </table> </fieldset> <?php } ?> <div class="submit"> <input type="submit" name="submit" value="<?php _e(FWP_CANCEL_BUTTON); ?> " /> <input class="delete" type="submit" name="submit" value="<?php _e(FWP_UNSUB_FULL); ?> " /> </div> </div> <?php return false; // Don't continue on to Syndicated Sites listing } }