menuIcon = get_post_meta( $menu_item->ID, '_menu_item_menuIcon', true ); return $menu_item; } /** * Save menu custom fields * * @param type $menu_id * @param type $menu_item_db_id * @param type $args */ public function updateCustomNavFields( $menu_id, $menu_item_db_id, $args ) { // Check if element is properly sent if ( isset($_REQUEST['menu-item-menuIcon']) && is_array( $_REQUEST['menu-item-menuIcon']) ) { $value = $_REQUEST['menu-item-menuIcon'][$menu_item_db_id]; update_post_meta( $menu_item_db_id, '_menu_item_menuIcon', $value ); } } /** * Define new Walker edit * * @param type $walker * @param type $menu_id * @return string */ public function editWalker( $walker, $menu_id ) { global $wp_version; if ( version_compare( $wp_version, '4.4.9999' , '>' ) ) { if ( class_exists( 'Agp\Plugin\Fac\Walker\WalkerNavMenuEdit_45' ) ) { $walker = 'Agp\Plugin\Fac\Walker\WalkerNavMenuEdit_45'; } } else { if ( class_exists( 'Agp\Plugin\Fac\Walker\WalkerNavMenuEdit' ) ) { $walker = 'Agp\Plugin\Fac\Walker\WalkerNavMenuEdit'; } } return $walker; } /** * Update menu item title * * @param type $item_output * @param type $item * @param type $depth * @param type $args * @return string */ public function updateTitle ($item_output, $item, $depth, $args) { if (!empty($item->menuIcon)) { $item_output = preg_replace("/()([^<]*?)menuIcon.'"> $2<', $item_output); } return $item_output; } /** * Render custom nav fields * * @param type $item_id * @param type $item * @return type */ public function renderCustomNavFields($item_id, $item) { ob_start(); $categories = Fac()->getIconRepository()->getAllCategories(); $selected = !empty($item->menuIcon) ? esc_attr( $item->menuIcon ) : ''; ?>