| Server IP : 35.201.19.92 / Your IP : 216.73.216.156 Web Server : nginx System : Linux pod-200961 6.8.0-1055-gke #61-Ubuntu SMP Tue May 26 22:57:42 UTC 2026 x86_64 User : fpm200098 ( 200098) PHP Version : 8.2.33 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /nas/content/live/questfamilyday/wp-content/themes/generatepress_child/admin/ |
Upload File : |
<?php
add_filter( 'gform_pre_render_12', 'prepare_profile_form_fields' );
function prepare_profile_form_fields( $form ) {
$current_user = wp_get_current_user();
foreach( $form['fields'] as &$field ) {
if ( $field->id == 3 ) {
$address = get_user_meta($current_user->ID, 'address', true);
$field->defaultValue = wp_strip_all_tags($address);
}
if ( $field->id == 4 ) {
$date_of_birth = get_user_meta($current_user->ID, 'date_of_birth', true);
$field->defaultValue = wp_strip_all_tags($date_of_birth);
}
if ( $field->id == 5 ) {
$abn = get_user_meta($current_user->ID, 'abn', true);
$field->defaultValue = wp_strip_all_tags($abn);
}
if ( $field->id == 6 ) {
$proda_ra_number = get_user_meta($current_user->ID, 'proda_ra_number', true);
$field->defaultValue = wp_strip_all_tags($proda_ra_number);
}
if ( $field->id == 11 ) {
$field->defaultValue = $current_user->user_firstname;
}
if ( $field->id == 12 ) {
$field->defaultValue = $current_user->user_lastname;
}
if ( $field->id == 14 ) {
$phone_number = get_user_meta($current_user->ID, 'phone_number', true);
$field->defaultValue = wp_strip_all_tags($phone_number);
}
}
return $form;
}
add_action( 'gform_after_submission_12', 'md_gform_after_submission_12', 10, 2 );
function md_gform_after_submission_12( $entry, $form ) {
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$metas = array(
'nickname' => $entry[ '11' ],
'first_name' => $entry[ '11' ],
'last_name' => $entry[ '12' ],
'address' => $entry[ '3' ],
'date_of_birth' => $entry[ '4' ],
'abn' => $entry[ '5' ],
'proda_ra_number' => $entry[ '6' ],
'phone_number' => $entry[ '14' ]
);
foreach($metas as $key => $value) {
update_user_meta( $user_id, $key, $value );
}
// Upload Documents
$user_docs_meta = empty_user_docs_meta( $user_id );
foreach ($user_docs_meta as $meta) {
$updateuserMeta = media_upload_file_by_url( $entry[ $meta['id'] ] );
update_user_meta( $user_id, $meta['meta_key'], $updateuserMeta );
}
$msg = 'Profile successfully updated.';
set_success_msg($msg);
}
add_filter( 'gform_field_content_12', 'profile_subsection_field', 10, 2 );
function profile_subsection_field( $field_content, $field ) {
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$user_docs_meta = user_docs_meta( $user_id );
foreach ($user_docs_meta as $meta) {
if ( $field->id == $meta['id'] ) {
// var_dump($meta['value']['guid']);
$html = "<div class='placement-wrap'>Successfully uploaded</div>";
$field_content = str_replace( '</label>', "</label>".$html."", $field_content );
$field_content = str_replace( "class='ginput_container", "class='ginput_container field_uploaded ", $field_content );
return $field_content;
}
}
return $field_content;
}
function user_docs_meta($user_id) {
$AnnualHomeSafety = get_user_meta( $user_id, 'home_safety_risk_assessment', true );
$EnvironmentRisk = get_user_meta( $user_id, 'environment_risk_assessment_renewal', true );
$MembershipCertificate = get_user_meta( $user_id, 'membership_certificate', true );
$docs_meta = [];
if ( !empty($AnnualHomeSafety) ) {
$docs_meta[] = array("id" => 8, "meta_key" => "home_safety_risk_assessment", "value"=> $AnnualHomeSafety);
}
if ( !empty($EnvironmentRisk) ) {
$docs_meta[] = array("id" => 9, "meta_key" => "environment_risk_assessment_renewal", "value"=> $EnvironmentRisk);
}
if ( !empty($MembershipCertificate) ) {
$docs_meta[] = array("id" => 10, "meta_key" => "membership_certificate", "value"=> $MembershipCertificate);
}
return $docs_meta;
}
function empty_user_docs_meta($user_id) {
$AnnualHomeSafety = get_user_meta( $user_id, 'home_safety_risk_assessment', true );
$EnvironmentRisk = get_user_meta( $user_id, 'environment_risk_assessment_renewal', true );
$MembershipCertificate = get_user_meta( $user_id, 'membership_certificate', true );
$docs_meta = [];
if ( empty($AnnualHomeSafety) ) {
$docs_meta[] = array("id" => 8, "meta_key" => "home_safety_risk_assessment", "value"=> $AnnualHomeSafety);
}
if ( empty($EnvironmentRisk) ) {
$docs_meta[] = array("id" => 9, "meta_key" => "environment_risk_assessment_renewal", "value"=> $EnvironmentRisk);
}
if ( empty($MembershipCertificate) ) {
$docs_meta[] = array("id" => 10, "meta_key" => "membership_certificate", "value"=> $MembershipCertificate);
}
return $docs_meta;
}
function media_upload_file_by_url( $image_url ) {
// it allows us to use download_url() and wp_handle_sideload() functions
require_once( ABSPATH . 'wp-admin/includes/file.php' );
// download to temp dir
$temp_file = download_url( $image_url );
if( is_wp_error( $temp_file ) ) {
return false;
}
// move the temp file into the uploads directory
$file = array(
'name' => basename( $image_url ),
'type' => mime_content_type( $temp_file ),
'tmp_name' => $temp_file,
'size' => filesize( $temp_file ),
);
$sideload = wp_handle_sideload(
$file,
array(
'test_form' => false // no needs to check 'action' parameter
)
);
if( ! empty( $sideload[ 'error' ] ) ) {
// you may return error message if you want
return false;
}
// it is time to add our uploaded image into WordPress media library
$attachment_id = wp_insert_attachment(
array(
'guid' => $sideload[ 'url' ],
'post_mime_type' => $sideload[ 'type' ],
'post_title' => basename( $sideload[ 'file' ] ),
'post_content' => '',
'post_status' => 'inherit',
),
$sideload[ 'file' ]
);
if( is_wp_error( $attachment_id ) || ! $attachment_id ) {
return false;
}
// update medatata, regenerate image sizes
require_once( ABSPATH . 'wp-admin/includes/image.php' );
wp_update_attachment_metadata(
$attachment_id,
wp_generate_attachment_metadata( $attachment_id, $sideload[ 'file' ] )
);
return $attachment_id;
}
// Shortcode get uploaded docs [user-uploaded-documents]
add_shortcode( 'user-uploaded-documents', 'shortcode_user_uploaded_documents' );
function shortcode_user_uploaded_documents() {
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$AnnualHomeSafety = get_user_meta( $user_id, 'home_safety_risk_assessment', true );
$EnvironmentRisk = get_user_meta( $user_id, 'environment_risk_assessment_renewal', true );
$MembershipCertificate = get_user_meta( $user_id, 'membership_certificate', true );
$html = '';
$html .= '<div id="profile-docs" class="doc-attachments">';
$html .= '<div class="attachments-wrapper">';
$html .= '<ul class="attachments">';
if ( !empty($AnnualHomeSafety['guid']) ) {
$filepath = $AnnualHomeSafety['guid'];
$filedir = dirname( $filepath );
$filebasename = str_replace('.', '-', basename($filepath)).'.jpg';
$thumbimg = $filedir.'/'.$filebasename;
$html .= '<li class="attachment">';
$html .= '<div class="attachment-title">Annual Home Safety Assessment Renewal</div>';
$html .= '<div class="attachment-preview">';
$html .= '<div class="thumbnail">';
$html .= '<div class="centered">';
$html .= '<img src="'.esc_url($thumbimg).'" class="img-thumbnail">';
$html .= '</div>';
$file = get_post_meta($resource_query->ID, 'file_download', true);
$html .= '<div class="filename"><div>'.basename($filepath).'</div></div>';
$html .= '
<div class="action_wrapper">
<div class="text-center">
<a href="'.esc_url($filepath).'" target="_blank" class="view-file" data-postid="'.get_the_ID().'"><i aria-hidden="true" class="fas fa-eye"></i></a>
<a href="'.esc_url($filepath).'" download class="download-file" data-postid="'.get_the_ID().'"><i aria-hidden="true" class="fas fa-download"></i></a>
</div>
</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="more-docs-wrapper"></div>';
$html .= '</li>';
}
if ( !empty($EnvironmentRisk['guid']) ) {
$filepath = $EnvironmentRisk['guid'];
$filedir = dirname( $filepath );
$filebasename = str_replace('.', '-', basename($filepath)).'.jpg';
$thumbimg = $filedir.'/'.$filebasename;
$html .= '<li class="attachment">';
$html .= '<div class="attachment-title">Environment Risk Assessment Renewal</div>';
$html .= '<div class="attachment-preview">';
$html .= '<div class="thumbnail">';
$html .= '<div class="centered">';
$html .= '<img src="'.esc_url($thumbimg).'" class="img-thumbnail">';
$html .= '</div>';
$file = get_post_meta($resource_query->ID, 'file_download', true);
$html .= '<div class="filename"><div>'.basename($filepath).'</div></div>';
$html .= '
<div class="action_wrapper">
<div class="text-center">
<a href="'.esc_url($filepath).'" target="_blank" class="view-file" data-postid="'.get_the_ID().'"><i aria-hidden="true" class="fas fa-eye"></i></a>
<a href="'.esc_url($filepath).'" download class="download-file" data-postid="'.get_the_ID().'"><i aria-hidden="true" class="fas fa-download"></i></a>
</div>
</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="more-docs-wrapper"></div>';
$html .= '</li>';
}
if ( !empty($MembershipCertificate['guid']) ) {
$filepath = $MembershipCertificate['guid'];
$filedir = dirname( $filepath );
$filebasename = str_replace('.', '-', basename($filepath)).'.jpg';
$thumbimg = $filedir.'/'.$filebasename;
$html .= '<li class="attachment">';
$html .= '<div class="attachment-title">(A copy of) Membership Certificate</div>';
$html .= '<div class="attachment-preview">';
$html .= '<div class="thumbnail">';
$html .= '<div class="centered">';
$html .= '<img src="'.esc_url($thumbimg).'" class="img-thumbnail">';
$html .= '</div>';
$file = get_post_meta($resource_query->ID, 'file_download', true);
$html .= '<div class="filename"><div>'.basename($filepath).'</div></div>';
$html .= '
<div class="action_wrapper">
<div class="text-center">
<a href="'.esc_url($filepath).'" target="_blank" class="view-file" data-postid="'.get_the_ID().'"><i aria-hidden="true" class="fas fa-eye"></i></a>
<a href="'.esc_url($filepath).'" download class="download-file" data-postid="'.get_the_ID().'"><i aria-hidden="true" class="fas fa-download"></i></a>
</div>
</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="more-docs-wrapper"></div>';
$html .= '</li>';
}
// Member Uploaded documents
if ( !is_null( current_educator_doc_id() ) ) {
$user_doc_id = current_educator_doc_id();
$doc_uploads = educator_documents_fields();
foreach ($doc_uploads as $meta) {
$doc_file = get_post_meta( $user_doc_id, $meta['meta_key'], true );
$archives_data = get_post_meta( $user_doc_id, 'archived_'.$meta['meta_key'], true );
// var_dump($doc_file);
$doc_file_array_urls = explode(",", $doc_file);
if ($doc_file_array_urls) {
$doc_file = current($doc_file_array_urls);
}
// check for uploaded documents
$has_uploaded_docs = false;
if (!empty($doc_file) || !empty($archives_data)) {
$has_uploaded_docs = true;
}
if ( !empty($meta['type']) && $meta['type'] == 'file' && $has_uploaded_docs ) {
if ( !empty($doc_file) ) {
$filepath = $doc_file;
$filedir = dirname( $filepath );
$filebasename = str_replace('.', '-', basename($filepath)).'.jpg';
$thumbimg = $filedir.'/'.$filebasename;
$file_ext = pathinfo($filepath, PATHINFO_EXTENSION);
$doc_expiry = get_post_meta( $user_doc_id, $meta['field_expiry'], true );
} else {
$archive_doc_latest = end($archives_data['documents']);
$archive_doc_latest_array_urls = explode(",", $archive_doc_latest['link']);
if ($archive_doc_latest_array_urls) {
$archive_doc_latest['link'] = current($archive_doc_latest_array_urls);
}
$filepath = $archive_doc_latest['link'];
$filedir = dirname( $filepath );
$filebasename = str_replace('.', '-', basename($filepath)).'.jpg';
$thumbimg = $filedir.'/'.$filebasename;
$file_ext = pathinfo($filepath, PATHINFO_EXTENSION);
$doc_expiry = $archive_doc_latest['expiry'];
}
$html .= '<li class="attachment">';
$html .= '<div class="attachment-title">'.$meta['title'].'</div>';
if ( !is_null($meta['field_expiry']) && !empty($doc_expiry) ) {
$expire_date = strtotime($doc_expiry);
$html .= '<div class="attachment-expiry">Expiry Date: '.date('jS M Y', $expire_date).'</div>';
}
$html .= '<div class="attachment-preview">';
$html .= '<div class="thumbnail">';
$html .= '<div class="centered">';
if ($file_ext == 'pdf') {
$thumbimg = '/wp-content/uploads/2022/12/pdf-file-logo.png';
} else {
$thumbimg = $filepath;
}
$html .= '<img src="'.esc_url($thumbimg).'" class="img-thumbnail">';
$html .= '</div>';
$html .= '<div class="filename"><div>'.basename($filepath).'</div></div>';
$html .= '
<div class="action_wrapper">
<div class="text-center">
<a href="'.esc_url($filepath).'" target="_blank" class="view-file"><i aria-hidden="true" class="fas fa-eye"></i></a>
<a href="'.esc_url($filepath).'" download class="download-file"><i aria-hidden="true" class="fas fa-download"></i></a>
</div>
</div>';
$html .= '</div>';
$html .= '</div>';
$show_more_docs = false;
$all_docs_count = 0;
if ( !empty($doc_file) ) {
$all_docs_count = $all_docs_count + count($doc_file_array_urls);
}
if ( !empty($archives_data) ) {
$docs_archives = $archives_data['documents'];
foreach ( $docs_archives as $doc_archive ) {
$doc_archive_urls = explode(",", $doc_archive['link']);
$all_docs_count = $all_docs_count + count($doc_archive_urls);
}
}
if ( $all_docs_count > 1) { $show_more_docs = true; }
if ( $show_more_docs ) {
$html .= '<div class="more-docs-wrapper"><button class="more-docs" type="button" data-toggle="modal" data-target=".modal_'.$meta['meta_key'].'">View More</button></div>';
$html .= '<div class="modal fade modal-archive-docs modal_'.$meta['meta_key'].'" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">'.$meta['title'].'</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body modal-docs-lists">
<ul class="attachments">';
if ( !empty($doc_file) ) {
foreach ( $doc_file_array_urls as $doc_file_url ) {
$filepath = $doc_file_url;
// $filepath = $doc_file;
$filedir = dirname( $filepath );
$filebasename = str_replace('.', '-', basename($filepath)).'.jpg';
$thumbimg = $filedir.'/'.$filebasename;
$file_ext = pathinfo($filepath, PATHINFO_EXTENSION);
$doc_expiry = get_post_meta( $user_doc_id, $meta['field_expiry'], true );
$html .= '<li class="attachment">';
if ( !is_null($meta['field_expiry']) && !empty($doc_expiry) ) {
$expire_date = strtotime($doc_expiry);
$html .= '<div class="attachment-expiry">Expiry Date: '.date('jS M Y', $expire_date).'</div>';
}
$html .= '<div class="attachment-preview">';
$html .= '<div class="thumbnail">';
$html .= '<div class="centered">';
if ($file_ext == 'pdf') {
$thumbimg = '/wp-content/uploads/2022/12/pdf-file-logo.png';
} else {
$thumbimg = $filepath;
}
$html .= '<img src="'.esc_url($thumbimg).'" class="img-thumbnail">';
$html .= '</div>';
$html .= '<div class="filename"><div>'.basename($filepath).'</div></div>';
$html .= '
<div class="action_wrapper">
<div class="text-center">
<a href="'.esc_url($filepath).'" target="_blank" class="view-file"><i aria-hidden="true" class="fas fa-eye"></i></a>
<a href="'.esc_url($filepath).'" download class="download-file"><i aria-hidden="true" class="fas fa-download"></i></a>
</div>
</div>';
$html .= '</div>';
$html .= '</div>';
$status = esc_attr( get_post_meta( $user_doc_id, $meta['status_key'], true ) );
// $html .= '<div class="approved-date">Status: '.$status.'</div>';
$html .= '<div class="approved-date">Latest upload</div>';
$html .= '</li>';
}
}
if ( !empty($archives_data) ) {
$docs_archive = array_reverse($archives_data['documents']);
foreach ( $docs_archive as $archive ) {
$archive_doc_array_urls = explode(",", $archive['link']);
foreach ( $archive_doc_array_urls as $archive_file_url ) {
$filepath = $archive_file_url;
// $filepath = $archive['link'];
$filedir = dirname( $filepath );
$filebasename = str_replace('.', '-', basename($filepath)).'.jpg';
$thumbimg = $filedir.'/'.$filebasename;
$file_ext = pathinfo($filepath, PATHINFO_EXTENSION);
$doc_expiry = $archive['expiry'];
$html .= '<li class="attachment">';
if ( !is_null($meta['field_expiry']) && !empty($doc_expiry) ) {
$expire_date = strtotime($doc_expiry);
$html .= '<div class="attachment-expiry">Expiry Date: '.date('jS M Y', $expire_date).'</div>';
}
$html .= '<div class="attachment-preview">';
$html .= '<div class="thumbnail">';
$html .= '<div class="centered">';
if ($file_ext == 'pdf') {
$thumbimg = '/wp-content/uploads/2022/12/pdf-file-logo.png';
} else {
$thumbimg = $filepath;
}
$html .= '<img src="'.esc_url($thumbimg).'" class="img-thumbnail">';
$html .= '</div>';
$html .= '<div class="filename"><div>'.basename($filepath).'</div></div>';
$html .= '
<div class="action_wrapper">
<div class="text-center">
<a href="'.esc_url($filepath).'" target="_blank" class="view-file"><i aria-hidden="true" class="fas fa-eye"></i></a>
<a href="'.esc_url($filepath).'" download class="download-file"><i aria-hidden="true" class="fas fa-download"></i></a>
</div>
</div>';
$html .= '</div>';
$html .= '</div>';
$date_approved = $archive['date_approved'];
$archive_date_approved = strtotime($date_approved);
// $html .= '<div class="approved-date">Approved on: '.date('M j, Y', $archive_date_approved).'</div>';
$html .= '<div class="approved-date">Uploaded on: '.date('M j, Y', $archive_date_approved).'</div>';
$html .= '</li>';
}
}
}
$html .= '</ul>
</div>
</div>
</div>
</div>';
} else {
$html .= '<div class="more-docs-wrapper"></div>';
}
$html .= '</li>';
}
}
}
// Staff Uploaded Documents
if ( !is_null( current_staff_doc_id() ) ) {
$user_doc_id = current_staff_doc_id();
$doc_uploads = staff_documents_fields();
foreach ($doc_uploads as $meta) {
$doc_file = get_post_meta( $user_doc_id, $meta['meta_key'], true );
$archives_data = get_post_meta( $user_doc_id, 'archived_'.$meta['meta_key'], true );
// var_dump($doc_file);
$doc_file_array_urls = explode(",", $doc_file);
if ($doc_file_array_urls) {
$doc_file = current($doc_file_array_urls);
}
// check for uploaded documents
$has_uploaded_docs = false;
if (!empty($doc_file) || !empty($archives_data)) {
$has_uploaded_docs = true;
}
if ( !empty($meta['type']) && $meta['type'] == 'file' && $has_uploaded_docs ) {
if ( !empty($doc_file) ) {
$filepath = $doc_file;
$filedir = dirname( $filepath );
$filebasename = str_replace('.', '-', basename($filepath)).'.jpg';
$thumbimg = $filedir.'/'.$filebasename;
$file_ext = pathinfo($filepath, PATHINFO_EXTENSION);
$doc_expiry = get_post_meta( $user_doc_id, $meta['field_expiry'], true );
} else {
$archive_doc_latest = end($archives_data['documents']);
$archive_doc_latest_array_urls = explode(",", $archive_doc_latest['link']);
if ($archive_doc_latest_array_urls) {
$archive_doc_latest['link'] = current($archive_doc_latest_array_urls);
}
$filepath = $archive_doc_latest['link'];
$filedir = dirname( $filepath );
$filebasename = str_replace('.', '-', basename($filepath)).'.jpg';
$thumbimg = $filedir.'/'.$filebasename;
$file_ext = pathinfo($filepath, PATHINFO_EXTENSION);
$doc_expiry = $archive_doc_latest['expiry'];
}
$html .= '<li class="attachment">';
$html .= '<div class="attachment-title">'.$meta['title'].'</div>';
if ( !is_null($meta['field_expiry']) && !empty($doc_expiry) ) {
$expire_date = strtotime($doc_expiry);
$html .= '<div class="attachment-expiry">Expiry Date: '.date('jS M Y', $expire_date).'</div>';
}
$html .= '<div class="attachment-preview">';
$html .= '<div class="thumbnail">';
$html .= '<div class="centered">';
if ($file_ext == 'pdf') {
$thumbimg = '/wp-content/uploads/2022/12/pdf-file-logo.png';
} else {
$thumbimg = $filepath;
}
$html .= '<img src="'.esc_url($thumbimg).'" class="img-thumbnail">';
$html .= '</div>';
$html .= '<div class="filename"><div>'.basename($filepath).'</div></div>';
$html .= '
<div class="action_wrapper">
<div class="text-center">
<a href="'.esc_url($filepath).'" target="_blank" class="view-file"><i aria-hidden="true" class="fas fa-eye"></i></a>
<a href="'.esc_url($filepath).'" download class="download-file"><i aria-hidden="true" class="fas fa-download"></i></a>
</div>
</div>';
$html .= '</div>';
$html .= '</div>';
$show_more_docs = false;
$all_docs_count = 0;
if ( !empty($doc_file) ) {
$all_docs_count = $all_docs_count + count($doc_file_array_urls);
}
if ( !empty($archives_data) ) {
$docs_archives = $archives_data['documents'];
foreach ( $docs_archives as $doc_archive ) {
$doc_archive_urls = explode(",", $doc_archive['link']);
$all_docs_count = $all_docs_count + count($doc_archive_urls);
}
}
if ( $all_docs_count > 1) { $show_more_docs = true; }
if ( $show_more_docs ) {
$html .= '<div class="more-docs-wrapper"><button class="more-docs" type="button" data-toggle="modal" data-target=".modal_'.$meta['meta_key'].'">View More</button></div>';
$html .= '<div class="modal fade modal-archive-docs modal_'.$meta['meta_key'].'" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">'.$meta['title'].'</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body modal-docs-lists">
<ul class="attachments">';
if ( !empty($doc_file) ) {
foreach ( $doc_file_array_urls as $doc_file_url ) {
$filepath = $doc_file_url;
// $filepath = $doc_file;
$filedir = dirname( $filepath );
$filebasename = str_replace('.', '-', basename($filepath)).'.jpg';
$thumbimg = $filedir.'/'.$filebasename;
$file_ext = pathinfo($filepath, PATHINFO_EXTENSION);
$doc_expiry = get_post_meta( $user_doc_id, $meta['field_expiry'], true );
$html .= '<li class="attachment">';
if ( !is_null($meta['field_expiry']) && !empty($doc_expiry) ) {
$expire_date = strtotime($doc_expiry);
$html .= '<div class="attachment-expiry">Expiry Date: '.date('jS M Y', $expire_date).'</div>';
}
$html .= '<div class="attachment-preview">';
$html .= '<div class="thumbnail">';
$html .= '<div class="centered">';
if ($file_ext == 'pdf') {
$thumbimg = '/wp-content/uploads/2022/12/pdf-file-logo.png';
} else {
$thumbimg = $filepath;
}
$html .= '<img src="'.esc_url($thumbimg).'" class="img-thumbnail">';
$html .= '</div>';
$html .= '<div class="filename"><div>'.basename($filepath).'</div></div>';
$html .= '
<div class="action_wrapper">
<div class="text-center">
<a href="'.esc_url($filepath).'" target="_blank" class="view-file"><i aria-hidden="true" class="fas fa-eye"></i></a>
<a href="'.esc_url($filepath).'" download class="download-file"><i aria-hidden="true" class="fas fa-download"></i></a>
</div>
</div>';
$html .= '</div>';
$html .= '</div>';
$status = esc_attr( get_post_meta( $user_doc_id, $meta['status_key'], true ) );
// $html .= '<div class="approved-date">Status: '.$status.'</div>';
$html .= '<div class="approved-date">Latest upload</div>';
$html .= '</li>';
}
}
if ( !empty($archives_data) ) {
$docs_archive = array_reverse($archives_data['documents']);
foreach ( $docs_archive as $archive ) {
$archive_doc_array_urls = explode(",", $archive['link']);
foreach ( $archive_doc_array_urls as $archive_file_url ) {
$filepath = $archive_file_url;
// $filepath = $archive['link'];
$filedir = dirname( $filepath );
$filebasename = str_replace('.', '-', basename($filepath)).'.jpg';
$thumbimg = $filedir.'/'.$filebasename;
$file_ext = pathinfo($filepath, PATHINFO_EXTENSION);
$doc_expiry = $archive['expiry'];
$html .= '<li class="attachment">';
if ( !is_null($meta['field_expiry']) && !empty($doc_expiry) ) {
$expire_date = strtotime($doc_expiry);
$html .= '<div class="attachment-expiry">Expiry Date: '.date('jS M Y', $expire_date).'</div>';
}
$html .= '<div class="attachment-preview">';
$html .= '<div class="thumbnail">';
$html .= '<div class="centered">';
if ($file_ext == 'pdf') {
$thumbimg = '/wp-content/uploads/2022/12/pdf-file-logo.png';
} else {
$thumbimg = $filepath;
}
$html .= '<img src="'.esc_url($thumbimg).'" class="img-thumbnail">';
$html .= '</div>';
$html .= '<div class="filename"><div>'.basename($filepath).'</div></div>';
$html .= '
<div class="action_wrapper">
<div class="text-center">
<a href="'.esc_url($filepath).'" target="_blank" class="view-file"><i aria-hidden="true" class="fas fa-eye"></i></a>
<a href="'.esc_url($filepath).'" download class="download-file"><i aria-hidden="true" class="fas fa-download"></i></a>
</div>
</div>';
$html .= '</div>';
$html .= '</div>';
$date_approved = $archive['date_approved'];
$archive_date_approved = strtotime($date_approved);
// $html .= '<div class="approved-date">Approved on: '.date('M j, Y', $archive_date_approved).'</div>';
$html .= '<div class="approved-date">Uploaded on: '.date('M j, Y', $archive_date_approved).'</div>';
$html .= '</li>';
}
}
}
$html .= '</ul>
</div>
</div>
</div>
</div>';
} else {
$html .= '<div class="more-docs-wrapper"></div>';
}
$html .= '</li>';
}
}
}
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
// Shortcode get home visit uploaded docs [homevisit-uploaded-documents]
add_shortcode( 'homevisit-uploaded-documents', 'shortcode_homevisit_uploaded_documents' );
function shortcode_homevisit_uploaded_documents() {
$html = '';
// Educator Home Visit Uploaded documents
if ( !is_null( current_educator_doc_id() ) ) {
$user_doc_id = current_educator_doc_id();
$home_visit_attachments = get_post_custom_values( 'schedule_home_visit', $user_doc_id );
$attachment_files = '';
if ( !is_null( $home_visit_attachments ) ) {
$html .= '<div class="profile-section-heading"><h3 class="heading">Home Visit Documents</h3></div>';
$html .= '<div id="profile-docs" class="doc-attachments">';
$html .= '<div class="attachments-wrapper">';
$html .= '<ul class="attachments">';
foreach ($home_visit_attachments as $attachment) {
$attachment_url = wp_get_attachment_url( $attachment );
$thumbimg = $attachment_url;
$file_ext = pathinfo($attachment_url, PATHINFO_EXTENSION);
if ($file_ext == 'pdf') {
$thumbimg = '/wp-content/uploads/2022/12/pdf-file-logo.png';
}
$html .= '<li class="attachment">';
$html .= '<div class="attachment-title">Home Visit</div>';
$html .= '<div class="attachment-preview">';
$html .= '<div class="thumbnail">';
$html .= '<div class="centered">';
$html .= '<img src="'.esc_url($thumbimg).'" class="img-thumbnail">';
$html .= '</div>';
$html .= '<div class="filename"><div>'.get_the_title($attachment).'</div></div>';
$html .= '
<div class="action_wrapper">
<div class="text-center">
<a href="'.esc_url($attachment_url).'" target="_blank" class="view-file"><i aria-hidden="true" class="fas fa-eye"></i></a>
<a href="'.esc_url($attachment_url).'" download class="download-file"><i aria-hidden="true" class="fas fa-download"></i></a>
</div>
</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</li>';
}
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
}
}
return $html;
}