Alex (SirShurf) Frenkel's Blog

A web log of a PHP professional

Archive for the ‘Plugin’ Category

WPML 3.1.8.x and the double slash problems continues.

leave a comment »

Well, after my previous post WPML have relised a new version, but it looks like this error gone unnoticed.

One other error with my solution was that on the homepage paging it had errors, so here is the revised version of the fix for WPML.

$arrUrl = parse_url($absolute_home_url);
if(!isset($arrUrl[‘path’])) $arrUrl[‘path’] = ‘/’;
$absolute_home_url = $arrUrl[‘scheme’].”://”.$arrUrl[‘host’].$arrUrl[‘path’];
if(isset($arrUrl[‘query’])) $absolute_home_url .= ‘?’.$arrUrl[‘query’];
if(isset($arrUrl[‘fragment’])) $absolute_home_url .= ‘#’.$arrUrl[‘fragment’];
$arrUrl = parse_url($this->settings[ ‘language_domains’ ][ $code ]);
if(!isset($arrUrl[‘path’])) $arrUrl[‘path’] = ‘/’;
$this->settings[ ‘language_domains’ ][ $code ] = $arrUrl[‘scheme’].”://”.$arrUrl[‘host’].$arrUrl[‘path’];
if(isset($arrUrl[‘query’])) $this->settings[ ‘language_domains’ ][ $code ] .= ‘?’.$arrUrl[‘query’];
if(isset($arrUrl[‘fragment’])) $this->settings[ ‘language_domains’ ][ $code ] .= ‘#’.$arrUrl[‘fragment’];
$arrUrl = parse_url($new_url);
if (!empty($arrUrl)){
if(!isset($arrUrl[‘path’])) $arrUrl[‘path’] = ‘/’;
$new_url = $arrUrl[‘scheme’].”://”.$arrUrl[‘host’].$arrUrl[‘path’];
if(isset($arrUrl[‘query’])) $new_url .= ‘?’.$arrUrl[‘query’];
if(isset($arrUrl[‘fragment’])) $new_url .= ‘#’.$arrUrl[‘fragment’];


The fix goes into sitepress.class.php on between lines 6463 and 6464:

                        $this->settings[ ‘language_domains’ ][ $default_language ] = $wpdb->get_var( “SELECT option_value FROM $wpdb->options WHERE option_name = ‘siteurl'”);
$new_url = str_replace( $absolute_home_url, $this->settings[ ‘language_domains’ ][ $code ], $new_url );


Written by Alex (Shurf) Frenkel

October 28, 2014 at 2:12 pm

Posted in Plugin, Wordpress, wpml

WPMU Ultimate Facebook Addon plugin Upgraded to version 0.3

with 2 comments

Well as stated in the topic, I have updated the WPMU Ultimate Facebook plugin Fix to version 0.3.

This is a maintenance only version since it’s only fixing posting description with a quotes (single quote to be exact).

You can download the plugin from:

And you can get the plugin from:


Written by Alex (Shurf) Frenkel

March 12, 2012 at 7:05 pm

WPMU Infinite SEO plugin fix

with 7 comments

As you where able to see from my previous post’s I was quite made at some of the development decisions of WPMU stuff and I was stuck with a problem that was not possible (at least I did not know how) to fix.

Well I fixed it and here is the result.
My new plugin was approved by and can be downloaded here:

This plugin fix multibite problems with the description and fixes usage of caption.

Comments are welcomed.

Written by Alex (Shurf) Frenkel

February 22, 2012 at 10:41 pm

WPMU Ultimate Facebook plugin Fix

with one comment

In addition to this post:Problem with UTF, Excepts — AND GOOD CODING PRACTICES!

I have created a fix to Ultimate Facebook:
This fix address next things:
* Facebook OpenGraph fails if the text in description is incorrect – especially in Hebrew
* Current version of the plugin sends in wall post description blog tag line. In my fix I am sending Excerpts.

The plugin can be downloaded at

Written by Alex (Shurf) Frenkel

February 20, 2012 at 9:42 pm

Problem with UTF, Excepts — AND GOOD CODING PRACTICES!

with 2 comments

I am sorry if what I am going to write will offend anybody but after more then 2 days of debugging… I am getting frustrated with this.

I have no problems with plugins not working with Hebrew, since this language is not that common, but for crying out loud, PLEASE pretty PLEASE use common sense when programming!

I will show here simple example of what I mean and this is only an example, unfortunaly the same problem exist in other plugins (I have seen the same general programming problems in Ultimate Facebook too).

This plugin create a description text for the “META-Description” tag.
Now the problem in the current version I faces is that it’s not stripping out “Caption” tags and it’s splitting multi-byte strings in the middle of the letter (usage of strlen which is not multibyte safe).
I am not asking here WHY the programmer not used a built in function to get excerpt of a set length, or added ANY hooks in his plugins!!!

Here is the code used:

First lets go to: wds_onepage.php that is responsible for printing the meta to the client, in it we see next code:

if (is_singular()) {
$metadesc = wds_get_value('metadesc');
if ($metadesc == '' || !$metadesc) {
$metadesc = wds_replace_vars($wds_options['metadesc-'.$post->post_type], (array) $post );

You can see here that first we try to get metadesc value and if it’s empty we are requesting metadesc value from the option.
Lets trace “wds_replace_vars” to the source, and we find it in wds_core.php
I will not put the full function here to save some space but here is the interesting part:
'%%excerpt%%' => !empty($r['post_excerpt']) ? apply_filters('get_the_excerpt', $r['post_excerpt']) : substr(wp_trim_excerpt($r['post_content']), 0, 155),

We are checking IF excerpt exists if not we will create one using “wp_trim_excerpt” and we will substr (not MB safe!!!).
The first part of the problem is easily fixed here all I need to do is to sit in the “wp_trim_excerpt” hook of WP:

add_filter( 'wp_trim_excerpt', array($objClass,'seo'));
function seo($strText){

$strText = strip_shortcodes( $strText );
$strText = strip_tags ( $strText );

return $strText;

That way we are getting text only and not all of the HTML junk the plugin is giving GOOGLE.

But now I am getting blank description, so lets trace it further, we have striped the text, and cutted it not MB safe to 155 characters. next things we have is this:

echo "\t".''."\n";

OUCH, now, we are stripping tags and using esc_attr on our cutted text. the first is stupid since the HTML we had was cutted to 155 in the middle so the strip_tags would not work, but that I have fixed using the hook above (I am stripping tags on the original text before the substr call).

But the biggest problem is the esc_attr call, since it’s checking for the CORRECT UTF text, and since we cutted the text in the middle of a letter it is not a VALID UTF!

to fix that lets change the hook above:

add_filter( 'wp_trim_excerpt', array($objClass,'seo'));
function seo($strText){

$strText = strip_shortcodes( $strText );
$strText = strip_tags ( $strText );
$strText = apply_filters('the_content', $strText);
$strText = str_replace(']]>', ']]>', $strText);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$strText = wp_trim_words( $strText, $excerpt_length, $excerpt_more );

return $strText;

This time I am responsible for the shortening of the text (I am making it only 55 characters to fit in 155 that will be cutted later), and using wp_trim_words in order to have only full words in the description (Google dont like paritial words).

This has taken ceare of the first part the client part, but what about the Admin part?

Well this is the one that got me to write this post, in the admin part for some reason the creation of the text does not uses the same function at all!!!!

The parameter here is $desc in wds-core-metabox.php and is acheaved by this code:

$desc = wds_get_value('metadesc');
if (empty($desc))
$desc = substr(strip_tags($post->post_content), 0, 130).' ...';
if (empty($desc))
$desc = 'temp description';

Now here there is NO hooks and no methods for me to catch.
Currently as of writing this post, I have not yet found an answere of how to bypass this and ANY ideas will be welcomed.

In any way, my fix for this plugin will be availible at this location as soon as approve it:

Written by Alex (Shurf) Frenkel

February 20, 2012 at 5:22 pm

Gravity Forms Popup Widget updated to version 0.5 – Supports open on button click.

with 16 comments

On the forum I was asked, can my plugin be opened only on pressing a button.

Since it was requested by 2 people I desided to add this functionality so here is an update to version 0.5 of the Gravity Forms Popup Widget Plugin.

Have fun 🙂

Written by Alex (Shurf) Frenkel

February 11, 2012 at 2:27 pm

WPMU MarketPress and “Comments are closed” – or a new WordPress plugin

with 3 comments

Laitly I desided to try and to move form Magento to a something simplier.

Since I had an account on WPMU I desided on MarketPress, a plugin that adds eCommerce to WordPress, but came to a problem that I had a “Comments are closed” on the theme they provided (at first I desided no to make a custom theme)

Searching the forum gave me nothing usefull (except a notification that “it is planned”) so I desided to hack it a bit.

The conclution of this hack us a plugin that re enables a comment on a product listing: WPMU MarketPress Allow Comments

Well, have fun 🙂

Written by Alex (Shurf) Frenkel

February 6, 2012 at 10:36 pm

Zopim Live Chat Addon – WordPress Plugin – Updated

with 3 comments

One of the users of my Zopim Live Chat Addon, activated the addon before he activated the Zopim itself.

What it did was adding a submenu before the menu was created and as such it was not working.

I have added a code that is allways moving this plugin to be the last on the list.

Good luck.

Written by Alex (Shurf) Frenkel

January 12, 2012 at 1:36 am

Zopim Live Chat Addon – WordPress Plugin

with 4 comments

A few weeks ago I have found a nice chat that can be installed in a website.

I called a client that I think can be interested in and we tested the chat on the clients WordPress.

One of the thigs that was missing was an option to exclude special pages from the chat and from that a new plugin came up.

I give you the Zopim Live Chat Addon Plugin (Zopim Live Chat Addon – WordPress Plugin).

P.S. If you consider to get you a new Zopim Live Chat please use my reference for a referal: Zopim Free registration page

Written by Alex (Shurf) Frenkel

December 24, 2011 at 12:30 am

Gravity Forms Popup Widget ver. 0.2

leave a comment »

Per a couple of requests I have updated Gravity Forms Popup Widget to a version 0.2.

The changes in this version are:
* Updated to work with WordPress 3.3.
* Added an option to set a position for the window location on opening.

As a side note, by the help of Andy here is a working installation of the plugin:

Thank you Andy for you link and for your feedback.

Written by Alex (Shurf) Frenkel

December 21, 2011 at 7:03 pm