When you get back to this project, here is some code you can use to accomplish your goal.
Start with the example code you can find in the /plugins/media-library-assistant/examples directory, file mla-hooks-example.php.txt
Rename the file to remove the “.txt” portion and place it in your /plugins directory. You can change the name of the plugin and file if you like.
Edit the file and add this block of code just below the error_log( ...
statement in the public static function mla_gallery_item_values_filter( $item_values )
function:
/*
* For this first example, we will reformat the 'date' value as d/m/Y. We use a shortcode parameter of our
* own to do this on a gallery-by-gallery basis, leaving other [mla_gallery] instances untouched.
*/
if ( isset( self::$shortcode_attributes['my_filter'] ) && 'format date' == self::$shortcode_attributes['my_filter'] ) {
/*
* Default format is YYYY-MM-DD HH:MM:SS (HH = 00 - 23), or 'Y-m-d H:i:s'
* Convert to UNIX timestamp so any reformat is possible
*/
$old_date = $item_values['date'];
$timestamp = mktime( substr( $old_date, 11, 2 ), substr( $old_date, 14, 2 ), substr( $old_date, 17, 2 ), substr( $old_date, 5, 2 ), substr( $old_date, 8, 2 ), substr( $old_date, 0, 4 ) );
/*
* Update the $item_values and pass them back from the filter.
* We must also update the caption because it was composed before this filter is called.
*/
$item_values['date'] = date( 'd/m/Y', $timestamp );
$item_values['caption'] = $item_values['description'] . $item_values['date'];
return $item_values;
}
Save the file and activate the plugin. Add the my_filter="format date"
parameter to the [mla_gallery]
shortcode and you should see the captions with the re-formatted date. ANy other shortcodes that do not contain the added parameter will be unaffected by the filter.
I’m going to mark this topic resolved for now, but feel free to update it if you have any problems or further questions. Thanks for your interest in the plugin.