Ticket #13273: 13273.diff
File 13273.diff, 7.1 KB (added by , 9 years ago) |
---|
-
src/wp-admin/css/nav-menus.css
399 399 float: left; 400 400 } 401 401 402 #menu-item-placeholder-wrap { 403 margin-left: 72px; 404 } 405 402 406 /* Menu item types */ 403 407 .quick-search { 404 408 width: 190px; … … 643 647 text-align: center; 644 648 } 645 649 650 .menu-item-placeholder .field-link-target, 651 .menu-item-placeholder .field-xfn { 652 display: none; 653 } 654 646 655 .link-to-original { 647 656 display: block; 648 657 margin: 0 0 10px; -
src/wp-admin/includes/ajax-actions.php
1051 1051 if ( 1052 1052 ! empty( $menu_item_data['menu-item-type'] ) && 1053 1053 'custom' != $menu_item_data['menu-item-type'] && 1054 'placeholder' != $menu_item_data['menu-item-type'] && 1054 1055 ! empty( $menu_item_data['menu-item-object-id'] ) 1055 1056 ) { 1056 1057 switch( $menu_item_data['menu-item-type'] ) { -
src/wp-admin/includes/nav-menu.php
195 195 </p> 196 196 197 197 <div class="menu-item-actions description-wide submitbox"> 198 <?php if( 'custom' != $item->type && $original_title !== false ) : ?>198 <?php if( 'custom' != $item->type && 'placeholder' != $item->type && $original_title !== false ) : ?> 199 199 <p class="link-to-original"> 200 200 <?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?> 201 201 </p> … … 576 576 577 577 ?> 578 578 <div class="customlinkdiv" id="customlinkdiv"> 579 <input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" /> 579 <input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" /> 580 <p id="menu-item-placeholder-wrap"> 581 <label for="custom-menu-item-placeholder"> 582 <input id="custom-menu-item-placeholder" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-placeholder]" type="checkbox" value="1" > <?php _e( 'Placeholder' ); ?> 583 </label> 584 </p> 585 580 586 <p id="menu-item-url-wrap"> 581 587 <label class="howto" for="custom-menu-item-url"> 582 588 <span><?php _e('URL'); ?></span> … … 1047 1053 1048 1054 // Loop through all the menu items' POST values 1049 1055 foreach( (array) $menu_data as $_possible_db_id => $_item_object_data ) { 1056 if ( isset( $_item_object_data['menu-item-placeholder'] ) ) { 1057 $_item_object_data['menu-item-type'] = 'placeholder'; 1058 } 1050 1059 if ( 1051 1060 empty( $_item_object_data['menu-item-object-id'] ) && // checkbox is not checked 1052 1061 ( 1053 1062 ! isset( $_item_object_data['menu-item-type'] ) || // and item type either isn't set 1054 in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) || // or URL is the default1055 ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page)1063 ( 'placeholder' != $_item_object_data['menu-item-type'] && in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) ) || // Or URL is the default (and it isn't a placeholder). 1064 ! ( in_array( $_item_object_data['menu-item-type'], array( 'custom', 'placeholder' ) ) && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // Or it's not a custom or placeholder menu item (but not the custom home page). 1056 1065 ! empty( $_item_object_data['menu-item-db-id'] ) // or it *is* a custom menu item that already exists 1057 1066 ) 1058 1067 ) { -
src/wp-admin/js/nav-menu.js
791 791 $( '#submit-customlinkdiv' ).click(); 792 792 } 793 793 }); 794 $( '#custom-menu-item-placeholder').change( function() { 795 if ( this.checked ) { 796 $( '#menu-item-url-wrap' ).slideUp( 'fast' ); 797 $( '#custom-menu-item-type' ).val( 'placeholder' ); 798 } else { 799 $( '#menu-item-url-wrap' ).slideDown( 'fast' ); 800 $( '#custom-menu-item-type' ).val( 'custom' ); 801 } 802 } ); 794 803 }, 795 804 796 805 /** … … 883 892 }, 884 893 885 894 addCustomLink : function( processMethod ) { 886 var url = $('#custom-menu-item-url').val(), 895 var type = $('#custom-menu-item-type').val(), 896 url = $('#custom-menu-item-url').val(), 887 897 label = $('#custom-menu-item-name').val(); 888 898 889 899 processMethod = processMethod || api.addMenuItemToBottom; 890 900 891 if ( '' === url || 'http://' == url ) 901 if ( 'placeholder' == type ) { 902 url = ''; 903 } else if ( 'custom' != type ) { 892 904 return false; 905 } else if ( '' === url || 'http://' == url ) { 906 return false; 907 } 893 908 894 909 // Show the ajax spinner 895 910 $('.customlinkdiv .spinner').show(); 896 this.addLinkToMenu( url, label, processMethod, function() {911 this.addLinkToMenu( type, url, label, processMethod, function() { 897 912 // Remove the ajax spinner 898 913 $('.customlinkdiv .spinner').hide(); 899 914 // Set custom link form back to defaults … … 902 917 }); 903 918 }, 904 919 905 addLinkToMenu : function( url, label, processMethod, callback) {920 addLinkToMenu : function( type, url, label, processMethod, callback ) { 906 921 processMethod = processMethod || api.addMenuItemToBottom; 907 922 callback = callback || function(){}; 908 923 909 924 api.addItemToMenu({ 910 925 '-1': { 911 'menu-item-type': 'custom',926 'menu-item-type': type, 912 927 'menu-item-url': url, 913 928 'menu-item-title': label 914 929 } -
src/wp-includes/nav-menu.php
349 349 350 350 $original_parent = 0 < $menu_item_db_id ? get_post_field( 'post_parent', $menu_item_db_id ) : 0; 351 351 352 if ( 'custom' != $args['menu-item-type'] ) {352 if ( 'custom' != $args['menu-item-type'] && 'placeholder' != $args['menu-item-type'] ) { 353 353 /* if non-custom menu item, then: 354 354 * use original object's URL 355 355 * blank default title to sync with original object's … … 407 407 if ( 'custom' == $args['menu-item-type'] ) { 408 408 $args['menu-item-object-id'] = $menu_item_db_id; 409 409 $args['menu-item-object'] = 'custom'; 410 } elseif ( 'placeholder' == $args['menu-item-type'] ) { 411 $args['menu-item-object-id'] = $menu_item_db_id; 412 $args['menu-item-object'] = 'placeholder'; 413 $args['menu-item-url'] = ''; 410 414 } 411 415 412 416 $menu_item_db_id = (int) $menu_item_db_id; … … 680 684 $menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title; 681 685 682 686 } else { 683 $menu_item->type_label = __('Custom');687 $menu_item->type_label = ( 'placeholder' == $menu_item->type ) ? __( 'Placeholder' ) : __( 'Custom' ); 684 688 $menu_item->title = $menu_item->post_title; 685 689 $menu_item->url = empty( $menu_item->url ) ? get_post_meta( $menu_item->ID, '_menu_item_url', true ) : $menu_item->url; 686 690 }