Ticket #38164: 38164.2.diff
File 38164.2.diff, 8.7 KB (added by , 7 years ago) |
---|
-
src/wp-admin/css/customize-controls.css
583 583 display: block; 584 584 font-style: italic; 585 585 line-height: 18px; 586 margin-top: 0; 586 587 margin-bottom: 5px; 587 588 } 588 589 … … 670 671 float: left; 671 672 } 672 673 674 #available-menu-items .accordion-section-content .new-content-item, 675 .customize-control-dropdown-pages .new-content-item { 676 width: -webkit-calc(100% - 30px); 677 width: calc(100% - 30px); 678 padding: 8px 15px; 679 position: absolute; 680 bottom: 0; 681 z-index: 10; 682 background: #eee; 683 display: -webkit-box; 684 display: -moz-box; 685 display: -ms-flexbox; 686 display: -webkit-flex; 687 display: flex; 688 } 689 690 .customize-control-dropdown-pages .new-content-item { 691 width: 98%; 692 padding: 5px 0 5px 1px; 693 position: relative; 694 } 695 696 #available-menu-items .new-content-item .create-item-input, 697 .customize-control-dropdown-pages .new-content-item .create-item-input { 698 -webkit-box-flex: 10; 699 -webkit-flex-grow: 10; 700 -moz-box-flex: 10; 701 -ms-flex-positive: 10; 702 -ms-flex: 10; 703 flex-grow: 10; 704 } 705 706 #available-menu-items .new-content-item .add-content, 707 .customize-control-dropdown-pages .new-content-item .add-content { 708 margin: 2px 0 2px 6px; 709 -webkit-box-flex: 10; 710 -webkit-flex-grow: 10; 711 -moz-box-flex: 10; 712 -ms-flex-positive: 10; 713 -ms-flex: 10; 714 flex-grow: 1; 715 } 716 717 .customize-control-dropdown-pages .new-content-item .create-item-input.invalid { 718 border: 1px solid #f00; 719 } 720 673 721 #customize-preview iframe { 674 722 width: 100%; 675 723 height: 100%; -
src/wp-admin/css/customize-nav-menus.css
572 572 padding: 0 15px 15px 15px; 573 573 } 574 574 575 #available-menu-items .accordion-section-content .new-content-item {576 width: -webkit-calc(100% - 30px);577 width: calc(100% - 30px);578 padding: 8px 15px;579 position: absolute;580 bottom: 0;581 z-index: 10;582 background: #eee;583 display: -webkit-box;584 display: -moz-box;585 display: -ms-flexbox;586 display: -webkit-flex;587 display: flex;588 }589 590 #available-menu-items .new-content-item .create-item-input {591 -webkit-box-flex: 10;592 -webkit-flex-grow: 10;593 -moz-box-flex: 10;594 -ms-flex-positive: 10;595 -ms-flex: 10;596 flex-grow: 10;597 margin-left: 5px;598 padding: 4.5px;599 }600 #available-menu-items .new-content-item .add-content {601 padding-left: 6px;602 -webkit-box-flex: 10;603 -webkit-flex-grow: 10;604 -moz-box-flex: 10;605 -ms-flex-positive: 10;606 -ms-flex: 10;607 flex-grow: 1;608 }609 610 575 #available-menu-items .menu-item-tpl { 611 576 margin: 0; 612 577 } -
src/wp-admin/js/customize-controls.js
2529 2529 * 2530 2530 * @abstract 2531 2531 */ 2532 ready: function() {}, 2532 ready: function() { 2533 if ( 'dropdown-pages' === this.params.type ) { 2534 var control = this; 2535 control.container.find( '.new-content-item' ).hide(); // Hide in JS to preserve flex display when showing. 2536 control.container.on( 'click', '.add-new-toggle', function( e ) { 2537 $( e.currentTarget ).slideUp( 180 ); 2538 control.container.find( '.new-content-item' ).slideDown( 180 ) 2539 .find( '.create-item-input' ).focus(); 2540 }); 2541 control.container.on( 'click', '.add-content', function() { 2542 control.addNewPage(); 2543 }); 2544 control.container.on( 'keyup', '.create-item-input', function( e ) { 2545 if ( 13 === e.which ) { // Enter 2546 control.addNewPage(); 2547 } 2548 }); 2549 } 2550 }, 2533 2551 2534 2552 /** 2535 2553 * Get the element inside of a control's container that contains the validation error message. … … 2747 2765 control.container.html( template( control.params ) ); 2748 2766 } 2749 2767 } 2768 }, 2769 2770 /** 2771 * Add a new page to a dropdown-pages control reusing menus code for this. 2772 * 2773 * @since 4.7.0 2774 */ 2775 addNewPage: function () { 2776 if ( 'dropdown-pages' !== this.params.type || ! api.Menus ) { 2777 return; 2778 } 2779 2780 var control = this, promise, 2781 toggle = control.container.find( '.add-new-toggle' ), 2782 container = control.container.find( '.new-content-item' ), 2783 input = control.container.find( '.create-item-input' ), 2784 title = input.val(); 2785 select = control.container.find( 'select' ); 2786 2787 if ( ! title ) { 2788 input.addClass( 'invalid' ); 2789 return; 2790 } 2791 2792 input.removeClass( 'invalid' ); 2793 input.attr( 'disabled', 'disabled' ); 2794 2795 // The menus functions add the page, publish when appropriate, and also add the new page to the dropdown-pages controls. 2796 promise = api.Menus.insertAutoDraftPost( { 2797 post_title: title, 2798 post_type: 'page' 2799 } ); 2800 promise.done( function( data ) { 2801 var availableItem, $content, itemTemplate; 2802 2803 // Prepare the new page as an available menu item. 2804 // See api.Menus.submitNew(). 2805 availableItem = new api.Menus.AvailableItemModel( { 2806 'id': 'post-' + data.post_id, // Used for available menu item Backbone models. 2807 'title': title, 2808 'type': 'page', 2809 'type_label': api.Menus.data.l10n.page_label, 2810 'object': 'post_type', 2811 'object_id': data.post_id, 2812 'url': data.url 2813 } ); 2814 2815 // Add the new item to the list of available menu items. 2816 api.Menus.availableMenuItemsPanel.collection.add( availableItem ); 2817 $content = $( '#available-menu-items-post_type-page' ).find( '.available-menu-items-list' ); 2818 itemTemplate = wp.template( 'available-menu-item' ); 2819 $content.prepend( itemTemplate( availableItem.attributes ) ); 2820 2821 // Focus the select control. 2822 select.focus(); 2823 control.setting.set( String( data.post_id ) ); // Triggers a preview refresh and updates the setting. 2824 select.val( String( data.post_id ) ); 2825 2826 // Reset the create page form. 2827 container.slideUp( 180 ); 2828 toggle.slideDown( 180 ); 2829 } ) 2830 .always( function() { 2831 input.val( '' ).removeAttr( 'disabled' ); 2832 } ); 2750 2833 } 2751 2834 }); 2752 2835 -
src/wp-includes/class-wp-customize-control.php
115 115 public $input_attrs = array(); 116 116 117 117 /** 118 * @access public 119 * @var array 120 */ 121 public $add_new = false; 122 123 /** 118 124 * @deprecated It is better to just call the json() method 119 125 * @access public 120 126 * @var array … … 557 563 echo $dropdown; 558 564 ?> 559 565 </label> 560 <?php 566 <?php if ( $this->add_new && current_user_can( 'publish_pages' ) && current_user_can( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?> 567 <button type="button" class="button add-new-toggle"><?php _e( 'Add new page' ); ?></button> 568 <div class="new-content-item"> 569 <label for="create-input-<?php echo $this->id; ?>"><span class="screen-reader-text"><?php _e( 'New page title' ); ?></span></label> 570 <input type="text" id="create-input-<?php echo $this->id; ?>" class="create-item-input" placeholder="<?php esc_attr_e( 'New page title…' ); ?>"> 571 <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button> 572 </div> 573 <?php endif; 561 574 break; 562 575 default: 563 576 ?> -
src/wp-includes/class-wp-customize-manager.php
3376 3424 'label' => __( 'Front page' ), 3377 3425 'section' => 'static_front_page', 3378 3426 'type' => 'dropdown-pages', 3427 'add_new' => true, 3379 3428 ) ); 3380 3429 3381 3430 $this->add_setting( 'page_for_posts', array( … … 3387 3436 'label' => __( 'Posts page' ), 3388 3437 'section' => 'static_front_page', 3389 3438 'type' => 'dropdown-pages', 3439 'add_new' => true, 3390 3440 ) ); 3391 3441 3392 3442 /* Custom CSS */ -
src/wp-includes/class-wp-customize-nav-menus.php
370 370 'untitled' => _x( '(no label)', 'missing menu item navigation label' ), 371 371 'unnamed' => _x( '(unnamed)', 'Missing menu name.' ), 372 372 'custom_label' => __( 'Custom Link' ), 373 'page_label' => __( 'Page' ), 373 374 /* translators: %s: menu location */ 374 375 'menuLocation' => _x( '(Currently set to: %s)', 'menu' ), 375 376 'menuNameLabel' => __( 'Menu Name' ),