'.esc_html((string)$q->found_posts).' matching opportunities';
if (!empty($status['at'])) echo ' · World Bank feed checked '.esc_html($status['at']);
echo '
Sources include World Bank notices (CC BY 4.0), Kenya PPRA/PPIP, Zimbabwe PRAZ eGP, Tanzania PPRA NeST (CC BY-SA 4.0), South Africa National Treasury OCDS (PDDL 1.0), and individually checked buyer notices. Coverage is partial; verify each official source.
';
if (is_user_logged_in()) echo pv_save_search_form($keyword, $country);
else echo '
No saved searches yet. Search opportunities, then save a country or keyword alert.
';
return $html;
});
add_action('pv_daily_alerts', function () {
$checked = 0; $sent_count = 0; $failed_count = 0;
foreach (get_users(['fields'=>['ID','user_email'], 'meta_key'=>'pv_saved_searches']) as $user) {
$saved = get_user_meta($user->ID,'pv_saved_searches',true);
if (!is_array($saved) || !$saved) continue;
$checked++;
$delivered = get_user_meta($user->ID,'pv_alerted_notice_ids',true);
if (!is_array($delivered)) $delivered=[];
$already = array_fill_keys($delivered,true);
$lines=[]; $new_ids=[];
foreach ($saved as $search) {
$keyword=sanitize_text_field($search['keyword'] ?? ''); $country=sanitize_text_field($search['country'] ?? '');
for ($page = 1; $page <= 5; $page++) {
$q = pv_alert_query($keyword, $country, $page);
foreach ($q->posts as $post) {
if (isset($already[$post->ID]) || isset($new_ids[$post->ID])) continue;
$new_ids[$post->ID]=true;
$lines[]=get_the_title($post->ID).' | '.get_post_meta($post->ID,'pv_country',true).' | Closes '.get_post_meta($post->ID,'pv_deadline',true).' | '.get_post_meta($post->ID,'pv_source_url',true);
if (count($lines)>=30) break 3;
}
if ($page >= $q->max_num_pages) break;
}
}
if ($lines) {
$message="New African opportunities matching your saved searches:\n\n".implode("\n\n",$lines)."\n\nManage alerts: ".site_url('/saved-searches/');
if (wp_mail($user->user_email,'PANVERIQ: '.count($lines).' matching opportunities',$message)) {
update_user_meta($user->ID,'pv_alerted_notice_ids',array_slice(array_merge($delivered,array_keys($new_ids)),-1000));
update_user_meta($user->ID,'pv_last_alert_accepted_at',gmdate('c'));
$sent_count++;
} else { $failed_count++; }
}
}
update_option('pv_last_alert_run', ['at'=>gmdate('c'),'users'=>$checked,'sent'=>$sent_count,'failed'=>$failed_count], false);
});
add_shortcode('panveriq_join', function () {
$html = '
Join PANVERIQ for free
Search African tender notices and send product sourcing inquiries across Africa. Create an account to save up to 20 searches and receive daily alerts for newly imported matches.
Product sourcing inquiries can be submitted without an account.
';
});
// Kept as a harmless alias for sites that already use the earlier shortcode.
add_shortcode('panveriq_subscription', function () { return do_shortcode('[panveriq_join]'); });
add_shortcode('panveriq_about', function () {
return '
About PANVERIQ
PANVERIQ connects companies worldwide with African tender notices and product sourcing inquiries. It has two clear paths: find work through tender discovery and seek supply through product or service inquiries.
Our tender discovery pilot brings source-linked procurement notices into a searchable view, with free accounts for saved searches and daily alerts. Buyers can also submit a product or service requirement for manual review and a possible introduction to a relevant African connection.
The tender feed is an initial source, not complete Africa-wide coverage. A sourcing inquiry is not an offer of stock or a guarantee of a supplier. Availability, supplier checks, transaction requirements and commercial terms are assessed case by case.
';
});
add_shortcode('panveriq_sourcing', function () {
$html='
Source products and suppliers from Africa
Looking for a product, service or supplier in Africa? Describe your requirement, quantity, destination and timeline. PANVERIQ will review it and contact you if we can help identify a suitable connection. Availability, supplier checks and terms are confirmed separately.
';
$html.='';
if (isset($_GET['sourcing'])) $html.='
'.($_GET['sourcing']==='received'?'Your request was received for review. We will contact you if we can help.':'The request could not be saved. Please try again later.').'
';
return $html.'
';
});
add_action('admin_post_nopriv_pv_sourcing','pv_handle_sourcing');
add_action('admin_post_pv_sourcing','pv_handle_sourcing');
function pv_handle_sourcing() {
if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_pv_nonce'] ?? '')),'pv_sourcing')) wp_die('Invalid request','',['response'=>403]);
if (!empty($_POST['pv_website'])) wp_die('Invalid request','',['response'=>400]);
$name=substr(sanitize_text_field(wp_unslash($_POST['pv_name'] ?? '')),0,100);
$email=sanitize_email(wp_unslash($_POST['pv_email'] ?? ''));
$organisation=substr(sanitize_text_field(wp_unslash($_POST['pv_organisation'] ?? '')),0,150);
$category=sanitize_key(wp_unslash($_POST['pv_category'] ?? ''));
$product=substr(sanitize_text_field(wp_unslash($_POST['pv_product'] ?? '')),0,150);
$quantity=substr(sanitize_text_field(wp_unslash($_POST['pv_quantity'] ?? '')),0,100);
$destination=substr(sanitize_text_field(wp_unslash($_POST['pv_destination'] ?? '')),0,100);
$requirement=substr(sanitize_textarea_field(wp_unslash($_POST['pv_requirement'] ?? '')),0,2000);
if (!$name || !is_email($email) || !$product || !$destination || !$requirement || !in_array($category,['minerals','agriculture','raw_materials','equipment','manufactured','services','other'],true) || ($_POST['pv_consent'] ?? '')!=='1') wp_die('Please complete all required fields','',['response'=>400]);
$rate_key='pv_sourcing_'.hash('sha256',strtolower($email));
if (get_transient($rate_key)) wp_die('Please wait before sending another request',429);
$id=wp_insert_post(['post_type'=>'pv_sourcing_request','post_status'=>'private','post_title'=>$product.' · '.$destination,'post_content'=>$requirement,'post_author'=>get_current_user_id()],true);
if (is_wp_error($id)) { wp_safe_redirect(add_query_arg('sourcing','error',site_url('/source-in-africa/'))); exit; }
update_post_meta($id,'pv_request_product',$product);
update_post_meta($id,'pv_request_quantity',$quantity);
update_post_meta($id,'pv_request_destination',$destination);
update_post_meta($id,'pv_request_name',$name);
update_post_meta($id,'pv_request_email',$email);
update_post_meta($id,'pv_request_organisation',$organisation);
update_post_meta($id,'pv_request_category',$category);
update_post_meta($id,'pv_request_consent_at',gmdate('c'));
set_transient($rate_key,1,10*MINUTE_IN_SECONDS);
if (defined('PANVERIQ_CONTACT_EMAIL') && is_email(PANVERIQ_CONTACT_EMAIL)) {
$notice = "New PANVERIQ sourcing inquiry\n\nProduct: ".$product."\nDestination: ".$destination."\nName: ".$name."\nEmail: ".$email."\n\nReview the private request in WordPress: ".admin_url('post.php?post='.$id.'&action=edit');
wp_mail(PANVERIQ_CONTACT_EMAIL, 'PANVERIQ sourcing request #'.$id, $notice, ['Reply-To: '.$email]);
}
wp_safe_redirect(add_query_arg('sourcing','received',site_url('/source-in-africa/'))); exit;
}
add_shortcode('panveriq_advertise', function () {
return '
Advertise with PANVERIQ
We are developing clearly labelled sponsorship space for organisations relevant to African tenders, products, sourcing and cross-border business connections.
Sponsored content will be identified as advertising and will not change official notice details or organic search rankings. Availability and rates are not yet final.
';
});
add_shortcode('panveriq_contact', function () {
$html = '
Contact PANVERIQ
Questions about tender discovery, sourcing, partnerships or advertising? Send an inquiry below. For a detailed product need, use the Source in Africa form.
';
$topics = ['General inquiry'=>'general','Tender data or source'=>'source','Product sourcing'=>'sourcing','Partnership'=>'partnership','Advertising'=>'advertising'];
$selected = sanitize_key(wp_unslash($_GET['topic'] ?? ''));
$html .= '';
if (isset($_GET['contact'])) $html.='
'.($_GET['contact']==='received'?'Thank you. Your inquiry was received for review.':'The inquiry could not be saved. Please try again later.').'
';
return $html.'
';
});
add_action('admin_post_nopriv_pv_contact','pv_handle_contact');
add_action('admin_post_pv_contact','pv_handle_contact');
function pv_handle_contact() {
if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_pv_nonce'] ?? '')),'pv_contact')) wp_die('Invalid request','',['response'=>403]);
if (!empty($_POST['pv_website'])) wp_die('Invalid request','',['response'=>400]);
$name = substr(sanitize_text_field(wp_unslash($_POST['pv_name'] ?? '')),0,100);
$email = sanitize_email(wp_unslash($_POST['pv_email'] ?? ''));
$message = substr(sanitize_textarea_field(wp_unslash($_POST['pv_message'] ?? '')),0,4000);
$topics = ['general','source','sourcing','partnership','advertising'];
$topic = sanitize_key(wp_unslash($_POST['pv_topic'] ?? 'general'));
if (!$name || !is_email($email) || !$message || !in_array($topic,$topics,true) || ($_POST['pv_consent'] ?? '')!=='1') wp_die('Please complete all required fields','',['response'=>400]);
$rate_key='pv_contact_'.hash('sha256',strtolower($email));
if (get_transient($rate_key)) wp_die('Please wait before sending another inquiry',429);
$id=wp_insert_post(['post_type'=>'pv_sourcing_request','post_status'=>'private','post_title'=>'Contact: '.$topic.' · '.$name,'post_content'=>$message,'post_author'=>get_current_user_id()],true);
if (is_wp_error($id)) { wp_safe_redirect(add_query_arg('contact','error',site_url('/contact-panveriq/'))); exit; }
update_post_meta($id,'pv_request_name',$name);
update_post_meta($id,'pv_request_email',$email);
update_post_meta($id,'pv_request_category','contact');
update_post_meta($id,'pv_contact_topic',$topic);
update_post_meta($id,'pv_request_consent_at',gmdate('c'));
set_transient($rate_key,1,10*MINUTE_IN_SECONDS);
if (defined('PANVERIQ_CONTACT_EMAIL') && is_email(PANVERIQ_CONTACT_EMAIL)) {
$notice = "New PANVERIQ contact inquiry\n\nTopic: ".$topic."\nName: ".$name."\nEmail: ".$email."\n\nReview the private inquiry in WordPress: ".admin_url('post.php?post='.$id.'&action=edit');
wp_mail(PANVERIQ_CONTACT_EMAIL, 'PANVERIQ contact inquiry #'.$id, $notice, ['Reply-To: '.$email]);
}
wp_safe_redirect(add_query_arg('contact','received',site_url('/contact-panveriq/'))); exit;
}
// South African National Treasury OCDS releases. One bounded page per run.
add_action('init', function () {
if (!wp_next_scheduled('pv_sa_sync')) wp_schedule_event(time() + HOUR_IN_SECONDS, 'daily', 'pv_sa_sync');
});
add_action('pv_sa_sync', 'pv_sync_south_africa');
add_action('admin_menu', function () {
add_management_page('Government feeds', 'Government feeds', 'manage_options', 'panveriq-government-feeds', function () {
$s = get_option('pv_sa_status', []);
echo '
Government tender feeds
South Africa: National Treasury OCDS releases. This source covers data submitted to the Treasury by public entities; it is not every government tender in South Africa.
';
echo '
Last run: '.esc_html($s['at'] ?? 'Never').' · Releases examined: '.esc_html($s['examined'] ?? 0).' · Open notices saved or updated: '.esc_html($s['saved'] ?? 0).' · Page: '.esc_html($s['page'] ?? 0).'
';
});
});
add_action('admin_post_pv_run_sa', function () {
if (!current_user_can('manage_options')) wp_die('Forbidden','',['response'=>403]);
check_admin_referer('pv_run_sa');
pv_sync_south_africa();
wp_safe_redirect(admin_url('tools.php?page=panveriq-government-feeds')); exit;
});
function pv_sync_south_africa() {
if (get_transient('pv_sa_lock')) return;
set_transient('pv_sa_lock', 1, 3 * MINUTE_IN_SECONDS);
$cursor = get_option('pv_sa_cursor', []);
if (!is_array($cursor) || empty($cursor['from']) || empty($cursor['to']) || empty($cursor['page'])) {
$cursor = ['from'=>gmdate('Y-m-d', time() - 30 * DAY_IN_SECONDS), 'to'=>gmdate('Y-m-d'), 'page'=>1];
}
$page = max(1, min(10000, absint($cursor['page'])));
$url = add_query_arg(['PageNumber'=>$page, 'PageSize'=>100, 'dateFrom'=>$cursor['from'].'T00:00:00Z', 'dateTo'=>$cursor['to'].'T23:59:59Z'], 'https://ocds-api.etenders.gov.za/api/OCDSReleases');
$response = wp_remote_get($url, ['timeout'=>65, 'headers'=>['Accept'=>'application/json']]);
$error = ''; $saved = 0; $examined = 0; $more = false;
if (is_wp_error($response)) $error = $response->get_error_message();
elseif (wp_remote_retrieve_response_code($response) !== 200) $error = 'National Treasury API HTTP '.wp_remote_retrieve_response_code($response);
else {
$data = json_decode(wp_remote_retrieve_body($response), true);
if (!is_array($data) || !isset($data['releases']) || !is_array($data['releases'])) $error = 'Invalid OCDS response';
else {
foreach ($data['releases'] as $release) {
$examined++;
$tender = $release['tender'] ?? [];
if (!is_array($tender) || strtolower((string)($tender['status'] ?? '')) !== 'active') continue;
$ocid = sanitize_text_field($release['ocid'] ?? '');
$end = (string)($tender['tenderPeriod']['endDate'] ?? '');
$deadline_time = $end ? strtotime($end) : false;
$deadline = $deadline_time ? gmdate('Y-m-d', $deadline_time) : '';
if (!$ocid || !$deadline || $deadline < gmdate('Y-m-d')) continue;
$description = sanitize_text_field($tender['description'] ?? '');
$title = $description ?: sanitize_text_field($tender['title'] ?? 'Government tender');
$source_url = '';
foreach (($tender['documents'] ?? []) as $document) {
$candidate = esc_url_raw($document['url'] ?? '');
if ($candidate && wp_http_validate_url($candidate)) { $source_url = $candidate; break; }
}
if (!$source_url) continue;
$source_id = 'za:'.$ocid;
$existing = get_posts(['post_type'=>'pv_opportunity', 'post_status'=>'any', 'meta_key'=>'pv_source_id', 'meta_value'=>$source_id, 'fields'=>'ids', 'posts_per_page'=>1]);
$post = ['post_type'=>'pv_opportunity', 'post_status'=>'publish', 'post_title'=>mb_substr($title,0,240), 'post_content'=>sanitize_textarea_field($description), 'post_author'=>1];
if ($existing) $post['ID'] = $existing[0];
$post_id = wp_insert_post($post, true);
if (is_wp_error($post_id)) { $error = $post_id->get_error_message(); continue; }
update_post_meta($post_id, 'pv_source_id', $source_id);
if (!$existing) update_post_meta($post_id, 'pv_first_seen', gmdate('Y-m-d'));
update_post_meta($post_id, 'pv_country', 'South Africa');
update_post_meta($post_id, 'pv_deadline', $deadline);
update_post_meta($post_id, 'pv_notice_type', sanitize_text_field($tender['procurementMethodDetails'] ?? 'Government tender'));
update_post_meta($post_id, 'pv_project', sanitize_text_field($tender['procuringEntity']['name'] ?? $release['buyer']['name'] ?? 'National Treasury'));
update_post_meta($post_id, 'pv_notice_date', sanitize_text_field($release['date'] ?? ''));
update_post_meta($post_id, 'pv_checked_at', gmdate('c'));
update_post_meta($post_id, 'pv_source_name', 'South Africa National Treasury');
update_post_meta($post_id, 'pv_source_url', $source_url);
$saved++;
}
$more = !empty($data['links']['next']);
if ($more && $page < 10000) update_option('pv_sa_cursor', ['from'=>$cursor['from'], 'to'=>$cursor['to'], 'page'=>$page+1], false);
else update_option('pv_sa_cursor', [], false);
}
}
update_option('pv_sa_status', ['at'=>gmdate('c'), 'page'=>$page, 'examined'=>$examined, 'saved'=>$saved, 'more'=>$more, 'error'=>$error], false);
delete_transient('pv_sa_lock');
}
// Government feed expansion: publish notice metadata, never account or bidder data.
add_action('init', function () {
foreach (['pv_ke_sync','pv_tz_sync','pv_tz_recent_sync'] as $hook) {
if (!wp_next_scheduled($hook)) wp_schedule_event(time() + 120, 'hourly', $hook);
}
});
add_action('pv_ke_sync','pv_sync_kenya');
add_action('pv_ke_continue','pv_sync_kenya');
add_action('pv_tz_sync','pv_sync_tanzania');
add_action('pv_tz_continue','pv_sync_tanzania');
add_action('init',function () { if (!get_option('pv_tz_midnight_v1')) { delete_option('pv_tz_recent_next'); update_option('pv_tz_midnight_v1',1,false); } });
function pv_sync_tanzania_recent() { pv_sync_tanzania(true); }
add_action('pv_tz_recent_sync','pv_sync_tanzania_recent');
add_action('pv_tz_recent_continue','pv_sync_tanzania_recent');
register_deactivation_hook(__FILE__, function () {
foreach (['pv_ke_sync','pv_ke_continue','pv_tz_sync','pv_tz_continue','pv_tz_recent_sync','pv_tz_recent_continue','pv_sa_sync'] as $hook) wp_clear_scheduled_hook($hook);
});
function pv_government_json($url) {
$r = wp_remote_get($url, ['timeout'=>35,'limit_response_size'=>12*1024*1024,'headers'=>['Accept'=>'application/json']]);
if (is_wp_error($r)) return $r;
if (wp_remote_retrieve_response_code($r)!==200) return new WP_Error('source_http','Source HTTP '.wp_remote_retrieve_response_code($r));
$d=json_decode(wp_remote_retrieve_body($r),true);
return is_array($d) ? $d : new WP_Error('source_json','Invalid source JSON');
}
function pv_store_government_notice($n) {
$id=sanitize_text_field($n['id'] ?? '');
if (!$id) return false;
$existing=get_posts(['post_type'=>'pv_opportunity','post_status'=>'any','meta_key'=>'pv_source_id','meta_value'=>$id,'fields'=>'ids','posts_per_page'=>1]);
// An older backfill release must not overwrite a newer notice update.
if ($existing) {
$stored_date=strtotime(get_post_meta($existing[0],'pv_notice_date',true));
$incoming_date=strtotime($n['published'] ?? '');
if ($stored_date && $incoming_date && $stored_date>$incoming_date) return false;
}
$deadline_time=strtotime($n['end'] ?? '');
if (empty($n['active']) || !$deadline_time || $deadline_time <= time()) {
if ($existing) {wp_update_post(['ID'=>$existing[0],'post_status'=>'draft']);if (!empty($n['published'])) update_post_meta($existing[0],'pv_notice_date',sanitize_text_field($n['published']));}
return false;
}
if (empty($n['title']) || empty($n['url'])) return false;
$post=['post_type'=>'pv_opportunity','post_status'=>'publish','post_title'=>sanitize_text_field($n['title']),'post_content'=>'','post_author'=>1];
if ($existing) $post['ID']=$existing[0];
$post_id=wp_insert_post($post,true);
if (is_wp_error($post_id)) return $post_id;
$meta=['pv_source_id'=>$id,'pv_country'=>$n['country'],'pv_deadline'=>gmdate('Y-m-d',$deadline_time),'pv_deadline_at'=>gmdate('c',$deadline_time),'pv_notice_type'=>$n['method'],'pv_project'=>$n['buyer'],'pv_notice_date'=>$n['published'],'pv_checked_at'=>gmdate('c'),'pv_source_name'=>$n['source'],'pv_source_url'=>$n['url'],'pv_reference'=>$n['reference'] ?? '', 'pv_source_license'=>$n['license'] ?? ''];
foreach ($meta as $key=>$value) update_post_meta($post_id,$key,sanitize_text_field($value));
if (!$existing) update_post_meta($post_id,'pv_first_seen',gmdate('Y-m-d'));
return $post_id;
}
function pv_sync_kenya() {
if (get_transient('pv_ke_lock')) return;
set_transient('pv_ke_lock',1,10*MINUTE_IN_SECONDS);
$page=max(1,(int)get_option('pv_ke_page',1));$seen=0;$saved=0;$error='';$more=false;
$cycle=get_option('pv_ke_cycle','');
if ($page===1 || !$cycle) {$cycle=wp_generate_uuid4();update_option('pv_ke_cycle',$cycle,false);}
for ($batch=0;$batch<10;$batch++) {
$url=add_query_arg(['search'=>'','perpage'=>100,'order'=>'asc','page'=>$page],'https://tenders.go.ke/api/active-tenders');
$d=pv_government_json($url);
if (is_wp_error($d)) {$error=$d->get_error_message();break;}
if (!isset($d['data']) || !is_array($d['data'])) {$error='Invalid Kenya feed';break;}
foreach ($d['data'] as $t) {
$seen++;
$end=isset($t['close_at']) ? strtotime($t['close_at'].' +0300') : false;
$id=absint($t['id'] ?? 0);
if (!$id || !$end) continue;
$result=pv_store_government_notice(['id'=>'ke:'.$id,'title'=>$t['title'] ?? '', 'end'=>gmdate('c',$end),'active'=>!empty($t['published']) && empty($t['terminated']),'country'=>'Kenya','method'=>$t['procurement_method']['title'] ?? 'Government tender','buyer'=>$t['pe']['name'] ?? '', 'published'=>$t['published_at'] ?? '', 'source'=>'Kenya Public Procurement Regulatory Authority (PPIP)','url'=>'https://tenders.go.ke/tenders/'.$id,'reference'=>$t['tender_ref'] ?? '']);
if (is_wp_error($result)) {$error=$result->get_error_message();break;}
if ($result) {$saved++;update_post_meta($result,'pv_ke_cycle',$cycle);}
}
if ($error) break;
$more=!empty($d['next_page_url']);
if (!$more) {$page=1;break;}
$page++;
}
update_option('pv_ke_page',$page,false);
if ($more && !$error && !wp_next_scheduled('pv_ke_continue')) wp_schedule_single_event(time()+5*MINUTE_IN_SECONDS,'pv_ke_continue');
if (!$more && !$error) {
wp_clear_scheduled_hook('pv_ke_continue');
// The active-only source omits terminated notices; hide them after a complete scan.
if ($seen>0 && isset($d['total']) && $seen >= (int)$d['total']) {
$old=get_posts(['post_type'=>'pv_opportunity','post_status'=>'publish','posts_per_page'=>-1,'fields'=>'ids','meta_query'=>[['key'=>'pv_source_name','value'=>'Kenya Public Procurement Regulatory Authority (PPIP)'],['key'=>'pv_ke_cycle','value'=>$cycle,'compare'=>'!=']]]);
foreach ($old as $post_id) wp_update_post(['ID'=>$post_id,'post_status'=>'draft']);
}
}
update_option('pv_ke_status',['at'=>gmdate('c'),'examined'=>$seen,'saved'=>$saved,'more'=>$more,'error'=>$error,'next_page'=>$page],false);
delete_transient('pv_ke_lock');
}
function pv_sync_tanzania($recent=false) {
$cursor_option=$recent ? "pv_tz_recent_next" : "pv_tz_next";
$continue_hook=$recent ? "pv_tz_recent_continue" : "pv_tz_continue";
$status_option=$recent ? "pv_tzrecent_status" : "pv_tz_status";
if (get_transient('pv_tz_lock')) return;
set_transient('pv_tz_lock',1,10*MINUTE_IN_SECONDS);
$base='https://nest.go.tz/gateway/nest-data-portal-api/api/releases';
$url=get_option($cursor_option,'');
if (!$url) $url=add_query_arg('since',gmdate('Y-m-d\T00:00:00\Z',time()-($recent ? 2 : 30)*DAY_IN_SECONDS),$base);
$seen=0;$saved=0;$error='';$more=false;$sample=[];
for ($batch=0;$batch<10;$batch++) {
// Follow only this documented source's pagination links.
if (strpos($url,$base.'?')!==0) {$error='Invalid Tanzania pagination URL';break;}
$d=pv_government_json($url);
if (is_wp_error($d)) {$error=$d->get_error_message();break;}
if (!isset($d['releases']) || !is_array($d['releases'])) {$error='Invalid Tanzania feed';break;}
foreach ($d['releases'] as $r) {
$seen++;$t=$r['tender'] ?? [];$ocid=$r['ocid'] ?? '';
if (!$sample) $sample=['release_date'=>$r['date'] ?? '', 'deadline'=>$t['tenderPeriod']['endDate'] ?? '', 'status'=>$t['status'] ?? '', 'has_title'=>!empty($t['title']) || !empty($t['description'])];
if (!$ocid || !is_array($t) || empty($t['status'])) continue;
$result=pv_store_government_notice(['id'=>'tz:'.$ocid,'title'=>$t['title'] ?? $t['description'] ?? '', 'end'=>$t['tenderPeriod']['endDate'] ?? '', 'active'=>strtolower($t['status'])==='active','country'=>'Tanzania','method'=>$t['procurementMethodDetails'] ?? 'Government tender','buyer'=>$r['buyer']['name'] ?? $t['procuringEntity']['name'] ?? '', 'published'=>$r['date'] ?? '', 'source'=>'Tanzania PPRA NeST (OCDS)','url'=>$url,'reference'=>$t['id'] ?? $ocid,'license'=>'https://data.nest.go.tz/license']);
if (is_wp_error($result)) {$error=$result->get_error_message();break;}
if ($result) $saved++;
}
if ($error) break;
$next=$d['links']['next'] ?? '';$more=(bool)$next;
if (!$more) break;
$url=$next;
}
if (!$error && !$more) {delete_option($cursor_option);wp_clear_scheduled_hook($continue_hook);}
else update_option($cursor_option,$url,false);
if (!$error && $more && !wp_next_scheduled($continue_hook)) wp_schedule_single_event(time()+5*MINUTE_IN_SECONDS,$continue_hook);
update_option($status_option,['at'=>gmdate('c'),'examined'=>$seen,'saved'=>$saved,'more'=>$more,'error'=>$error,'sample'=>$sample],false);
delete_transient('pv_tz_lock');
}
add_action('admin_menu',function () {
add_management_page('Africa government feeds','Africa government feeds','manage_options','pv-africa-feeds',function () {
echo '
Africa government tender feeds
Kenya, Tanzania and Zimbabwe: hourly automatic imports while WP-Cron runs. Large feeds continue in batches. Only currently open notice metadata is published; original sources and references are retained.
';
foreach (['Kenya Public Procurement Regulatory Authority (PPIP)','Tanzania PPRA NeST (OCDS)','Zimbabwe PRAZ eGP'] as $source_name) {
$published=get_posts(['post_type'=>'pv_opportunity','post_status'=>'publish','posts_per_page'=>-1,'fields'=>'ids','meta_key'=>'pv_source_name','meta_value'=>$source_name]);
echo '
'.esc_html($source_name).' · Published notices: '.count($published).'
Pro tools are ready for controlled trials. Paid checkout is not open. Registration of interest does not create a paid subscription.
Be first to hear about Pro
Tell us your preferred billing cycle and the markets you follow. We will use these details to respond about PANVERIQ membership.
Your interest has been recorded. No payment has been taken.'; ?>
Before you join
The free plan remains available. Pro tools are available to activated trial members; Pro cannot be purchased yet. Tender discovery is not a bidding service or a guarantee of a contract. Source coverage is partial; always check the official notice, amendments and eligibility rules.
Pro checkout is not enabled. No paid access is sold. Membership enquiries are stored privately.
';
});
});
add_action('admin_post_pv_growth_pages',function () {
if (!current_user_can('manage_options')) wp_die('Forbidden','',['response'=>403]);check_admin_referer('pv_growth_pages');
$pages=[
'membership-plans'=>['Membership plans','[panveriq_membership]'],
'zimbabwe-government-tenders'=>['Zimbabwe government tenders','
Zimbabwe government tenders
Search notices from Zimbabwe’s official PRAZ electronic procurement bulletin board, alongside other available procurement sources. Compare buyer names, requirements and closing dates, then follow the original notice to check documents and amendments.
Use a keyword to focus on your business. Create a free account to save this search and receive daily emails when new matching notices are imported.
PANVERIQ aggregates notice information and is not the issuing authority. Eligibility, registration, submission procedures and tender-specific charges are set by each buyer.
[panveriq_opportunities country="Zimbabwe"]'],
'tanzania-government-tenders'=>['Tanzania government tenders','
Tanzania government tenders
Explore notices from Tanzania PPRA NeST procurement data and other available sources. Find buyers, tender references and closing dates in one searchable view.
The original data links identify the source of each notice. Use the tender reference to locate the corresponding procurement notice in the official NeST system before preparing a bid.
Import backfill is in progress and coverage is partial. Join free for saved searches and daily matching alerts.
[panveriq_opportunities country="Tanzania"]'],
'african-tender-guide'=>['How to find African government tenders','
How to find African government tenders
Use PANVERIQ to discover source-linked procurement notices and build a focused search. The issuing authority’s current notice remains the place to confirm requirements.
1. Start with your country and service
Choose a country and search for a clear product or service keyword, such as construction, laboratory equipment or transport. Try related terms if the first search is too narrow.
Open the official notice or source-data link. Match the tender reference, buyer and deadline. Read documents and amendments at the source. Publication in PANVERIQ does not establish eligibility.
3. Review the submission details
Confirm the deadline time and timezone, submission method, registration requirements and any buyer-imposed fees before deciding whether to bid. Contact the issuing authority when details are unclear.
4. Save a relevant search
Create a free account, run your search and choose Save search. PANVERIQ supports up to 20 saved searches and sends a daily email when newly imported notices match. Broad terms can produce less relevant results, so refine them over time.
5. Keep a working shortlist
Record the tender reference, source URL, buyer, deadline and your next action. Recheck the source before submission for amended requirements or dates.
What does PANVERIQ cover?
Sources include World Bank notices in African markets, Zimbabwe PRAZ eGP and Tanzania PPRA NeST. Coverage is partial and source availability can vary.
Receive an email for shortlisted open notices within 72 hours and again within 24 hours of closing. Times and amendments must be confirmed at the official source. Reminders depend on scheduled tasks and email delivery.
';
});
function pv_csv_cell($v) {$v=wp_strip_all_tags((string)$v);return preg_match('/^[\s]*[=+\-@]/u',$v) ? "'".$v : $v;}
add_action('admin_post_pv_export_shortlist',function () {
pv_pro_guard('pv_export_shortlist');nocache_headers();header('Content-Type: text/csv; charset=UTF-8');header('Content-Disposition: attachment; filename="panveriq-shortlist.csv"');
$out=fopen('php://output','w');fwrite($out,"\xEF\xBB\xBF");fputcsv($out,['Title','Country','Buyer','Reference','Deadline date','Deadline time (if supplied)','Source','Official URL','Status'],',','"','');
foreach (pv_shortlist() as $id=>$added) {if (get_post_type($id)!=='pv_opportunity') continue;$row=[get_the_title($id),get_post_meta($id,'pv_country',true),get_post_meta($id,'pv_project',true),get_post_meta($id,'pv_reference',true) ?: get_post_meta($id,'pv_source_id',true),get_post_meta($id,'pv_deadline',true),get_post_meta($id,'pv_deadline_at',true),get_post_meta($id,'pv_source_name',true) ?: 'World Bank',get_post_meta($id,'pv_source_url',true),get_post_status($id)];fputcsv($out,array_map('pv_csv_cell',$row),',','"','');}
fclose($out);pv_metric_record('csv_export');exit;
});
add_action('admin_post_pv_reminder_preferences',function () {pv_pro_guard('pv_reminder_preferences');update_user_meta(get_current_user_id(),'pv_deadline_reminders',!empty($_POST['enabled']) ? 1 : 0);wp_safe_redirect(home_url('/pro-workspace/?preferences=saved'));exit;});
function pv_reminder_candidates($uid,$now=0) {
$now=$now ?: time();$sent=get_user_meta($uid,'pv_deadline_reminders_sent',true);if (!is_array($sent)) $sent=[];$rows=[];
foreach (pv_shortlist($uid) as $id=>$added) {
if (get_post_status($id)!=='publish') continue;
$end=get_post_meta($id,'pv_deadline_at',true);if (!$end) $end=get_post_meta($id,'pv_deadline',true).'T23:59:59Z';$close=strtotime($end);$remaining=$close-$now;
if (!$close || $remaining<=0 || $remaining>72*HOUR_IN_SECONDS) continue;
$stage=$remaining<=24*HOUR_IN_SECONDS ? 24 : 72;$key=$id.':'.hash('sha256',$end).':'.$stage;
if (isset($sent[$key])) continue;$rows[]=['id'=>$id,'end'=>$end,'stage'=>$stage,'key'=>$key];
}
return array_slice($rows,0,30);
}
add_action('init',function () {if (!wp_next_scheduled('pv_pro_reminders')) wp_schedule_event(time()+HOUR_IN_SECONDS,'hourly','pv_pro_reminders');});
register_deactivation_hook(__FILE__,function () {wp_clear_scheduled_hook('pv_pro_reminders');});
add_action('pv_pro_reminders',function () {
if (get_transient('pv_pro_reminders_lock')) return;set_transient('pv_pro_reminders_lock',1,10*MINUTE_IN_SECONDS);$accepted=0;$failed=0;$checked=0;
foreach (get_users(['fields'=>['ID','user_email'],'meta_key'=>'pv_deadline_reminders','meta_value'=>1]) as $u) {
if (!pv_is_pro($u->ID)) continue;$checked++;$rows=pv_reminder_candidates($u->ID);if (!$rows) continue;$lines=[];
foreach ($rows as $r) $lines[]=get_the_title($r['id']).' | Closing within '.$r['stage'].' hours | Source deadline: '.$r['end'].' | '.get_post_meta($r['id'],'pv_source_url',true);
$message="Deadline reminders for your PANVERIQ shortlist:\n\n".implode("\n\n",$lines)."\n\nAlways confirm the official deadline and amendments. Manage reminders: ".home_url('/pro-workspace/');
if (wp_mail($u->user_email,'PANVERIQ: shortlisted tender deadlines',$message)) {$accepted++;$sent=get_user_meta($u->ID,'pv_deadline_reminders_sent',true);if (!is_array($sent)) $sent=[];foreach ($rows as $r) $sent[$r['key']]=gmdate('c');update_user_meta($u->ID,'pv_deadline_reminders_sent',array_slice($sent,-600,null,true));}else $failed++;
}
update_option('pv_pro_reminder_status',['at'=>gmdate('c'),'checked'=>$checked,'accepted'=>$accepted,'failed'=>$failed],false);delete_transient('pv_pro_reminders_lock');
});
// Aggregate analytics: no IP, cookie, account ID, email or search phrase stored.
add_action('init',function () {
if (get_option('pv_metrics_version')==='1') return;global $wpdb;$table=$wpdb->prefix.'pv_metrics';require_once ABSPATH.'wp-admin/includes/upgrade.php';
dbDelta("CREATE TABLE $table (\n day date NOT NULL,\n event varchar(32) NOT NULL,\n source varchar(32) NOT NULL,\n campaign varchar(50) NOT NULL,\n total bigint unsigned NOT NULL DEFAULT 0,\n PRIMARY KEY (day,event,source,campaign)\n) ".$wpdb->get_charset_collate().';');
if ($wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s',$table))===$table) update_option('pv_metrics_version','1',false);
});
function pv_metric_context() {
$source=sanitize_key(wp_unslash($_POST['_pv_source'] ?? $_GET['utm_source'] ?? 'direct'));$campaign=sanitize_key(wp_unslash($_POST['_pv_campaign'] ?? $_GET['utm_campaign'] ?? 'none'));
if (!in_array($source,['linkedin','facebook','instagram','email','google','direct','qa'],true)) $source='other';
if (!in_array($campaign,['membership_launch','organic','none','qa'],true)) $campaign='other';return [$source,$campaign];
}
function pv_metric_record($event,$qa=false) {
if (!in_array($event,['page_view','registration','saved_search','pro_interest','shortlist_add','csv_export'],true) || (! $qa && (current_user_can('manage_options') || ($_SERVER['HTTP_DNT'] ?? '')==='1'))) return;
global $wpdb;[$source,$campaign]=pv_metric_context();if ($qa) {$source='qa';$campaign='qa';}
$table=$wpdb->prefix.'pv_metrics';$wpdb->query($wpdb->prepare("INSERT INTO $table (day,event,source,campaign,total) VALUES (%s,%s,%s,%s,1) ON DUPLICATE KEY UPDATE total=total+1",gmdate('Y-m-d'),$event,$source,$campaign));
}
add_action('template_redirect',function () {if (($_SERVER['REQUEST_METHOD'] ?? '')==='GET' && !is_preview() && !is_404() && !preg_match('/bot|crawler|spider|python|curl/i',$_SERVER['HTTP_USER_AGENT'] ?? '')) pv_metric_record('page_view');});
add_action('user_register',function () {pv_metric_record('registration');});
add_action('register_form',function () {[$source,$campaign]=pv_metric_context();echo '';});
add_action('wp_footer',function () { ?>
PANVERIQ Pro and analytics
Aggregate events over the past 30 days (UTC). These are page views and action counts, not unique visitors. Admin activity, known crawler requests, Do Not Track visits and QA counts are excluded. URL campaign tags carry attribution; there is no cross-device tracking. Pages served entirely from a cache may not be counted.
';
$rows=$wpdb->get_results($wpdb->prepare('SELECT event,source,campaign,SUM(total) AS total FROM '.$wpdb->prefix.'pv_metrics WHERE day >= %s AND source <> %s GROUP BY event,source,campaign ORDER BY event,total DESC',gmdate('Y-m-d',time()-29*DAY_IN_SECONDS),'qa'),ARRAY_A);
echo '
Event
Source
Campaign
Count
';foreach ($rows as $r) echo '
'.esc_html($r['event']).'
'.esc_html($r['source']).'
'.esc_html($r['campaign']).'
'.absint($r['total']).'
';if (!$rows) echo '
No visitor events yet. Counts start from deployment.
Grant an existing account Pro access until a date. This does not charge or enrol anyone in recurring billing.
';
});
});
add_action('admin_post_pv_pro_grant',function () {if (!current_user_can('manage_options')) wp_die('Forbidden','',['response'=>403]);check_admin_referer('pv_pro_grant');$u=get_user_by('email',sanitize_email(wp_unslash($_POST['email'] ?? '')));$date=sanitize_text_field($_POST['until'] ?? '');$end=preg_match('/^\d{4}-\d{2}-\d{2}$/',$date) ? strtotime($date.'T23:59:59Z') : false;if (!$u || !$end || $end<=time() || $end>time()+366*DAY_IN_SECONDS) wp_die('Select an existing account and a future date within one year.','',['response'=>400]);update_user_meta($u->ID,'pv_pro_until',$end);wp_safe_redirect(admin_url('tools.php?page=pv-pro-analytics'));exit;});
add_action('admin_post_pv_pro_setup',function () {
if (!current_user_can('manage_options')) wp_die('Forbidden','',['response'=>403]);check_admin_referer('pv_pro_setup');$p=get_page_by_path('pro-workspace');if (!$p) wp_insert_post(['post_type'=>'page','post_status'=>'publish','post_title'=>'Pro workspace','post_name'=>'pro-workspace','post_content'=>'[panveriq_pro_workspace]','post_author'=>get_current_user_id()]);
global $wpdb;$before=(int)$wpdb->get_var("SELECT SUM(total) FROM ".$wpdb->prefix."pv_metrics WHERE source='qa' AND event='page_view'");pv_metric_record('page_view',true);$after=(int)$wpdb->get_var("SELECT SUM(total) FROM ".$wpdb->prefix."pv_metrics WHERE source='qa' AND event='page_view'");
$checks=['at'=>gmdate('c'),'admin_pro'=>pv_is_pro(),'pro_limit_50'=>pv_search_limit()===50,'free_limit_20'=>pv_search_limit(999999999)===20,'csv_formula_escaped'=>pv_csv_cell('=SUM(1,2)')==="'=SUM(1,2)",'csv_text_preserved'=>pv_csv_cell('Tender notice')==='Tender notice','analytics_atomic_increment'=>$after===$before+1,'reminder_schedule'=>!!wp_next_scheduled('pv_pro_reminders'),'reminder_preview_count'=>count(pv_reminder_candidates(get_current_user_id())),'emails_sent_by_checks'=>0];update_option('pv_pro_qa',$checks,false);wp_safe_redirect(admin_url('tools.php?page=pv-pro-analytics'));exit;
});
// Source-linked intelligence hub: existing recorded notices, no invented forecasts.
add_shortcode('panveriq_intelligence', function () {
$view=sanitize_key(wp_unslash($_GET['pv_view'] ?? 'current'));
if (!in_array($view,['current','past','future'],true)) $view='current';
$keyword=substr(sanitize_text_field(wp_unslash($_GET['pv_q'] ?? '')),0,120);
$page=max(1,min(10000,absint($_GET['pv_page'] ?? 1)));
$html='
African tender intelligence
Explore current opportunities, recorded past notices and announced procurement plans. Each record links back to its source.
No procurement plans have been verified for this section yet. Planned activity will be listed only when a buyer publishes an identifiable plan or advance notice. Plans may change and are not open invitations to bid.
'.($past?'Recorded past notices':'Current tender notices').'
'.($past?'These notices have a recorded closing date before today. They are retained for research; a passed deadline does not establish an award, cancellation or contract outcome. This archive contains records previously imported by PANVERIQ, not a complete historical database.':'Check the issuing authority for the current status, deadline time and amendments before acting.').'
No matching recorded notices yet. Try another keyword.
';
if ($page>1) $html.='Previous ';
if ($page<$q->max_num_pages) $html.='Next';
return $html.'
How we check intelligence
We retain source links, references, recorded deadlines and import timestamps. Import checks show when data was retrieved; they do not mean the buyer or every document has been independently verified. Check amendments and outcomes directly with the publisher. Report a correction.
Publicly accessible data is not automatically licensed for unrestricted reuse. PANVERIQ links to publishers and follows source-specific reuse terms. The core plugin is available under the MIT licence: download the source.
A standard listing would run for up to 30 days or until the tender closing deadline, whichever comes first. Publication starts after review and payment confirmation. Closed notices would be clearly marked in the research archive.
Paid publisher listings will be labelled separately from imported official notices. Payment will not change organic tender rankings or imply buyer endorsement.
Request a listing
Send your organisation name, tender title, reference, country, deadline with timezone, official notice link and a contact authorised by the buyer. We will check the submission before quoting and arranging publication.
'.$content;
return $content;
},9);
// Public release serves an approved snapshot, never configuration or database files.
function pv_open_license() {
return "MIT License
Copyright (c) 2026 PANVERIQ contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
";
}
add_shortcode('panveriq_open_source',function () {
$release=get_option('pv_public_release',[]);
$html='
OPEN SOURCE · OPEN INTELLIGENCE
Build African opportunity together.
PANVERIQ combines free tender discovery with open-source software. Developers can inspect, reuse and improve the released core plugin under the MIT licence.
Released source code for feed imports, tender search, saved searches, alerts and workflow tools.
Free browsing of source-linked current and recorded past notices.
Source references, recorded deadlines and retrieval timestamps.
A public route for corrections and contributions.
How PANVERIQ earns revenue
Discovery remains free. Our commercial model is managed hosting, workflow services, reviewed tender listings and clearly labelled sponsorship. Paid listing enquiries are open; online checkout is still being prepared. Pro is currently offered through controlled trials.
Download and review the source. Send a bug report, proposed patch or official source suggestion through our contact form, including the release version and steps to reproduce. Contributions are reviewed before deployment. Do not include passwords, API keys or personal bidder data. A public Git repository is not yet connected.
The MIT licence applies to the released PANVERIQ plugin code. Procurement notices remain subject to their original publishers’ rights and source-specific licences. It does not grant unrestricted rights to third-party notices, buyer documents, PANVERIQ branding or other plugins.
Private by design
Account details, private enquiries, payment information, server configuration and credentials are excluded from the release.
';
});
});
add_action('admin_post_pv_publish_open_source',function () {
if (!current_user_can('manage_options')) wp_die('Forbidden','',['response'=>403]);check_admin_referer('pv_publish_open_source');
$code=file_get_contents(__FILE__);if (!$code || strpos($code,'License: MIT')===false) wp_die('Release validation failed.');
$readme="PANVERIQ Core 0.10.0
MIT licence. See LICENSE.txt.
INSTALLATION
Use a separate WordPress site with PHP 8.3, DOM and mbstring extensions. Create wp-content/plugins/panveriq-core/panveriq.php with the downloaded source. Place LICENSE.txt and README.txt alongside it. Activate PANVERIQ MVP. Do not activate a second copy alongside the existing plugin. Configure WordPress mail delivery and an actual scheduled cron task before relying on alerts. If desired, define PANVERIQ_CONTACT_EMAIL privately in wp-config.php. Enable registration with the subscriber default role.
PAGES
Use the setup tools for growth pages, Pro workspace and tender intelligence. Other shortcodes: panveriq_opportunities, panveriq_join, panveriq_saved_searches, panveriq_contact, panveriq_sourcing, panveriq_about, panveriq_advertise. Place them on pages. No theme, menus, assets, credentials or database records are included.
LIMITATIONS
This is an early MVP, not a fully audited production framework. Source availability and layout can change. Kenya is rate-limited; South Africa integration needs repair. Scheduled tasks depend on cron and mail acceptance is not delivery proof. Future procurement currently has no verified plans. Paid checkout is not implemented. Data rights are separate from the software licence. Do not treat historic deadlines as award outcomes.
CONTRIBUTIONS
Send version, reproduction steps, proposed patch or official source suggestion through https://panveriq.com/contact-panveriq/?topic=source . Never include credentials or personal bidder data. Contributions must be yours to license under MIT. No public Git repository is connected yet.
BUSINESS MODEL
Free discovery and open-source code; revenue from managed services, optional workflow services, reviewed listings and labelled sponsorship. Core self-hosting is allowed under MIT.
";
update_option('pv_public_release',['code'=>$code,'readme'=>$readme,'at'=>gmdate('c'),'sha256'=>hash('sha256',$code)],false);
if (!get_page_by_path('open-source')) wp_insert_post(['post_type'=>'page','post_status'=>'publish','post_title'=>'Open source','post_name'=>'open-source','post_content'=>'[panveriq_open_source]','post_author'=>get_current_user_id()]);
wp_safe_redirect(admin_url('tools.php?page=pv-open-source'));exit;
});
add_action('wp_footer',function () {echo '