Archive for January, 2009

WordPress MU AdSense revenue sharing plugin with link unit widget

Thursday, January 29th, 2009

I have done  some changes to assense revenue share plugin to working with wordpress MU site : see plugin page

I have expanded to this plugin to woking with google adsense link unit widget.

This is now working with blogs.lk domain. see blogs.lk demo blog for live example

If you need this plugin and it is usefull , just put a comment with your blog name. If more intersted I will release this to public.

WordPress MU 2.7 is now available

Thursday, January 29th, 2009

The 2.7 version of WordPress MU is now available for download:

http://mu.wordpress.org/download/

Get WPMU 2.7 and Upgared your system.

WordPress patch for problamatic libxml2 version

Wednesday, January 14th, 2009

I have gone throught many post regarding wordpress problem with buggy libxml2 version, The many woraround was downgrade libxml2 version to 2.6.32 or older.  The current version of libxml2 2.7.2 also have bug ’stripping leading angle brackets and & sign’.

Many wordpress use shared hosting plan and can not downgrade libxml2. This is for you , I like to shara with you.

Known wordpress problems with libxml2

XMLRPC api stripping leading angle brackets (when you post using blog writer , Flickr or any xmlrpc API your post <>& are missing).

Blogger Importer mising URL etc.

Remove ‘<>&’ character from RSS widget result urls.

Any not specified here please comment.

Wordpress libxml2 USE files

blogger.php, blogger_mearge.php, link-parse-opml.php, atomlib.php, class-IXR.php, feed.php, rss.php

Workaround patch for wordpress

Currently I have modified 3 files those are blogger.php, class-IXR.php and rss.php. If you found any isue in oter files please reply this post.

Before going to call xml_parse fuction put this code segment

