<?php
// إنشاء صفحة إعدادات الملف الشخصي في لوحة التحكم
function profile_page_settings() {
add_menu_page(
‘الملف الشخصي’,
‘الملف الشخصي’,
‘manage_options’,
‘profile-settings’,
‘profile_settings_page’,
‘dashicons-admin-users’,
30
);
}
add_action(‘admin_menu’, ‘profile_page_settings’);

// صفحة إعدادات الملف الشخصي
function profile_settings_page() {
?>
<div class=”wrap”>
<h1>إعدادات الملف الشخصي</h1>

<?php
if (isset($_POST[‘submit’])) {
// حفظ البيانات
update_option(‘profile_name’, sanitize_text_field($_POST[‘profile_name’]));
update_option(‘profile_title’, sanitize_text_field($_POST[‘profile_title’]));
update_option(‘profile_image’, esc_url_raw($_POST[‘profile_image’]));
update_option(‘full_name’, sanitize_text_field($_POST[‘full_name’]));
update_option(‘profile_age’, sanitize_text_field($_POST[‘profile_age’]));
update_option(‘nationality’, sanitize_text_field($_POST[‘nationality’]));
update_option(‘marital_status’, sanitize_text_field($_POST[‘marital_status’]));

// التعليم
update_option(‘education_degree’, sanitize_text_field($_POST[‘education_degree’]));
update_option(‘education_major’, sanitize_text_field($_POST[‘education_major’]));
update_option(‘education_university’, sanitize_text_field($_POST[‘education_university’]));
update_option(‘education_year’, sanitize_text_field($_POST[‘education_year’]));

// الخبرة العملية
update_option(‘current_job’, sanitize_text_field($_POST[‘current_job’]));
update_option(‘current_company’, sanitize_text_field($_POST[‘current_company’]));
update_option(‘job_responsibilities’, sanitize_textarea_field($_POST[‘job_responsibilities’]));
update_option(‘experience_years’, sanitize_text_field($_POST[‘experience_years’]));

// المهارات
update_option(‘programming_languages’, sanitize_textarea_field($_POST[‘programming_languages’]));
update_option(‘frameworks’, sanitize_textarea_field($_POST[‘frameworks’]));
update_option(‘languages’, sanitize_textarea_field($_POST[‘languages’]));

// روابط التواصل الاجتماعي
update_option(‘facebook_url’, esc_url_raw($_POST[‘facebook_url’]));
update_option(‘twitter_url’, esc_url_raw($_POST[‘twitter_url’]));
update_option(‘instagram_url’, esc_url_raw($_POST[‘instagram_url’]));
update_option(‘linkedin_url’, esc_url_raw($_POST[‘linkedin_url’]));
update_option(‘youtube_url’, esc_url_raw($_POST[‘youtube_url’]));

echo ‘<div class=”notice notice-success”><p>تم حفظ الإعدادات بنجاح!</p></div>’;
}
?>

<form method=”post” action=””>
<h2>المعلومات الأساسية</h2>
<table class=”form-table”>
<tr>
<th><label for=”profile_name”>الاسم المعروض</label></th>
<td><input type=”text” name=”profile_name” value=”<?php echo esc_attr(get_option(‘profile_name’)); ?>” class=”regular-text”></td>
</tr>
<tr>
<th><label for=”profile_title”>المسمى الوظيفي</label></th>
<td><input type=”text” name=”profile_title” value=”<?php echo esc_attr(get_option(‘profile_title’)); ?>” class=”regular-text”></td>
</tr>
<tr>
<th><label for=”profile_image”>صورة الملف الشخصي</label></th>
<td>
<input type=”text” name=”profile_image” id=”profile_image” value=”<?php echo esc_attr(get_option(‘profile_image’)); ?>” class=”regular-text”>
<input type=”button” class=”button” value=”رفع صورة” onclick=”upload_image(‘profile_image’);”>
<p class=”description”>رابط URL لصورتك الشخصية</p>
</td>
</tr>
</table>

<h2>المعلومات الشخصية</h2>
<table class=”form-table”>
<tr>
<th><label for=”full_name”>الاسم الكامل</label></th>
<td><input type=”text” name=”full_name” value=”<?php echo esc_attr(get_option(‘full_name’)); ?>” class=”regular-text”></td>
</tr>
<tr>
<th><label for=”profile_age”>العمر</label></th>
<td><input type=”text” name=”profile_age” value=”<?php echo esc_attr(get_option(‘profile_age’)); ?>” class=”regular-text”></td>
</tr>
<tr>
<th><label for=”nationality”>الجنسية</label></th>
<td><input type=”text” name=”nationality” value=”<?php echo esc_attr(get_option(‘nationality’)); ?>” class=”regular-text”></td>
</tr>
<tr>
<th><label for=”marital_status”>الحالة الاجتماعية</label></th>
<td><input type=”text” name=”marital_status” value=”<?php echo esc_attr(get_option(‘marital_status’)); ?>” class=”regular-text”></td>
</tr>
</table>

<!– أقسام التعليم والخبرة والمهارات وروابط التواصل الاجتماعي –>

<p class=”submit”>
<input type=”submit” name=”submit” class=”button-primary” value=”حفظ التغييرات”>
</p>
</form>

<script>
function upload_image(field_id) {
var uploader = wp.media({
title: ‘اختر صورة’,
button: { text: ‘استخدام هذه الصورة’ },
multiple: false
}).on(‘select’, function() {
var attachment = uploader.state().get(‘selection’).first().toJSON();
document.getElementById(field_id).value = attachment.url;
}).open();
}
</script>
</div>
<?php
}

// تسجيل إعدادات الملف الشخصي
function register_profile_settings() {
register_setting(‘profile_options’, ‘profile_name’);
register_setting(‘profile_options’, ‘profile_title’);
register_setting(‘profile_options’, ‘profile_image’);
// تسجيل باقي الإعدادات بنفس الطريقة
}
add_action(‘admin_init’, ‘register_profile_settings’);

// إنشاء صفحة قالب الملف الشخصي
function create_profile_page() {
$page_title = ‘الملف الشخصي’;
$page_content = ”;
$page_check = get_page_by_title($page_title);

if (!$page_check) {
$new_page = array(
‘post_title’ => $page_title,
‘post_content’ => $page_content,
‘post_status’ => ‘publish’,
‘post_type’ => ‘page’,
‘page_template’ => ‘personal-profile.php’
);

wp_insert_post($new_page);
}
}
add_action(‘after_switch_theme’, ‘create_profile_page’);
?>

تصميم موقع كهذا باستخدام ووردبريس.كوم
ابدأ