hi teseo, thanks for your time on this. I really admire what you do on this forum. Of course, time is precious.
But I cannot follow you, is javascript, but how I can use it?
I really mean, what I need to do in concrete?
This is the code for custom field for a function you post in times and I use it with a variable $epoch:
<?php $epoch = cust_get_custom_field_item_value($cf_name) ; ?>
and this is the code for showing the dates:
<?php $epoch = cust_get_custom_field_item_value($cf_name) + 86400; $dt = new DateTime("@$epoch"); ?>
<?php $day = 86400; $interval = $epoch - $day; ?>
<?php if(time() > $interval && time() < $epoch ) {?><strong>Expira hoje!</strong>
<?php } elseif(time() < $interval) { ?>Expira a <?php echo $dt->format('j F Y g:i:s'); ?>
<?php } elseif(time() > $interval && time() > $epoch){ ?>Expirou a <?php echo $dt->format('j F Y g:i:s'); ?>
<?php } ?>
On a specific plugin I have this function:
<?php
function updateItemExpired($item) {
$day = 86400;
$epoch = cust_get_custom_field_item_value($cf_name) + 86400; /* return the fix date expire value chosen */
$dt = new DateTime("@$epoch") ;
$conn = getConnection();
$conn->osc_dbExec("UPDATE %st_item SET dt_expiration = '".$dt->format('Y-m-d H:i:s')."' WHERE pk_i_id = '%d'", DB_TABLE_PREFIX, $item['pk_i_id']);
}
osc_add_hook('posted_item', 'updateItemExpired');
osc_add_hook('edited_item', 'updateItemExpired');
On your javascript code I change the name .cf_date to cf_name (don't know if is needed).
Where I need to put the javascript code, creating a new function on functions.php and add hook to post/edit, or other situation?
Sorry, I really don't know.
Thanks again
Regards