From 70d8998a3f69278e48edbd778efc91fc42180d4b Mon Sep 17 00:00:00 2001 From: asus Date: Sun, 17 Mar 2024 14:06:25 +0100 Subject: [PATCH] custer : changed namespace, now all function use it --- plugins/cipf_plugin/fipfcard_plugin.php | 2 +- plugins/custer/author_id.php | 2 +- plugins/custer/change_id.php | 2 +- plugins/custer/filter_mail.php | 12 +------- plugins/custer/format_user_infos.php | 41 +++++++++++++++++-------- plugins/custer/user_infos.php | 12 ++++---- 6 files changed, 38 insertions(+), 33 deletions(-) diff --git a/plugins/cipf_plugin/fipfcard_plugin.php b/plugins/cipf_plugin/fipfcard_plugin.php index 9816c5f..b6a2932 100644 --- a/plugins/cipf_plugin/fipfcard_plugin.php +++ b/plugins/cipf_plugin/fipfcard_plugin.php @@ -42,7 +42,7 @@ include_once(PLGNTLS_class::root_path() . '/php/hide_admin.php'); include_once(PLGNTLS_class::root_path() . 'php/register_partenaires.php'); include_once(PLGNTLS_class::root_path() . 'php/redirections.php'); include_once(PLGNTLS_class::root_path() . 'php/author_restriction.php'); -include_once(PLGNTLS_class::root_path() . 'php/filter_mail.php'); +//include_once(PLGNTLS_class::root_path() . 'php/filter_mail.php'); include_once(PLGNTLS_class::root_path() . 'php/prof_check_page.php'); include_once(PLGNTLS_class::root_path() . 'php/renew_card.php'); //include_once(PLGNTLS_class::root_path() . 'php/reset_card_form.php'); diff --git a/plugins/custer/author_id.php b/plugins/custer/author_id.php index c1d8a39..4e3de3e 100644 --- a/plugins/custer/author_id.php +++ b/plugins/custer/author_id.php @@ -1,5 +1,5 @@ $$ * diff --git a/plugins/custer/format_user_infos.php b/plugins/custer/format_user_infos.php index 02ff4fb..c542fbc 100644 --- a/plugins/custer/format_user_infos.php +++ b/plugins/custer/format_user_infos.php @@ -10,13 +10,40 @@ if (!defined('ABSPATH')) { +/* +* return the result +* +*/ +function return_result($output) { + if (is_array($output) && count($output) === 0) + $output = ''; + if (!is_string($output)) + $output = json_encode($output, JSON_UNESCAPED_SLASHES); + return esc_html($output); +} + +/* +* format the output +* if is acf, use acf default format +*/ function format_user_info($query, &$current_user, $user_id) { $output_date_format = Custer::USER_INFO_DATE_FORMAT; $is_acf = false; + /* + * if is special query __author_page__ + * return author page url + * + */ + if ($query === '__author_page__') { + $output = get_author_posts_url($user_id); + return \CUSTER\return_result($output); + } + + /* * check if it's an acf field, and a date * second method : check what get_field_object() returns @@ -67,21 +94,9 @@ function format_user_info($query, &$current_user, $user_id) { } } - - - /* - * return the result - * - */ - if (is_array($output) && count($output) === 0) - $output = ''; - if (!is_string($output)) - $output = json_encode($output, JSON_UNESCAPED_SLASHES); - return esc_html($output); + return \CUSTER\return_result($output); } - - ?> diff --git a/plugins/custer/user_infos.php b/plugins/custer/user_infos.php index d3d1ad4..bd23ad6 100644 --- a/plugins/custer/user_infos.php +++ b/plugins/custer/user_infos.php @@ -21,14 +21,14 @@ function extract_if_array_size_one($value) { function merge_two_arrays($array1, $array2) { $new_array = $array1; foreach ($array2 as $key2 => $value2) { - $value = extract_if_array_size_one($value2); + $value = \CUSTER\extract_if_array_size_one($value2); // if key was not in first array, add the new element to it if (!isset($new_array[$key2])) { $new_array[$key2] = $value2; continue; } // if key was in first array, add both in an array - $value1 = extract_if_array_size_one($new_array[$key2]); + $value1 = \CUSTER\extract_if_array_size_one($new_array[$key2]); if (empty($value1)) $new_array[$key2] = $value2; else if (empty($value2)) @@ -47,7 +47,7 @@ function output_list_front($array, $current_user, $user_id) { foreach ($array as $key => $value) { if (str_starts_with($key, '_')) continue ; - $value = format_user_info($key, $current_user, $user_id); + $value = \CUSTER\format_user_info($key, $current_user, $user_id); $output .= '
  • '; $output .= ''; $output .= $key; @@ -158,8 +158,8 @@ function current_user_infos($atts) { if ($output_all) { $user_properties = (array) get_userdata($user_id)->data; $user_metas = get_user_meta($user_id); - $user_infos = merge_two_arrays($user_metas, $user_properties); - return output_list_front($user_infos, $current_user, $user_id); + $user_infos = \CUSTER\merge_two_arrays($user_metas, $user_properties); + return \CUSTER\output_list_front($user_infos, $current_user, $user_id); } @@ -174,7 +174,7 @@ function current_user_infos($atts) { $query = $atts; else return ''; - return format_user_info($query, $current_user, $user_id); + return \CUSTER\format_user_info($query, $current_user, $user_id); } add_shortcode('custer_user_info', __NAMESPACE__.'\current_user_infos');