<?php

/*
Plugin Name: WP-Wishlistr
Plugin URI: http://bueltge.de/wp-wishlistr-plugin/238/
Description: View your wishlist from <a href="http://www.wishlistr.com/">wishlistr.com</a> in your WP-Blog.
Author: Frank Bueltge
Version: 1.5
Author URI: http://bueltge.de
*/ 

/*
INSTRUCTIONS:
1. copy to /wp-content/plugins/
2. aktivate in WordPress-Admin-Area
3. go to Options --> Wishlistr and write your data for your wishlistr.com-Account
4. make a new site or content in WP with string: <!--wishlistr--> or with php: wp_wishlistr()
*/

if(function_exists('load_plugin_textdomain'))
    
load_plugin_textdomain('wp-wishlistr','wp-content/plugins/');

$fbwl_wishlistrdisplay  get_option('fbwl_wishlistrdisplay');
$fbwl_wishlistrurl      get_option('fbwl_wishlistrurl');
$fbwl_wishlistrusername get_option('fbwl_wishlistrusername');
$fbwl_linkbutton_new    get_option('fbwl_linkbutton_new');
$fbwl_linkbutton_org    get_option('fbwl_linkbutton_org');
$fbwl_liststart         get_option('fbwl_liststart');
$fbwl_liststartitem     get_option('fbwl_liststartitem');
$fbwl_listenditem       get_option('fbwl_listenditem');
$fbwl_listend           get_option('fbwl_listend');

function 
add_wp_wishlistr_menu() {
    if(
function_exists('add_options_page')) {
        
add_options_page(__('Settings to WP-Wishlistr''wp-wishlistr'), 'Wishlistr'9basename(__FILE__), 'wp_wishlistr_sub_page');  
    }
}

