Thanks for the compliment, for your question and for posting the source text of your [mla_gallery]
shortcode.
Making the {+title+} portion of your caption a clickable link is a bit tricky. The obvious answer might be:
mla_caption='<a href="{+file_url+}">{+title+}</a>, {+date+}'
But that fails because you can’t add raw HTML in the parameter value. You could define a custom markup template and add your modified caption there, but you’d still have the second part of your question (reformat the date) to deal with.
You can solve both of your needs by adding a bit of PHP code to one of the filters provided by [mla_gallery]
. In fact, the date reformat question was answered in this earlier support topic:
format date
Have a look at that topic, which will tell you find and modify the example code provided with MLA. To accomplish both parts of your requrements, replace the mla_gallery_item_values_filter
with this version:
public static function mla_gallery_item_values_filter( $item_values ) {
/*
* For this 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.
*/
$item_values['date'] = date( 'd/m/Y', $timestamp );
/*
* Compose a new caption with a "clickable" document title.
*/
$item_values['caption'] = sprintf( '<a href="%1$s">%2$s</a><br>%3$s', $item_values['file_url'], $item_values['title'], $item_values['date'] );
return $item_values;
}
}
Once that’s done, replace the mla_caption='{+title+}, {+date+}'
parameter in your shortcode with this one: my_filter="format date"
. That will be picked up by the filter code and your caption should come out the way you want.
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.