Advertisement
Guest User

Replete temp mega menu fix

a guest
May 16th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.41 KB | None | 0 0
  1. <?php  if ( ! defined('AVIA_FW')) exit('No direct script access allowed');
  2. /**
  3.  * This file holds various classes and methods necessary to hijack the wordpress menu and improve it with mega menu capabilities
  4.  *
  5.  *
  6.  * @author      Christian "Kriesi" Budschedl
  7.  * @copyright   Copyright (c) Christian Budschedl
  8.  * @link        http://kriesi.at
  9.  * @link        http://aviathemes.com
  10.  * @since       Version 1.0
  11.  * @package     AviaFramework
  12.  */
  13.  
  14. /**
  15.  *
  16.  */
  17.  
  18.  
  19. if( !class_exists( 'avia_megamenu' ) )
  20. {
  21.  
  22.     /**
  23.      * The avia megamenu class contains various methods necessary to create mega menus out of the admin backend
  24.      * @package     AviaFramework
  25.      */
  26.     class avia_megamenu
  27.     {
  28.  
  29.         /**
  30.          * avia_megamenu constructor
  31.          * The constructor uses wordpress hooks and filters provided and
  32.          * replaces the default menu with custom functions and classes within this file
  33.          * @package     AviaFramework
  34.          */
  35.         function avia_megamenu()
  36.         {
  37.             //adds stylesheet and javascript to the menu page
  38.             add_action('admin_menu', array(&$this,'avia_menu_header'));
  39.  
  40.             //exchange arguments and tell menu to use the avia walker for front end rendering
  41.             add_filter('wp_nav_menu_args', array(&$this,'modify_arguments'), 100);
  42.  
  43.             //exchange argument for backend menu walker
  44.             add_filter( 'wp_edit_nav_menu_walker', array(&$this,'modify_backend_walker') , 100);
  45.  
  46.             //save avia options:
  47.             add_action( 'wp_update_nav_menu_item', array(&$this,'update_menu'), 100, 3);
  48.  
  49.         }
  50.  
  51.         /**
  52.          * If we are on the nav menu page add javascript and css for the page
  53.          */
  54.         function avia_menu_header()
  55.         {
  56.             if(basename( $_SERVER['PHP_SELF']) == "nav-menus.php" )
  57.             {
  58.                 wp_enqueue_style(  'avia_admin', AVIA_CSS_URL . 'avia_admin.css');
  59.                 wp_enqueue_script( 'avia_mega_menu' , AVIA_JS_URL . 'avia_mega_menu.js',array('jquery', 'jquery-ui-sortable'), false, true );
  60.             }
  61.         }
  62.  
  63.  
  64.         /**
  65.          * Replaces the default arguments for the front end menu creation with new ones
  66.          */
  67.         function modify_arguments($arguments){
  68.  
  69.             $walker = apply_filters("avia_mega_menu_walker", "avia_walker");
  70.  
  71.             if($walker)
  72.             {
  73.                 $arguments['walker']                = new $walker();
  74.                 $arguments['container_class']       = $arguments['container_class'] .= ' megaWrapper';
  75.                 $arguments['menu_class']            = 'avia_mega';
  76.             }
  77.  
  78.             return $arguments;
  79.         }
  80.  
  81.  
  82.         /**
  83.          * Tells wordpress to use our backend walker instead of the default one
  84.          */
  85.         function modify_backend_walker($name)
  86.         {
  87.             return 'avia_backend_walker';
  88.         }
  89.  
  90.  
  91.  
  92.         /*
  93.          * Save and Update the Custom Navigation Menu Item Properties by checking all $_POST vars with the name of $check
  94.          * @param int $menu_id
  95.          * @param int $menu_item_db
  96.          */
  97.         function update_menu($menu_id, $menu_item_db)
  98.         {
  99.             $check = apply_filters('avf_mega_menu_post_meta_fields',array('megamenu','division','textarea'), $menu_id, $menu_item_db);
  100.  
  101.             foreach ( $check as $key )
  102.             {
  103.                 if(!isset($_POST['menu-item-avia-'.$key][$menu_item_db]))
  104.                 {
  105.                     $_POST['menu-item-avia-'.$key][$menu_item_db] = "";
  106.                 }
  107.  
  108.                 $value = $_POST['menu-item-avia-'.$key][$menu_item_db];
  109.                 update_post_meta( $menu_item_db, '_menu-item-avia-'.$key, $value );
  110.             }
  111.         }
  112.     }
  113. }
  114.  
  115.  
  116.  
  117. if( !class_exists( 'avia_walker' ) )
  118. {
  119.  
  120.     /**
  121.      * The avia walker is the frontend walker and necessary to display the menu, this is a advanced version of the wordpress menu walker
  122.      * @package WordPress
  123.      * @since 1.0.0
  124.      * @uses Walker
  125.      */
  126.     class avia_walker extends Walker {
  127.         /**
  128.          * @see Walker::$tree_type
  129.          * @var string
  130.          */
  131.         var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
  132.  
  133.         /**
  134.          * @see Walker::$db_fields
  135.          * @todo Decouple this.
  136.          * @var array
  137.          */
  138.         var $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' );
  139.  
  140.         /**
  141.          * @var int $columns
  142.          */
  143.         var $columns = 0;
  144.  
  145.         /**
  146.          * @var int $max_columns maximum number of columns within one mega menu
  147.          */
  148.         var $max_columns = 0;
  149.  
  150.         /**
  151.          * @var int $rows holds the number of rows within the mega menu
  152.          */
  153.         var $rows = 1;
  154.  
  155.         /**
  156.          * @var array $rowsCounter holds the number of columns for each row within a multidimensional array
  157.          */
  158.         var $rowsCounter = array();
  159.  
  160.         /**
  161.          * @var string $mega_active hold information whetever we are currently rendering a mega menu or not
  162.          */
  163.         var $mega_active = 0;
  164.  
  165.  
  166.  
  167.         /**
  168.          * @see Walker::start_lvl()
  169.          *
  170.          * @param string $output Passed by reference. Used to append additional content.
  171.          * @param int $depth Depth of page. Used for padding.
  172.          */
  173.         function start_lvl(&$output, $depth = 0, $args = array()) {
  174.             $indent = str_repeat("\t", $depth);
  175.             if($depth === 0) $output .= "\n{replace_one}\n";
  176.             $output .= "\n$indent<ul class=\"sub-menu\">\n";
  177.         }
  178.  
  179.         /**
  180.          * @see Walker::end_lvl()
  181.          *
  182.          * @param string $output Passed by reference. Used to append additional content.
  183.          * @param int $depth Depth of page. Used for padding.
  184.          */
  185.         function end_lvl(&$output, $depth = 0, $args = array()) {
  186.             $indent = str_repeat("\t", $depth);
  187.             $output .= "$indent</ul>\n";
  188.  
  189.             if($depth === 0)
  190.             {
  191.                 if($this->mega_active)
  192.                 {
  193.  
  194.                     $output .= "\n</div>\n";
  195.                     $output = str_replace("{replace_one}", "<div class='avia_mega_div avia_mega".$this->max_columns."'>", $output);
  196.  
  197.                     foreach($this->rowsCounter as $row => $columns)
  198.                     {
  199.                         $output = str_replace("{current_row_".$row."}", "avia_mega_menu_columns_".$columns, $output);
  200.                     }
  201.  
  202.                     $this->columns = 0;
  203.                     $this->max_columns = 0;
  204.                     $this->rowsCounter = array();
  205.  
  206.                 }
  207.                 else
  208.                 {
  209.                     $output = str_replace("{replace_one}", "", $output);
  210.                 }
  211.             }
  212.         }
  213.  
  214.         /**
  215.          * @see Walker::start_el()
  216.          *
  217.          * @param string $output Passed by reference. Used to append additional content.
  218.          * @param object $item Menu item data object.
  219.          * @param int $depth Depth of menu item. Used for padding.
  220.          * @param int $current_page Menu item ID.
  221.          * @param object $args
  222.          */
  223.         function start_el(&$output, $item, $depth = 0, $args = array(), $current_object_id = 0 ) {
  224.             global $wp_query;
  225.  
  226.             //set maxcolumns
  227.             if(!isset($args->max_columns)) $args->max_columns = 5;
  228.  
  229.  
  230.             $item_output = $li_text_block_class = $column_class = "";
  231.  
  232.             if($depth === 0)
  233.             {
  234.                 $this->mega_active = get_post_meta( $item->ID, '_menu-item-avia-megamenu', true);
  235.             }
  236.  
  237.  
  238.             if($depth === 1 && $this->mega_active)
  239.             {
  240.                 $this->columns ++;
  241.  
  242.                 //check if we have more than $args['max_columns'] columns or if the user wants to start a new row
  243.                 if($this->columns > $args->max_columns || (get_post_meta( $item->ID, '_menu-item-avia-division', true) && $this->columns != 1))
  244.                 {
  245.                     $this->columns = 1;
  246.                     $this->rows ++;
  247.                     $output .= "\n<li class='avia_mega_hr'></li>\n";
  248.                 }
  249.  
  250.                 $this->rowsCounter[$this->rows] = $this->columns;
  251.  
  252.                 if($this->max_columns < $this->columns) $this->max_columns = $this->columns;
  253.  
  254.  
  255.                 $title = apply_filters( 'the_title', $item->title, $item->ID );
  256.  
  257.                 if($title != "-" && $title != '"-"') //fallback for people who copy the description o_O
  258.                 {
  259.                     $item_output .= "<h4>".$title."</h4>";
  260.                 }
  261.  
  262.                 $column_class  = ' {current_row_'.$this->rows.'}';
  263.  
  264.                 if($this->columns == 1)
  265.                 {
  266.                     $column_class  .= " avia_mega_menu_columns_fist";
  267.                 }
  268.             }
  269.             else if($depth >= 2 && $this->mega_active && get_post_meta( $item->ID, '_menu-item-avia-textarea', true) )
  270.             {
  271.                 $li_text_block_class = 'avia_mega_text_block ';
  272.  
  273.                 $item_output.= do_shortcode($item->post_content);
  274.  
  275.  
  276.             }
  277.             else
  278.             {
  279.                 $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
  280.                 $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
  281.                 $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
  282.                 $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
  283.  
  284.                 $item_output .= $args->before;
  285.                 $item_output .= '<a'. $attributes .'>';
  286.                 $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
  287.                 $item_output .= '</a>';
  288.                 $item_output .= $args->after;
  289.             }
  290.  
  291.  
  292.             $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  293.             $class_names = $value = '';
  294.  
  295.             $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  296.  
  297.             $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
  298.             $class_names = ' class="'.$li_text_block_class. esc_attr( $class_names ) . $column_class.'"';
  299.  
  300.             $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
  301.  
  302.  
  303.  
  304.  
  305.             $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
  306.         }
  307.  
  308.         /**
  309.          * @see Walker::end_el()
  310.          *
  311.          * @param string $output Passed by reference. Used to append additional content.
  312.          * @param object $item Page data object. Not used.
  313.          * @param int $depth Depth of page. Not Used.
  314.          */
  315.         function end_el(&$output, $item, $depth = 0, $args = array()) {
  316.             $output .= "</li>\n";
  317.         }
  318.     }
  319. }
  320.  
  321.  
  322.  
  323.  
  324.  
  325. if( !class_exists( 'avia_backend_walker' ) )
  326. {
  327. /**
  328.  * Create HTML list of nav menu input items.
  329.  * This walker is a clone of the wordpress edit menu walker with some options appended, so the user can choose to create mega menus
  330.  *
  331.  * @package AviaFramework
  332.  * @since 1.0
  333.  * @uses Walker_Nav_Menu
  334.  */
  335.     class avia_backend_walker extends Walker_Nav_Menu
  336.     {
  337.         /**
  338.          * @see Walker_Nav_Menu::start_lvl()
  339.          * @since 3.0.0
  340.          *
  341.          * @param string $output Passed by reference.
  342.          * @param int $depth Depth of page.
  343.          */
  344.         function start_lvl(&$output, $depth = 0, $args = array() ) {}
  345.  
  346.         /**
  347.          * @see Walker_Nav_Menu::end_lvl()
  348.          * @since 3.0.0
  349.          *
  350.          * @param string $output Passed by reference.
  351.          * @param int $depth Depth of page.
  352.          */
  353.         function end_lvl(&$output, $depth = 0, $args = array()) {
  354.         }
  355.  
  356.         /**
  357.          * @see Walker::start_el()
  358.          * @since 3.0.0
  359.          *
  360.          * @param string $output Passed by reference. Used to append additional content.
  361.          * @param object $item Menu item data object.
  362.          * @param int $depth Depth of menu item. Used for padding.
  363.          * @param int $current_page Menu item ID.
  364.          * @param object $args
  365.          */
  366.         function start_el(&$output, $item, $depth = 0, $args = array(), $current_object_id = 0 ) {
  367.             global $_wp_nav_menu_max_depth;
  368.             $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
  369.  
  370.             $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  371.  
  372.             ob_start();
  373.             $item_id = esc_attr( $item->ID );
  374.             $removed_args = array(
  375.                 'action',
  376.                 'customlink-tab',
  377.                 'edit-menu-item',
  378.                 'menu-item',
  379.                 'page-tab',
  380.                 '_wpnonce',
  381.             );
  382.  
  383.             $original_title = '';
  384.             if ( 'taxonomy' == $item->type ) {
  385.                 $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
  386.             } elseif ( 'post_type' == $item->type ) {
  387.                 $original_object = get_post( $item->object_id );
  388.                 $original_title = $original_object->post_title;
  389.             }
  390.  
  391.             $classes = array(
  392.                 'menu-item menu-item-depth-' . $depth,
  393.                 'menu-item-' . esc_attr( $item->object ),
  394.                 'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
  395.             );
  396.  
  397.             $title = $item->title;
  398.  
  399.             if ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
  400.                 $classes[] = 'pending';
  401.                 /* translators: %s: title of menu item in draft status */
  402.                 $title = sprintf( __('%s (Pending)'), $item->title );
  403.             }
  404.  
  405.             $title = empty( $item->label ) ? $title : $item->label;
  406.  
  407.             $itemValue = "";
  408.             if($depth == 0)
  409.             {
  410.                 $itemValue = get_post_meta( $item->ID, '_menu-item-avia-megamenu', true);
  411.                 if($itemValue != "") $itemValue = 'avia_mega_active ';
  412.             }
  413.  
  414.             ?>
  415.  
  416.             <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo $itemValue; echo implode(' ', $classes ); ?>">
  417.                 <dl class="menu-item-bar">
  418.                     <dt class="menu-item-handle">
  419.                         <span class="item-title"><?php echo esc_html( $title ); ?></span>
  420.                         <span class="item-controls">
  421.  
  422.  
  423.                             <span class="item-type item-type-default"><?php echo esc_html( $item->type_label ); ?></span>
  424.                             <span class="item-type item-type-avia"><?php _e('Column'); ?></span>
  425.                             <span class="item-type item-type-megafied"><?php _e('(Mega Menu)'); ?></span>
  426.                             <span class="item-order">
  427.                                 <a href="<?php
  428.                                     echo wp_nonce_url(
  429.                                         add_query_arg(
  430.                                             array(
  431.                                                 'action' => 'move-up-menu-item',
  432.                                                 'menu-item' => $item_id,
  433.                                             ),
  434.                                             remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
  435.                                         ),
  436.                                         'move-menu_item'
  437.                                     );
  438.                                 ?>" class="item-move-up"><abbr title="<?php esc_attr_e('Move up'); ?>">&#8593;</abbr></a>
  439.                                 |
  440.                                 <a href="<?php
  441.                                     echo wp_nonce_url(
  442.                                         add_query_arg(
  443.                                             array(
  444.                                                 'action' => 'move-down-menu-item',
  445.                                                 'menu-item' => $item_id,
  446.                                             ),
  447.                                             remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
  448.                                         ),
  449.                                         'move-menu_item'
  450.                                     );
  451.                                 ?>" class="item-move-down"><abbr title="<?php esc_attr_e('Move down'); ?>">&#8595;</abbr></a>
  452.                             </span>
  453.                             <a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php _e('Edit Menu Item'); ?>" href="<?php
  454.                                 echo ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? admin_url( 'nav-menus.php' ) : add_query_arg( 'edit-menu-item', $item_id, remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) );
  455.                             ?>"><?php _e( 'Edit Menu Item' ); ?></a>
  456.                         </span>
  457.                     </dt>
  458.                 </dl>
  459.  
  460.                 <div class="menu-item-settings" id="menu-item-settings-<?php echo $item_id; ?>">
  461.                     <?php if( 'custom' == $item->type ) : ?>
  462.                         <p class="field-url description description-wide">
  463.                             <label for="edit-menu-item-url-<?php echo $item_id; ?>">
  464.                                 <?php _e( 'URL' ); ?><br />
  465.                                 <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" />
  466.                             </label>
  467.                         </p>
  468.                     <?php endif; ?>
  469.                     <p class="description description-thin description-label avia_label_desc_on_active">
  470.                         <label for="edit-menu-item-title-<?php echo $item_id; ?>">
  471.                         <span class='avia_default_label'><?php _e( 'Navigation Label' ); ?></span>
  472.                         <span class='avia_mega_label'><?php _e( 'Mega Menu Column Title <span class="avia_supersmall">(if you dont want to display a title just enter a single dash: "-" )</span>' ); ?></span>
  473.  
  474.                             <br />
  475.                             <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" />
  476.                         </label>
  477.                     </p>
  478.                     <p class="description description-thin description-title">
  479.                         <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
  480.                             <?php _e( 'Title Attribute' ); ?><br />
  481.                             <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_excerpt ); ?>" />
  482.                         </label>
  483.                     </p>
  484.                     <p class="field-link-target description description-thin">
  485.                         <label for="edit-menu-item-target-<?php echo $item_id; ?>">
  486.                             <?php _e( 'link Target' ); ?><br />
  487.                             <select id="edit-menu-item-target-<?php echo $item_id; ?>" class="widefat edit-menu-item-target" name="menu-item-target[<?php echo $item_id; ?>]">
  488.                                 <option value="" <?php selected( $item->target, ''); ?>><?php _e('Same window or tab'); ?></option>
  489.                                 <option value="_blank" <?php selected( $item->target, '_blank'); ?>><?php _e('New window or tab'); ?></option>
  490.                             </select>
  491.                         </label>
  492.                     </p>
  493.                     <p class="field-css-classes description description-thin">
  494.                         <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
  495.                             <?php _e( 'CSS Classes (optional)' ); ?><br />
  496.                             <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode(' ', $item->classes ) ); ?>" />
  497.                         </label>
  498.                     </p>
  499.                     <p class="field-xfn description description-thin">
  500.                         <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
  501.                             <?php _e( 'link Relationship (XFN)' ); ?><br />
  502.                             <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
  503.                         </label>
  504.                     </p>
  505.                     <p class="field-description description description-wide">
  506.                         <label for="edit-menu-item-description-<?php echo $item_id; ?>">
  507.                             <?php _e( 'Description' ); ?><br />
  508.                             <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->post_content ); ?></textarea>
  509.                         </label>
  510.                     </p>
  511.  
  512.                     <div class='avia_mega_menu_options'>
  513.                     <!-- ################# avia custom code here ################# -->
  514.                         <?php
  515.                         $title = 'Use as Mega Menu';
  516.                         $key = "menu-item-avia-megamenu";
  517.                         $value = get_post_meta( $item->ID, '_'.$key, true);
  518.  
  519.                         if($value != "") $value = "checked='checked'";
  520.                         ?>
  521.  
  522.                         <p class="description description-wide avia_checkbox avia_mega_menu avia_mega_menu_d0">
  523.                             <label for="edit-<?php echo $key.'-'.$item_id; ?>">
  524.                                 <input type="checkbox" value="active" id="edit-<?php echo $key.'-'.$item_id; ?>" class=" <?php echo $key; ?>" name="<?php echo $key . "[". $item_id ."]";?>" <?php echo $value; ?> /><?php _e( $title ); ?>
  525.                             </label>
  526.                         </p>
  527.                         <!-- ***************  end item *************** -->
  528.  
  529.                         <?php
  530.                         $title = 'This column should start a new row';
  531.                         $key = "menu-item-avia-division";
  532.                         $value = get_post_meta( $item->ID, '_'.$key, true);
  533.  
  534.                         if($value != "") $value = "checked='checked'";
  535.                         ?>
  536.  
  537.                         <p class="description description-wide avia_checkbox avia_mega_menu avia_mega_menu_d1">
  538.                             <label for="edit-<?php echo $key.'-'.$item_id; ?>">
  539.                                 <input type="checkbox" value="active" id="edit-<?php echo $key.'-'.$item_id; ?>" class=" <?php echo $key; ?>" name="<?php echo $key . "[". $item_id ."]";?>" <?php echo $value; ?> /><?php _e( $title ); ?>
  540.                             </label>
  541.                         </p>
  542.                         <!-- ***************  end item *************** -->
  543.  
  544.  
  545.  
  546.                         <?php
  547.                         $title = 'Use the description to create a Text Block. Dont display this item as a link. (note: dont remove the label text, otherwise wordpress will delete the item)';
  548.                         $key = "menu-item-avia-textarea";
  549.                         $value = get_post_meta( $item->ID, '_'.$key, true);
  550.  
  551.                         if($value != "") $value = "checked='checked'";
  552.                         ?>
  553.  
  554.                         <p class="description description-wide avia_checkbox avia_mega_menu avia_mega_menu_d2">
  555.                             <label for="edit-<?php echo $key.'-'.$item_id; ?>">
  556.                                 <input type="checkbox" value="active" id="edit-<?php echo $key.'-'.$item_id; ?>" class=" <?php echo $key; ?>" name="<?php echo $key . "[". $item_id ."]";?>" <?php echo $value; ?> /><span class='avia_long_desc'><?php _e( $title ); ?></span>
  557.                             </label>
  558.                         </p>
  559.                         <!-- ***************  end item *************** -->
  560.  
  561.  
  562.  
  563.  
  564.                     </div>
  565.  
  566.                     <?php do_action('avia_mega_menu_option_fields', $output, $item, $depth, $args); ?>
  567.  
  568.                     <!-- ################# end avia custom code here ################# -->
  569.  
  570.                     <div class="menu-item-actions description-wide submitbox">
  571.                         <?php if( 'custom' != $item->type ) : ?>
  572.                             <p class="link-to-original">
  573.                                 <?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
  574.                             </p>
  575.                         <?php endif; ?>
  576.                         <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
  577.                         echo wp_nonce_url(
  578.                             add_query_arg(
  579.                                 array(
  580.                                     'action' => 'delete-menu-item',
  581.                                     'menu-item' => $item_id,
  582.                                 ),
  583.                                 remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
  584.                             ),
  585.                             'delete-menu_item_' . $item_id
  586.                         ); ?>"><?php _e('Remove'); ?></a> <span class="meta-sep"> | </span> <a class="item-cancel submitcancel" id="cancel-<?php echo $item_id; ?>" href="<?php echo add_query_arg( array('edit-menu-item' => $item_id, 'cancel' => time()), remove_query_arg( $removed_args, admin_url( 'nav-menus.php' ) ) );
  587.                             ?>#menu-item-settings-<?php echo $item_id; ?>">Cancel</a>
  588.                     </div>
  589.  
  590.                     <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
  591.                     <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" />
  592.                     <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
  593.                     <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" />
  594.                     <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
  595.                     <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
  596.                 </div><!-- .menu-item-settings-->
  597.                 <ul class="menu-item-transport"></ul>
  598.             <?php
  599.             $output .= ob_get_clean();
  600.         }
  601.     }
  602.  
  603.  
  604. }
  605.  
  606.  
  607.  
  608.  
  609. if( !function_exists( 'avia_fallback_menu' ) )
  610. {
  611.     /**
  612.      * Create a navigation out of pages if the user didnt create a menu in the backend
  613.      *
  614.      */
  615.     function avia_fallback_menu()
  616.     {
  617.         $current = "";
  618.         $exclude = avia_get_option('frontpage');
  619.         if (is_front_page()){$current = "class='current-menu-item'";}
  620.         if ($exclude) $exclude ="&exclude=".$exclude;
  621.  
  622.         echo "<div class='fallback_menu'>";
  623.         echo "<ul class='avia_mega menu'>";
  624.         echo "<li $current><a href='".get_bloginfo('url')."'>Home</a></li>";
  625.         wp_list_pages('title_li=&sort_column=menu_order'.$exclude);
  626.         echo apply_filters('avf_fallback_menu_items', "", 'fallback_menu');
  627.         echo "</ul></div>";
  628.     }
  629. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement