Making WordPress.org

Changeset 918


Ignore:
Timestamp:
10/21/2014 03:31:33 AM (10 years ago)
Author:
iandunn
Message:

Misc: Add a menu shortcode for displaying menus in posts.

This is a safe version of r916.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php

    r917 r918  
    3737 */
    3838add_filter( 'widget_text', 'do_shortcode' );
     39
     40/**
     41 * Output a menu via a shortcode
     42 *
     43 * @param array $attributes
     44 *
     45 * @return string
     46 */
     47function wcorg_shortcode_menu( $attributes ) {
     48    $attributes = shortcode_atts(
     49        array(
     50            'menu'       => '',
     51            'menu_class' => 'menu',
     52            'depth'      => 1,
     53        ),
     54        $attributes
     55    );
     56
     57    $attributes['depth'] = absint( $attributes['depth'] );
     58    $attributes['echo']  = false;
     59
     60    return wp_nav_menu( $attributes );
     61}
     62add_shortcode( 'menu', 'wcorg_shortcode_menu' );
    3963
    4064/**
Note: See TracChangeset for help on using the changeset viewer.