some improvments on shortcode user_info, to output the right secure string in most cases
This commit is contained in:
@@ -39,20 +39,18 @@ function merge_two_arrays_CIPF($array1, $array2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function output_list_front_CIPF($array) {
|
function output_list_front_CIPF($array, $current_user, $user_id) {
|
||||||
PLGNTLS_class::debug_infos();
|
PLGNTLS_class::debug_infos();
|
||||||
$output = '<ul>';
|
$output = '<ul>';
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
if (str_starts_with($key, '_'))
|
if (str_starts_with($key, '_'))
|
||||||
continue ;
|
continue ;
|
||||||
|
$value = format_user_info_CIPF($key, $current_user, $user_id);
|
||||||
$output .= '<li>';
|
$output .= '<li>';
|
||||||
$output .= '<span>';
|
$output .= '<span>';
|
||||||
$output .= $key;
|
$output .= $key;
|
||||||
$output .= ' : ';
|
$output .= ' : ';
|
||||||
if (is_array($value) && count($value) === 1)
|
$output .= $value;
|
||||||
$output .= json_encode($value[0]);
|
|
||||||
else
|
|
||||||
$output .= json_encode($value);
|
|
||||||
$output .= '</span>';
|
$output .= '</span>';
|
||||||
$output .= '</li>';
|
$output .= '</li>';
|
||||||
}
|
}
|
||||||
@@ -127,10 +125,13 @@ function format_user_info_CIPF($query, &$current_user, $user_id) {
|
|||||||
* return the result
|
* return the result
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (is_string($output))
|
while (is_array($output) && count($output) === 1)
|
||||||
return $output;
|
$output = reset($output);
|
||||||
else
|
if (is_array($output) && count($output) === 0)
|
||||||
return json_encode($output);
|
$output = '';
|
||||||
|
if (!is_string($output))
|
||||||
|
$output = json_encode($output, JSON_UNESCAPED_SLASHES);
|
||||||
|
return esc_html($output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -217,7 +218,7 @@ function current_user_infos_CIPF($atts) {
|
|||||||
$user_properties = (array) get_userdata($user_id)->data;
|
$user_properties = (array) get_userdata($user_id)->data;
|
||||||
$user_metas = get_user_meta($user_id);
|
$user_metas = get_user_meta($user_id);
|
||||||
$user_infos = merge_two_arrays_CIPF($user_metas, $user_properties);
|
$user_infos = merge_two_arrays_CIPF($user_metas, $user_properties);
|
||||||
return output_list_front_CIPF($user_infos);
|
return output_list_front_CIPF($user_infos, $current_user, $user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -226,7 +227,7 @@ function current_user_infos_CIPF($atts) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (is_array($atts))
|
if (is_array($atts))
|
||||||
$query = reset($atts);
|
$query = $atts[0];
|
||||||
else if (is_string($atts))
|
else if (is_string($atts))
|
||||||
$query = $atts;
|
$query = $atts;
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user