//Shortcode for date generation.
//Use: %CURRENT_DATE%date_format_string%
//Example: %CURRENT_DATE%d/m/Y%
$varname='%CURRENT_DATE%';
$default_format="d/m/Y"; //in case no format is supplied
$startpos=0;
while ($startpos!==false){
$startpos=strpos($value, $varname);
if ($startpos !== false) {
$endpos=strpos($value, '%', $startpos + strlen($varname));
if ($endpos!==false){
$placeholder= substr($value,$startpos,$endpos-$startpos+1);
$dateformatstring= substr($value,$startpos + strlen($varname), $endpos - ($startpos + strlen($varname)));
$value = str_replace($placeholder, date($dateformatstring), $value);
}else{
$value = str_replace($varname, date($default_format), $value);
}
}
}
//This is a workaround for date fields since we cannot write a placeholder in the datetime textbox I use these weird dates as placeholders themselves
//01/01/1000 - First day of current month
//15/01/1000 - Current day of current month
//31/01/1000 - Last day of current month
$placeholder_first_day_current_month='01/01/1000';
$placeholder_current_day_current_month='15/01/1000';
$placeholder_last_day_current_month='31/01/1000';
if (strpos($value, $placeholder_first_day_current_month) !== false) {
$value = str_replace($placeholder_first_day_current_month, date("01/m/Y"), $value);
}
if (strpos($value, $placeholder_current_day_current_month) !== false) {
$value = str_replace($placeholder_current_day_current_month, date("d/m/Y"), $value);
}
if (strpos($value, $placeholder_last_day_current_month) !== false) {
$value = str_replace($placeholder_last_day_current_month, date("t/m/Y"), $value);
}
I should change also table_settings_block.inc.php so it appears there and lets me set a default value for query, but since I'll probably need to replicate changes on next wpdatatables update, I decided to keep it simple for now.
Hi
I really need placeholders with current date info.
As a suggestion: Please add it :)
Meanwhile I coded a workaround and I decided to share it. May be someone finds it useful. Better ideas? Better code? Please share :)
Edit file class.wdttools.php
After :
(around line 590)
Add:
Edit file class.wpdatacolumn.php
After:
(around line 590)
Add:
I should change also table_settings_block.inc.php so it appears there and lets me set a default value for query, but since I'll probably need to replicate changes on next wpdatatables update, I decided to keep it simple for now.
Cheers
Hi Raul,
Thank you for your purchase.
Thank you for sharing your solution with us.
I will definitely add this workaround to our TODO list so we can test it for the future updates.
Thank you again for sharing your suggestions and ideas with us.
Best regards.
Kind Regards,
Miloš Jovanović
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables