Guest User

Untitled

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