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 '
'; echo '
' . esc_html__('Rate this plugin ★★★★★', 'wp-attachments') . ' ' . esc_html__('Changelog', 'wp-attachments') . '
'; echo '

' . esc_html__('WP Attachments Settings', 'wp-attachments') . '

'; settings_errors('wpatt_messages'); echo ''; $current = isset($_GET['tab']) ? sanitize_key($_GET['tab']) : 'general'; $tabs = array( 'general' => esc_html__('General Settings', 'wp-attachments'), 'appearance' => esc_html__('Appearance & Templates', 'wp-attachments') ); echo ''; echo '
'; switch ($current) { case 'general': wp_nonce_field('wpatt_general_settings'); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
' . esc_html__('List Header', 'wp-attachments') . ' ' . esc_html__('Text displayed above the attachments list (e.g., "Downloads" or "Attachments"). Leave empty to hide the heading.', 'wp-attachments') . '

' . esc_html__('Display Options', 'wp-attachments') . '
' . esc_html__('Date Format', 'wp-attachments') . ' ' . sprintf( /* translators: %s: the WordPress date format, e.g. F j, Y */ esc_html__('Format for the %%DATE%% tag, following PHP date standards (e.g. d.m.Y). Leave empty to use the WordPress date format: %s', 'wp-attachments'), '' . esc_html(get_option('date_format')) . '' ) . '
' . esc_html__('Download Tracker', 'wp-attachments') . '
' . esc_html__('Post Type Permissions', 'wp-attachments') . '

' . esc_html__('Configure where WP Attachments should be available.', 'wp-attachments') . '
' . esc_html__('"Enable Frontend" shows the list after the content. Each post can still hide it from the Media Attachments box of the editor.', 'wp-attachments') . '

'; $post_types = get_post_types(['public' => true], 'objects'); foreach ($post_types as $post_type) { if ($post_type->name === 'attachment') continue; $mb_enabled = get_option('wpatt_enable_metabox_' . $post_type->name, '1'); $fe_enabled = wpatt_is_frontend_enabled($post_type->name) ? '1' : '0'; echo ''; } echo '
' . esc_html__('Post Type', 'wp-attachments') . ' ' . esc_html__('Enable Metabox', 'wp-attachments') . ' ' . esc_html__('Enable Frontend', 'wp-attachments') . '
' . esc_html($post_type->labels->singular_name) . '
'; submit_button(__('Save General Settings', 'wp-attachments'), 'primary', 'submit-general'); break; case 'appearance': wp_nonce_field('wpatt_appearance_settings'); echo ''; /* ---------- Icon pack ---------- */ echo ''; /* ---------- Display template ---------- */ echo ''; echo ''; // Admin only: copy a template into the custom one; picking a colour // selects the Custom colour option. echo ''; submit_button(__('Save Appearance Settings', 'wp-attachments'), 'primary', 'submit-appearance'); break; } echo '
'; echo '
'; } ?>