Make WordPress Core


Ignore:
Timestamp:
12/17/2018 03:51:08 AM (6 years ago)
Author:
desrosj
Message:

Editor: Add custom fields meta box support in the block editor.

This brings support for the custom fields meta box into the new block editor.

The webpack and copy-webpack-plugin packages have also been updated.

This does not bump the @wordpress packages like in [43861] because of conflicts with package versions already installed in trunk. The packages will be brought up to date in a subsequent merge.

Merges [43861] and [43863] into trunk.

See #45145.
Fixes #45257.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-admin/includes/post.php

    r44243 r44260  
    21132113            'slug'  => 'common',
    21142114            'title' => __( 'Common Blocks' ),
    2115             'icon'  => 'screenoptions',
     2115            'icon'  => null,
    21162116        ),
    21172117        array(
     
    22152215    <?php the_block_editor_meta_box_post_form_hidden_fields( $post ); ?>
    22162216    </form>
     2217    <form id="toggle-custom-fields-form" method="post" action="<?php echo esc_attr( admin_url( 'post.php' ) ); ?>">
     2218        <?php wp_nonce_field( 'toggle-custom-fields' ); ?>
     2219        <input type="hidden" name="action" value="toggle-custom-fields" />
     2220    </form>
    22172221    <?php foreach ( $locations as $location ) : ?>
    22182222        <form class="metabox-location-<?php echo esc_attr( $location ); ?>" onsubmit="return false;">
     
    22902294    }
    22912295
     2296    /**
     2297     * If the 'postcustom' meta box is enabled, then we need to perform some
     2298     * extra initialization on it.
     2299     */
     2300    $enable_custom_fields = (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true );
     2301    if ( $enable_custom_fields ) {
     2302        $script = "( function( $ ) {
     2303            if ( $('#postcustom').length ) {
     2304                $( '#the-list' ).wpList( {
     2305                    addBefore: function( s ) {
     2306                        s.data += '&post_id=$post->ID';
     2307                        return s;
     2308                    },
     2309                    addAfter: function() {
     2310                        $('table#list-table').show();
     2311                    }
     2312                });
     2313            }
     2314        } )( jQuery );";
     2315        wp_enqueue_script( 'wp-lists' );
     2316        wp_add_inline_script( 'wp-lists', $script );
     2317    }
     2318
    22922319    // Reset meta box data.
    22932320    $wp_meta_boxes = $_original_meta_boxes;
Note: See TracChangeset for help on using the changeset viewer.