added message payments in admin menu

This commit is contained in:
asus
2024-03-27 17:18:14 +01:00
parent a0018c903b
commit dd0d4dfbeb
13 changed files with 229 additions and 34 deletions

View File

@@ -14,16 +14,32 @@ if (!defined('ABSPATH')) {
* return the result
*
*/
function return_result($output) {
if (is_array($output) && count($output) === 0) {
$output = '';
function return_result($output, $if_empty = '') {
/*
* if empty, apply options, or default empty string ''
*
*/
if (empty($output)) {
$output = $if_empty;
}
/*
* if number, output a string
*
*/
if (is_numeric($output)) {
$output = (string)$output;
}
if (!is_string($output)) {
/*
* if not scalar, stringify output
*
*/
if (!is_scalar($output)) {
$output = json_encode($output, JSON_UNESCAPED_SLASHES);
}
return esc_html($output);
}
@@ -32,7 +48,7 @@ function return_result($output) {
* format the output
* if is acf, use acf default format
*/
function format_user_info($query, $current_user, $user_id) {
function format_user_info($query, $current_user, $user_id, $if_empty = '') {
$output_date_format = Custer::USER_INFO_DATE_FORMAT;
$is_acf = false;
@@ -75,10 +91,12 @@ function format_user_info($query, $current_user, $user_id) {
* otherwise, use the default wordpress value
*
*/
if ($is_acf)
if ($is_acf) {
$output = get_field($query, $acf_id);
else
}
else {
$output = $current_user->$query;
}
@@ -86,8 +104,9 @@ function format_user_info($query, $current_user, $user_id) {
* try to extract a string
*
*/
while (is_array($output) && count($output) === 1)
while (is_array($output) && count($output) === 1) {
$output = reset($output);
}
@@ -110,7 +129,12 @@ function format_user_info($query, $current_user, $user_id) {
}
}
return \CUSTER\return_result($output);
/*
* check options to format the result
*
*/
return \CUSTER\return_result($output, $if_empty);
}