//xmllib 2.7.0 -2.7.2 stripping leading angle brackets bug patch
if(LIBXML_DOTTED_VERSION == ‘2.7.0′ ||
LIBXML_DOTTED_VERSION == ‘2.7.1′ ||
LIBXML_DOTTED_VERSION == ‘2.7.2′
){
$xml =str_replace(”&lt;”,”&#60;”,$xml );
$xml =str_replace(”&gt;”,”&#62;”,$xml );
$xml =str_replace(”&amp;”,”&#38;”,$xml );
}
//end Fix
xml_parse($parser, $xml);

blogger.php Patch update parse function

function parse($xml) {

global $app_logging;
array_unshift($this->ns_contexts, array());

$parser = xml_parser_create_ns();
xml_set_object($parser, $this);
xml_set_element_handler($parser, “start_element”, “end_element”);
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,0);
xml_set_character_data_handler($parser, “cdata”);
xml_set_default_handler($parser, “_default”);
xml_set_start_namespace_decl_handler($parser, “start_ns”);
xml_set_end_namespace_decl_handler($parser, “end_ns”);

$contents = “”;

//xmllib 2.7.0 -2.7.2 stripping leading angle brackets bug patch
if(LIBXML_DOTTED_VERSION == ‘2.7.0′ ||
LIBXML_DOTTED_VERSION == ‘2.7.1′ ||
LIBXML_DOTTED_VERSION == ‘2.7.2′
){
$xml =str_replace(”&lt;”,”&#60;”,$xml );
$xml =str_replace(”&gt;”,”&#62;”,$xml );
$xml =str_replace(”&amp;”,”&#38;”,$xml );
}
//end Fix
xml_parse($parser, $xml);

xml_parser_free($parser);

return true;
}

class-IXR.php Patch update parse function

function parse() {
// first remove the XML declaration
$this->message = preg_replace(’/<\?xml(.*)?\?’.'>/’, ”, $this->message);
if (trim($this->message) == ”) {
return false;
}
$this->_parser = xml_parser_create();
// Set XML parser to take the case of tags in to account
xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
// Set XML parser callback functions
xml_set_object($this->_parser, $this);
xml_set_element_handler($this->_parser, ‘tag_open’, ‘tag_close’);
xml_set_character_data_handler($this->_parser, ‘cdata’);

//xmllib 2.7.0 -2.7.2 stripping leading angle brackets bug patch
if(LIBXML_DOTTED_VERSION == ‘2.7.0′ ||
LIBXML_DOTTED_VERSION == ‘2.7.1′ ||
LIBXML_DOTTED_VERSION == ‘2.7.2′
){
$this->message =str_replace(”&lt;”,”&#60;”,$this->message);
$this->message =str_replace(”&gt;”,”&#62;”,$this->message);
$this->message =str_replace(”&amp;”,”&#38;”,$this->message);
}

if (!xml_parse($this->_parser, $this->message)) {
/* die(sprintf(’XML error: %s at line %d’,
xml_error_string(xml_get_error_code($this->_parser)),
xml_get_current_line_number($this->_parser))); */
return false;
}
xml_parser_free($this->_parser);
// Grab the error messages, if any
if ($this->messageType == ‘fault’) {
$this->faultCode = $this->params[0]['faultCode'];
$this->faultString = $this->params[0]['faultString'];
}
return true;
}

rss.php Patch update MagpieRSS function

function MagpieRSS ($source) {

# if PHP xml isn’t compiled in, die
#
if ( !function_exists(’xml_parser_create’) )
trigger_error( “Failed to load PHP’s XML Extension. http://www.php.net/manual/en/ref.xml.php” );

$parser = @xml_parser_create();

if ( !is_resource($parser) )
trigger_error( “Failed to create an instance of PHP’s XML parser. http://www.php.net/manual/en/ref.xml.php”);

$this->parser = $parser;

# pass in parser, and a reference to this object
# setup handlers
#
xml_set_object( $this->parser, $this );
xml_set_element_handler($this->parser,
‘feed_start_element’, ‘feed_end_element’ );

xml_set_character_data_handler( $this->parser, ‘feed_cdata’ );

//xmllib 2.7.0 -2.7.2 stripping leading angle brackets bug patch
if(LIBXML_DOTTED_VERSION == ‘2.7.0′ ||
LIBXML_DOTTED_VERSION == ‘2.7.1′ ||
LIBXML_DOTTED_VERSION == ‘2.7.2′
){
$source =str_replace(”&lt;”,”&#60;”,$source );
$source =str_replace(”&gt;”,”&#62;”,$source );
$source =str_replace(”&amp;”,”&#38;”,$source );
}
$status = xml_parse( $this->parser, $source );

if (! $status ) {
$errorcode = xml_get_error_code( $this->parser );
if ( $errorcode != XML_ERROR_NONE ) {
$xml_error = xml_error_string( $errorcode );
$error_line = xml_get_current_line_number($this->parser);
$error_col = xml_get_current_column_number($this->parser);
$errormsg = “$xml_error at line $error_line, column $error_col”;

$this->error( $errormsg );
}
}

xml_parser_free( $this->parser );

$this->normalize();
}

Note

I have check only for 3 libxml version , If you need this patch for other version please reply or modify your self.

Updates

New libxml ‘2.7.3′ also not working , add this version also above code .

Wordpress MU delicious widget

Monday, January 12th, 2009

Wordpress MU Delicious (del.icio.us)  widget plugin available for download.

The Fallowing customization availabe for this widget

  • Widget title - The title that will appear above the bookmarks when the widget is displayed in your sidebar.
  • del.icio.us login - Your username on the delicious site.
  • Number of links -How many links/bookmarks you want to show in the widget
  • Show bookmarks containg all of these tags - If this text box is used, the widget will only display bookmarks with the specified tags. Make sure to separate the tags with spaces or it will not work. You could tag the bookmarks you wanted to share with your readers “blog” or “wordpress”, and effectively filter out any of the others.
  • Whether the link’s description is shown, if you provided one.
  • Whether the link’s tags are shown.
  • Whether the link’s favicon is shown.

Wordpress MU Admin Options

  • Delicious Default number of link.
  • Delicious Default login.
  • Delicious Default title.
  • Delicious Default setting for link open new window option.

Installation

Edit deliciousmu.php fallowing values as you need.

$delicious_default_number_of_link = 10;
$delicious_default_login = ‘comlanka’;
$delicious_default_title = ‘Delicious’;
$delicious_link_open_new_window = true;

Copy deliciousmu.php in to mu-plugins directory

Go to design option , Drag Delicius widget and edit setting.

See working demo and instruction available at demo blog

Download Wordpress Mu Delicius widget