<?php
/*
Plugin Name: Ping Pingbacks
Description: This plugin generates a list of pingbacks and adds them to your Linklicious account for pinging.
Version: 1.0 Beta
Author; Danny Scheers based on work by Hudson Atwell
IMPORTANT Replace the X's above with your Linklicous API key or this will not work.
*/
/*----------------------------------------------------------------------------------------------------
A D M I N M E N U
----------------------------------------------------------------------------------------------------*/
function vpb_add_menu() {
add_options_page('Ping Pingbacks', 'Ping Pingbacks', 8, 'Ping-Pingbacks', 'vpb_options_display');
}
add_action('admin_menu', 'vpb_add_menu');
function vpb_options_display()
{
global $wpdb;
$MyLinkliciousAPI = $_POST["LL_API_Key"];
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<br>
<h2>Ping PingBacks with Your Linklicious Account"</h2>
<br>
<br>
<form method="post" action="<?php echo $PHP_SELF;?>">
Linklicious API Key:<input type="text" size="36" maxlength="36" name="LL_API_Key"><br />
<input type="submit" value="Ping Pingbacks Now" name="submit">
</form>
<?
}
else
{
//getting option/settings from Google XML Sitemaps
$query = "SELECT * FROM ".$wpdb->prefix."comments WHERE comment_type='pingback' AND `comment_author_url` NOT LIKE '%".$_SERVER['SERVER_NAME']."%'";
$result = mysql_query($query);
if (!$result){echo $query; echo mysql_error();}
$count = mysql_num_rows($result);
while ($arr = mysql_fetch_array($result))
{
$query2 = "SELECT post_title,guid FROM ".$wpdb->prefix."posts WHERE ID='{$arr['comment_post_ID']}'";
$result2 = mysql_query($query2);
$arr2 = mysql_fetch_array($result2);
$post_titles[] = $arr2['post_title'];
$guids[] = $arr2['guid'];
$post_ids[] = $arr['comment_post_ID'];
$remote_anchors[] = $arr['comment_author'];
$pingbacks[] = $arr['comment_author_url'];
}
if($count==0):
?>
<div class="wrap">
<h2>Ping Pingbacks</h2>
<div id="message" class="updated fade"><p class="">No Pingbacks!</p></div>
</div>
<?php
exit;
else:
?>
<div style='font-size:10px;text-align:left;'>
<pre><?php
foreach ($pingbacks as $key=>$val)
{
echo "{$pingbacks[$key]} ----> ";
echo file_get_contents('http://linklicious.me/api/addlinks?userId='.$MyLinkliciousAPI.'&links='.$pingbacks[$key]);
echo "<br>";
}
?>
</pre>
</div>
<?php
endif;
}
}
?>