Skip to content

Commit 409bff8

Browse files
committed
Implemented multi-text-groups component in the theme
1 parent 80b8f75 commit 409bff8

8 files changed

Lines changed: 37 additions & 5 deletions

File tree

dt-core/admin/js/dt-settings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,7 @@ jQuery(document).ready(function ($) {
12831283
<option value="user_select">User Select</option>
12841284
<option value="location">Location (grid only)</option>
12851285
<option value="communication_channel">Communication Channel</option>
1286+
<option value="multi_text_groups">Multi Text Groups</option>
12861287
</select>
12871288
<p id="field-type-select-description" style="margin:0.2em 0">
12881289
${window.field_settings.field_types.key_select.description}

dt-core/admin/menu/tabs/tab-custom-fields.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,7 @@ private function add_field( $post_type ){
10801080
<option value="datetime"><?php esc_html_e( 'DateTime', 'disciple_tools' ) ?></option>
10811081
<option value="connection"><?php esc_html_e( 'Connection', 'disciple_tools' ) ?></option>
10821082
<option value="user_select"><?php esc_html_e( 'User Select', 'disciple_tools' ) ?></option>
1083+
<option value="multi_text_groups"><?php esc_html_e( 'Multi Text Groups', 'disciple_tools' ) ?></option>
10831084
</select>
10841085
</td>
10851086
</tr>
@@ -1194,6 +1195,7 @@ private function add_field( $post_type ){
11941195
<li><?php esc_html_e( 'Link: Create a collection of links', 'disciple_tools' ) ?></li>
11951196
<li><?php esc_html_e( 'Connection: An autocomplete picker to connect to another record.', 'disciple_tools' ) ?></li>
11961197
<li><?php esc_html_e( 'User Select: An autocomplete picker to connect to a user account.', 'disciple_tools' ) ?></li>
1198+
<li><?php esc_html_e( 'Multi Text Groups: A field to add multiple text inputs and group them.', 'disciple_tools' ) ?></li>
11971199
</ul>
11981200
<strong><?php esc_html_e( 'Private Field:', 'disciple_tools' ) ?></strong>
11991201
<ul style="list-style: disc; padding-left:40px">
@@ -1348,6 +1350,15 @@ private function process_add_field( $post_submission ){
13481350
'customizable' => 'all',
13491351
'private' => $field_private
13501352
];
1353+
} elseif ( $field_type === 'multi_text_groups' ){
1354+
$new_field = [
1355+
'name' => $post_submission['new_field_name'],
1356+
'type' => 'multi_text_groups',
1357+
'default' => '',
1358+
'tile' => $field_tile,
1359+
'customizable' => 'all',
1360+
'private' => $field_private
1361+
];
13511362
} elseif ( $field_type === 'connection' ){
13521363
if ( !$post_submission['connection_target'] ){
13531364
self::admin_notice( __( 'Please select a connection target', 'disciple_tools' ), 'error' );

dt-core/admin/menu/tabs/tab-fields.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function box_message( $post_type ) {
9595
$fields = $post_settings['fields'];
9696

9797
/* breadcrumb: new-field-type Add field type to field explorer */
98-
$types = [ 'text', 'textarea', 'date', 'datetime', 'boolean', 'key_select', 'multi_select', 'array', 'connection', 'number', 'link', 'communication_channel', 'tags', 'user_select', 'task', 'location', 'location_meta' ];
98+
$types = [ 'text', 'textarea', 'date', 'datetime', 'boolean', 'key_select', 'multi_select', 'array', 'connection', 'number', 'link', 'communication_channel', 'tags', 'user_select', 'task', 'location', 'location_meta', 'multi_text_groups' ];
9999
foreach ( $types as $type ){
100100
?>
101101
<h3>Field type: <?php echo esc_html( $type ) ?></h3>

dt-core/global-functions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ function render_field_for_display( $field_key, $fields, $post, $show_extra_contr
601601
}
602602
if ( isset( $fields[$field_key]['type'] ) && !$custom_display && empty( $fields[$field_key]['hidden'] ) ) {
603603
/* breadrcrumb: new-field-type Add allowed field types */
604-
$allowed_types = apply_filters( 'dt_render_field_for_display_allowed_types', [ 'boolean', 'key_select', 'multi_select', 'date', 'datetime', 'text', 'textarea', 'number', 'link', 'connection', 'location', 'location_meta', 'communication_channel', 'tags', 'user_select' ] );
604+
$allowed_types = apply_filters( 'dt_render_field_for_display_allowed_types', [ 'boolean', 'key_select', 'multi_select', 'date', 'datetime', 'text', 'textarea', 'number', 'link', 'connection', 'location', 'location_meta', 'communication_channel', 'tags', 'user_select', 'multi_text_groups' ] );
605605
if ( !in_array( $field_type, $allowed_types ) ){
606606
return;
607607
}
@@ -654,6 +654,9 @@ function render_field_for_display( $field_key, $fields, $post, $show_extra_contr
654654
case 'user_select':
655655
DT_Components::render_user_select( $field_key, $fields, $post, $params );
656656
break;
657+
case 'multi_text_groups':
658+
DT_Components::render_multi_text_groups( $field_key, $fields, $post, $params );
659+
break;
657660
default:
658661
$is_legacy = true;
659662
break;

dt-core/utilities/dt-components.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public static function shared_attributes( $field_key, $fields, $post, $params =
3434
'location_meta',
3535
'communication_channel',
3636
'tags',
37-
'user_select'
37+
'user_select',
38+
'multi_text_groups',
3839
] );
3940
if ( !in_array( $field_type, $allowed_types ) ){
4041
return;
@@ -321,4 +322,14 @@ public static function render_user_select( $field_key, $fields, $post, $params =
321322
</dt-users-connection>
322323
<?php
323324
}
325+
326+
public static function render_multi_text_groups( $field_key, $fields, $post, $params = [] ) {
327+
$shared_attributes = self::shared_attributes( $field_key, $fields, $post, $params );
328+
?>
329+
<dt-multi-text-groups <?php echo wp_kses_post( $shared_attributes ) ?>
330+
value="<?php echo esc_attr( isset( $post[$field_key] ) ? json_encode( $post[$field_key] ) : '' ) ?>">
331+
<?php dt_render_icon_slot( $fields[$field_key] ) ?>
332+
</dt-multi-text-groups>
333+
<?php
334+
}
324335
}

dt-import/admin/dt-import-admin-tab.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ private function get_field_types() {
324324
'connection' => __( 'Connection', 'disciple_tools' ),
325325
'user_select' => __( 'User Select', 'disciple_tools' ),
326326
'location' => __( 'Location', 'disciple_tools' ),
327-
'location_meta' => __( 'Location Meta', 'disciple_tools' )
327+
'location_meta' => __( 'Location Meta', 'disciple_tools' ),
328+
'multi_text_groups' => __( 'Multi Text Groups', 'disciple_tools' )
328329
];
329330
}
330331

dt-posts/dt-posts.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3275,6 +3275,11 @@ public static function get_field_types(){
32753275
'description' => 'Array of data',
32763276
'user_creatable' => false,
32773277
],
3278+
'multi_text_groups' => [
3279+
'label' => 'Multi Text Groups',
3280+
'description' => 'Field for multiple text inputs grouped together',
3281+
'user_creatable' => true,
3282+
],
32783283
];
32793284
}
32803285
}

dt-users/user-metrics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static function get_user_activity( $user_id, $include = [] ) {
6363
* This hard coded array has come from the filter dt_render_field_for_display_allowed_types
6464
* and needs to be refactored for both here and there.
6565
*/
66-
$allowed_field_types = [ 'key_select', 'multi_select', 'date', 'datetime', 'text', 'textarea', 'number', 'connection', 'location', 'location_meta', 'communication_channel', 'tags', 'user_select' ];
66+
$allowed_field_types = [ 'key_select', 'multi_select', 'date', 'datetime', 'text', 'textarea', 'number', 'connection', 'location', 'location_meta', 'communication_channel', 'tags', 'user_select', 'multi_text_groups' ];
6767
array_push( $allowed_field_types, '' );
6868
$allowed_field_types_sql = dt_array_to_sql( $allowed_field_types );
6969
$allowed_post_statuses_sql = dt_array_to_sql( [ 'publish' ] );

0 commit comments

Comments
 (0)