Tag Support for the Onlywire Autosubmit Plugin

This will be the first time I ventured into editing a plugin. It is hard to find information on tag support for Wordpress 2.3. This post will tell me if I found everything I needed to make this plugin work a little better. The original onlywire autosubmit plugin can be found here.

After using it a few times and then checking my delicious account, I realized the tagging functioning of this plugin didn't work. Then I opened up the plugin and it didn't even add tags. It just bookmarked your post without any tags to identify it. So I did some research and think I added the correct lines of code.

First I have to work around the exec-php plugin to post the code here. I fit in it as good as I could.

Wait until I update this post to see if it worked.

 

<?php
/**
Plugin Name: Only Wire Autosubmitter
Plugin URI: http:www.lionstarr.de/onlywire-autosubmitter-wordpress-plugin
Version: 2.0
Description: Autosubmits a excerpt of a posts to Onlywire when published
Author: lionstarr
Author URI: http:www.lionstarr.de
*/
/* Copyright 2007 lionstarr (email : lionstarr@googlemail.com)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

function onlywireSubmit($post_ID){
$username=get_option('onlywire_username');
$password=get_option('onlywire_password');
$post=get_post($post_ID);
$permalink = get_permalink($post_ID);
if ($posttags) {
$tags = get_the_tags($post_ID);
foreach($tags as $tag) {
$taglist .= $tag->name." ";
}
}
$url="http://$username:$password@www.onlywire.com/api/add?
url=".$permalink."&title=".urlencode($post->post_title)."&tags=".$taglist;
$returncode = file_get_contents($url);
update_option('onlywire_returncode',$returncode);
update_option('onlywire_perm',$permalink);
update_option('onlywire_title',$post->post_title);
update_option('onlywire_url',$url);
return $post_ID;
}
add_action('publish_post', 'onlywireSubmit');


// mt_add_pages() is the sink function for the 'admin_menu' hook
function mt_add_pages_onlywire() {
// Add a new menu under Options:
add_options_page('OnlyWire Options', 'OnlyWire Options', 8, 'onlywireoptions', 'mt_options_page_onlywire');
}

// mt_options_page() displays the page content for the Test Options submenu
function mt_options_page_onlywire() {
if($_POST['onlywire_save']){
update_option('onlywire_username',$_POST['onlywire_username']);
update_option('onlywire_password',$_POST['onlywire_password']);
echo '<div class="updated"><p>OnlyWire Username '.$_POST['onlywire_username'].' and his password were sucessfully saved!</p></div>';
}
if($_POST['onlywire_reward'] && get_option('onlywire_rewarded')!="true"){

$username=get_option('onlywire_username');
$password=get_option('onlywire_password');
$url="http://$username:$password@www.onlywire.com/api/add?
url=http://www.lionstarr.de&title=Linux%20Tutorials";
$url2="http://$username:$password@www.onlywire.com/api/add?
url=http://www.lionstarr.de/onlywire-autosubmit-a-wordpress-plugin.html&title=".urlencode("OnlyWire Autosubmit A Wordpress Plugin");

$ret1=file_get_contents($url);
$ret2=file_get_contents($url2);
if($ret1=="<?xml version=\"1.0\" encoding=\"utf-8\"?><result code=\"success\" />" && $ret2=="<?xml version=\"1.0\" encoding=\"utf-8\"?><result code=\"success\" />"){
echo '<div class="updated"><p>Thanks for rewarding the author!</p></div>';
update_option('onlywire_rewarded','true');
}
else{
echo '<div class="updated"><p>It didn\'t work! Please try again another time!</p></div>';
}
update_option('onlywire_returncode',$ret2);
update_option('onlywire_perm',"http://www.lionstarr.de/onlywire-autosubmit-a-wordpress-plugin.html");
update_option('onlywire_title',"OnlyWire Autosubmit A Wordpress Plugin");
update_option('onlywire_url',$url2);
}
?>
<div class="wrap">
<h2>OnlyWire Autosubmit Options</h2>
<form method="post" id="onlywire_options">
<fieldset class="options">
<legend>OnlyWire Authentifcation</legend>
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th width="33%" scope="row">OnlyWire Username:</th>
<td><input name="onlywire_username" type="text" id="onlywire_username" value="<?php echo get_option('onlywire_username') ;?>"/>
</td>
</tr>
<tr valign="top">
<th width="33%" scope="row">OnlyWire Password:</th>
<td><input name="onlywire_password" type="password" id="onlywire_username" value="<?php echo get_option('onlywire_password') ;?>"/>
</td>
</tr>
</table>
<p class="submit"><input type="submit" name="onlywire_save" value="Save" /></p>
</fieldset></form>
<b>If you'd like to reward the author of this plugin, please press the Reward Author button once. It will submit the Author's Sites to OnlyWire using your Username. If the button doesn't show up, you have already rewarded the author.</b>
<?php if(get_option('onlywire_rewarded')!="true"){ ?>
<form method="post" id="onlywire_reward_author">
<p class="submit"><input type="submit" name="onlywire_reward" value="Reward the Author of this Plugin" /></p><?php } ?>
</form>
<p>The last Item submitted to OnlyWire was <a href="<?php echo get_option('onlywire_perm'); ?>"><?php echo get_option('onlywire_title'); ?></a>.The Return Code from OnlyWire was <p><i><?php

$retcode=get_option('onlywire_returncode');
echo substr($retcode, 52, strlen($retcode)-56);

?></i></p> For further Information on Return Codes, please visit <a href="http://www.onlywire.com?api">OnlyWires API Page</a>. If you want, you can try to submit the item manually by <a href="http://www.onlywire.com/b/bmnoframe?u=<?php echo get_option('onlywire_perm');?>&t=<?php echo get_option('onlywire_title')?>">clicking on this link</a>.</p>
</div>
<?php
}

// Insert the mt_add_pages() sink into the plugin hook list for 'admin_menu'
add_action('admin_menu', 'mt_add_pages_onlywire');
?>

 

 

UPDATE:

I am not yet sure if this works or not. Onlywire gave me this message:

Error - You have already submitted 6 items today. Due to spammers misusing the system you are not allowed to submit more than 5 per day. Your counter will reset at midnight Pacific Standard Time. If you have a legitmate use for submitting more items per day you can request to have this limit increased, send an email to info@onlywire.com and justify your reason for increasing this limit. Thank you for your understanding.

Even though this is the second bookmark I made today.