Skip to content

Commit

Permalink
Merge branch 'refs/heads/develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	dt-core/admin/menu/tabs/tab-custom-fields.php
  • Loading branch information
corsacca committed Jun 25, 2024
2 parents 9334285 + 250503d commit 60bb129
Show file tree
Hide file tree
Showing 34 changed files with 1,374 additions and 977 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: ["7.4", "8.2"]
php: ["7.4", "8.3"]

name: PHP ${{ matrix.php }}
steps:
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
![Build Status](https://github.com/DiscipleTools/disciple-tools-theme/actions/workflows/ci.yml/badge.svg?branch=master)

```
██╗
████╗ ██████╗ ██╗███████╗ ██████╗██╗██████╗ ██╗ ███████╗
██████╗ ██╔══██╗██║██╔════╝██╔════╝██║██╔══██╗██║ ██╔════╝
████████╗ ██║ ██║██║███████╗██║ ██║██████╔╝██║ █████╗
██████████╗ ██║ ██║██║╚════██║██║ ██║██╔═══╝ ██║ ██╔══╝
█████╔═█████╗ ██████╔╝██║███████║╚██████╗██║██║ ███████╗███████╗██╗
█████╔╝ █████╗ ╚═════╝ ╚═╝╚══════╝ ╚═════╝╚═╝╚═╝ ╚══════╝╚══════╝╚═╝
█████╔╝ █████╗
█████╔╝ █████╗ ████████╗ ██████╗ ██████╗ ██╗ ███████╗
█████╔╝ █████╗ ╚══██╔══╝██╔═══██╗██╔═══██╗██║ ██╔════╝
█████╔╝ █████╗ ██║ ██║ ██║██║ ██║██║ ███████╗
█████╔╝ █████╗ ██║ ██║ ██║██║ ██║██║ ╚════██║
█████╔╝ █████╗ ██║ ╚██████╔╝╚██████╔╝███████╗███████║
█████╔╝ █████╗ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚══════╝
╚════╝ ╚════╝
```
# Disciple.Tools
Disciple.Tools software boosts collaboration, clarity, and accountability for disciple and church multiplication movements.

Expand Down
2 changes: 1 addition & 1 deletion dt-assets/build/css/style.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dt-assets/build/js/scripts.min.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions dt-assets/scss/_main.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use "sass:map";
/************************************************
Stylesheet: Main Stylesheet
Expand Down Expand Up @@ -43,6 +44,13 @@ color:$light-gray;
width: 100%;
}

html {
--primary-color: #{map.get($foundation-palette, "primary")};
--secondary-color: #{map.get($foundation-palette, "secondary")};
--success-color: #{map.get($foundation-palette, "success")};
--warning-color: #{map.get($foundation-palette, "warning")};
--alert-color: #{map.get($foundation-palette, "alert")};
}
body {
background-color: #e2e2e2;
}
Expand Down
4 changes: 2 additions & 2 deletions dt-assets/scss/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ $global-width: rem-calc(1200);
$global-lineheight: 1.5;
$foundation-palette: (
primary: #3F729B,
secondary: #00aeff,
success: #3adb76,
secondary: #8BC34A,
success: #4caf50,
warning: #ffae00,
alert: #cc4b37,
//original
Expand Down
42 changes: 14 additions & 28 deletions dt-contacts/access-module.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,6 @@ public function dt_custom_fields_settings( $fields, $post_type ){
if ( isset( $fields['type']['default']['personal'] ) ){
$fields['type']['default']['personal']['default'] = false;
}
$fields['type']['default']['access'] = [
'label' => __( 'Standard Contact', 'disciple_tools' ),
'color' => '#2196F3',
'description' => __( 'A contact to collaborate on', 'disciple_tools' ),
'visibility' => __( 'Me and project leadership', 'disciple_tools' ),
'icon' => get_template_directory_uri() . '/dt-assets/images/share.svg?v=2',
'order' => 20,
'default' => true,
];
$fields['type']['default']['access_placeholder'] = [
'label' => __( 'Connection', 'disciple_tools' ),
'color' => '#FF9800',
'description' => __( 'Connected to a contact, or generational fruit', 'disciple_tools' ),
'icon' => get_template_directory_uri() . '/dt-assets/images/share.svg?v=2',
'order' => 40,
'visibility' => __( 'Collaborators', 'disciple_tools' ),
'in_create_form' => false,
];

$fields['assigned_to'] = [
'name' => __( 'Assigned To', 'disciple_tools' ),
'description' => __( 'Select the main person who is responsible for reporting on this contact.', 'disciple_tools' ),
Expand Down Expand Up @@ -777,7 +758,7 @@ public function dt_post_create_fields( $fields, $post_type ){
}
if ( isset( $fields['additional_meta']['created_from'] ) ){
$from_post = DT_Posts::get_post( 'contacts', $fields['additional_meta']['created_from'], true, false );
if ( !is_wp_error( $from_post ) && isset( $from_post['type']['key'] ) && $from_post['type']['key'] === 'access' ){
if ( !is_wp_error( $from_post ) && isset( $from_post['type']['key'] ) && in_array( $from_post['type']['key'], [ 'access', 'access_placeholder', 'user' ] ) ){
$fields['type'] = 'access_placeholder';
}
}
Expand All @@ -790,11 +771,19 @@ public function dt_post_create_fields( $fields, $post_type ){
if ( !isset( $fields['type'] ) && get_current_user_id() === 0 ){
$fields['type'] = 'access';
}

/**
* Stop here if the type is not "access"
*/
if ( !isset( $fields['type'] ) || $fields['type'] !== 'access' ){
return $fields;
}
if ( !isset( $fields['seeker_path'] ) ){
$fields['seeker_path'] = 'none';
if ( !isset( $fields['overall_status'] ) ){
if ( get_current_user_id() ){
$fields['overall_status'] = 'active';
} else {
$fields['overall_status'] = 'new';
}
}
if ( !isset( $fields['assigned_to'] ) ){
if ( get_current_user_id() ) {
Expand All @@ -814,13 +803,10 @@ public function dt_post_create_fields( $fields, $post_type ){
}
}
}
if ( !isset( $fields['overall_status'] ) ){
if ( get_current_user_id() ){
$fields['overall_status'] = 'active';
} else {
$fields['overall_status'] = 'new';
}
if ( !isset( $fields['seeker_path'] ) ){
$fields['seeker_path'] = 'none';
}

if ( !isset( $fields['sources'] ) ) {
$fields['sources'] = [ 'values' => [ [ 'value' => 'personal' ] ] ];
}
Expand Down
65 changes: 39 additions & 26 deletions dt-contacts/base-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ public function dt_custom_fields_settings( $fields, $post_type ){
'tile' => 'details',
'icon' => get_template_directory_uri() . '/dt-assets/images/nametag.svg?v=2',
];
$contact_preferences = get_option( 'dt_contact_preferences', [] );
$post_type_settings = get_option( 'dt_custom_post_types', [] );
$private_contacts_enabled = $post_type_settings['contacts']['enable_private_contacts'] ?? false;
$fields['type'] = [
'name' => __( 'Contact Type', 'disciple_tools' ),
'type' => 'key_select',
Expand All @@ -125,9 +126,27 @@ public function dt_custom_fields_settings( $fields, $post_type ){
'visibility' => __( 'Only me', 'disciple_tools' ),
'icon' => get_template_directory_uri() . '/dt-assets/images/locked.svg?v=2',
'order' => 50,
'hidden' => !empty( $contact_preferences['hide_personal_contact_type'] ),
'hidden' => !$private_contacts_enabled,
'default' => true
],
'access' => [
'label' => __( 'Standard Contact', 'disciple_tools' ),
'color' => '#2196F3',
'description' => __( 'A contact to collaborate on', 'disciple_tools' ),
'visibility' => __( 'Me and project leadership', 'disciple_tools' ),
'icon' => get_template_directory_uri() . '/dt-assets/images/share.svg?v=2',
'order' => 20,
'default' => true,
],
'access_placeholder' => [
'label' => __( 'Connection', 'disciple_tools' ),
'color' => '#FF9800',
'description' => __( 'Connected to a contact, or generational fruit', 'disciple_tools' ),
'icon' => get_template_directory_uri() . '/dt-assets/images/share.svg?v=2',
'order' => 40,
'visibility' => __( 'Collaborators', 'disciple_tools' ),
'in_create_form' => false,
]
],
'description' => 'See full documentation here: https://disciple.tools/user-docs/getting-started-info/contacts/contact-types',
'icon' => get_template_directory_uri() . '/dt-assets/images/circle-square-triangle.svg?v=2',
Expand Down Expand Up @@ -187,25 +206,6 @@ public function dt_custom_fields_settings( $fields, $post_type ){
'customizable' => false
];

// add location fields
$fields['location_grid'] = [
'name' => __( 'Locations', 'disciple_tools' ),
'description' => _x( 'The general location where this contact is located.', 'Optional Documentation', 'disciple_tools' ),
'type' => 'location',
'mapbox' => false,
'in_create_form' => true,
'tile' => 'details',
'icon' => get_template_directory_uri() . '/dt-assets/images/location.svg?v=2',
];
$fields['location_grid_meta'] = [
'name' => __( 'Locations or Address', 'disciple_tools' ),
'type' => 'location_meta',
'tile' => 'details',
'mapbox' => false,
'hidden' => true,
'in_create_form' => true,
'icon' => get_template_directory_uri() . '/dt-assets/images/map-marker-multiple.svg?v=2',
];
$fields['contact_address'] = [
'name' => __( 'Address', 'disciple_tools' ),
'icon' => get_template_directory_uri() . '/dt-assets/images/house.svg?v=2',
Expand All @@ -219,10 +219,6 @@ public function dt_custom_fields_settings( $fields, $post_type ){
$fields['contact_address']['mapbox'] = true;
$fields['contact_address']['hidden'] = true;
unset( $fields['contact_address']['tile'] );
$fields['location_grid']['mapbox'] = true;
$fields['location_grid']['hidden'] = true;
$fields['location_grid_meta']['mapbox'] = true;
$fields['location_grid_meta']['hidden'] = false;
}

// add social media
Expand Down Expand Up @@ -466,8 +462,25 @@ public function dt_post_updated( $post_type, $post_id, $update_fields, $old_post
//Add, remove or modify fields before the fields are processed in post create
public function dt_post_create_fields( $fields, $post_type ){
if ( $post_type === 'contacts' ){
if ( !isset( $fields['type'] ) && isset( $fields['additional_meta']['created_from'] ) ){
$from_post = DT_Posts::get_post( 'contacts', $fields['additional_meta']['created_from'], true, false );
if ( !is_wp_error( $from_post ) && isset( $from_post['type']['key'] ) ){
switch ( $from_post['type']['key'] ){
case 'personal':
case 'placeholder':
$fields['type'] = 'placeholder';
break;
case 'access':
case 'access_placeholder':
case 'user':
$fields['type'] = 'access_placeholder';
break;
}
}
}

if ( !isset( $fields['type'] ) ){
$fields['type'] = 'personal';
$fields['type'] = 'access';
}
}
return $fields;
Expand Down
9 changes: 3 additions & 6 deletions dt-contacts/dmm-module.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(){
public function dt_custom_fields_settings( $fields, $post_type ){
$declared_fields = $fields;
if ( $post_type === 'contacts' ){
$contact_preferences = get_option( 'dt_contact_preferences', [] );
$private_contacts_enabled = $post_type_settings['contacts']['enable_private_contacts'] ?? false;
$fields['type']['default']['placeholder'] = [
'label' => __( 'Private Connection', 'disciple_tools' ),
'color' => '#FF9800',
Expand All @@ -53,7 +53,7 @@ public function dt_custom_fields_settings( $fields, $post_type ){
'order' => 40,
'visibility' => __( 'Only me', 'disciple_tools' ),
'in_create_form' => false,
'hidden' => !empty( $contact_preferences['hide_personal_contact_type'] ),
'hidden' => !$private_contacts_enabled,
];
$fields['milestones'] = [
'name' => __( 'Faith Milestones', 'disciple_tools' ),
Expand Down Expand Up @@ -330,11 +330,8 @@ public function post_connection_removed( $post_type, $post_id, $post_key, $value
//Add, remove or modify fields before the fields are processed in post create
public function dt_post_create_fields( $fields, $post_type ){
if ( $post_type === 'contacts' ){
if ( !isset( $fields['type'] ) ){
$fields['type'] = 'placeholder';
}
//mark a new user contact as being coached be the user who added the new user.
if ( $fields['type'] === 'user' ){
if ( isset( $fields['type'] ) && $fields['type'] === 'user' ){
$current_user_contact = Disciple_Tools_Users::get_contact_for_user( get_current_user_id() );
if ( $current_user_contact && !is_wp_error( $current_user_contact ) ){
$fields['coached_by'] = [ 'values' => [ [ 'value' => $current_user_contact ] ] ];
Expand Down
51 changes: 51 additions & 0 deletions dt-core/admin/admin-settings-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,57 @@ public function add_api_routes() {
'permission_callback' => [ $this, 'default_permission_check' ],
]
);

register_rest_route(
$this->namespace, '/languages', [
'methods' => 'POST',
'callback' => [ $this, 'update_languages' ],
'permission_callback' => [ $this, 'default_permission_check' ],
]
);
}

public function update_languages( WP_REST_REQUEST $request ) {
$params = $request->get_params();
$languages = dt_get_option( 'dt_working_languages' );

$langs = dt_get_available_languages();
foreach ( $languages as $language_key => $language_options ){

if ( isset( $params[$language_key]['label'] ) ){
$label = sanitize_text_field( wp_unslash( $params[$language_key]['label'] ) );
if ( ( $language_options['label'] ?? '' ) != $label ){
$languages[$language_key]['label'] = $label;
}
}
if ( isset( $params[$language_key]['iso_639-3'] ) ){
$code = sanitize_text_field( wp_unslash( $params[$language_key]['iso_639-3'] ) );
if ( ( $language_options['iso_639-3'] ?? '' ) != $code ) {
$languages[$language_key]['iso_639-3'] = $code;
}
}
if ( isset( $params[$language_key]['enabled'] ) ){
$enabled = sanitize_text_field( wp_unslash( $params[$language_key]['enabled'] ) );
if ( ( $language_options['enabled'] ?? '' ) != $enabled ) {
$languages[$language_key]['enabled'] = !empty( $enabled );
}
}
if ( isset( $params[$language_key]['translations'] ) ) {
foreach ( $langs as $lang => $val ){
$langcode = $val['language'];
if ( isset( $params[$language_key]['translations'][$langcode] ) ) {
$translated_label = sanitize_text_field( wp_unslash( $params[$language_key]['translations'][$langcode] ) );
if ( ( empty( $translated_label ) && !empty( $languages[$language_key]['translations'][$langcode] ) ) || !empty( $translated_label ) ){
$languages[$language_key]['translations'][$langcode] = $translated_label;
}
}
}
}
$languages[$language_key]['deleted'] = empty( $params[$language_key]['enabled'] );
}

update_option( 'dt_working_languages', $languages, false );
return true;
}

public static function get_post_fields() {
Expand Down
Loading

0 comments on commit 60bb129

Please sign in to comment.