mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 15:08:10 +01:00
Use custom fields for custom URL and new window data. Links no longer automatically open in a new window. see #11817
git-svn-id: http://svn.automattic.com/wordpress/trunk@13397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cb8fd85d1e
commit
280a19ff6c
@ -117,15 +117,18 @@ if ( $post_counter > 0 && $menu_selected_id > 0 && ! $updated ) {
|
||||
|
||||
$post = array( 'post_status' => 'publish', 'post_type' => 'nav_menu_item', 'post_author' => $user_ID,
|
||||
'ping_status' => 0, 'post_parent' => 0, 'menu_order' => $position,
|
||||
'guid' => $custom_linkurl, 'post_excerpt' => $custom_anchor_title, 'tax_input' => array( 'nav_menu' => $menu_title ),
|
||||
'post_excerpt' => $custom_anchor_title, 'tax_input' => array( 'nav_menu' => $menu_title ),
|
||||
'post_content' => $custom_description, 'post_title' => $custom_title );
|
||||
if ( $new_window )
|
||||
$post['post_content_filtered'] = '_blank';
|
||||
update_post_meta( $db_id, 'menu_new_window', 1 );
|
||||
else
|
||||
$post['post_content_filtered'] = '';
|
||||
update_post_meta( $db_id, 'menu_new_window', 0 );
|
||||
if ( $parent_id > 0 && isset( $parent_menu_ids[$parent_id] ) )
|
||||
$post['post_parent'] = $parent_menu_ids[$parent_id];
|
||||
|
||||
if ( $custom_linkurl )
|
||||
update_post_meta( $db_id, 'menu_link', esc_url_raw( $custom_linkurl ) );
|
||||
|
||||
// New menu item
|
||||
if ( $db_id == 0 ) {
|
||||
$db_id = wp_insert_post( $post );
|
||||
|
@ -116,7 +116,7 @@ function wp_print_nav_menu_item($menu_item, $context, $args = array() ) {
|
||||
<input type="hidden" name="position<?php echo esc_attr( $menu_item->menu_order ); ?>" id="position<?php echo esc_attr( $menu_item->menu_order ); ?>" value="<?php echo esc_attr( $menu_item->menu_order ); ?>" />
|
||||
<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 ) ); ?>" />
|
||||
<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 ); ?>" />
|
||||
<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' ); ?>" />
|
||||
<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' ); ?>" />
|
||||
<?php
|
||||
break;
|
||||
|
||||
|
@ -74,6 +74,7 @@ function wp_setup_nav_menu_item($menu_item, $type = 'item', $position = 0) {
|
||||
if ( 'item' == $type ) {
|
||||
$menu_item->type = get_post_meta($menu_item->ID, 'menu_type', true);
|
||||
$menu_item->object_id = get_post_meta($menu_item->ID, 'object_id', true);
|
||||
$menu_item->target = ( get_post_meta( $menu_item->ID, 'menu_new_window', true ) ) ? 'target="_blank"' : '';
|
||||
if ( isset( $parent_menu_order[ $menu_item->post_parent ] ) )
|
||||
$menu_item->parent_item = $parent_menu_order[ $menu_item->post_parent ];
|
||||
else
|
||||
@ -92,8 +93,7 @@ function wp_setup_nav_menu_item($menu_item, $type = 'item', $position = 0) {
|
||||
}
|
||||
|
||||
switch ( $menu_item->type ) {
|
||||
// Page Menu Item
|
||||
case 'page':
|
||||
case 'page' :
|
||||
$menu_item->link = get_page_link( $menu_item->object_id );
|
||||
|
||||
if ( $menu_item->post_title == '' )
|
||||
@ -105,11 +105,9 @@ function wp_setup_nav_menu_item($menu_item, $type = 'item', $position = 0) {
|
||||
$menu_item->description = get_post_meta( $menu_item->ID, 'page-description', true );
|
||||
else
|
||||
$menu_item->description = $menu_item->post_content;
|
||||
$menu_item->target = '';
|
||||
$menu_item->append = _x('Page', 'menu nav item type');
|
||||
break;
|
||||
// Category Menu Item
|
||||
case 'category':
|
||||
case 'category' :
|
||||
$menu_item->link = get_category_link( $menu_item->object_id );
|
||||
|
||||
if ( empty($menu_item->post_title) ) {
|
||||
@ -123,15 +121,13 @@ function wp_setup_nav_menu_item($menu_item, $type = 'item', $position = 0) {
|
||||
$menu_item->description = strip_tags( category_description( $menu_item->object_id ) );
|
||||
else
|
||||
$menu_item->description = $menu_item->post_content;
|
||||
$menu_item->target = '';
|
||||
$menu_item->append = _x('Category', 'menu nav item type');
|
||||
break;
|
||||
default:
|
||||
// Custom Menu Item
|
||||
$menu_item->link = $menu_item->guid;
|
||||
case 'custom' :
|
||||
default :
|
||||
$menu_item->link = esc_url_raw( get_post_meta( $menu_item->ID, 'menu_link', true ) );
|
||||
$menu_item->title = $menu_item->post_title;
|
||||
$menu_item->description = $menu_item->post_content;
|
||||
$menu_item->target = 'target="_blank"';
|
||||
$menu_item->append = _x('Custom', 'menu nav item type');
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user