Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#64486 new defect (bug)

Deactivating plugin removes native wp metabox from page editor

Reported by: mrdollar4444's profile mrDollar4444 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Editor Keywords: close
Focuses: Cc:

Description

Hi, can you please confirm the issue?
Path to recreate:

  1. On a brand new latest version WordPress installation, install and activate the Classic Editor plugin:


wp plugin install classic-editor --activate
  1. Create and activate a new test plugin:


  wp scaffold plugin first-test-plugin --activate

  1. Open the main test plugin file and insert code that creates a metabox with a metabox area (it is real code that I took from the Advanced Custom Fields plugin).
<?php
/**
 * Plugin Name:     First Test Plugin
 * Plugin URI:      PLUGIN SITE HERE
 * Description:     PLUGIN DESCRIPTION HERE
 * Author:          YOUR NAME HERE
 * Author URI:      YOUR SITE HERE
 * Text Domain:     first-test-plugin
 * Domain Path:     /languages
 * Version:         0.1.0
 *
 * @package         First_Test_Plugin
 */

add_action( 'add_meta_boxes', 'test_register_metabox', 10, 2 );
function test_register_metabox( $post_type, $post ) {
    // Register a box into our custom context.
    add_meta_box(
        'test_box_id',
        'First plugin metabox',
        'test_box_callback',
        $post_type,
        'test_do_meta_boxes',
    );
}
function test_box_callback( $post ) {
    echo '<h1>First Plugin Metabox</h1>';
}

add_action( 'edit_form_after_title', 'set_meta_box_in_special_area' );
function set_meta_box_in_special_area() {
	global $post;
	do_meta_boxes( get_current_screen(), 'test_do_meta_boxes', $post );
}

  1. Now create a new page.
  1. On the new page screen, move the “Featured Image” meta box above our “First plugin metabox”. https://i.imgur.com/osFygs0.png
  1. Now deactivate our first-test-plugin:


wp plugin deactivate first-test-plugin
  1. Reload the page.
  1. Observe the issue: the “Featured Image” metabox disappears and is not accessible anymore.

Expected behaviour: The visibility of native WP metaboxes should not be affected by 3-party disabled plugins.

Change History (1)

#1 @sabernhardt
5 weeks ago

  • Keywords close added
  • Version 6.9 deleted

I was able to reproduce this behavior in 6.9, 6.8.3, and 5.0. (I used the Plugins screen interface to activate and deactivate instead of CLI.)

However, this unpleasant experience seems to be correct. The sample third-party plugin adds the functionality of any meta boxes in the 'edit_form_after_title' hook with do_meta_boxes(). If you create another plugin with only that part, and activate it, the second plugin will reinstate the missing Featured image meta box in the special area.

add_action( 'edit_form_after_title', 'set_meta_box_in_special_area2' );
function set_meta_box_in_special_area2() {
	global $post;
	do_meta_boxes( get_current_screen(), 'test_do_meta_boxes', $post );
}
Note: See TracTickets for help on using tickets.