Genesis Favicon Uploader Bug
-
Hello all,
I was surprised to see that the favicon uploader plugin for the venerable Genesis / Studiopress platform isn’t working (though the plugin isn’t maintained by that team). I thought I would bring it to everyone’s attention since, even as advanced users, our clients might want to use a plugin like this in the future.
I’m not sure how to put this without being over critical, but I will try.
The problem:
I attempted to upload a favicon.ico file using this plugin to make sure it worked for my client. It failed. Not only that, but I got a vexing error: “Currently at this time only file type supported are .ico.” Oddly, the file I was uploading was favicon.ico. Weird.Ok so I dug into the code in case anyone cares. There’s a bit of an issue with how the plugin detects whether or not you have uploaded the appropriate file extension – EXCEPT it’s not using an appropriate regular expression or something similar. It is simply waiting for the first period and grabbing the text afterward.
Here’s the succinct version:
If I do a print_r on $explosion (via “explode()” which is a function that separates all parts of a string based on a common separating character – in this case the period). The problem here is that my directory structure includes the domain name, so it catches the “dot” in the/home/andrew/myurl.com/wp-content/plugins/genesis-favicon-uploader/favicons/favicon.ico”
So because the “myurl.com” string is in my file structure, it counts that period as shown here:
Explosion: Array ( [0] => /home/andrew/609south [1] => com/wp-content/plugins/genesis-favicon-uploader/favicons/favicon [2] => ico )
So instead of seeing the “.ico” as array value [1], it’s seeing “.com” which is the value of array index [2], since explode is simply splitting the strings every time it sees a period and creates a new array member.
This is where it all goes awry. It’s a simple problem, and I think the plugin could use a re-write, though I don’t know if there’s much demand for such a thing if it has gone this long unresolved.
And since we are looking for a hardcoded value, it will never see the “.ico” in my case.
$check = $favicon_check; if ( !is_multisite() ) { $favicon = $favicon_path .'favicon.ico'; } else { $favicon = $favicon_path .'favicon-'.$blog_id.'.ico'; } $explosion = explode(".", $check); // The explode function should be a preg_match or similar expression that would only match the end of the filename - or even easier - just require that the name be "favicon.ico" :) $name = $explosion[0]; $extension = $explosion[1];
http://wordpress.org/extend/plugins/genesis-favicon-uploader/
- The topic ‘Genesis Favicon Uploader Bug’ is closed to new replies.