[ 'name' => 'Job Worker Profiles', 'singular_name' => 'Worker Profile', 'add_new_item' => 'Add New Profile', 'edit_item' => 'Edit Profile', ], 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_icon' => 'dashicons-businessperson', 'supports' => ['title', 'editor', 'thumbnail', 'comments'], 'capability_type' => 'post', 'map_meta_cap' => true, ]); } add_action('init', 'jwp_register_cpt'); // 2. Global Toggle add_action('admin_menu', function() { add_submenu_page('edit.php?post_type=jwp_profile', 'Global Visibility', 'Global Toggle', 'manage_options', 'jwp-global-toggle', 'jwp_global_toggle_page'); }); function jwp_global_toggle_page() { if (isset($_POST['jwp_global_toggle']) && current_user_can('manage_options')) { update_option('jwp_global_show_profiles', $_POST['jwp_global_toggle'] === 'on' ? 'on' : 'off'); echo '

Global visibility updated!

'; } $show = get_option('jwp_global_show_profiles', 'on'); ?>

Global Profiles Visibility

ID, $f, true); if(!$data['_admin_visibility']) $data['_admin_visibility'] = 'show'; if(!$data['_user_visibility']) $data['_user_visibility'] = 'show'; ?>
Location
Job Title/Tag
Phone

Full Biodata Details
Father's Name
Current Address
Preferred Job Location
Past Experience (Companies)
School Name
College Name
Degrees / Certifications

Grid Details
Total Experience
Education
Skills (Comma Separated)
Work Type
Availability
Expected Salary

Media & Social Links
YouTube Video URL
Facebook Link
Instagram Link
YouTube Channel
Twitter (X) Link

