Speichern von Werten eines wiederholten Felds im wp-Menü

Ich benutze ein benutzerdefiniertes Menü Nav Walker, um einen Schieberegler zu erstellen, den ich im üblichen WP-Menü Builder verwenden kann.

Benutzerdefinierter Navigationscode:

public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { $repeatable_fields = $item->megamenu_image_slideshow;  <input class="custom_media_url widefat" id="edit-menu-item-megamenu-image-slideshow-" type="text" name="menu-item-megamenu-image-slideshow-[]" value="">    <input class="custom_media_url widefat" id="edit-menu-item-megamenu-image-slideshow-" type="text" name="menu-item-megamenu-image-slideshow-[]">    <input id="edit-menu-item-megamenu-image-slideshow-" class="" type="text" name="menu-item-megamenu-image-slideshow-[]">  Add Image } 

Das Problem, das ich habe, ist seine Werte zu speichern. Wenn ich var_dump( $repeatable_fields ); Sein Wert bleibt leer.

 function custom_nav_fields_update($menu_id, $menu_item_db_id, $args) { //slider $old = get_post_meta($menu_item_db_id, '_menu_item_megamenu_image_slideshow', true); $new = array(); $urls = $_REQUEST['menu-item-megamenu-image-slideshow'][$menu_item_db_id]; $count = count( $urls ); for ( $i = 0; $i < $count; $i++ ) { if ( $urls[$i] == 'http://' ) { $new[$i] = ''; } else { $new[$i] = stripslashes( $urls[$i] ); // and however you want to sanitize } if ( !empty( $new ) && $new != $old ) { update_post_meta( $menu_item_db_id, '_menu_item_megamenu_image_slideshow', $new ); } elseif ( empty($new) && $old ) { delete_post_meta( $menu_item_db_id, '_menu_item_megamenu_image_slideshow', $old ); } } /* if ( ! empty($_REQUEST['menu-item-megamenu-image-slideshow'][$menu_item_db_id]) && isset($_REQUEST['menu-item-megamenu-image-slideshow']) && is_array($_REQUEST['menu-item-megamenu-image-slideshow'])) { $custom_value = $_REQUEST['menu-item-megamenu-image-slideshow'][$menu_item_db_id]; update_post_meta($menu_item_db_id, '_menu_item_megamenu_image_slideshow', $custom_value); } else { $custom_value = ''; update_post_meta($menu_item_db_id, '_menu_item_megamenu_image_slideshow',$custom_value); } */ } add_action('wp_update_nav_menu_item', 'custom_nav_fields_update', 10, 3); 

Der Code, den ich verwendet habe, basiert auf diesem GitHub: https://gist.github.com/da1nonly/2057532

Jede Hilfe wird sehr geschätzt.

Solutions Collecting From Web of "Speichern von Werten eines wiederholten Felds im wp-Menü"