function 
wp_wishlistr_sub_page() {
    global 
$fbwl_linkbutton_new$fbwl_linkbutton_org$fbwl_liststart$fbwl_liststartitem$fbwl_listenditem$fbwl_listend$fbwl_wishlistrdisplay$fbwl_wishlistrurl$fbwl_wishlistrusername;
    
$fbwl_wishlistrurl "http://www.wishlistr.com/rss/".$fbwl_wishlistrusername."/";

    if(
$_POST['wp_wishlistr_options_save']){
        
update_option('fbwl_wishlistrdisplay',$_POST['fbwl_wishlistrdisplay']);
        
update_option('fbwl_wishlistrusername',$_POST['fbwl_wishlistrusername']);
        
update_option('fbwl_wishlistrurl',$_POST['fbwl_wishlistrurl']);
        
update_option('fbwl_linkbutton_new',$_POST['fbwl_linkbutton_new']);
        
update_option('fbwl_linkbutton_org',$_POST['fbwl_linkbutton_org']);
        
update_option('fbwl_liststart',$_POST['fbwl_liststart']);
        
update_option('fbwl_liststartitem',$_POST['fbwl_liststartitem']);
        
update_option('fbwl_listenditem',$_POST['fbwl_listenditem']);
        
update_option('fbwl_listend',$_POST['fbwl_listend']);
        echo 
'<div class="updated"><p>';
        echo 
__('WP-Wishlist settings successfully stored','wp-wishlistr').".";
        echo 
'</p></div>';
    }
?>
<style type="text/css">textarea {width: 95%;}</style>
<div class="wrap">
  <h2><?php _e('WP-Wishlistr''wp-wishlistr'); ?></h2>
  <fieldset class="options">
    <legend><?php _e('Settings''wp-wishlistr');?></legend>
    <form name="form1" method="post" id="wp_wishlistr_options" action="<?=$location ?>">
      <table width="100%" border="0">
       <tr class="alternate">
        <td><?php _e('Number''wp-wishlistr');?></td>
        <td><input name="fbwl_wishlistrdisplay" value="<?=get_option("fbwl_wishlistrdisplay");?>" type="text" /></td>
       </tr>
       <tr>
        <td><?php _e('Username''wp-wishlistr');?></td>
        <td><input name="fbwl_wishlistrusername" value="<?=get_option("fbwl_wishlistrusername");?>" type="text" size="70" /></td>
       </tr>
       <tr class="alternate">
        <td><?php _e('URL''wp-wishlistr');?></td>
        <td><input name="fbwl_wishlistrurl" value="<?=$fbwl_wishlistrurl;?>" type="text" size="70" disabled="disabled" /></td>
       </tr>
       <tr>
        <td><?php _e('Link-Text''wp-wishlistr');?></td>
        <td><input name="fbwl_linkbutton_new" value="<?=stripslashes(get_option("fbwl_linkbutton_new"));?>" type="text" size="70" class="code" /><br /><small><?php _e('XHTML possibly, example: &lt;small class=\'alignright\'&gt;Kaufen oder Ansehen&lt;/small&gt;''wp-wishlistr'); ?></small></td>
       </tr>
       <tr class="alternate">
        <td><?php _e('Link-Text XML''wp-wishlistr');?></td>
        <td><input name="fbwl_linkbutton_org" value="<?=get_option("fbwl_linkbutton_org");?>" type="text" size="70" /><br /><small><?php _e('This is the link text in the XML which can be substituted.''wp-wishlistr'); ?></small></td>
       </tr>
       <tr>
        <td><?php _e('HTML before it''wp-wishlistr');?></td>
        <td><input name="fbwl_liststart" value="<?=stripslashes(get_option("fbwl_liststart"));?>" type="text" size="70" class="code" /></td>
       </tr>
       <tr class="alternate">
        <td><?php _e('HTML before every wish''wp-wishlistr');?></td>
        <td><input name="fbwl_liststartitem" value="<?=stripslashes(get_option("fbwl_liststartitem"));?>" type="text" size="70" class="code" /></td>
       </tr>
       <tr>
        <td><?php _e('HTML by every wish''wp-wishlistr');?></td>
        <td><input name="fbwl_listenditem" value="<?=stripslashes(get_option("fbwl_listenditem"));?>" type="text" size="70" class="code" /></td>
       </tr>
       <tr class="alternate">
        <td><?php _e('HTML afterwards''wp-wishlistr');?></td>
        <td><input name="fbwl_listend" value="<?=stripslashes(get_option("fbwl_listend"));?>" type="text" size="70" class="code" /></td>
       </tr>
      </table>
      <p class="submit">
        <input type="submit" value="<?php _e('Save''wp-wishlistr');?> &raquo;" name="wp_wishlistr_options_save" />
        <input name="action" value="insert" type="hidden" />
      </p>
    </form>
  </fieldset>
  <fieldset class="options">
    <legend><?php _e('Informations''wp-wishlistr'); ?></legend>
    <h3>Instruktionen</h3>
    <p><?php _e('The Plugin inserts html code in your contribution or your side. In addition the following code must be copied to the place''wp-wishlistr'); ?>: <code>&lt;!--wishlistr--&gt;</code>.</p>
    <p><?php _e('In addition, the function is able to''wp-wishlistr'); ?> <code>wp_wishlistr()</code> <?php _e('Are integrated into Templates (e.g., sidebar.php), so that also there the issue is possible.''wp-wishlistr'); ?><br /><br /><strong><?php _e('Example:'''); ?></strong><br /><code>&lt;?php if (function_exists('wp_wishlistr')) : ?&gt;&lt;li&gt;<br />&lt;h2&gt;Wishlistr&lt;/h2&gt;<br />&lt;?php wp_wishlistr(); ?&gt;<br />&lt;/li&gt;&lt;?php endif; ?&gt;</code></p>
    <p><?php _e('Different settings can be carried out in the Plugin, in addition the above fields are to be used. All fields should be filled!''wp-wishlistr'); ?></p>
    <p><?php _e('The link text from the XML from wishlistr.com can be substituted. Therefore you can give your desirable text and also format with xHMTL and CSS.''wp-wishlistr'); ?> <?php _e('Besides, is to be followed, that you with single quotation marks''wp-wishlistr'); ?> (') <?php _e('Works, not with quotation mark''wp-wishlistr'); ?> (")!</p>
    <h3><?php _e('Linkbutton to your wishlist''wp-wishlistr'); ?></h3>
    <p><?php _e('You can insert a badge with a link to your list of presents with wishlistr.com, in addition you must copy the following code to the place where your Wishlistr badge should appear.''wp-wishlistr');?><br /><br /><strong><?php _e('Two examples''wp-wishlistr');?>:</strong><br /><a class="alignright" style="border: 0; margin-left: 10px;" href="http://www.wishlistr.com/<?=$fbwl_wishlistrusername;?>" title="<?php _e('Visits my list of presents''wp-wishlistr');?>"><img border="0" alt="My wishlist" src="http://www.wishlistr.com/images/88x31alt2.gif"/></a><code>&lt;a href="http://www.wishlistr.com/<?=$fbwl_wishlistrusername;?>" title="<?php _e('Visits my list of presents''wp-wishlistr');?>"&gt;&lt;img border="0" alt="My wishlist" src="http://www.wishlistr.com/images/88x31alt2.gif"/&gt;&lt;/a&gt;</code><br /><br /><a class="alignright" style="border: 0; margin-left: 10px;" href="http://www.wishlistr.com/<?=$fbwl_wishlistrusername;?>" title="<?php _e('Visits my list of presents''wp-wishlistr');?>"><img border="0" alt="My wishlist" src="http://www.wishlistr.com/images/80x15.gif"/></a><code>&lt;a href="http://www.wishlistr.com/<?=$fbwl_wishlistrusername;?>" title="<?php _e('Visits my list of presents''wp-wishlistr');?>"&gt;&lt;img border="0" alt="My wishlist" src="http://www.wishlistr.com/images/80x15.gif"/&gt;</code></p>
    <hr />
    <p><?php _e('This Plugin comes from Frank Bueltge. Feedback can be given about the website <a href=\'http://bueltge.de\'>bueltge.de</a>. English translation of <a href=\'http://eisregen1986.de.vu\'>Fabian K&uuml;nzel</a>.''wp-wishlistr'); ?></p>
  </fieldset>
</div>
<?php
}

require_once(
ABSPATH.'wp-includes/rss-functions.php');

function 
wp_wishlistr() {
    global 
$fbwl_linkbutton_new$fbwl_linkbutton_org$fbwl_liststart$fbwl_liststartitem$fbwl_listenditem$fbwl_listend$fbwl_wishlistrdisplay$fbwl_wishlistrurl$fbwl_wishlistrusername;
    
$fbwl_wishlistrurl "http://www.wishlistr.com/rss/".$fbwl_wishlistrusername."/";

    if (
$fbwl_wishlistrurl) {
        
$fbwl_rss fetch_rss($fbwl_wishlistrurl);
        echo 
str_replace("\'""'",$fbwl_liststart)."\n";
        foreach (
$fbwl_rss->items as $item) {
            if (
$fbwl_wishlistrdisplay == 0) {
                break;
            }
            
$href $item['link'];
            
$desc trim($item['description']);
            
$item['fulltitle'] = $item['title'];
            
$umlaute = array('€','‚','ƒ','„','…','†','‡','ˆ','‰','Š','‹','Œ','Ž','‘','’','“','”','•','–','—','˜','™','š','›','œ','ž','Ÿ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','&szlig;','','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','&ouml;','÷','ø','ù','ú','û','&uuml;','ý','þ','ÿ',utf8_encode('€'),utf8_encode('‚'),utf8_encode('ƒ'),utf8_encode('„'),utf8_encode('…'),utf8_encode('†'),utf8_encode('‡'),utf8_encode('ˆ'),utf8_encode('‰'),utf8_encode('Š'),utf8_encode('‹'),utf8_encode('Œ'),utf8_encode('Ž'),utf8_encode('‘'),utf8_encode('’'),utf8_encode('“'),utf8_encode('”'),utf8_encode('•'),utf8_encode('–'),utf8_encode('—'),utf8_encode('˜'),utf8_encode('™'),utf8_encode('š'),utf8_encode('›'),utf8_encode('œ'),utf8_encode('ž'),utf8_encode('Ÿ'),utf8_encode('¡'),utf8_encode('¢'),utf8_encode('£'),utf8_encode('¤'),utf8_encode('¥'),utf8_encode('¦'),utf8_encode('§'),utf8_encode('¨'),utf8_encode('©'),utf8_encode('ª'),utf8_encode('«'),utf8_encode('¬'),utf8_encode('®'),utf8_encode('¯'),utf8_encode('°'),utf8_encode('±'),utf8_encode('²'),utf8_encode('³'),utf8_encode('´'),utf8_encode('µ'),utf8_encode('¶'),utf8_encode('·'),utf8_encode('¸'),utf8_encode('¹'),utf8_encode('º'),utf8_encode('»'),utf8_encode('¼'),utf8_encode('½'),utf8_encode('¾'),utf8_encode('¿'),utf8_encode('À'),utf8_encode('Á'),utf8_encode('Â'),utf8_encode('Ã'),utf8_encode('Ä'),utf8_encode('Å'),utf8_encode('Æ'),utf8_encode('Ç'),utf8_encode('È'),utf8_encode('É'),utf8_encode('Ê'),utf8_encode('Ë'),utf8_encode('Ì'),utf8_encode('Í'),utf8_encode('Î'),utf8_encode('Ï'),utf8_encode('Ð'),utf8_encode('Ñ'),utf8_encode('Ò'),utf8_encode('Ó'),utf8_encode('Ô'),utf8_encode('Õ'),utf8_encode('Ö'),utf8_encode('×'),utf8_encode('Ø'),utf8_encode('Ù'),utf8_encode('Ú'),utf8_encode('Û'),utf8_encode('Ü'),utf8_encode('Ý'),utf8_encode('Þ'),utf8_encode('&szlig;'),utf8_encode('à'),utf8_encode('á'),utf8_encode('â'),utf8_encode('ã'),utf8_encode('ä'),utf8_encode('å'),utf8_encode('æ'),utf8_encode('ç'),utf8_encode('è'),utf8_encode('é'),utf8_encode('ê'),utf8_encode('ë'),utf8_encode('ì'),utf8_encode('í'),utf8_encode('î'),utf8_encode('ï'),utf8_encode('ð'),utf8_encode('ñ'),utf8_encode('ò'),utf8_encode('ó'),utf8_encode('ô'),utf8_encode('õ'),utf8_encode('&ouml;'),utf8_encode('÷'),utf8_encode('ø'),utf8_encode('ù'),utf8_encode('ú'),utf8_encode('û'),utf8_encode('&uuml;'),utf8_encode('ý'),utf8_encode('þ'),utf8_encode('ÿ'),chr(128),chr(129),chr(130),chr(131),chr(132),chr(133),chr(134),chr(135),chr(136),chr(137),chr(138),chr(139),chr(140),chr(141),chr(142),chr(143),chr(144),chr(145),chr(146),chr(147),chr(148),chr(149),chr(150),chr(151),chr(152),chr(153),chr(154),chr(155),chr(156),chr(157),chr(158),chr(159),chr(160),chr(161),chr(162),chr(163),chr(164),chr(165),chr(166),chr(167),chr(168),chr(169),chr(170),chr(171),chr(172),chr(173),chr(174),chr(175),chr(176),chr(177),chr(178),chr(179),chr(180),chr(181),chr(182),chr(183),chr(184),chr(185),chr(186),chr(187),chr(188),chr(189),chr(190),chr(191),chr(192),chr(193),chr(194),chr(195),chr(196),chr(197),chr(198),chr(199),chr(200),chr(201),chr(202),chr(203),chr(204),chr(205),chr(206),chr(207),chr(208),chr(209),chr(210),chr(211),chr(212),chr(213),chr(214),chr(215),chr(216),chr(217),chr(218),chr(219),chr(220),chr(221),chr(222),chr(223),chr(224),chr(225),chr(226),chr(227),chr(228),chr(229),chr(230),chr(231),chr(232),chr(233),chr(234),chr(235),chr(236),chr(237),chr(238),chr(239),chr(240),chr(241),chr(242),chr(243),chr(244),chr(245),chr(246),chr(247),chr(248),chr(249),chr(250),chr(251),chr(252),chr(253),chr(254),chr(255),chr(256));
            
$htmlcode = array('&euro;','&sbquo;','&fnof;','&bdquo;','&hellip;','&dagger;','&Dagger;','&circ;','&permil;','&Scaron;','&lsaquo;','&OElig;','&#x017D;','&lsquo;','&rsquo;','&ldquo;','&rdquo;','&bull;','&ndash;','&mdash;','&tilde;','&trade;','&scaron;','&rsaquo;','&oelig;','&#x017E;','&Yuml;','&iexcl;','&cent;','&pound;','&curren;','&yen;','&brvbar;','&sect;','&uml;','&copy;','&ordf;','&laquo;','&not;','&reg;','&macr;','&deg;','&plusmn;','&sup2;','&sup3;','&acute;','&micro;','&para;','&middot;','&cedil;','&supl;','&ordm;','&raquo;','&frac14;','&frac12;','&frac34;','&iquest;','&Agrave;','&Aacute;','&Acirc;','&Atilde;','&Auml;','&Aring;','&AElig;','&Ccedil;','&Egrave;','&Eacute;','&Ecirc;','&Euml;','&Igrave;','&Iacute;','&Icirc;','&Iuml;','&ETH;','&Ntilde;','&Ograve;','&Oacute;','&Ocirc;','&Otilde;','&Ouml;','&times;','&Oslash;','&Ugrave;','&Uacute;','&Ucirc;','&Uuml;','&Yacute;','&THORN;','&szlig;','&agrave;','&aacute;','&acirc;','&atilde;','&auml;','&aring;','&aelig;','&ccedil;','&egrave;','&eacute;','&ecirc;','&euml;','&igrave;','&iacute;','&icirc;','&iuml;','&eth;','&ntilde;','&ograve;','&oacute;','&ocirc;','&otilde;','&ouml;','&divide;','&oslash;','&ugrave;','&uacute;','&ucirc;','&uuml;','&yacute;','&thorn;','&yuml;','&euro;','&sbquo;','&fnof;','&bdquo;','&hellip;','&dagger;','&Dagger;','&circ;','&permil;','&Scaron;','&lsaquo;','&OElig;','&#x017D;','&lsquo;','&rsquo;','&ldquo;','&rdquo;','&bull;','&ndash;','&mdash;','&tilde;','&trade;','&scaron;','&rsaquo;','&oelig;','&#x017E;','&Yuml;','&iexcl;','&cent;','&pound;','&curren;','&yen;','&brvbar;','&sect;','&uml;','&copy;','&ordf;','&laquo;','&not;','&reg;','&macr;','&deg;','&plusmn;','&sup2;','&sup3;','&acute;','&micro;','&para;','&middot;','&cedil;','&supl;','&ordm;','&raquo;','&frac14;','&frac12;','&frac34;','&iquest;','&Agrave;','&Aacute;','&Acirc;','&Atilde;','&Auml;','&Aring;','&AElig;','&Ccedil;','&Egrave;','&Eacute;','&Ecirc;','&Euml;','&Igrave;','&Iacute;','&Icirc;','&Iuml;','&ETH;','&Ntilde;','&Ograve;','&Oacute;','&Ocirc;','&Otilde;','&Ouml;','&times;','&Oslash;','&Ugrave;','&Uacute;','&Ucirc;','&Uuml;','&Yacute;','&THORN;','&szlig;','&agrave;','&aacute;','&acirc;','&atilde;','&auml;','&aring;','&aelig;','&ccedil;','&egrave;','&eacute;','&ecirc;','&euml;','&igrave;','&iacute;','&icirc;','&iuml;','&eth;','&ntilde;','&ograve;','&oacute;','&ocirc;','&otilde;','&ouml;','&divide;','&oslash;','&ugrave;','&uacute;','&ucirc;','&uuml;','&yacute;','&thorn;','&yuml;','&euro;','','&sbquo;','&fnof;','&bdquo;','&hellip;','&dagger;','&Dagger;','&circ;','&permil;','&Scaron;','&lsaquo;','&OElig;','','&#x017D;','','','&lsquo;','&rsquo;','&ldquo;','&rdquo;','&bull;','&ndash;','&mdash;','&tilde;','&trade;','&scaron;','&rsaquo;','&oelig;','','&#x017E;','&Yuml;','&nbsp;','&iexcl;','&iexcl;','&iexcl;','&iexcl;','&yen;','&brvbar;','&sect;','&uml;','&copy;','&ordf;','&laquo;','&not;','­&shy;','&reg;','&macr;','&deg;','&plusmn;','&sup2;','&sup3;','&acute;','&micro;','&para;','&middot;','&cedil;','&supl;','&ordm;','&raquo;','&frac14;','&frac12;','&frac34;','&iquest;','&Agrave;','&Aacute;','&Acirc;','&Atilde;','&Auml;','&Aring;','&AElig;','&Ccedil;','&Egrave;','&Eacute;','&Ecirc;','&Euml;','&Igrave;','&Iacute;','&Icirc;','&Iuml;','&ETH;','&Ntilde;','&Ograve;','&Oacute;','&Ocirc;','&Otilde;','&Ouml;','&times;','&Oslash;','&Ugrave;','&Uacute;','&Ucirc;','&Uuml;','&Yacute;','&THORN;','&szlig;','&agrave;','&aacute;','&acirc;','&atilde;','&auml;','&aring;','&aelig;','&ccedil;','&egrave;','&eacute;','&ecirc;','&euml;','&igrave;','&iacute;','&icirc;','&iuml;','&eth;','&ntilde;','&ograve;','&oacute;','&ocirc;','&otilde;','&ouml;','&divide;','&oslash;','&ugrave;','&uacute;','&ucirc;','&uuml;','&yacute;','&thorn;','&yuml;');
            
//$item['fulltitle'] = str_replace($umlaute, $htmlcode, $item);
            //$desc = str_replace($umlaute, $htmlcode, $desc);
      
            
echo wptexturize("\n".str_replace("\'""'",$fbwl_liststartitem));
            echo 
wptexturize(str_replace("\'""'",str_replace($fbwl_linkbutton_org $fbwl_linkbutton_new$desc)));
            
$fbwl_wishlistrdisplay--;
            echo 
wptexturize(str_replace("\'""'",$fbwl_listenditem));
        }
        echo 
str_replace("\'""'",$fbwl_listend);
    }
}

define('WP_WISHLISTR_PAGE''<!--wishlistr-->');

function 
wp_wishlistr_filter($data) {
    
$start strpos($dataWP_WISHLISTR_PAGE);
    if(
$start !== false) {
        
ob_start();
        
wp_wishlistr();
        
$content ob_get_contents();
        
ob_end_clean();
        
$data substr_replace($data$content$startstrlen(WP_WISHLISTR_PAGE));
    }
    return 
$data;
}

// install standart options
function wp_wishlistr_install(){
    
add_option('fbwl_wishlistrdisplay''10');
    
add_option('fbwl_wishlistrusername''UserName');
    
add_option('fbwl_wishlistrurl''http://www.wishlistr.com/rss/UserName/');
    
add_option('fbwl_linkbutton_new''<small>Kaufen oder Ansehen</small>');
    
add_option('fbwl_linkbutton_org''Buy or view this item');
    
add_option('fbwl_liststart''<ul>');
    
add_option('fbwl_liststartitem''<li>');
    
add_option('fbwl_listenditem''</li>');
    
add_option('fbwl_listend''</ul>');
}

if (isset(
$_GET['activate']) && $_GET['activate'] == 'true') {
    
add_action('init''wp_wishlistr_install');
}

if(
function_exists('add_filter')) {
    
add_filter('the_content''wp_wishlistr_filter');
}

if(
function_exists('add_action')) {
    
add_action('admin_menu','add_wp_wishlistr_menu');
}
?>