WordPress.org

Make WordPress Core

Changeset 13397


Ignore:
Timestamp:
02/25/2010 08:48:17 AM (10 years ago)
Author:
markjaquith
Message:

Use custom fields for custom URL and new window data. Links no longer automatically open in a new window. see #11817

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/nav-menus.php

    r13395 r13397  
    118118        $post = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'post_author' => $user_ID,
    119119            'ping_status' => 0, 'post_parent' => 0, 'menu_order' => $position,
    120             'guid' => $custom_linkurl, 'post_excerpt' => $custom_anchor_title, 'tax_input' => array( 'nav_menu' => $menu_title ),
     120            'post_excerpt' => $custom_anchor_title, 'tax_input' => array( 'nav_menu' => $menu_title ),
    121121            'post_content' => $custom_description, 'post_title' => $custom_title );
    122122        if ( $new_window )
    123             $post['post_content_filtered'] = '_blank';
     123            update_post_meta( $db_id, 'menu_new_window', 1 );
    124124        else
    125             $post['post_content_filtered'] = '';
     125            update_post_meta( $db_id, 'menu_new_window', 0 );
    126126        if ( $parent_id > 0 && isset( $parent_menu_ids[$parent_id] ) )
    127127            $post['post_parent'] = $parent_menu_ids[$parent_id];
     128
     129        if ( $custom_linkurl )
     130            update_post_meta( $db_id, 'menu_link', esc_url_raw( $custom_linkurl ) );
    128131
    129132        // New menu item
  • trunk/wp-includes/nav-menu-template.php

    r13395 r13397  
    117117                        <input type="hidden" name="linktype<?php echo esc_attr( $menu_item->menu_order ); ?>" id="linktype<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( get_post_meta( $menu_item->ID, 'menu_type', true ) ); ?>" />
    118118                        <input type="hidden" name="anchortitle<?php echo esc_attr( $menu_item->menu_order ); ?>" id="anchortitle<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->post_excerpt ); ?>" />
    119                         <input type="hidden" name="newwindow<?php echo esc_attr( $menu_item->menu_order ); ?>" id="newwindow<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo ( '' == $menu_item->post_content_filtered ? '0' : '1' ); ?>" />
     119                        <input type="hidden" name="newwindow<?php echo esc_attr( $menu_item->menu_order ); ?>" id="newwindow<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo ( get_post_meta( $menu_item->ID, 'menu_new_window', true ) ? '1' : '0' ); ?>" />
    120120<?php
    121121        break;
  • trunk/wp-includes/nav-menu.php

    r13375 r13397  
    7575        $menu_item->type = get_post_meta($menu_item->ID, 'menu_type', true);
    7676        $menu_item->object_id = get_post_meta($menu_item->ID, 'object_id', true);
     77        $menu_item->target = ( get_post_meta( $menu_item->ID, 'menu_new_window', true ) ) ? 'target="_blank"' : '';
    7778        if ( isset( $parent_menu_order[ $menu_item->post_parent ] ) )
    7879            $menu_item->parent_item = $parent_menu_order[ $menu_item->post_parent ];
     
    9394
    9495    switch ( $menu_item->type ) {
    95         // Page Menu Item
    96         case 'page':
     96        case 'page' :
    9797            $menu_item->link = get_page_link( $menu_item->object_id );
    9898
     
    106106            else
    107107                $menu_item->description = $menu_item->post_content;
    108             $menu_item->target = '';
    109108            $menu_item->append = _x('Page', 'menu nav item type');
    110         break;
    111         // Category Menu Item
    112         case 'category':
     109            break;
     110        case 'category' :
    113111            $menu_item->link = get_category_link( $menu_item->object_id );
    114112
     
    124122            else
    125123                $menu_item->description = $menu_item->post_content;
    126             $menu_item->target = '';
    127124            $menu_item->append = _x('Category', 'menu nav item type');
    128         break;
    129         default:
    130             // Custom Menu Item
    131             $menu_item->link = $menu_item->guid;
     125            break;
     126        case 'custom' :
     127        default :
     128            $menu_item->link = esc_url_raw( get_post_meta( $menu_item->ID, 'menu_link', true ) );
    132129            $menu_item->title =  $menu_item->post_title;
    133130            $menu_item->description = $menu_item->post_content;
    134             $menu_item->target = 'target="_blank"';
    135131            $menu_item->append = _x('Custom', 'menu nav item type');
    136         break;
     132            break;
    137133    }
    138134
Note: See TracChangeset for help on using the changeset viewer.