Archive for the ‘Web Programming’ Category

WordPress 4.0 Menu Behavior Change

September 9, 2014

I recently upgraded a site to the new WordPress 4.0.  As usual, there were no noticeable hiccups… until I looked at my main navigation more closely a couple of days later.  I have a couple menus defined but one called “Primary Navigation” – a pretty typical set up.  I’ve written my own theme, as I have for many, many sites and have used the same menu code for as long as I can remember:

// after_setup_theme callback
register_nav_menus( array( 'primary' => __( 'Primary Navigation',
           'somethingidontrememberwhyitisshereandcantfinditinthedocs' ), ) );

// in template menu 
wp_nav_menu( array('menu' => 'Primary Navigation' ))

This was causing a different menu to show up in the location of the wp_nav_menu.

A quick web search showed I wasn’t the only one running into this as well as no obvious indicators of changes in the behavior of wp_nav_menu. There was a hint, and I followed it, that changing to the actual name of the menu would fix this – and it did. My code now reads:

wp_nav_menu( array('menu' => 'Main Navigation' ))

“Main Navigation” is the actual name of the menu I defined inside of my site.

This doesn’t seem quite right having to know the exact menu name instead of allowing a menu to be abstractly identified and then mapped.

I also tried:

  • switching to using register_nav_menu
  • switching to using the menu identifier/slug “primary”
    • WordPress codex for wp_nav_menu says the menu parameter “accepts (matching in order) id, slug, name”
    • Reminder that the second parameter for register_nav_menu is a “description” not a “name”

Only using the actual menu name worked. 

Advertisements

Applets, Flex and JavaScript

April 10, 2010

I’ve been doing web programming for a very long time.  In the past I’ve done large Swing clients in applets (long before Swing was part of the standard JDK) and lately I’ve been using Adobe Flex to build Flash and AIR applications.  I enjoy how the Flex framework and structure makes Flash work for a mere programmer whereas time-line programming never really worked for me.  All along the way there’s been JavaScript; a misnamed language that has nothing to do with Java and as many platform dependency problems as CSS and HTML.  Throughout my career I’ve carefully avoided its annoyances.  I suppose that’s what’s previously pushed me at applets and Flash – they are technologies that have let me avoid JavaScript.

Recently, I had to develop a prototype that revolved around Google Maps.  One of the requirements was that it had to work on the iPhone.  As we all know, the iPhone (currently) does not support Flash.  So, since no one was jumping up to go buy me an iPhone and a Mac to build my app on, my only real option was JavaScript.  The prototyping went well – the project has been approved to be developed for real.  While I still don’t prefer JavaScript (the faked out object definitions and prolific use of anonymous functions is just ugly) I found the GoogleMaps API to be well designed and the JQuery library to be nearly redeeming of JavaScript in general.

If JavaScript had features like JQuery back in the beginning I probably wouldn’t have had to endure all the craziness of deploying signed applets.  I’ve often lamented the lack of mathematical expressions in CSS.  I understand why it is not there, but there have been so many times I wanted to size something as 100% minus  “whatever that width over there is”… now I can.

I like having good tools available to me so that I have the maximum amount of flexibility when I need to solve a problem.  I’m not throwing away my Flex anytime soon (though I did toss applets away a good while ago), if you’ve been like me, avoiding JavaScript at almost any cost, you might want to check out JQuery. It makes JavaScript programming much more reasonable.