The code is below – it uses a wordpress shortcode which is [my_hmg=widget.xml]
but if you try change the xml file like this [my_hmg=example_gallery.xml]
it just always reverts to the default widget.xml
The problem is in the function my_hmg_filter_Callback
in particular these 2 lines;
@$my_hmg_file = @$output['filename'];
if($my_hmg_file==""){$my_hmg_file = "widget.xml";}
For some reason it always thinks the file name is blank so always reverts to widget.xml.
The files can be downloaded from here – http://www.gopiplus.com/work/2010/07/18/horizontal-motion-gallery/
function my_hmg_show_filter($content){
return preg_replace_callback('/[my_hmg=(.*?)]/sim','my_hmg_filter_Callback',$content);
}
function my_hmg_filter_Callback($matches)
{
$my_hmg_package = "";
$var = $matches[1];
parse_str($var, $output);
@$my_hmg_file = @$output['filename'];
if($my_hmg_file==""){$my_hmg_file = "widget.xml";
}
Firstly change the short code to
[my_hmg file='file.xml']
Then if you have a quick read of WordPress’s short code API you’ll see that the first argument in the callback function are the attributes of the short code.
This way you can the reference the attribute ‘file’ in the array and get the proper url.