true], 'objects'); foreach ($post_types as $post_type) { if ($post_type->name === 'attachment') continue; // Save metabox enabled/disabled $metabox_enabled = !empty($_POST['wpatt_enable_' . $post_type->name]) ? '1' : '0'; update_option('wpatt_enable_metabox_' . $post_type->name, $metabox_enabled); // Save frontend list enabled/disabled $frontend_enabled = !empty($_POST['wpatt_frontend_' . $post_type->name]) ? '1' : '0'; update_option('wpatt_enable_frontend_' . $post_type->name, $frontend_enabled); // Replaced by the frontend switch above. delete_option('wpatt_enable_display_' . $post_type->name); } $updated = true; } // Handle appearance settings submission securely if (isset($_POST['submit-appearance'])) { check_admin_referer('wpatt_appearance_settings'); $pack = (int) ($_POST['style'] ?? 0); update_option('wpa_ict', (string) (($pack >= 0 && $pack <= WPATT_PACK_MODERN) ? $pack : 0)); $template = (int) ($_POST['template'] ?? 0); update_option('wpa_template', (string) (($template >= 0 && $template <= WPATT_TEMPLATE_CARD) ? $template : 0)); $color_mode = sanitize_key($_POST['wpatt_icons_color'] ?? 'type'); update_option('wpatt_icons_color', in_array($color_mode, array('type', 'theme', 'custom'), true) ? $color_mode : 'type'); // Modern Card: unticked checkboxes are not posted, so start from all off; // wpatt_get_card_options() validates layout and width. $card_post = isset($_POST['wpatt_card']) && is_array($_POST['wpatt_card']) ? wp_unslash($_POST['wpatt_card']) : array(); $card_save = array(); foreach (array('ext', 'size', 'date', 'downloads', 'caption') as $flag) { $card_save[$flag] = empty($card_post[$flag]) ? 0 : 1; } $card_save['layout'] = sanitize_key($card_post['layout'] ?? 'grid'); $card_save['width'] = sanitize_key($card_post['width'] ?? 'normal'); update_option('wpatt_card', wpatt_get_card_options($card_save)); $custom_color = sanitize_hex_color(wp_unslash($_POST['wpatt_icons_custom_color'] ?? '')); if ($custom_color) { update_option('wpatt_icons_custom_color', $custom_color); } update_option('wpa_template_custom', wp_kses_post($_POST['wpa_template_custom'] ?? '')); $updated = true; } if ($updated) { add_settings_error('wpatt_messages', 'wpatt_message', __('Settings Saved', 'wp-attachments'), 'updated'); } wpa_register_initial_settings(); echo '