[wp-hackers] Adding new Menu Modules to Wordpress
nikolov.tmw at gmail.com
Wed Jan 29 21:37:51 UTC 2014
>From what I tracked in source for the past couple of minutes is that pretty
much these are just normal meta boxes, just registered for the nav-menu
screen with context set to "side".
I'll do some tests and poke around and come back with any findings.
On Wed, Jan 29, 2014 at 11:33 PM, Dobri <dyordan1 at ramapo.edu> wrote:
> Just speaking from experience, I tried to do something like that a couple
> of months ago and reached pretty much nowhere using multiple approaches.
> Menu items seem to be semi-hardcoded. What I ended up doing in the end is I
> used custom links and used their title/link/alt fields as parameters that
> are parsed by a custom walker. Here's some code if you'd like to look into
> the idea:
> //you need a custom walker class. you can override start_el and a bunch of
> other methods, look into the definition of Walker_Nav_Menu
> class Custom_Walker extends Walker_Nav_Menu
> function start_el(&$output, $item, $depth=0, $args=array())
> //If it's a subitem, ignore and revert to regular
> if( 0 != $depth )
> parent::start_el($output, $item, $depth,
> //If the title of the thing begins with
> the word Divider
> == 1)
> global $wp_query;
> //assure proper indentation
> $indent = ( $depth ) ? str_repeat(
> "\t", $depth ) : '';
> //open the divider li
> $output .= $indent . '<li
> //generate the inside code
> $item_output = $args->before;
> $item_output .= $args->link_before
> . apply_filters( 'the_title', $item->attr_title, $item->ID ) .
> $item_output .= $args->after;
> //finish it up
> $output .= apply_filters(
> 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
> parent::start_el($output, $item,
> $depth, $args);
> and wherever you render the menu:
> $walker = new Custom_Walker();
> wp_nav_menu(array('theme_location' => 'rail_menu', ..., 'walker' =>
> Not very extensible as you might imagine though. The code above adds a
> little divider element if the title of the custom link begins with Divider.
> I'd be happy to see someone else offer a better solution, I'd implement it
> myself right away.
> On Wed, 29 Jan 2014, at 4:21 PM, BenderisGreat wrote:
> > I have searched around, and have not been able to find the solution
> > I would like to add a new module of items to the Appearance->Menus page
> > the backend.
> > This is the page:
> > http://codex.wordpress.org/images/c/ca/appearance-menus.png
> > <http://codex.wordpress.org/images/c/ca/appearance-menus.png>
> > Where it says Pages, Links, Categories. Is it possible to add an
> > section there with unique menu items specific to a plugin. The links I
> > would like to add in a custom module are dynamic, created using rewrite
> > rules.
> > --
> > View this message in context:
> > Sent from the Wordpress Hackers mailing list archive at Nabble.com.
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers