Ejemplo n.º 1
0
/**
 * The main output function for our plugin.
 * 
 * @param  array  $atts An array of shortcode attributes.
 * @return string A WordPress custom menu, via our custom walker.
 */
function csst_nav($atts = array())
{
    // Invoke our menu class, passing our atts to it.
    $csst_nav = new CSST_Nav($atts);
    // Get the custom menu.
    $out = $csst_nav->get();
    // Shortcodes must return, not echo.
    return $out;
}
Ejemplo n.º 2
0
 public function __construct($atts)
 {
     // If we have not yet run this script on this page load...
     if (!self::$already_constructed) {
         /**
          * Pass some php stuff to our JS. This has to happen before we print
          * our inline scripts or call our external scripts.
          */
         add_action('wp_footer', array($this, 'localize'), 1);
         /**
          * Grab our plugin scripts and styles. Normally we could do this at
          * wp_enqueue_scripts, but we want to wait and see if the shortcode
          * is being used.  If this code is being run, then the shortcode is in
          * use, so enqueue them now.
          */
         $this->enqueue();
         /**
          * Apply our jQuery plugin to our menu. This has to happen after we
          * localize our php.
          */
         add_action('wp_footer', array($this, 'inline_js'), 900);
         /**
          * Take note!  We have already run this block and
          * don't need to do it again.
          */
         self::$already_constructed = TRUE;
     }
     // Set our $which_menu member to the value passed to the shortcode.
     $this->which_menu = $atts['which_menu'];
 }
Ejemplo n.º 3
0
/**
 * The main output function for our plugin.
 * 
 * @param  array  $atts An array of shortcode attributes.
 * @return string A WordPress custom menu, via our custom walker.
 */
function csst_nav_cb($atts = array())
{
    $csst_nav = new CSST_Nav($atts);
    $out = $csst_nav->get();
    echo $out;
}