Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $menu_control .= '<select style="'. $style .'" name="penci_cat_mega_menu[' . $item->ID . ']" id="" class="widefat code edit-menu-item-url">';
- foreach ( $td_category_tree as $category => $category_id ) {
- $menu_control .= '<option value="' . $category_id . '"' . selected( $penci_cat_mega_menu, $category_id, false ) . '>' . $category . '</option>';
- }
- function penci_wp_update_nav_menu_item( $menu_id, $menu_item_id, $args ) {
- // Update meta menu items
- if ( isset( $_POST['penci_cat_mega_menu'][$menu_item_id] ) ) {
- update_post_meta( $menu_item_id, 'penci_cat_mega_menu', $_POST['penci_cat_mega_menu'][$menu_item_id] );
- }
- if ( isset( $_POST['penci_number_mega_menu'][$menu_item_id] ) ) {
- update_post_meta( $menu_item_id, 'penci_number_mega_menu', $_POST['penci_number_mega_menu'][$menu_item_id] );
- }
- }
- function hook_wp_nav_menu_objects( $items, $args = '' ) {
- $menu_items = array();
- foreach ( $items as &$item ) {
- $item->is_mega_menu = false;
- // if menu is mega menu, render mega menu
- $penci_catid_mega_menu = get_post_meta( $item->ID, 'penci_cat_mega_menu', true );
- $penci_number_mega_menu = get_post_meta( $item->ID, 'penci_number_mega_menu', true );
- if( ! isset( $penci_number_mega_menu ) || empty ( $penci_number_mega_menu ) ): $penci_number_mega_menu = '1'; endif;
- if ( ! empty( $penci_catid_mega_menu ) ) {
- $item->classes[] = 'penci-mega-menu';
- // add the parent menu
- $menu_items[] = $item;
- // create mega menu item
- $post = new stdClass;
- $post->ID = 0;
- $post->post_author = '';
- $post->post_date = '';
- $post->post_date_gmt = '';
- $post->post_password = '';
- $post->post_type = 'menu_penci';
- $post->post_status = 'draft';
- $post->to_ping = '';
- $post->pinged = '';
- $post->comment_status = get_option( 'default_comment_status' );
- $post->ping_status = get_option( 'default_ping_status' );
- $post->post_pingback = get_option( 'default_pingback_flag' );
- $post->post_category = get_option( 'default_category' );
- $post->page_template = 'default';
- $post->post_parent = 0;
- $post->menu_order = 0;
- $new_item = new WP_Post( $post );
- /*
- * if this is mega menu
- * set the is_mega_menu flag
- * render content of this mega menu
- */
- $new_item->is_mega_menu = true; // sent to the menu walkers
- $new_item->menu_item_parent = $item->ID;
- $new_item->url = '';
- $new_item->title = '';
- $new_item->title .= '<div class="penci-megamenu">';
- $new_item->title .= penci_return_html_mega_menu( $penci_catid_mega_menu, $penci_number_mega_menu );
- $new_item->title .= '</div>';
- $menu_items[] = $new_item;
- }
- else {
- $menu_items[] = $item;
- }
- } //end foreach
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement