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.

git-svn-id: https://develop.svn.wordpress.org/trunk@44260 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers
2018-12-17 03:51:08 +00:00
parent b6a378d345
commit e63acae939
7 changed files with 90 additions and 11 deletions

View File

@@ -2112,7 +2112,7 @@ function get_block_categories( $post ) {
array(
'slug' => 'common',
'title' => __( 'Common Blocks' ),
'icon' => 'screenoptions',
'icon' => null,
),
array(
'slug' => 'formatting',
@@ -2214,6 +2214,10 @@ function the_block_editor_meta_boxes() {
<form class="metabox-base-form">
<?php the_block_editor_meta_box_post_form_hidden_fields( $post ); ?>
</form>
<form id="toggle-custom-fields-form" method="post" action="<?php echo esc_attr( admin_url( 'post.php' ) ); ?>">
<?php wp_nonce_field( 'toggle-custom-fields' ); ?>
<input type="hidden" name="action" value="toggle-custom-fields" />
</form>
<?php foreach ( $locations as $location ) : ?>
<form class="metabox-location-<?php echo esc_attr( $location ); ?>" onsubmit="return false;">
<div id="poststuff" class="sidebar-open">
@@ -2289,6 +2293,29 @@ function the_block_editor_meta_boxes() {
printf( "<script type='text/javascript'>\n%s\n</script>\n", trim( $script ) );
}
/**
* If the 'postcustom' meta box is enabled, then we need to perform some
* extra initialization on it.
*/
$enable_custom_fields = (bool) get_user_meta( get_current_user_id(), 'enable_custom_fields', true );
if ( $enable_custom_fields ) {
$script = "( function( $ ) {
if ( $('#postcustom').length ) {
$( '#the-list' ).wpList( {
addBefore: function( s ) {
s.data += '&post_id=$post->ID';
return s;
},
addAfter: function() {
$('table#list-table').show();
}
});
}
} )( jQuery );";
wp_enqueue_script( 'wp-lists' );
wp_add_inline_script( 'wp-lists', $script );
}
// Reset meta box data.
$wp_meta_boxes = $_original_meta_boxes;
}