<?php
if ( ! defined( 'ABSPATH' ) ) exit;
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- admin view partial; local variables are not global
// phpcs:disable WordPress.Security.NonceVerification -- read-only prefill; capability check handled by admin menu registration
// phpcs:disable WordPress.Security.ValidatedSanitizedInput -- GET params sanitized by scholar_sync_get_param() callers

require_once SCHOLAR_SYNC_PLUGIN_DIR . '/admin/scholar_sync_functions.php';

$action = 'add-author';
$submit_label = 'Add New Author';

$author_data = new stdClass();
$author_data->name = scholar_sync_get_param('name');
$author_data->position = scholar_sync_get_param('position');
$author_data->affiliations = scholar_sync_get_param('affiliations');
$author_data->interests = scholar_sync_get_param('interests');
$author_data->thumbnail = scholar_sync_get_param('thumbnail');
$author_data->citations_all = scholar_sync_get_param('cite');
$author_data->h_index_all = scholar_sync_get_param('h_index');
$author_data->i10_index_all = scholar_sync_get_param('i10_index');
$author_data->directory_link = scholar_sync_get_param('directory_link');


echo '<h1>Add Author Manually</h1>';

$save_error = sanitize_key( scholar_sync_get_param( 'save_error' ) );
if ( $save_error === 'missing_name' ) {
    echo '<div class="notice notice-error"><p>' . esc_html__( 'Full Name is required.', 'scholar-sync' ) . '</p></div>';
} elseif ( $save_error === 'save_failed' ) {
    echo '<div class="notice notice-error"><p>' . esc_html__( 'Could not save the author — please check your input (e.g. a field may be too long) and try again.', 'scholar-sync' ) . '</p></div>';
}

require_once SCHOLAR_SYNC_PLUGIN_DIR . '/admin/author_edit_details_tab.php';
