add_filter( "get_user_option_meta-box-order_{$post_type}", $this, 'force_main_column' ); } $loader->add_action( 'admin_print_footer_scripts-post.php', $this, 'block_sidebar_drop' ); $loader->add_action( 'admin_print_footer_scripts-post-new.php', $this, 'block_sidebar_drop' ); } private static function is_plugin_box( string $id ): bool { return str_starts_with( $id, 'acc_' ); } /** * @param mixed $order [ 'side' => 'id,id', 'normal' => 'id,id', 'advanced' => … ] or false. * @return mixed */ public function force_main_column( $order ) { if ( ! is_array( $order ) || empty( $order['side'] ) ) { return $order; } $side = array_filter( explode( ',', (string) $order['side'] ) ); $moved = array_values( array_filter( $side, [ self::class, 'is_plugin_box' ] ) ); if ( ! $moved ) { return $order; } $normal = array_filter( explode( ',', (string) ( $order['normal'] ?? '' ) ) ); $order['side'] = implode( ',', array_diff( $side, $moved ) ); $order['normal'] = implode( ',', array_merge( $normal, $moved ) ); return $order; } /** Send a plugin box dropped on the sidebar straight back where it came from. */ public function block_sidebar_drop(): void { $screen = get_current_screen(); if ( ! $screen || ! in_array( $screen->post_type, self::POST_TYPES, true ) ) { return; } ?>