From: Laury GvR Date: Fri, 30 Jun 2017 14:05:03 +0000 (-0400) Subject: glm_custom_fields filter only wpautop on textareas X-Git-Tag: v1.0.3^2~3 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=1f03cbaea105d2f442810809adf16ea9f4157227;p=WP-Plugins%2Fglm-member-db-fields.git glm_custom_fields filter only wpautop on textareas wpautop() was being applied to all results from the glm_custom_fields, so the query was expanded to check for the field's type, and only apply to textareas, so that not every field gets a paragraph tag wrapped around it. --- diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 916b023..4c7bf9a 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -111,10 +111,17 @@ add_filter('glm-member-db-fields-front-list-query-params', function( $query ){ add_filter('glm_custom_fields', function($attribute, $id = 0) { global $wpdb; - $query = "SELECT field_data FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data WHERE ref_dest = $id " - . "AND field_id IN (SELECT id FROM ".GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX."custom_fields WHERE field_name LIKE '$attribute' )"; - $result = wpautop($wpdb->get_var( $query )); - return $result; + $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.ref_dest = $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 = $this->wpdb->get_row( $query, ARRAY_A ); + if ($result['field_type'] == 'textarea') { + $result['field_data'] = wpautop($result['field_data']); + } +// echo "
AA" . print_r($result) . "ZZ";
+    return $result['field_data'];
     },
     10,
     2