// 1 START: Admin Page — Settings + Actions + Self-check (calls helpers below) if (!defined('ABSPATH')) { exit; } function gmm_temp_admin_page() { if (!current_user_can('manage_options')) { return; } // Handle actions first (messages shown at top) $action_msg = ''; if (isset($_POST['gmm_temp_action'])) { if ($_POST['gmm_temp_action'] === 'create_posts') { $action_msg = gmm_temp_action_create_posts(); } elseif ($_POST['gmm_temp_action'] === 'gen_folder_images') { $action_msg = gmm_temp_action_generate_folder_images(); } } $root = get_option(GMM_TEMP_OPT_ROOT, ''); $phid = (int) get_option(GMM_TEMP_OPT_PLACEHOLDER, 0); $font_opt = get_option('gmm_temp_font_path', ''); echo '

GMM Temp — v0.0

'; echo '

Status: Tools to preview, create/update draft posts, and generate folder images.

'; if ($action_msg) { echo '

'.wp_kses_post($action_msg).'

'; } echo '
'; settings_fields('gmm_temp_group'); do_settings_sections('gmm_temp_group'); echo ''; echo ''; echo ''; echo ''; submit_button('Save Settings'); echo '
'; // Helpers (read-only) gmm_temp_render_root_hints(); gmm_temp_preview_candidates(); // Action: Create/Update Posts echo '
'; echo '

Action — Create/Update Posts (first-level folders)

'; echo '

Creates or updates draft posts (title “{Folder} Media”, slug “{folder}-media”), assigns the folder sub-category only, adds a matching tag, and sets a featured image if available.

'; echo '
'; wp_nonce_field('gmm_temp_create_posts'); echo ''; submit_button('Create/Update Posts', 'primary', 'submit', false); echo '
'; echo '
'; // Action: Generate Folder Images (+ optional font path) echo '
'; echo '

Action — Generate Folder Images

'; echo '

Overwrites {folder}.jpg in each first-level folder (size auto-detected from your Featured/Large image). Uses TTF text if a font path is provided or auto-detected, else bitmap fallback.

'; echo '
'; wp_nonce_field('gmm_temp_gen_folder_images'); echo ''; echo '


'; echo '

'; submit_button('Generate Folder Images', 'secondary', 'submit', false); echo '
'; echo '
'; // Self-check $checks = [ 'admin/settings.php' => GMM_TEMP_DIR.'admin/settings.php', 'admin/generator.php' => GMM_TEMP_DIR.'admin/generator.php', 'core/render.php' => GMM_TEMP_DIR.'core/render.php', 'core/files.php' => GMM_TEMP_DIR.'core/files.php', 'core/feature_image.php' => GMM_TEMP_DIR.'core/feature_image.php', ]; echo '

Self-check

'; echo '
'; } // 1 STOP: Admin Page — Settings + Actions + Self-check (calls helpers below)