🤩 File Manager - Mr.X
PHP:
8.3.33
Server:
Apache
OS:
Linux 5.14.0-611.49.1.el9_7.x86_64
User:
websparkit
Navigate
Upload:
Upload
New File
New Folder
Editing:theme-options.php
<?php add_action('admin_menu', 'unfia_add_admin_menu'); function unfia_add_admin_menu() { add_menu_page( __('UNFIA Settings', 'unfia'), __('UNFIA', 'unfia'), 'manage_options', 'unfia-options', 'unfia_options_page', 'dashicons-universal-access', 3 ); add_submenu_page( 'unfia-options', __('General Settings', 'unfia'), __('General', 'unfia'), 'manage_options', 'unfia-options', 'unfia_options_page' ); add_submenu_page( 'unfia-options', __('Theme Options', 'unfia'), __('Theme Options', 'unfia'), 'manage_options', 'unfia-theme-options', 'unfia_theme_options_page' ); } add_action('admin_init', 'unfia_register_settings'); function unfia_register_settings() { register_setting('unfia_settings_group', 'unfia_options', 'unfia_sanitize_options'); } function unfia_sanitize_options($input) { $output = []; $numeric_fields = ['logo', 'favicon']; $text_fields = [ 'primary_color', 'secondary_color', 'accent_color', 'dark_color', 'heading_font', 'body_font', 'facebook_url', 'twitter_url', 'instagram_url', 'linkedin_url', 'youtube_url', 'tiktok_url', 'whatsapp_usa', 'whatsapp_sri', 'contact_email', 'contact_address', 'hero_heading', 'hero_subheading', 'counter_label_1', 'counter_value_1', 'counter_label_2', 'counter_value_2', 'counter_label_3', 'counter_value_3', 'counter_label_4', 'counter_value_4', 'counter_label_5', 'counter_value_5', 'footer_text', 'footer_copyright', ]; foreach ($numeric_fields as $field) { if (isset($input[$field]) && $input[$field] !== '') { $output[$field] = intval($input[$field]); } else { $output[$field] = 0; } } foreach ($text_fields as $field) { if (isset($input[$field])) { $output[$field] = sanitize_text_field($input[$field]); } } $output['hero_btn_1_text'] = isset($input['hero_btn_1_text']) ? sanitize_text_field($input['hero_btn_1_text']) : __('Become Member', 'unfia'); $output['hero_btn_1_url'] = isset($input['hero_btn_1_url']) ? esc_url_raw($input['hero_btn_1_url']) : '#'; $output['hero_btn_2_text'] = isset($input['hero_btn_2_text']) ? sanitize_text_field($input['hero_btn_2_text']) : __('Apply Award', 'unfia'); $output['hero_btn_2_url'] = isset($input['hero_btn_2_url']) ? esc_url_raw($input['hero_btn_2_url']) : '#'; $output['hero_btn_3_text'] = isset($input['hero_btn_3_text']) ? sanitize_text_field($input['hero_btn_3_text']) : __('Conference', 'unfia'); $output['hero_btn_3_url'] = isset($input['hero_btn_3_url']) ? esc_url_raw($input['hero_btn_3_url']) : '#'; $output['hero_btn_4_text'] = isset($input['hero_btn_4_text']) ? sanitize_text_field($input['hero_btn_4_text']) : __('Donate', 'unfia'); $output['hero_btn_4_url'] = isset($input['hero_btn_4_url']) ? esc_url_raw($input['hero_btn_4_url']) : '#'; return $output; } function unfia_options_page() { if (!current_user_can('manage_options')) { return; } $options = get_option('unfia_options', []); ?> <div class="wrap unfia-admin-wrap"> <h1><?php echo esc_html(get_admin_page_title()); ?></h1> <form method="post" action="options.php"> <?php settings_fields('unfia_settings_group'); ?> <div class="unfia-admin-tabs"> <div class="tab-nav"> <button type="button" class="tab-btn active" data-tab="tab-branding"><?php _e('Branding', 'unfia'); ?></button> <button type="button" class="tab-btn" data-tab="tab-colors"><?php _e('Colors & Fonts', 'unfia'); ?></button> <button type="button" class="tab-btn" data-tab="tab-social"><?php _e('Social & Contact', 'unfia'); ?></button> <button type="button" class="tab-btn" data-tab="tab-hero"><?php _e('Hero Section', 'unfia'); ?></button> <button type="button" class="tab-btn" data-tab="tab-counters"><?php _e('Counters', 'unfia'); ?></button> <button type="button" class="tab-btn" data-tab="tab-footer"><?php _e('Footer', 'unfia'); ?></button> </div> <div class="tab-content"> <div id="tab-branding" class="tab-pane active"> <h2><?php _e('Branding', 'unfia'); ?></h2> <table class="form-table"> <tr> <th><label for="logo"><?php _e('Logo', 'unfia'); ?></label></th> <td> <div class="image-upload-wrapper"> <input type="hidden" id="logo" name="unfia_options[logo]" value="<?php echo esc_attr($options['logo'] ?? '48'); ?>" /> <button type="button" class="button upload-image-btn" data-target="logo"><?php _e('Upload Logo', 'unfia'); ?></button> <button type="button" class="button remove-image-btn" data-target="logo"><?php _e('Remove', 'unfia'); ?></button> <div class="image-preview" id="logo-preview"> <?php if (!empty($options['logo'])): ?> <?php echo wp_get_attachment_image($options['logo'], 'medium'); ?> <?php endif; ?> </div> </div> </td> </tr> <tr> <th><label for="favicon"><?php _e('Favicon', 'unfia'); ?></label></th> <td> <div class="image-upload-wrapper"> <input type="hidden" id="favicon" name="unfia_options[favicon]" value="<?php echo esc_attr($options['favicon'] ?? ''); ?>" /> <button type="button" class="button upload-image-btn" data-target="favicon"><?php _e('Upload Favicon', 'unfia'); ?></button> <button type="button" class="button remove-image-btn" data-target="favicon"><?php _e('Remove', 'unfia'); ?></button> <div class="image-preview" id="favicon-preview"> <?php if (!empty($options['favicon'])): ?> <?php echo wp_get_attachment_image($options['favicon'], 'thumbnail'); ?> <?php endif; ?> </div> </div> </td> </tr> </table> </div> <div id="tab-colors" class="tab-pane"> <h2><?php _e('Colors & Fonts', 'unfia'); ?></h2> <table class="form-table"> <tr> <th><label for="primary_color"><?php _e('Primary Color', 'unfia'); ?></label></th> <td><input type="text" id="primary_color" name="unfia_options[primary_color]" value="<?php echo esc_attr($options['primary_color'] ?? '#1F45D8'); ?>" class="color-picker" data-default-color="#1F45D8" /></td> </tr> <tr> <th><label for="secondary_color"><?php _e('Secondary Color', 'unfia'); ?></label></th> <td><input type="text" id="secondary_color" name="unfia_options[secondary_color]" value="<?php echo esc_attr($options['secondary_color'] ?? '#1AA9E8'); ?>" class="color-picker" data-default-color="#1AA9E8" /></td> </tr> <tr> <th><label for="accent_color"><?php _e('Accent Color', 'unfia'); ?></label></th> <td><input type="text" id="accent_color" name="unfia_options[accent_color]" value="<?php echo esc_attr($options['accent_color'] ?? '#38BDF8'); ?>" class="color-picker" data-default-color="#38BDF8" /></td> </tr> <tr> <th><label for="dark_color"><?php _e('Dark Color', 'unfia'); ?></label></th> <td><input type="text" id="dark_color" name="unfia_options[dark_color]" value="<?php echo esc_attr($options['dark_color'] ?? '#111827'); ?>" class="color-picker" data-default-color="#111827" /></td> </tr> </table> </div> <div id="tab-social" class="tab-pane"> <h2><?php _e('Social & Contact', 'unfia'); ?></h2> <table class="form-table"> <tr><th><label for="facebook_url"><?php _e('Facebook URL', 'unfia'); ?></label></th><td><input type="url" id="facebook_url" name="unfia_options[facebook_url]" value="<?php echo esc_attr($options['facebook_url'] ?? ''); ?>" class="regular-text" /></td></tr> <tr><th><label for="twitter_url"><?php _e('Twitter URL', 'unfia'); ?></label></th><td><input type="url" id="twitter_url" name="unfia_options[twitter_url]" value="<?php echo esc_attr($options['twitter_url'] ?? ''); ?>" class="regular-text" /></td></tr> <tr><th><label for="instagram_url"><?php _e('Instagram URL', 'unfia'); ?></label></th><td><input type="url" id="instagram_url" name="unfia_options[instagram_url]" value="<?php echo esc_attr($options['instagram_url'] ?? ''); ?>" class="regular-text" /></td></tr> <tr><th><label for="linkedin_url"><?php _e('LinkedIn URL', 'unfia'); ?></label></th><td><input type="url" id="linkedin_url" name="unfia_options[linkedin_url]" value="<?php echo esc_attr($options['linkedin_url'] ?? ''); ?>" class="regular-text" /></td></tr> <tr><th><label for="youtube_url"><?php _e('YouTube URL', 'unfia'); ?></label></th><td><input type="url" id="youtube_url" name="unfia_options[youtube_url]" value="<?php echo esc_attr($options['youtube_url'] ?? ''); ?>" class="regular-text" /></td></tr> <tr><th><label for="tiktok_url"><?php _e('TikTok URL', 'unfia'); ?></label></th><td><input type="url" id="tiktok_url" name="unfia_options[tiktok_url]" value="<?php echo esc_attr($options['tiktok_url'] ?? ''); ?>" class="regular-text" /></td></tr> <tr><th><label for="whatsapp_usa"><?php _e('USA WhatsApp', 'unfia'); ?></label></th><td><input type="text" id="whatsapp_usa" name="unfia_options[whatsapp_usa]" value="<?php echo esc_attr($options['whatsapp_usa'] ?? '+1 (307) 393-9042'); ?>" class="regular-text" /></td></tr> <tr><th><label for="whatsapp_sri"><?php _e('Sri Lanka WhatsApp', 'unfia'); ?></label></th><td><input type="text" id="whatsapp_sri" name="unfia_options[whatsapp_sri]" value="<?php echo esc_attr($options['whatsapp_sri'] ?? '+94 772305309'); ?>" class="regular-text" /></td></tr> <tr><th><label for="contact_email"><?php _e('Email', 'unfia'); ?></label></th><td><input type="email" id="contact_email" name="unfia_options[contact_email]" value="<?php echo esc_attr($options['contact_email'] ?? 'ranjithopatha@gmail.com'); ?>" class="regular-text" /></td></tr> <tr><th><label for="contact_address"><?php _e('Address', 'unfia'); ?></label></th><td><textarea id="contact_address" name="unfia_options[contact_address]" rows="3" class="large-text"><?php echo esc_textarea($options['contact_address'] ?? "50D Mathugama Road\nDodangoda, 12020\nSri Lanka"); ?></textarea></td></tr> </table> </div> <div id="tab-hero" class="tab-pane"> <h2><?php _e('Hero Section', 'unfia'); ?></h2> <table class="form-table"> <tr><th><label for="hero_heading"><?php _e('Heading', 'unfia'); ?></label></th><td><textarea id="hero_heading" name="unfia_options[hero_heading]" rows="3" class="large-text"><?php echo esc_textarea($options['hero_heading'] ?? "Connecting Knowledge\nInspiring Excellence\nBuilding Global Unity"); ?></textarea></td></tr> <tr><th><label for="hero_subheading"><?php _e('Subheading', 'unfia'); ?></label></th><td><textarea id="hero_subheading" name="unfia_options[hero_subheading]" rows="2" class="large-text"><?php echo esc_textarea($options['hero_subheading'] ?? 'Building International Cooperation Through Education, Research, Awards, Cultural Exchange and Humanitarian Service.'); ?></textarea></td></tr> <tr><th><label for="hero_btn_1_text"><?php _e('Button 1 Text', 'unfia'); ?></label></th><td><input type="text" id="hero_btn_1_text" name="unfia_options[hero_btn_1_text]" value="<?php echo esc_attr($options['hero_btn_1_text'] ?? __('Become Member', 'unfia')); ?>" class="regular-text" /></td></tr> <tr><th><label for="hero_btn_1_url"><?php _e('Button 1 URL', 'unfia'); ?></label></th><td><input type="url" id="hero_btn_1_url" name="unfia_options[hero_btn_1_url]" value="<?php echo esc_attr($options['hero_btn_1_url'] ?? '#'); ?>" class="regular-text" /></td></tr> <tr><th><label for="hero_btn_2_text"><?php _e('Button 2 Text', 'unfia'); ?></label></th><td><input type="text" id="hero_btn_2_text" name="unfia_options[hero_btn_2_text]" value="<?php echo esc_attr($options['hero_btn_2_text'] ?? __('Apply Award', 'unfia')); ?>" class="regular-text" /></td></tr> <tr><th><label for="hero_btn_2_url"><?php _e('Button 2 URL', 'unfia'); ?></label></th><td><input type="url" id="hero_btn_2_url" name="unfia_options[hero_btn_2_url]" value="<?php echo esc_attr($options['hero_btn_2_url'] ?? '#'); ?>" class="regular-text" /></td></tr> <tr><th><label for="hero_btn_3_text"><?php _e('Button 3 Text', 'unfia'); ?></label></th><td><input type="text" id="hero_btn_3_text" name="unfia_options[hero_btn_3_text]" value="<?php echo esc_attr($options['hero_btn_3_text'] ?? __('Conference', 'unfia')); ?>" class="regular-text" /></td></tr> <tr><th><label for="hero_btn_3_url"><?php _e('Button 3 URL', 'unfia'); ?></label></th><td><input type="url" id="hero_btn_3_url" name="unfia_options[hero_btn_3_url]" value="<?php echo esc_attr($options['hero_btn_3_url'] ?? '#'); ?>" class="regular-text" /></td></tr> <tr><th><label for="hero_btn_4_text"><?php _e('Button 4 Text', 'unfia'); ?></label></th><td><input type="text" id="hero_btn_4_text" name="unfia_options[hero_btn_4_text]" value="<?php echo esc_attr($options['hero_btn_4_text'] ?? __('Donate', 'unfia')); ?>" class="regular-text" /></td></tr> <tr><th><label for="hero_btn_4_url"><?php _e('Button 4 URL', 'unfia'); ?></label></th><td><input type="url" id="hero_btn_4_url" name="unfia_options[hero_btn_4_url]" value="<?php echo esc_attr($options['hero_btn_4_url'] ?? '#'); ?>" class="regular-text" /></td></tr> </table> </div> <div id="tab-counters" class="tab-pane"> <h2><?php _e('Counter Statistics', 'unfia'); ?></h2> <table class="form-table"> <?php for ($i = 1; $i <= 5; $i++): ?> <tr> <th><?php printf(__('Counter %d', 'unfia'), $i); ?></th> <td> <input type="text" name="unfia_options[counter_label_<?php echo $i; ?>]" placeholder="<?php _e('Label', 'unfia'); ?>" value="<?php echo esc_attr($options['counter_label_' . $i] ?? ''); ?>" class="regular-text" /> <input type="number" name="unfia_options[counter_value_<?php echo $i; ?>]" placeholder="<?php _e('Value', 'unfia'); ?>" value="<?php echo esc_attr($options['counter_value_' . $i] ?? ''); ?>" class="small-text" /> </td> </tr> <?php endfor; ?> </table> </div> <div id="tab-footer" class="tab-pane"> <h2><?php _e('Footer Settings', 'unfia'); ?></h2> <table class="form-table"> <tr><th><label for="footer_text"><?php _e('Footer About Text', 'unfia'); ?></label></th><td><textarea id="footer_text" name="unfia_options[footer_text]" rows="4" class="large-text"><?php echo esc_textarea($options['footer_text'] ?? 'UNFIA is dedicated to building international cooperation through education, research, awards, cultural exchange and humanitarian service.'); ?></textarea></td></tr> <tr><th><label for="footer_copyright"><?php _e('Copyright Text', 'unfia'); ?></label></th><td><input type="text" id="footer_copyright" name="unfia_options[footer_copyright]" value="<?php echo esc_attr($options['footer_copyright'] ?? '© 2026 United Nations Federation of International Astro. All Rights Reserved.'); ?>" class="large-text" /></td></tr> </table> </div> </div> </div> <?php submit_button(); ?> </form> </div> <style> .unfia-admin-wrap { max-width: 1200px; margin: 20px auto; } .unfia-admin-tabs { display: flex; gap: 20px; margin-top: 20px; } .tab-nav { width: 220px; flex-shrink: 0; } .tab-btn { display: block; width: 100%; padding: 12px 16px; background: #f1f5f9; border: 1px solid #e2e8f0; text-align: left; cursor: pointer; font-size: 14px; transition: all 0.2s; } .tab-btn:first-child { border-radius: 8px 8px 0 0; } .tab-btn:last-child { border-radius: 0 0 8px 8px; } .tab-btn:not(:last-child) { border-bottom: none; } .tab-btn.active { background: #1F45D8; color: #fff; border-color: #1F45D8; } .tab-btn:hover:not(.active) { background: #e2e8f0; } .tab-content { flex: 1; background: #fff; padding: 20px; border: 1px solid #e2e8f0; border-radius: 8px; } .tab-pane { display: none; } .tab-pane.active { display: block; } .image-upload-wrapper { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; } .image-preview { width: 100%; margin-top: 10px; } .image-preview img { max-width: 200px; height: auto; border: 1px solid #e2e8f0; border-radius: 4px; padding: 4px; } </style> <?php } function unfia_theme_options_page() { if (!current_user_can('manage_options')) { return; } ?> <div class="wrap"> <h1><?php _e('UNFIA Theme Options', 'unfia'); ?></h1> <p><?php _e('Additional theme options coming soon.', 'unfia'); ?></p> </div> <?php }
Save Changes
Cancel
Create New File
Create New Folder