Admin Visibility
Views
Likes
admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('jwp_save_nonce'), 'view_nonce' => wp_create_nonce('jwp_view_nonce')]); } add_action('wp_enqueue_scripts', 'jwp_enqueue_assets'); add_action('wp_ajax_jwp_increment_view', 'jwp_increment_view'); add_action('wp_ajax_nopriv_jwp_increment_view', 'jwp_increment_view'); function jwp_increment_view() { check_ajax_referer('jwp_view_nonce', 'nonce'); $post_id = intval($_POST['post_id']); if ($post_id > 0 && get_post_type($post_id) === 'jwp_profile') { $views = (int) get_post_meta($post_id, '_profile_views', true); update_post_meta($post_id, '_profile_views', ++$views); wp_send_json_success(['views' => number_format_i18n($views)]); } wp_send_json_error(); } add_action('wp_ajax_jwp_like_profile', 'jwp_like_profile_ajax'); add_action('wp_ajax_nopriv_jwp_like_profile', 'jwp_like_profile_ajax'); function jwp_like_profile_ajax() { check_ajax_referer('jwp_view_nonce', 'nonce'); $post_id = intval($_POST['post_id']); $liked_posts = isset($_COOKIE['jwp_liked_posts']) ? explode(',', $_COOKIE['jwp_liked_posts']) : []; if (in_array($post_id, $liked_posts)) wp_send_json_error('Already liked'); if ($post_id > 0 && get_post_type($post_id) === 'jwp_profile') { $likes = (int) get_post_meta($post_id, '_jwp_likes', true); update_post_meta($post_id, '_jwp_likes', ++$likes); $liked_posts[] = $post_id; setcookie('jwp_liked_posts', implode(',', $liked_posts), time() + (86400 * 365), "/"); wp_send_json_success(['likes' => number_format_i18n($likes)]); } wp_send_json_error(); } // 5. AJAX Form Handler add_action('wp_ajax_jwp_save_profile', 'jwp_save_profile_handler'); add_action('wp_ajax_nopriv_jwp_save_profile', 'jwp_save_profile_handler'); function jwp_save_profile_handler() { check_ajax_referer('jwp_save_nonce', 'nonce'); if (!is_user_logged_in()) wp_send_json_error('कृपया लॉगिन करें।'); $user_id = get_current_user_id(); $existing = get_posts(['post_type' => 'jwp_profile', 'author' => $user_id, 'posts_per_page' => 1, 'post_status' => 'any']); $pid = $existing ? $existing[0]->ID : 0; $name = sanitize_text_field($_POST['name'] ?? ''); $phone = sanitize_text_field($_POST['phone'] ?? ''); if (empty($name) || empty($phone)) wp_send_json_error('नाम और फोन नंबर जरूरी हैं।'); $postarr = [ 'post_title' => $name, 'post_content' => wp_kses_post($_POST['desc'] ?? ''), 'post_type' => 'jwp_profile', 'post_status' => 'publish', 'post_author' => $user_id, 'comment_status' => 'open' ]; if ($pid) { $postarr['ID'] = $pid; wp_update_post($postarr); } else { $pid = wp_insert_post($postarr); } $fields = ['location', 'tag', 'phone', 'experience', 'education', 'skills', 'worktype', 'availability', 'salary', 'social_fb', 'social_insta', 'social_yt', 'social_twitter', 'yt_video', 'father_name', 'current_address', 'pref_location', 'past_experience', 'school_name', 'college_name', 'degrees']; foreach ($fields as $field) update_post_meta($pid, '_' . $field, sanitize_text_field($_POST[$field] ?? '')); update_post_meta($pid, '_user_visibility', in_array($_POST['visibility'] ?? '', ['show', 'hide']) ? $_POST['visibility'] : 'show'); if (!empty($_FILES['photo']['name'])) { require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/media.php'); require_once(ABSPATH . 'wp-admin/includes/image.php'); $current_user = wp_get_current_user(); $current_user->add_cap('upload_files'); $attach_id = media_handle_upload('photo', $pid); $current_user->remove_cap('upload_files'); if (!is_wp_error($attach_id)) set_post_thumbnail($pid, $attach_id); } wp_send_json_success('प्रोफाइल सफलतापूर्वक सेव हो गई!'); } add_action('wp_ajax_jwp_fetch_profiles', 'jwp_fetch_profiles_ajax'); add_action('wp_ajax_nopriv_jwp_fetch_profiles', 'jwp_fetch_profiles_ajax'); function jwp_fetch_profiles_ajax() { check_ajax_referer('jwp_view_nonce', 'nonce'); $offset = isset($_POST['offset']) ? intval($_POST['offset']) : 0; $limit = isset($_POST['limit']) ? intval($_POST['limit']) : 5; $filter = isset($_POST['filter']) ? sanitize_text_field($_POST['filter']) : 'all'; $keyword = isset($_POST['keyword']) ? sanitize_text_field($_POST['keyword']) : ''; $args = [ 'post_type' => 'jwp_profile', 'post_status' => 'publish', 'posts_per_page' => $limit, 'offset' => $offset, 'meta_query' => ['relation' => 'AND', ['key' => '_admin_visibility', 'value' => 'hide', 'compare' => '!='], ['key' => '_user_visibility', 'value' => 'hide', 'compare' => '!=']] ]; if ($filter !== 'all' && !empty($filter)) { $args['meta_query'][] = ['relation' => 'OR', ['key' => '_tag', 'value' => $filter, 'compare' => 'LIKE'], ['key' => '_skills', 'value' => $filter, 'compare' => 'LIKE']]; } if (!empty($keyword)) { $args['s'] = $keyword; } $query = new WP_Query($args); $html = ''; if ($query->have_posts()) { ob_start(); while ($query->have_posts()) { $query->the_post(); global $post; es_render_card_html($post); } $html = ob_get_clean(); } wp_reset_postdata(); wp_send_json_success(['html' => $html, 'has_more' => ($query->found_posts > ($offset + $limit))]); } function es_render_card_html($p) { if (has_post_thumbnail($p->ID)) { $img = get_the_post_thumbnail_url($p->ID, 'medium'); } else { $img = 'https://ui-avatars.com/api/?name=' . urlencode($p->post_title) . '&background=e2e8f0&color=334155&size=150&font-size=0.4&bold=true'; } $phone = get_post_meta($p->ID, '_phone', true); $tag = get_post_meta($p->ID, '_tag', true) ?: 'Worker'; $loc = get_post_meta($p->ID, '_location', true) ?: '-'; $views = (int) get_post_meta($p->ID, '_profile_views', true); $likes = (int) get_post_meta($p->ID, '_jwp_likes', true); $comments_count = get_comments_number($p->ID); $exp = get_post_meta($p->ID, '_experience', true) ?: '-'; $edu = get_post_meta($p->ID, '_education', true) ?: '-'; $avail = get_post_meta($p->ID, '_availability', true) ?: '-'; $sal = get_post_meta($p->ID, '_salary', true) ?: '-'; $skills_raw = get_post_meta($p->ID, '_skills', true); $skills_arr = empty($skills_raw) ? [] : array_filter(array_map('trim', explode(',', $skills_raw))); ?>
featured
Profile
Verified

post_title); ?>

