# v1.0.0-dev-changes

## Code Changes Overview

* Contact and group v1 endpoints removed and API v1 removed (Disciple\_Tools\_Contacts and Disciple\_Tools\_Groups).
* Contact and Group Record and list files removed and replace with the custom post type structure.
  * All tiles are modular including details tile.
  * Page for creating posts is more flexible.
* Channels merged into fields list.
* List query upgraded.
* List page upgraded.
  * Dynamic list columns.
  * Dynamic list columns order.
* Roles and capabilities are now built by the post-types.
* Support for deleting a post.
* Contacts are divided into `types`.
* Modules to add to a post-type.
  * Some field are only available if the module is active. Ex: the seeker\_path field is only available when the access module is enabled.

## Structure changes

Files removed:

* dt-contacts/contacts.php
* dt-contacts/contact-endpoints.php
* dt-contacts/contacts-template.php
* archive-contacts.php
* template-contacts-new\.php
* single-contacts.php
* dt-assets/parts/contact-details.php
* dt-assets/parts/content-contacts.php
* dt-groups/groups.php
* dt-groups/group-endpoints.php
* dt-groups/groups-template.php
* archive-groups.php
* template-groups-new\.php
* single-groups.php
* dt-assets/parts/group-details.php
* dt-assets/parts/content-groups.php

## API changes

### v1 Function removed

**Search for these**

* Disciple\_Tools\_Contact\_Post\_Type::
* Disciple\_Tools\_Contacts::
* Disciple\_Tools\_Groups\_Post\_Type::
* Disciple\_Tools\_Groups::

And replace as follows:

| Find                                                                          | Replace                                            | Note                                                                            |
| ----------------------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------- |
| `Disciple_Tools_Contacts::get_contact(`                                       | `DT_Posts::get_post( "contacts",`                  | The order of parameters has also changed. $check\_permissions is before $silent |
| `Disciple_Tools_Contacts::create_contact(`                                    | `DT_Posts::create_post( "contacts",`               | The order of parameters has also changed. $check\_permissions is before $silent |
| `Disciple_Tools_Contacts::update_contact(`                                    | `DT_Posts::update_post( "contacts",`               | The order of parameters has also changed. $check\_permissions is before $silent |
| `Disciple_Tools_Contacts::add_comment(`                                       | `DT_Posts::add_post_comment( "contacts",`          |                                                                                 |
| `Disciple_Tools_Contacts::search_viewable_contacts(`                          | `DT_Posts::search_viewable_post( "contacts",`      |                                                                                 |
| `Disciple_Tools_Contacts::get_contact_fields();`                              | `DT_Posts::get_post_field_settings( "contacts" );` |                                                                                 |
| `Disciple_Tools_Contact_Post_Type::instance()->get_custom_fields_settings();` | `DT_Posts::get_post_field_settings( "contacts" );` |                                                                                 |
| `Disciple_Tools_Groups::get_group(`                                           | `DT_Posts::get_post( "groups",`                    | The order of parameters has also changed. $check\_permissions is before $silent |
| `Disciple_Tools_Groups::create_group(`                                        | `DT_Posts::create_post( "groups",`                 | The order of parameters has also changed. $check\_permissions is before $silent |
| `Disciple_Tools_Groups::update_group(`                                        | `DT_Posts::update_post( "groups",`                 | The order of parameters has also changed. $check\_permissions is before $silent |
| `Disciple_Tools_Groups_Post_Type::instance()->get_custom_fields_settings();`  | `DT_Posts::get_post_field_settings( "groups" );`   |                                                                                 |

### Hooks Removed:

* `dt_contact_update`
* `dt_contact_created`
* `dt_group_created`
* `dt_group_updated`
* `dt_pre_contacts_connections_section`
* `dt_post_contacts_progress_section`
* `dt_pre_contacts_progress_section`
* `dt_pre_contacts_other_section`
* `dt_post_contacts_other_section`
* `dt_contact_detail_notification` -> `dt_record_top_above_details`

