Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request weblab#7 from szk11001/master
Fix referencing of ACF fields & Require LDAP
  • Loading branch information
jmr06005 committed Sep 2, 2015
2 parents e5b70a3 + 91ae8ac commit b203a65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions uc-people.js
Expand Up @@ -13,9 +13,9 @@ jQuery(document).ready(function($){
$('#uc_people_lookup_metabox p.howto').text("Person found");
var fields = ['first_name', 'last_name', 'phone', 'email'];
fields.forEach(function(el,i,a){
$('#acf-field-'+el).val("");
$('#acf-field_'+el).val("");
if( response.hasOwnProperty(el) ){
$('#acf-field-'+el).val( response[el] );
$('#acf-field_'+el).val( response[el] );
}
});
} else {
Expand Down
13 changes: 5 additions & 8 deletions uc-people.php
Expand Up @@ -11,7 +11,7 @@ if ( ! defined( 'WPINC' ) ) {
die;
}
require 'acf-export.php';
//require_once(WP_CONTENT_DIR . '/ldap.php');
require_once(WP_CONTENT_DIR . '/ldap.php');


function create_custom_custom_post_type(){
Expand Down Expand Up @@ -113,20 +113,20 @@ if(!function_exists('processCSV')){
}
}

function importFile(){
function importFile( $filename ){
if( isset( $_POST['_wpnonce_ucp_import_people_nonce'] ) ){
check_admin_referer( 'ucp_import_people_nonce', '_wpnonce_ucp_import_people_nonce' );

if ( ! function_exists( 'wp_handle_upload' ) ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}

if( $_FILES['csv_file']['type'] !== 'text/csv' ){
if( $_FILES[$filename]['type'] !== 'text/csv' ){
echo '<div class="error notice is-dismissible below-h2" id="message"><p>Please upload a CSV file</p><button class="notice-dismiss" type="button"><span class="screen-reader-text">Dismiss this notice.</span></button></div>';
return;
}

$uploadedFile = wp_handle_upload( $_FILES['csv_file'], array( 'test_form' => false ) );
$uploadedFile = wp_handle_upload( $_FILES[$filename], array( 'test_form' => false ) );

if( $uploadedFile && !isset($uploadedFile['error']) ){
$data = processCSV( $uploadedFile['file'] );
Expand All @@ -135,7 +135,6 @@ function importFile(){
'first_name' => 'First Name',
'last_name' => 'Last Name',
'title' => 'Title',
//'about' => 'Biographical Info',
'email' => 'Email Address',
'phone' => 'Phone 1',
'phone_(alternate)' => 'Phone 2',
Expand Down Expand Up @@ -170,8 +169,6 @@ function importFile(){
}
}



function uc_people_settings_page_menu(){
add_submenu_page('tools.php', 'Import People', 'Import People', 'manage_options', 'uc-import-people', 'uc_people_settings_page' );
}
Expand All @@ -196,7 +193,7 @@ function uc_people_settings_page(){
?>
<input type="file" name="csv_file" />
<?php
importFile();
importFile( 'csv_file' );
submit_button( 'Import People' );
?>
</form>
Expand Down

0 comments on commit b203a65

Please sign in to comment.