व्यूज
अनुभव:
शिक्षा:
उपलब्धता:
वेतन: ₹
Skills
Not Specified
Likes Comments
पूरी प्रोफाइल व बायोडाटा देखें
प्रोफाइल बनाने के लिए पहले लॉगिन करें।

लॉगिन करें

'; $user_id = get_current_user_id(); $existing = get_posts(['post_type' => 'jwp_profile', 'author' => $user_id, 'posts_per_page' => 1]); $p = $existing ? $existing[0] : null; $id = $p ? $p->ID : 0; if ($id && has_post_thumbnail($id)) { $thumbnail = get_the_post_thumbnail_url($id, 'medium'); } else { $thumbnail = 'https://ui-avatars.com/api/?name=' . urlencode(wp_get_current_user()->display_name) . '&background=e2e8f0&color=334155&size=150'; } ob_start(); ?>

प्रोफाइल डिटेल्स भरें

फुल बायोडाटा (Full Biodata)

प्रोफेशनल जानकारी (Short Info)

सोशल मीडिया और वीडियो (वैकल्पिक)

Profiles Hidden.
'; ob_start(); ?>
सभी
CCTV
इलेक्ट्रीशियन
प्लंबर
ब्यूटीशियन
ड्राइवर
हेल्पर

सभी कारीगर प्रोफाइल्स

लोड हो रहा है...
प्रोफाइल जोड़ें
> <?php wp_title('|', true, 'right'); ?> ID; $name = get_the_title($id); if (has_post_thumbnail($id)) { $thumb_url = get_the_post_thumbnail_url($id, 'large'); } else { $thumb_url = 'https://ui-avatars.com/api/?name=' . urlencode($name) . '&background=e2e8f0&color=334155&size=300&font-size=0.4&bold=true'; } $desc = wpautop($post->post_content); $loc = get_post_meta($id, '_location', true) ?: ''; $tag = get_post_meta($id, '_tag', true) ?: '-'; $phone = get_post_meta($id, '_phone', true); $exp = get_post_meta($id, '_experience', true) ?: '-'; $edu = get_post_meta($id, '_education', true) ?: '-'; $skills_raw = get_post_meta($id, '_skills', true); $skills_arr = empty($skills_raw) ? [] : array_filter(array_map('trim', explode(',', $skills_raw))); $avail = get_post_meta($id, '_availability', true) ?: '-'; $sal = get_post_meta($id, '_salary', true) ?: '-'; // NEW BIODATA FIELDS $father = get_post_meta($id, '_father_name', true) ?: '-'; $address = get_post_meta($id, '_current_address', true) ?: '-'; $pref_loc = get_post_meta($id, '_pref_location', true) ?: '-'; $past_exp = get_post_meta($id, '_past_experience', true) ?: '-'; $school = get_post_meta($id, '_school_name', true) ?: '-'; $college = get_post_meta($id, '_college_name', true) ?: '-'; $degrees = get_post_meta($id, '_degrees', true) ?: '-'; $likes = (int) get_post_meta($id, '_jwp_likes', true); $comments_count = get_comments_number($id); $permalink = get_permalink($id); $fb = get_post_meta($id, '_social_fb', true); $insta = get_post_meta($id, '_social_insta', true); $yt_channel = get_post_meta($id, '_social_yt', true); $twitter = get_post_meta($id, '_social_twitter', true); $yt_video = get_post_meta($id, '_yt_video', true); $yt_embed_url = ''; if ($yt_video) { preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/\s]{11})%i', $yt_video, $match); if(isset($match[1])) { $yt_embed_url = 'https://www.youtube.com/embed/' . $match[1]; } } $vcard = "BEGIN:VCARD\r\nVERSION:3.0\r\nFN:" . $name . "\r\nTEL:" . $phone . "\r\nTITLE:" . $tag . "\r\nEND:VCARD"; $vcard_uri = "data:text/vcard;charset=utf-8," . rawurlencode($vcard); ?>
सभी प्रोफाइल्स देखें

मेरा काम (My Work)
प्रोफेशनल जानकारी
अनुभव:
शिक्षा:
उपलब्धता:
वेतन: ₹
Skills & Machines
Not Specified
पूरा नाम
पिता का नाम
फ़ोन नंबर
वर्तमान पता
पसंदीदा कार्यस्थल
कुल अनुभव
पुराना काम (कंपनियां)
स्कूल का नाम
कॉलेज का नाम
डिग्री (Degrees)
लोकेशन (Map)
Likes Comments
सेव कॉन्टैक्ट
कमेंट्स बंद कर दिए गए हैं।

'; } ?>

Popular posts from this blog

Gj