From d5dcc03e67dba05a1ad5d92b8f25959a64a82f9b Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 10 Aug 2018 11:38:01 -0400 Subject: [PATCH] New filter for front and style for admin fields Admin fields - add padding and margin to align the checkboxes. Front end - filter for the CGCS --- setup/frontHooks.php | 33 ++++++++++++++++++++++++++++++++- views/admin/entity/fields.html | 11 ++++------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 8304a48..0ccc0ca 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -227,12 +227,43 @@ add_filter('glm_custom_fields', function($attribute, $id = 0) { if ($result['field_type'] == 'textarea') { $result['field_data'] = wpautop($result['field_data']); } -// echo "
AA" . print_r($result) . "ZZ";
     return $result['field_data'];
     },
     10,
     2
 );
+
+add_filter('glm_get_contact_custom_data_by_ref_dest', function( $custom_field_id, $ref_dest = 0 ) {
+
+    global $wpdb;
+    $query = "SELECT D.field_data, F.field_type FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data D, ".GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX."custom_fields F "
+        . "WHERE D.entity_id = $id "
+        . "AND D.field_id IN (SELECT id FROM ".GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX."custom_fields WHERE field_name LIKE '$attribute' ) "
+        . "AND F.field_name LIKE '$attribute'";
+
+    $result = $wpdb->get_row(
+        $wpdb->prepare(
+            "SELECT field_data
+               FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data
+              WHERE entity_id = (
+                    SELECT id
+                      FROM " . GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts
+                     WHERE ref_dest = %d )
+                AND field_id = %d",
+            $ref_dest,
+            $custom_field_id
+        ),
+        ARRAY_A
+    );
+    if ($result['field_type'] == 'textarea') {
+        $result['field_data'] = wpautop($result['field_data']);
+    }
+    return $result['field_data'];
+    },
+    10,
+    2
+);
+
 add_filter('glm_custom_fields_member_types', function() {
 
     $query = "SELECT name FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_type";
diff --git a/views/admin/entity/fields.html b/views/admin/entity/fields.html
index cdcd3b0..f4d76ab 100644
--- a/views/admin/entity/fields.html
+++ b/views/admin/entity/fields.html
@@ -10,14 +10,14 @@
 
             {if $field.field_type.value == 'checkbox'}
                 
- +
- + {else}
{$field.field_name}
{/if} - + {$fail = ''} @@ -36,16 +36,13 @@ {php} wp_editor('{if isset($customFieldsData[$field.id])}{$customFieldsData[$field.id]|escape:quotes}{/if}', 'custom-field-{$field.id}', array( 'media_buttons' => false, - // 'quicktags' => false, - // 'wpautop' => false, NOTE: Dont's use. Problem when numerous spaces before text. 'textarea_name' => '{$prefix}[{$field.id}]', 'editor_height' => 200, // Height in px, overrides editor_rows - // 'textarea_rows' => 8, {if $field.required.value == 1}'editor_class' => 'glm-required' {/if} )); {/php} {elseif $field.field_type.value == 'checkbox'} -