<?php/*Plugin Name: Linkfest Auto PostPlugin URI: http://www.linkfests.us//Registry.htmlDescription: This plugin will add a ping to Linkfest Haven for any post in the specified category. In order to use this plugin, your blogmust be in the Linkfest Haven Deluxe Blog Registry. The ping will cause the article to be listed in the current Open Trackbacks list, and thenpeople will be able to trackback and link to you simply and quickly.Tags: Open Trackbacks, Linkfests, Linkfest Haven DeluxeAuthor: Bruce ParrelloVersion: 1.0Author URI: http://www.conservativecat.com/Ferdy/Resume.html*/// Adder for the options page.function ferdy_add_options() {if (function_exists('add_options_page')) {add_options_page('Linkfest Notifier', 'Linkfest Category', 8, basename(__FILE__), 'ferdy_options_subpanel');}}// This does all the work.function ferdy_checkpost($post_ID) {// Set the options.$linkfestCat = ferdy_get_cat();$linkfestPing = "http://www.conservativecat.com/cgi-bin/mt/plugins/BackPing/BackPing.cgi/115";// Get access to the database.global $wpdb;// Find out if we're in the linkfest category.$query_text = "SELECT $wpdb->categories.cat_ID FROM $wpdb->categories, $wpdb->post2cat WHERE " ."$wpdb->categories.cat_ID = $wpdb->post2cat.category_id AND $wpdb->post2cat.post_id = '$post_ID' AND " ."$wpdb->categories.cat_name = '$linkfestCat'";$cats_found = $wpdb->get_row($query_text);if ($cats_found) {// This post is eligible. Get its ping history.$ping_data = $wpdb->get_row("SELECT to_ping, pinged FROM $wpdb->posts WHERE ID = '$post_ID'");// See if we've already done backping stuff.$mass_ping = "$ping_data->to_ping $ping_data->pinged";$result = stristr($linkfestPing, $mass_ping);if ($result === FALSE) {// We haven't, so we do it now.$new_pings = "$ping_data->to_ping $linkfestPing";$wpdb->query("UPDATE $wpdb->posts SET to_ping = '$new_pings' WHERE ID = '$post_ID'");}}}// Display the options panel and update the category name.function ferdy_options_subpanel() {if (isset($_POST['info_update'])) {$newCat = $_POST['new_cat'];update_option('ferdy_cat', $newCat);echo("<p>New category is $newCat.</p>");}$oldCat = ferdy_get_cat(); ?><div class=wrap><form method="post"><h2>Linkfest Category Name</h2><?phpecho('<p><input type="text" maxlength="55" name="new_cat" value="' . $oldCat . '" /></p>'); ?><p><input type="submit" name="info_update" value="UPDATE" /></p></form></div><?php}// This computes the category name. The default is "linkfests".function ferdy_get_cat() {$linkfestCat = get_option('ferdy_cat');if (! $linkfestCat) {$linkfestCat = 'linkfests';}return $linkfestCat;}// Now we set that function up to execute when the admin_footer action is calledadd_action('publish_post', 'ferdy_checkpost', 1, 1);add_action('admin_menu', 'ferdy_add_options');?>