Block Editor for Data Entry

Block Editor for Data Entry is a rudimentary plugin designed to strip out the content area of the block editor and leave just the basic UI for metaboxes.

It is intended to be used where a predefined template is applied on the front end, leaving a simple back end of custom fields for clients to enter data on instances of a custom post type (CPT).

I am making the plugin available to anybody who wants to develop it further so that it has a settings dashboard where you can select the post types it is to be applied to.

This version of the plugin is not available on the WordPress repository and is not available for general consumption. It can only be configured manually by installing it and then manually editing the PHP file to specify which CPT it should be applied to.

You can download the zip file from this GitHub repository.

The current plugin is made up of the following action that restyles the block editor and removes the elements that allow you to add blocks .

// Post type dashboard customisation:

function remove_content_editor_for_CPT() {
  
  if ( get_current_post_type() == 'car' ) {
       echo '<style>

       .edit-post-layout__content {
          background: #bfc0c5;
        }

       .edit-post-visual-editor.editor-styles-wrapper {
          background-color: #bfc0c5;
          max-height: 80px;
        }

        .edit-post-layout .block-editor-editor-skeleton__content {
            background-color: #bfc0c5;
        }

        .editor-post-title {
          margin-top: 50px;
          padding-left: 0;
        }

        .editor-post-title__block .editor-post-title__input {
          padding-left: 0;
        }

        .editor-post-title__input:hover {
          border-color: transparent !important;
        }

        .editor-styles-wrapper .wp-block {
          margin-left: 0 !important;
          margin-right: 0 !important;
        }

        .block-editor-block-list__layout {
            display: none;
        }

        .edit-post-layout__metaboxes {
            border: none !important;
        }

        .edit-post-visual-editor.editor-styles-wrapper {
          margin-top: -20px;
          padding-left: 50px !important;
          padding-right: 50px !important;
        }
        
        #wpcontent,
        #wpfooter {
          background-color: #bfc0c5;
        }
  
        .postbox {
          margin-bottom: 20px !important;
          border-radius: 6px;
          -webkit-box-shadow: 0 5px 30px rgba(0, 0, 0, 0.1);
          -moz-box-shadow: 0 5px 30px rgba(0, 0, 0, 0.1);
          box-shadow: 0 5px 30px rgba(0, 0, 0, 0.1);
        }

        .edit-post-layout__metaboxes:not(:empty) {
          margin-top: 60px;
        }
    
    </style>';
  }

}

add_action('admin_head', 'remove_content_editor_for_CPT');

The action calls the following function which I found online. Thanks to Brad Vincent for this.

function get_current_post_type() {
  global $post, $typenow, $current_screen;
  //we have a post so we can just get the post type from that
  if ( $post && $post->post_type ) {
    return $post->post_type;
  }
  //check the global $typenow - set in admin.php
  elseif ( $typenow ) {
    return $typenow;
  }
  //check the global $current_screen object - set in sceen.php
  elseif ( $current_screen && $current_screen->post_type ) {
    return $current_screen->post_type;
  }
  //check the post_type querystring
  elseif ( isset( $_REQUEST['post_type'] ) ) {
    return sanitize_key( $_REQUEST['post_type'] );
  }
  //lastly check if post ID is in query string
  elseif ( isset( $_REQUEST['post'] ) ) {
    return get_post_type( $_REQUEST['post'] );
  }
  //we do not know the post type!
  return null;
}

To apply the styling to more than one post type you will need to edit the opening conditional to a boolean call in the following manner:

function remove_content_editor_for_CPT() {
  
  if (( get_current_post_type() == 'car' ) || ( get_current_post_type() == 'trick' )){
       echo '<style>
      // etc...