[API Hooks documentation](https://developers.disciple.tools/theme-core/hooks/api-hooks) [Record Page Hooks documentation](https://developers.disciple.tools/theme-core/hooks/record-page-hooks)

### Consistently using post\_date in the API

The post date was represented in 4 different ways:

* create\_date (in creating a post)
* created\_date (in getting a post)
* created\_on (in list query)
* post\_date (in getting a post in the list)

We've changed them all to be `post_date`

* create\_date => post\_date
* created\_date => post\_date
* created\_on -> post\_date

### Consistently using name for record title/name

* List response included: **post\_title**. Now includes **name** and **post\_title**
* Create post accepted: **title** and now accepts **title** and **name**
* Get post returned: **title** and now returns **name** and **title**
* Search posts was N/A -> You can now search for **name**

### ID returned from `create_contact`

`create_contact` used to return the contact\_id.\
`create_post` returns the full post.\
If the user has permissions to create posts but not read posts the function will return only an array with the ID of the new post:

```php
[ "ID" => 123 ]
```

### Field settings changes

* Contacts
  * `name`: new field. Type: `text`
    * See [Consistently using name for record title/name](#consistently-using-name-for-record-titlename)
  * `nickname`: new field. Type: `text`
  * `faith_status`: new field (DMM module). Type: `multi_select`
  * `post_date`: repurposed. Type: `date`
    * See [Consistently using post\_date in the API](#consistently-using-post_date-in-the-api)
  * `type`: repurposed. Type: `multi_select`
    * Contact `type` field value `media` is now `access` and a migration converts them all.
  * `languages`: new field. Type: `multi_select`
  * `contact_phone`: Channel migration. Type: `communication_channel`
    * See [Channels](#channels)
  * `contact_email`: Channel migration. Type: `communication_channel`
    * See [Channels](#channels)
  * `contact_address`: Channel migration. Type: `communication_channel`
    * See [Channels](#channels)
  * `contact_facebook`: Channel migration. Type: `communication_channel`
    * See [Channels](#channels)
  * `contact_twitter`: Channel migration. Type: `communication_channel`
    * See [Channels](#channels)
  * `baptism_generation`: Changed from `text` to `number`. Type: `number`
  * `last_modified`: Changed from `number` to `date`. Type: `date`
* Groups
  * `name`: new field. Type: `text`
  * `post_date`: repurposed. Type: `date`
    * See [Consistently using post\_date in the API](#consistently-using-post_date-in-the-api)
  * `member_count`: Changed from `text` to `number`. Type: `number`
  * `address`: Channel migration. Type: `communication_channel`
    * See [Channels](#channels)

### List query

* `assigned_to => 'all'` is now not a query
* `assigned_to => 'shared'` is now "shared\_with" => \[ "me"]
* The `combine` parameter no longer works.
* Maximum query limit is 1000.

The list query is now more flexible with:

* More fields types supported: communication\_channel, text, number
* Negative queries to exclude data.
* Exact match for text and communication\_channel fields.
* [Better AND/OR capabilities](https://github.com/DiscipleTools/Documentation/tree/d05945fa8e00435ee251dd92ababf88b593c14cc/theme-core/api/posts/list-query.md#combining-with-andor-logic).
* [Get recently viewed posts](https://github.com/DiscipleTools/Documentation/tree/d05945fa8e00435ee251dd92ababf88b593c14cc/theme-core/api/posts/list-query.md#recently-viewed-posts)

[See List Query Documentation](https://github.com/DiscipleTools/Documentation/tree/d05945fa8e00435ee251dd92ababf88b593c14cc/theme-core/api/posts/list-query.md).

### Transfer Contact API

The Endpoint used by the front end to send a contact to another instance has changed:\
POST `dt/v1/contact/transfer` -> POST `dt-posts/v2/contacts/transfer`

The endpoint to receive a transfer has also changed:\
POST `dt-public/v1/contact/transfer` -> POST `dt-posts/v2/contact/receive-transfer`

### Channels

Upgrade to the function to get the channels list:\
`Disciple_Tools_Contact_Post_Type::instance()->get_channels_list();` -> `DT_Posts::get_post_settings( "contacts" )["channels"];`

Channels continue to be available in the "channels" key in the post type settings array.

Channel are now also part of the field list and follow the new format in the field list.\
So Instead of:

```php
"phone" => [
    'label' => "Phone
]
```

the field will look like

```php
"contact_phone => [
   'name' => "Phone"
]
```

* `dt_custom_channels` filter was removed
* `dt_custom_channels` option was removed

### Javascript changes

`contactsDetailsWpApiSettings` and `wpApiGroupsSettings` are no longer available. Look for `window.detailsSettings` or `window.wpApiShare` instead

Examples: `window.contactsDetailsWpApiSettings.contacts_custom_fields_settings` -> `window.detailsSettings.post_settings.fields` `window.contactsDetailsWpApiSettings.contact` -> `window.detailsSettings.post_fields`

## DT\_Posts Functions

### Removed:

* removed function `find_contacts_by_title()`
* removed function `get_viewable_post()`

### New Functions:

//get the list of tiles for a post\_type\
`DT_Posts::get_post_tiles( $post_type );`

//get the list of fields for a post\_type\
`DT_Posts::get_post_field_settings( $post_type );`

//Get all the post\_type settings\
`DT_Posts::get_post_settings( $post_type )`

//get modules\
`dt_get_option( 'dt_post_type_modules' );`\
[See modules documentation](https://developers.disciple.tools/theme-core/customization/modules)

//Duplicate checker

#### Notes

Please submit a PR if you find something missing from this page.
