<?php
/**
 * Standalone White Label admin page (direct access when hidden from Settings).
 *
 * @package WP_PowerSuite\Admin\Views
 * @since 1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

use WP_PowerSuite\Admin\PageHero;
use WP_PowerSuite\Core\WhiteLabel;

$white_label_settings      = WhiteLabel::getSettings();
$has_agency_license        = WhiteLabel::hasAgencyLicense();
$white_label_logo_url      = WhiteLabel::logoUrl();
$white_label_menu_icon_url = WhiteLabel::menuIconUrl();
$brand_name                = WhiteLabel::pluginName();
$default_brand_name        = WhiteLabel::defaultPluginName();
$default_brand_description = WhiteLabel::defaultPluginDescription();
$preview_menu_title        = trim( (string) ( $white_label_settings['menu_title'] ?? '' ) );
$preview_plugin_name       = trim( (string) ( $white_label_settings['plugin_name'] ?? '' ) );
$preview_menu_label        = $preview_menu_title !== '' ? $preview_menu_title : ( $preview_plugin_name !== '' ? $preview_plugin_name : $default_brand_name );
$preview_plugin_label      = $preview_plugin_name !== '' ? $preview_plugin_name : $default_brand_name;
$preview_description       = trim( (string) ( $white_label_settings['plugin_description'] ?? '' ) );
$preview_description       = $preview_description !== '' ? $preview_description : $default_brand_description;
$preview_author            = trim( (string) ( $white_label_settings['plugin_author'] ?? '' ) );
$hero_logo_url             = $white_label_logo_url !== '' ? $white_label_logo_url : PageHero::default_icon_url();
$standalone                = true;
?>

<div class="wrap wpps-admin-wrap">
	<hr class="wp-header-end" style="margin:0;padding:0;border:none;height:0;overflow:hidden;">

	<?php
	PageHero::render(
		[
			'eyebrow'  => '',
			'title'    => __( 'White Label', 'wp-powersuite' ),
			'tagline'  => __( 'Customize plugin branding for client delivery.', 'wp-powersuite' ),
			'logo_url' => $hero_logo_url !== '' ? $hero_logo_url : '',
			'icon'     => $hero_logo_url !== '' ? '' : 'dashicons-art',
			'actions'  => PageHero::nav_actions( 'settings' ),
		]
	);
	?>

	<div class="wp-powersuite-settings">
		<?php
		$partial = defined( 'WP_POWERSUITE_PLUGIN_DIR' )
			? WP_POWERSUITE_PLUGIN_DIR . 'src/Admin/Views/partials/white-label-panel.php'
			: __DIR__ . '/partials/white-label-panel.php';
		if ( is_readable( $partial ) ) {
			include $partial;
		}
		?>
	</div>
</div>
