<?php
/**
 * Editor layout tweaks — meta box placement only; no plugin code is touched.
 *
 * As of 2026-07-20 all page-level settings live in ONE ACF box, "Page Settings"
 * (group_bwm_page_hero): the H1 title override, the hero settings, and the
 * footer background image. The override is an ACF field bridged to the bw-dev
 * `_bw_dev_title_override` meta (see inc/bw-title-override-acf.php), so the
 * bw-dev plugin's own classic "Page Title Override" meta box is now a duplicate.
 *
 * This file removes that plugin box (leaving the plugin otherwise intact — its
 * the_title filter still renders the override on the front end). Runs late
 * (999) so the box already exists when we remove it.
 */
if ( ! defined( 'ABSPATH' ) ) { exit; }

add_action( 'add_meta_boxes', function ( $post_type ) {
	if ( ! in_array( $post_type, array( 'page', 'post', 'landing' ), true ) ) {
		return;
	}

	// The bw-dev plugin registers its box in the sidebar ('side'/'high'). The
	// override now lives in the ACF "Page Settings" box, so drop the plugin box
	// to avoid two editors for the same value.
	remove_meta_box( 'bw_dev_title_override', $post_type, 'side' );
	// Defensive: also clear it if an older layout had moved it to 'normal'.
	remove_meta_box( 'bw_dev_title_override', $post_type, 'normal' );
}, 999 );
