Make WordPress Core

Ticket #34923: 34923.5.diff

File 34923.5.diff, 23.5 KB (added by celloexpressions, 9 years ago)

Add info notifications to menu item controls with links to edit new content after it's published. This is displayed inline for each control, and could be compiled into a centralized notifications area in the future in #35210.

  • src/wp-admin/css/customize-nav-menus.css

     
    4747        text-align: right;
    4848}
    4949
     50.customize-control-nav_menu_item.has-notifications .menu-item-handle {
     51        border-left: 4px solid #00a0d2;
     52}
     53
    5054.wp-customizer .menu-item-settings {
    5155        max-width: 100%;
    5256        overflow: hidden;
     
    483487        color: #23282d;
    484488}
    485489
    486 #available-menu-items .accordion-section-content {
     490#available-menu-items .available-menu-items-list {
    487491        overflow-y: auto;
    488492        max-height: 200px; /* This gets set in JS to fit the screen size, and based on # of sections. */
    489493        background: transparent;
     
    520524}
    521525
    522526#available-menu-items .accordion-section-content {
    523         padding: 1px 15px 15px 15px;
     527        max-height: 290px;
    524528        margin: 0;
    525         max-height: 290px;
     529        padding: 0;
     530        position: relative;
     531        background: transparent;
    526532}
    527533
     534#available-menu-items .accordion-section-content .available-menu-items-list {
     535        margin: 0 0 45px 0;
     536        padding: 1px 15px 15px 15px;
     537}
     538
     539#available-menu-items .accordion-section-content .available-menu-items-list:only-child { /* Types that do not support new items for the current user */
     540        margin-bottom: 0;
     541}
     542
     543#new-custom-menu-item .accordion-section-content {
     544        padding: 0 15px 15px 15px;
     545}
     546
     547#available-menu-items .accordion-section-content .new-content-item {
     548        width: calc(100% - 30px);
     549        padding: 8px 15px;
     550        position: absolute;
     551        bottom: 0;
     552        z-index: 10;
     553        background: #eee;
     554}
     555
     556#available-menu-items .new-content-item .add-content {
     557        float: right;
     558        padding-left: 6px;
     559}
     560
     561#available-menu-items .new-content-item .add-content:before {
     562        content: "\f543";
     563        font: 20px/16px dashicons;
     564        position: relative;
     565        display: inline-block;
     566        top: 5px;
     567        left: -2px;
     568}
     569
    528570#available-menu-items .menu-item-tpl {
    529571        margin: 0;
    530572}
  • src/wp-admin/js/customize-nav-menus.js

     
    100100                        'click .menu-item-tpl': '_submit',
    101101                        'click #custom-menu-item-submit': '_submitLink',
    102102                        'keypress #custom-menu-item-name': '_submitLink',
     103                        'click .new-content-item .add-content': '_submitNew',
     104                        'keypress .create-item-input': '_submitNew',
    103105                        'keydown': 'keyboardAccessible'
    104106                },
    105107
     
    115117                pages: {},
    116118                sectionContent: '',
    117119                loading: false,
     120                addingNew: false,
    118121
    119122                initialize: function() {
    120123                        var self = this;
     
    124127                        }
    125128
    126129                        this.$search = $( '#menu-items-search' );
    127                         this.sectionContent = this.$el.find( '.accordion-section-content' );
     130                        this.sectionContent = this.$el.find( '.available-menu-items-list' );
    128131
    129132                        this.debounceSearch = _.debounce( self.search, 500 );
    130133
     
    160163
    161164                        // Load more items.
    162165                        this.sectionContent.scroll( function() {
    163                                 var totalHeight = self.$el.find( '.accordion-section.open .accordion-section-content' ).prop( 'scrollHeight' ),
     166                                var totalHeight = self.$el.find( '.accordion-section.open .available-menu-items-list' ).prop( 'scrollHeight' ),
    164167                                        visibleHeight = self.$el.find( '.accordion-section.open' ).height();
    165168
    166169                                if ( ! self.loading && $( this ).scrollTop() > 3 / 4 * totalHeight - visibleHeight ) {
     
    337340                                }
    338341                                items = new api.Menus.AvailableItemCollection( items ); // @todo Why is this collection created and then thrown away?
    339342                                self.collection.add( items.models );
    340                                 typeInner = availableMenuItemContainer.find( '.accordion-section-content' );
     343                                typeInner = availableMenuItemContainer.find( '.available-menu-items-list' );
    341344                                items.each(function( menuItem ) {
    342345                                        typeInner.append( itemTemplate( menuItem.attributes ) );
    343346                                });
     
    356359
    357360                // Adjust the height of each section of items to fit the screen.
    358361                itemSectionHeight: function() {
    359                         var sections, totalHeight, accordionHeight, diff;
     362                        var sections, lists, totalHeight, accordionHeight, diff, totalWidth, button, buttonWidth;
    360363                        totalHeight = window.innerHeight;
    361364                        sections = this.$el.find( '.accordion-section:not( #available-menu-items-search ) .accordion-section-content' );
    362                         accordionHeight =  46 * ( 2 + sections.length ) - 13; // Magic numbers.
     365                        lists = this.$el.find( '.accordion-section:not( #available-menu-items-search ) .available-menu-items-list:not(":only-child")' );
     366                        accordionHeight =  46 * ( 1 + sections.length ) + 14; // Magic numbers.
    363367                        diff = totalHeight - accordionHeight;
    364368                        if ( 120 < diff && 290 > diff ) {
    365369                                sections.css( 'max-height', diff );
     370                                lists.css( 'max-height', ( diff - 60 ) );
    366371                        }
     372                        // Fit the new-content input and button in the available space.
     373                        totalWidth = this.$el.width();
     374                        // Clone button to get width of invisible element.
     375                        button = this.$el.find( '.accordion-section .new-content-item .add-content' ).first().clone().appendTo( 'body' ).css({ 'display': 'block', 'visibility': 'hidden' });
     376                        buttonWidth = button.outerWidth();
     377                        button.remove();
     378                        this.$el.find( '.accordion-section .new-content-item .create-item-input' ).width( ( totalWidth - buttonWidth - 70 ) ); // 70 = additional margins and padding.
    367379                },
    368380
    369381                // Highlights a menu item.
     
    456468                        itemName.val( '' );
    457469                },
    458470
     471                // Submit handler for keypress (enter) on field and click on button.
     472                _submitNew: function( event ) {
     473                        // Only proceed with keypress if it is Enter.
     474                        if ( 'keypress' === event.type && 13 !== event.which ) {
     475                                return;
     476                        }
     477
     478                        if ( this.addingNew ) {
     479                                return;
     480                        }
     481
     482                        var container = $( event.target ).closest( '.accordion-section' );
     483
     484                        this.submitNew( container );
     485                },
     486
     487                // Creates a new object and adds an associated menu item to the menu.
     488                submitNew: function( container ) {
     489                        var panel = this,
     490                                itemName = container.find( '.create-item-input' ),
     491                                title = itemName.val(),
     492                                dataContainer = container.find( '.available-menu-items-list' ),
     493                                itemType = dataContainer.data( 'type' ),
     494                                itemObject = dataContainer.data( 'object' ),
     495                                itemTypeLabel = dataContainer.data( 'type_label' ),
     496                                promise;
     497
     498                        if ( ! this.currentMenuControl ) {
     499                                return;
     500                        }
     501
     502                        if ( '' === itemName.val() ) {
     503                                itemName.addClass( 'invalid' );
     504                                return;
     505                        } else {
     506                                container.find( '.accordion-section-title' ).addClass( 'loading' );
     507                        }
     508
     509                        // Only posts are supported currently.
     510                        if ( 'post_type' !== itemType ) {
     511                                return;
     512                        }
     513
     514                        panel.addingNew = true;
     515                        itemName.attr( 'disabled', 'disabled' );
     516                        promise = wp.customize.Posts.insertAutoDraftPost( {
     517                                post_title: title,
     518                                post_type: itemObject,
     519                                post_status: 'publish'
     520                        } );
     521                        promise.done( function( data ) {
     522                                var menuItem = {
     523                                        'title': itemName.val(),
     524                                        'type': itemType,
     525                                        'type_label': itemTypeLabel,
     526                                        'object': itemObject,
     527                                        'object_id': data.postId,
     528                                        'url': data.url
     529                                }, availableItems, $content, itemTemplate;
     530
     531                                // Add new item to menu.
     532                                panel.currentMenuControl.addItemToMenu( menuItem );
     533
     534                                // Add the new item to the list of available items.
     535                                menuItem['id'] = 'post-' + data.postId; // `id` is used for available menu item Backbone models.
     536                                availableItems = new api.Menus.AvailableItemCollection( [ menuItem ] );
     537                                api.Menus.availableMenuItemsPanel.collection.add( availableItems.models );
     538                                $content = container.find( '.available-menu-items-list' ),
     539                                itemTemplate = wp.template( 'available-menu-item' );
     540                                $content.prepend( itemTemplate( menuItem ) );
     541                                $content.scrollTop();
     542
     543                                // Reset the create content form.
     544                                itemName.val( '' )
     545                                        .removeAttr( 'disabled' )
     546                                        .focus();
     547                                panel.addingNew = false;
     548                                container.find( '.accordion-section-title' ).removeClass( 'loading' );
     549                        } );
     550                },
     551
    459552                // Opens the panel.
    460553                open: function( menuControl ) {
    461554                        this.currentMenuControl = menuControl;
  • src/wp-admin/js/customize-posts.js

     
     1/* global jQuery, wp, _, console */
     2
     3(function( api, $ ) {
     4        'use strict';
     5
     6        var component;
     7
     8        if ( ! api.Posts ) {
     9                api.Posts = {};
     10        }
     11
     12        component = api.Posts;
     13
     14        component.autoDrafts = [];
     15
     16        /**
     17         * Insert a new `auto-draft` post.
     18         *
     19         * @param {object} params - Parameters for the draft post to create.
     20         * @param {string} params.post_type - Post type to add.
     21         * @param {number} params.title - Post title to use.
     22         * @return {jQuery.promise} Promise resolved with the added post.
     23         */
     24        component.insertAutoDraftPost = function( params ) {
     25                var request, deferred = $.Deferred();
     26
     27                request = wp.ajax.post( 'customize-posts-insert-auto-draft', {
     28                        'customize-menus-nonce': api.settings.nonce['customize-menus'],
     29                        'wp_customize': 'on',
     30                        'params': params
     31                } );
     32
     33                request.done( function( response ) {
     34                        if ( response.postId ) {
     35                                deferred.resolve( response );
     36                                component.autoDrafts.push( response.postId );
     37                                api( 'nav_menus_created_posts' ).set( component.autoDrafts );
     38                        }
     39                } );
     40
     41                request.fail( function( response ) {
     42                        var error = response || '';
     43
     44                        if ( 'undefined' !== typeof response.message ) {
     45                                error = response.message;
     46                        }
     47
     48                        console.error( error );
     49                        deferred.rejectWith( error );
     50                } );
     51
     52                return deferred.promise();
     53        };
     54
     55        api.bind( 'ready', function() {
     56
     57                api.bind( 'saved', function( data ) {
     58                        // Show users links to edit newly-published posts.
     59                        api.control.each( function( control ) {
     60                                var id, url, message;
     61                                if ( 'nav_menu_item' === control.params.type ) {
     62                                        if ( -1 !== component.autoDrafts.indexOf( control.setting().object_id ) ) {
     63                                                id = component.autoDrafts[component.autoDrafts.indexOf( control.setting().object_id )];
     64                                                url = api.Menus.data.editPostURL.replace( '%d', id );
     65                                                message = api.Menus.data.l10n.newPostPublished.replace( '%3$s', url );
     66                                                message = message.replace( '%1$s', control.params.item_type_label );
     67                                                message = message.replace( '%2$s', control.setting().original_title );
     68                                                control.setting.notifications.add( 'content_published', new wp.customize.Notification(
     69                                                        'content_published',
     70                                                        {
     71                                                                type: 'info',
     72                                                                message: message
     73                                                        }
     74                                                ));
     75                                        }
     76                                }
     77                        });
     78
     79                        // Reset auto-drafts.
     80                        component.autoDrafts = []; // Reset the array the next time an item is created. Don't update the setting yet as that would trigger the customizer's dirty state.
     81                } );
     82
     83        } );
     84
     85})( wp.customize, jQuery );
  • src/wp-includes/class-wp-customize-manager.php

     
    15351535                <script type="text/html" id="tmpl-customize-control-notifications">
    15361536                        <ul>
    15371537                                <# _.each( data.notifications, function( notification ) { #>
    1538                                         <li class="notice notice-{{ notification.type || 'info' }} {{ data.altNotice ? 'notice-alt' : '' }}" data-code="{{ notification.code }}" data-type="{{ notification.type }}">{{ notification.message || notification.code }}</li>
     1538                                        <li class="notice notice-{{ notification.type || 'info' }} {{ data.altNotice ? 'notice-alt' : '' }}" data-code="{{ notification.code }}" data-type="{{ notification.type }}">{{{ notification.message || notification.code }}}</li>
    15391539                                <# } ); #>
    15401540                        </ul>
    15411541                </script>
  • src/wp-includes/class-wp-customize-nav-menus.php

     
    5656                add_filter( 'customize_refresh_nonces', array( $this, 'filter_nonces' ) );
    5757                add_action( 'wp_ajax_load-available-menu-items-customizer', array( $this, 'ajax_load_available_items' ) );
    5858                add_action( 'wp_ajax_search-available-menu-items-customizer', array( $this, 'ajax_search_available_items' ) );
     59                add_action( 'wp_ajax_customize-posts-insert-auto-draft', array( $this, 'ajax_add_new_auto_draft_post' ) );
    5960                add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    60 
    61                 // Needs to run after core Navigation section is set up.
    6261                add_action( 'customize_register', array( $this, 'customize_register' ), 11 );
    63 
    6462                add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_dynamic_setting_args' ), 10, 2 );
    6563                add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_dynamic_setting_class' ), 10, 3 );
    6664                add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_templates' ) );
    6765                add_action( 'customize_controls_print_footer_scripts', array( $this, 'available_items_template' ) );
    6866                add_action( 'customize_preview_init', array( $this, 'customize_preview_init' ) );
     67                add_action( 'customize_preview_init', array( $this, 'make_auto_draft_status_previewable' ) );
     68                add_action( 'customize_save_nav_menus_created_posts', array( $this, 'publish_auto_draft_posts' ) );
    6969
    7070                // Selective Refresh partials.
    7171                add_filter( 'customize_dynamic_partial_args', array( $this, 'customize_dynamic_partial_args' ), 10, 2 );
     
    356356        public function enqueue_scripts() {
    357357                wp_enqueue_style( 'customize-nav-menus' );
    358358                wp_enqueue_script( 'customize-nav-menus' );
     359                wp_enqueue_script( 'customize-posts' );
    359360
    360361                $temp_nav_menu_setting      = new WP_Customize_Nav_Menu_Setting( $this->manager, 'nav_menu[-1]' );
    361362                $temp_nav_menu_item_setting = new WP_Customize_Nav_Menu_Item_Setting( $this->manager, 'nav_menu_item[-1]' );
     
    392393                                'reorderModeOff'    => __( 'Reorder mode closed' ),
    393394                                'reorderLabelOn'    => esc_attr__( 'Reorder menu items' ),
    394395                                'reorderLabelOff'   => esc_attr__( 'Close reorder mode' ),
     396                                /* translators: %1$s: post type, %2$s: post title, %3$s: link to edit post */
     397                                'newPostPublished'  => __( 'New %1$s %2$s published. Edit it <a href="%3$s" target="_blank">here<span class="screen-reader-text"> (link opens in new tab)</span></a>.' ),
    395398                        ),
    396399                        'settingTransport'     => 'postMessage',
    397400                        'phpIntMax'            => PHP_INT_MAX,
     
    400403                                'nav_menu_item' => $temp_nav_menu_item_setting->default,
    401404                        ),
    402405                        'locationSlugMappedToName' => get_registered_nav_menus(),
     406                        'editPostURL'          => admin_url( 'post.php?post=%d&action=edit' ),
    403407                );
    404408
    405409                $data = sprintf( 'var _wpCustomizeNavMenusSettings = %s;', wp_json_encode( $settings ) );
     
    626630                        'section'  => 'add_menu',
    627631                        'settings' => array(),
    628632                ) ) );
     633
     634                $this->manager->add_setting( new WP_Customize_Filter_Setting( $this->manager, 'nav_menus_created_posts', array(
     635                        'transport' => 'postMessage',
     636                        'default'   => array(),
     637                ) ) );
    629638        }
    630639
    631640        /**
     
    660669                        foreach ( $post_types as $slug => $post_type ) {
    661670                                $item_types[] = array(
    662671                                        'title'  => $post_type->labels->name,
     672                                        'label'  => $post_type->labels->singular_name,
    663673                                        'type'   => 'post_type',
    664674                                        'object' => $post_type->name,
    665675                                );
     
    674684                                }
    675685                                $item_types[] = array(
    676686                                        'title'  => $taxonomy->labels->name,
     687                                        'label'  => $taxonomy->labels->singular_name,
    677688                                        'type'   => 'taxonomy',
    678689                                        'object' => $taxonomy->name,
    679690                                );
     
    693704        }
    694705
    695706        /**
     707         * Add a new `auto-draft` post.
     708         *
     709         * @access public
     710         * @since 4.7.0
     711         *
     712         * @param string $post_type The post type.
     713         * @param string $title     The post title.
     714         * @return WP_Post|WP_Error
     715         */
     716        public function insert_auto_draft_post( $post_type, $title ) {
     717
     718                $post_type_obj = get_post_type_object( $post_type );
     719                if ( ! $post_type_obj ) {
     720                        return new WP_Error( 'unknown_post_type', __( 'Unknown post type', 'customize-posts' ) );
     721                }
     722
     723                add_filter( 'wp_insert_post_empty_content', '__return_false' );
     724                $args = array(
     725                        'post_status' => 'auto-draft',
     726                        'post_type'   => $post_type,
     727                        'post_title'  => $title,
     728                        'post_name'  => sanitize_title( $title ), // Auto-drafts are allowed to have empty post_names, so we need to explicitly set it.
     729                );
     730                $r = wp_insert_post( wp_slash( $args ), true );
     731                remove_filter( 'wp_insert_post_empty_content', '__return_false' );
     732
     733                if ( is_wp_error( $r ) ) {
     734                        return $r;
     735                } else {
     736                        return get_post( $r );
     737                }
     738        }
     739
     740        /**
     741         * Ajax handler for adding a new auto-draft post.
     742         *
     743         * @action wp_ajax_customize-posts-insert-auto-draft
     744         * @access public
     745         * @since 4.7.0
     746         */
     747        public function ajax_add_new_auto_draft_post() {
     748                if ( ! check_ajax_referer( 'customize-menus', 'customize-menus-nonce' ) ) {
     749                        status_header( 400 );
     750                        wp_send_json_error( 'bad_nonce' );
     751                }
     752
     753                if ( ! current_user_can( 'customize' ) ) {
     754                        status_header( 403 );
     755                        wp_send_json_error( 'customize_not_allowed' );
     756                }
     757
     758                if ( empty( $_POST['params'] ) || ! is_array( $_POST['params'] ) ) {
     759                        status_header( 400 );
     760                        wp_send_json_error( 'missing_params' );
     761                }
     762
     763                $params = wp_unslash( $_POST['params'] );
     764
     765                if ( empty( $params['post_type'] ) ) {
     766                        status_header( 400 );
     767                        wp_send_json_error( 'missing_post_type_param' );
     768                }
     769
     770                $post_type_object = get_post_type_object( $params['post_type'] );
     771                if ( ! $post_type_object || ! current_user_can( $post_type_object->cap->create_posts ) ) {
     772                        status_header( 403 );
     773                        wp_send_json_error( 'insufficient_post_permissions' );
     774                }
     775
     776                if ( ! $params['title'] ) {
     777                        $params['title'] = '';
     778                }
     779
     780                $r = $this->insert_auto_draft_post( $post_type_object->name, $params['post_title'] );
     781                if ( is_wp_error( $r ) ) {
     782                        $error = $r;
     783                        if ( ! empty( $post_type_object->labels->singular_name ) ) {
     784                                $singular_name = $post_type_object->labels->singular_name;
     785                        } else {
     786                                $singular_name = __( 'Post' );
     787                        }
     788
     789                        $data = array(
     790                                /* translators: %1$s is the post type name and %2$s is the error message. */
     791                                'message' => sprintf( __( '%1$s could not be created: %2$s' ), $singular_name, $error->get_error_message() ),
     792                        );
     793                        wp_send_json_error( $data );
     794                } else {
     795                        $post = $r;
     796                        $data = array(
     797                                'postId' => $post->ID,
     798                                'url'    => get_permalink( $post->ID ),
     799                        );
     800                        wp_send_json_success( $data );
     801                }
     802        }
     803
     804        /**
    696805         * Print the JavaScript templates used to render Menu Customizer components.
    697806         *
    698807         * Templates are imported into the JS use wp.template.
     
    768877                                        <span class="spinner"></span>
    769878                                </div>
    770879                                <button type="button" class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></button>
    771                                 <ul class="accordion-section-content" data-type="search"></ul>
     880                                <ul class="accordion-section-content available-menu-items-list" data-type="search"></ul>
    772881                        </div>
    773882                        <div id="new-custom-menu-item" class="accordion-section">
    774883                                <h4 class="accordion-section-title" role="presentation">
     
    797906                                </div>
    798907                        </div>
    799908                        <?php
    800                         // Containers for per-post-type item browsing; items added with JS.
     909                        /**
     910                         * Filter the content types that do not allow new items to be created from nav menus.
     911                         *
     912                         * Types are formated as 'post_type'|'taxonomy' _ post_type_name; for example, 'taxonomy_post_format'.
     913                         * Taxonomies are not yet supported by this UI but will be in the future. Post types are only available
     914                         * here if `show_in_nav_menus` is true.
     915                         *
     916                         * @since 4.7.0
     917                         *
     918                         * @param array  $types  Array of disallowed types.
     919                         */
     920                        $disallowed_new_content_types = apply_filters( 'customize_nav_menus_disallow_new_content_types', array( 'taxonomy_post_format' ) );
     921
     922                        // Containers for per-post-type item browsing; items are added with JS.
    801923                        foreach ( $this->available_item_types() as $available_item_type ) {
    802924                                $id = sprintf( 'available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object'] );
    803925                                ?>
     
    813935                                                        <span class="toggle-indicator" aria-hidden="true"></span>
    814936                                                </button>
    815937                                        </h4>
    816                                         <ul class="accordion-section-content" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>"></ul>
     938                                        <div class="accordion-section-content">
     939                                                <?php if ( 'post_type' === $available_item_type['type'] && ! in_array( $available_item_type['type'] . '_' . $available_item_type['object'], $disallowed_new_content_types ) ) : ?>
     940                                                        <?php $post_type_obj = get_post_type_object( $available_item_type['object'] ); ?>
     941                                                        <?php if ( current_user_can( $post_type_obj->cap->create_posts ) && current_user_can( $post_type_obj->cap->publish_posts ) ) : ?>
     942                                                                <div class="new-content-item">
     943                                                                        <input type="text" class="create-item-input" placeholder="<?php
     944                                                                        /* translators: %s: Singular title of post type or taxonomy */
     945                                                                        printf( __( 'Create New %s' ), $post_type_obj->labels->singular_name ); ?>">
     946                                                                        <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button>
     947                                                                </div>
     948                                                        <?php endif; ?>
     949                                                <?php endif; ?>
     950                                                <ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( $available_item_type['label'] ); ?>"></ul>
     951                                        </div>
    817952                                </div>
    818953                                <?php
    819954                        }
     
    8811016        }
    8821017
    8831018        /**
     1019         * Make the auto-draft status protected so that it can be queried.
     1020         *
     1021         * @since 4.7.0
     1022         * @access public
     1023         */
     1024        public function make_auto_draft_status_previewable() {
     1025                global $wp_post_statuses;
     1026                $wp_post_statuses['auto-draft']->protected = true;
     1027        }
     1028
     1029        /**
     1030         * Make the auto-draft status protected so that it can be queried.
     1031         *
     1032         * @since 4.7.0
     1033         * @access public
     1034         *
     1035         * @param WP_Customize_Setting $setting Customizer Setting object.
     1036         */
     1037        public function publish_auto_draft_posts( $setting ) {
     1038                $value = $setting->post_value();
     1039                if ( ! empty ( $value ) ) {
     1040                        global $wpdb;
     1041                        foreach ( $value as $index => $post_id ) {
     1042                                $post = get_post( $post_id );
     1043                                wp_publish_post( $post );
     1044                        }
     1045                }
     1046        }
     1047
     1048        /**
    8841049         * Keep track of the arguments that are being passed to wp_nav_menu().
    8851050         *
    8861051         * @since 4.3.0
  • src/wp-includes/class-wp-customize-setting.php

     
    498498        /**
    499499         * Fetch and sanitize the $_POST value for the setting.
    500500         *
     501         * During a save request prior to save, post_value() provides the new value while value() does not.
     502         *
    501503         * @since 3.4.0
    502504         *
    503505         * @param mixed $default A default value which is used as a fallback. Default is null.
  • src/wp-includes/script-loader.php

     
    473473        $scripts->add( 'customize-nav-menus', "/wp-admin/js/customize-nav-menus$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls', 'accordion', 'nav-menu' ), false, 1 );
    474474        $scripts->add( 'customize-preview-nav-menus', "/wp-includes/js/customize-preview-nav-menus$suffix.js", array( 'jquery', 'wp-util', 'customize-preview', 'customize-selective-refresh' ), false, 1 );
    475475
     476        $scripts->add( 'customize-posts', "/wp-admin/js/customize-posts$suffix.js", array( 'jquery', 'wp-backbone', 'customize-controls' ), false, 1 );
     477
    476478        $scripts->add( 'accordion', "/wp-admin/js/accordion$suffix.js", array( 'jquery' ), false, 1 );
    477479
    478480        $scripts->add( 'shortcode', "/wp-includes/js/shortcode$suffix.js", array( 'underscore' ), false, 1 );