Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
Conflicts:
	uc-people.php
  • Loading branch information
Salman Z Kaleem committed Jul 15, 2015
2 parents 719e449 + 2c9afc8 commit 7916fa0
Showing 1 changed file with 38 additions and 27 deletions.
65 changes: 38 additions & 27 deletions uc-people.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,51 @@
if ( ! defined( 'WPINC' ) ) {
die;
}
include 'acf-export.php';

function create_custom_custom_post_type(){
$labels = array(
'name' => 'Contacts',
'singular_name' => 'Contact',
'add_new' => 'New Contact',
'add_new_item' => 'Add New Contact',
'edit_item' => 'Edit Contact',
'view_item' => 'View Contact',
'search_items' => 'Search Contacts'
'name' => 'People',
'singular_name' => 'Person',
'add_new' => 'New Person',
'add_new_item' => 'Add New Person',
'edit_item' => 'Edit Person',
'view_item' => 'View Person',
'search_items' => 'Search People'
);

$args = array(
'label' => 'Contacts',
'label' => 'People',
'labels' => $labels,
'description' => '',
'public' => true,
'menu_position' => 5,
'menu_icon' => null,
'menu_position' => 35,
'menu_icon' => 'dashicons-groups',
'supports' => array( 'tags', 'thumbnail', 'revisions', 'page-attributes' ),
'has_archive' => true
);

register_post_type( 'contact', $args );
register_post_type( 'person', $args );

register_taxonomy( 'team', 'contact',
register_taxonomy( 'team', 'person',
array(
'label' => 'Teams',
'label' => 'Groups',
'labels' => array(
'name' => 'Teams',
'singular_name' => 'Team',
'search_items' => 'Search Teams',
'edit_item' => 'Edit ',
'view_item' => 'Team.viewitem',
'update_item' => 'Update Team',
'add_new_item' => 'Add new Team',
'new_item_name' => 'Team.newitemname'
'name' => 'Groups',
'singular_name' => 'Group',
'search_items' => 'Search Groups',
'edit_item' => 'Edit Group',
'view_item' => 'View Group',
'update_item' => 'Update Group',
'add_new_item' => 'Add new Group',
'new_item_name' => 'New Group'
),
'public' => true,
'hierarchical' => true,
'rewrite' => array('hierarchical' => true )
)
);
register_taxonomy( 'tag', 'contact',
register_taxonomy( 'tag', 'person',
array(
'label' => 'Tags',
'labels' => array(
Expand Down Expand Up @@ -130,7 +131,7 @@ function importFile(){
'post_title' => $title,
'post_name' => 'testing-contact',
'post_status' => 'publish',
'post_type' => 'contact',
'post_type' => 'person',
'menu_order' => ( !empty($v['Order']) ? $v['Order'] : 0 ),
);
$id = wp_insert_post( $args, true );
Expand All @@ -148,22 +149,31 @@ function importFile(){
}

function uc_people_settings_page_menu(){
add_users_page( 'Import People', 'Import People', 'manage_options', 'uc-import-people', 'uc_people_settings_page' );
add_submenu_page('tools.php', 'Import People', 'Import People', 'manage_options', 'uc-import-people', 'uc_people_settings_page' );
}
add_action('admin_menu', 'uc_people_settings_page_menu');

function uc_people_settings_page(){
?>
<div class="wrap">
<h2>Import People</h2>
<h2>Import People from Users CSV</h2>
<p>This tool is to help people with the initial setup of "People" in their site.</p>
<h3>New Site Setup</h3>
<p>For new sites, use the <a href="tools.php?page=export-users-to-csv">"Export Users" tool</a> to generate a template. Open that in a spreadsheet program, and fill out *all* of the information you'll want on your site, and then import that .csv here.</p>
<h3>Converting UUP Users to "People"</h3>
<p>For sites that were using the University User Profiles plugin, use the <a href="tools.php?page=export-users-to-csv">"Export Users" tool</a> and then import that full list here.</p>
<hr/>
<h2>One Time Use</h2>
<p>This tool can not be used to <i>update</i> information about each Person. If you upload the same .csv twice, you will end up with two records for each person.</p>
<p>Choose .csv in the "export users" specific format.</p>
<form action="" method="POST" enctype="multipart/form-data" name="ucp-import">
<?php
wp_nonce_field( 'ucp_import_people_nonce', '_wpnonce_ucp_import_people_nonce' );
?>
<input type="file" name="csv_file" />
<?php
importFile();
submit_button( 'Import' );
submit_button( 'Import People' );
?>
</form>

Expand All @@ -175,4 +185,5 @@ function uc_acf_admin_enqueue_scripts(){
wp_enqueue_script( 'ucpeoplejs', plugin_dir_url(__FILE__).'/uc-people.js', array('jquery'), '1.0' );
}

add_action('acf/input/admin_enqueue_scripts', 'uc_acf_admin_enqueue_scripts');
add_action('acf/input/admin_enqueue_scripts', 'uc_acf_admin_enqueue_scripts');
?>

0 comments on commit 7916fa0

Please sign in to comment.