More on Short Codes

I had posted a question on Short Codes to the wp-hackers mailing list and got a pointed to an article on the Codex which explained the process of coding up a short code.  I expected it to be more involved than it was and I was pleasantly surprised to find it was really straight forward.  I have already implemented one short code for the wp-SwimTeam plugin and expect I’ll have half a dozen more done by the end of the week.

What I implemented for Flickr was pretty simple – it allows the insertion of a Flickr slideshow in a post or page using the Flickr UserId value (which is different than the username) and the Set Id.  Here is the snippet of code:

/**
 * wpst_flickr_slideshow shortcode handler
 *
 * Build a short code handler to display a Flickr slide show.
 *
 * [wpst_flickr_slideshow userid="id" slideshowid="id"
 *     frameborder="pixels" *     width="pixels" height="pixels"
 *     scrolling="yes|no" align="left|center|right" view="yes|y"]
 *
 * To show this Flickr slide show:
 *
 * http://www.flickr.com/photos/27604893@N04/sets/72157605764227907/show
 *
 * Use this shortcode:
 *
 * [wpst_flickr_slideshow userid="27604893@N04" slideshowid="72157605764227907"]
 *
 * This is the resulting IFRAME tag which is returned to the caller.
 *
 * <iframe align=center src=http://www.flickr.com/slideShow/index.gne?
 *     user_id=27604893@N04&set_id=72157605761943480 frameBorder=0
 *     width=500 scrolling=no height=500></iframe>
 *
 * If the 'view="yes"' or 'view="y"' attribute is include, a linl to the
 * Flickr slideshow will be placed under the IFRAME.
 *    
 * @param array - shortcode attributes
 * @return string -  HTML code
 */
function wpst_flickr_slideshow_sc_handler($atts)
{
    $c = container() ;
    //  Parse the shortcode
 
    extract(shortcode_atts(array(
        'userid' => '',
        'slideshowid' => '',
        'frameborder' => 'default 0',
        'width' => '500',
        'height' => '500',
        'scrolling' => 'no',
        'align' => 'center',
        'view' => 'no',
    ), $atts)) ;
    //  If either the userid or slideshowid are missing then
    //  we have a problem and can't do anything meaningful.
    if (empty($userid) || empty($slideshowid))
    {
        $c->add(html_br(),
            html_b("wpst_flickr_slideshow::Invalid Shortcode Syntax"),
            html_br(2)) ;
        return $c->render() ;
    }
    $if_src = "http://www.flickr.com/slideShow/index.gne?" .
        sprintf("user_id=%s&set_id=%s frameBorder=%s align=%s",
            $userid, $slideshowid, $frameborder, $align) ;
    $c->add(html_iframe($if_src, $width, $height, $scrolling)) ;
    if (($view == 'yes') || ($view == 'y'))
    {
        $link = "http://www.flickr.com/slideShow/index.gne?" .
        sprintf("user_id=%s&set_id=%s", $userid, $slideshowid) ;
        $c->add(html_br(2), html_a($link, "View this slideshow on Flickr."), html_br(2)) ;
    }
 return $c->render() ;
}

The code above makes use of the phpHtmlLib to generate HTML code but the general intent should be pretty obvious.

 

Working on my WordPress Swim Team plugin

For the last few months I have been writing a WordPress plugin called wp-swimteam.  This plugin builds on top of WordPress to turn it into an application which can be used to manage a youth swim team.  The plugin is hosted on SourceForge and I am using a blog on that site to track the development progress.  It is going pretty well, I am having fun working on it as it will be a huge benefit to our swim team which has been driven by a paper process forever.

Retro-Dashboard Admin Theme updated

The other day I committed some changes to my Retro-Dashboard admin theme.  There was a wierd situation which only showed up with IE7 and since I use IE7 as my primary browser, it got to the point where it was driving me nuts.  The main DIV (wp-wrap) would move up and down by about 10 pixels depending on the focus of the cursor.  After a lot of putzing around with CSS I figured out how to make it stop.  The lastest version now behaves the same with all browsers but there is more space between the menus and the body content on IE than there is on Firefox.

WordPress updated

I went ahead and upgraded WordPress to 2.5.1 even though I don’t like the new Dashboard.  It turns out I wanted to use the Email Users plugin with the MacDolphins site and since Email Users needed 2.5, I had to upgrade the MacDolphins site in order to use it.  Since the Swim Team plugin exposes the Dashboard pretty extensively to the end user, I decided to see if I could modify the Dashboard so it was more to my liking.

The result of that work is Retro-Dashboard, a WordPress Admin Theme plugin which I released yesterday.  It isn’t anything super fancy but it is waaaaaaay better than the default Dashboard (bleh, who thought that was a good idea).

Retro-Dashboard Admin Theme

Yesterday I received an e-mail letting me know that my WordPress plugin request for Retro-Dashboard h ad been approved so last night I checked all of the code and supporting files into Subversion.  Is it perfect?  Nope.  Does it clean up stuff in the 2.5 Dashboard which I dislike?  Yes.  I imagine I will continue to tweak it and use it as a Admin Theme learning platform.  Maybe I’ll do a Rock Band theme … Hmmm.

You can find Retro-Dashboard on WordPress.org at:  http://wordpress.org/extend/plugins/retro-dashboard/

WordPress 2.5 Admin Theme Plugin?

Like many people, I am not a big fan of the new admin theme with WP 2.5.  While somethings (like categories being below the post) I find cumbersome, I can deal with those, it is the visual layout and color scheme which I don’t like.

I am not a fan of web sites that fill the entire browser window all the way up to the edge.  I like a little bit of a border – something which says “I spent some time making this look crisp and finished”.  Letting sites fill all the way to the edge always seemed lazy to me.  And I really don’t like the mish-mash of colors either.

So after poking around for a new admin theme and not finding anything, I decided to see if I could do some simple CSS tweaks to clean up the Dashboard more to my liking.  I now have something running which I am reasonably happy with and have requested a project on wp-plugins.org.  Hopefully if I am accepted, I will have it available to others, should anyone else want it, later today or tonight.

Update:  As of 6:00 AM on Friday I still haven’t heard anything back from wp-plugins.org.   I thought this was supposed to happen quickly and was one of the selling points for wp-plugins.org?

WordPress 2.5 Dashboard Interface

The 2.5 WordPress release has been out for a few weeks but, I haven’t paid too much attention to it as I was focusing on getting the plugin sufficiently complete to support our Swim Team registation last weekend.

Today I uploaded 2.5 into my development area.  Yuch.  I really don’t like the color schemes at all nor do I like the “all the way to the edge of the browser” design.  I am not sure what to do now – the new interface really clashes with the work I have done on the plugin.  I guess it was inevitable but I don’t really feel like dealing wiht it right now.

If I can make some simple CSS changes, that may be ok, otherwise I’ll probably stick with 2.3.3 until after this season is over.