Hi! I'm building a settings page where user enters data that is processed somewhere else in a code block. On that page (settings), I'm trying to display field group data using Custom HTML with a PHP callback.
I've entered the following function in "Code Snippets". What I want is the $index variable to display on the page so the user knows his settings' result in backend. So I'm entering 'mb_quote_index_return' in the "PHP callback" line of the "Custom HTML" field, but nothing shows.
Can someone tell me where I got it wrong?
Thanks!
CODE (mb_quote_index_return):
<?php
function get_mb_settings_field( $field_id ) {
return rwmb_meta( $field_id, ['object_type' => 'setting'], 'options' );
}
date_default_timezone_set("America/New_York");
$quotes = get_mb_settings_field( 'pensees_quotes' );
$max = count($quotes);
$lastIndex = get_mb_settings_field( 'start_index' );
$lastTime = get_mb_settings_field( 'start_date' );
$lastTimeA = strtotime($lastTime);
$gap_s = strtotime('now') - $lastTimeA;
$gap_d = floor($gap_s / (60<em>60</em>24));
$index = ($lastIndex - 1) + $gap_d;
$rem = $index;
while ($rem >= $max) {
$rem = $rem - $max;
}
$index = $rem;
echo "Pensée: ".($index + 1)."/".$max;
?>