I am using the Transients API to hold the output for a gallery plugin's shortcode I created. Due to the number of images used and different layouts needed, the transient name looks lik the following:
_transient_galleries_single_shortcode_5183five
So - the int
portion is the post ID it is referencing and the five
is this specific shortcode's column setting. Where I'm running into trouble is flushing these shortcodes on-save of the referenced galleries.
What I'd normally do is something like following:
function galleries_delete_transient($post_id) {
switch (get_post_type()) {
case 'galleries':
delete_transient('galleries_single_shortcode_'.$post_id);
break;
}
}
add_action('save_post','galleries_delete_transient');
The problem being here is that the column setting can be different based on a certain page's needs - so I was wondering if there is any type of wildcard I can use here to make this a bit more dynamic (to just clear all of them - something like delete_transient('galleries_single_shortcode_'.$post_id%);
). Any help would be greatly appreciated. Thanks!
Update
Complete shortcode function added for clarity how everything is constructed:
function galleries_single_shortcode($atts, $content = null) {
extract(shortcode_atts(array(
"id" => '',
"columns" => 'four'
), $atts));
global $galleries_options;
$galleries_single_shortcode_output = get_transient('galleries_single_shortcode_'.$id.$columns);
if ($galleries_single_shortcode_output === false) {
ob_start();
// OUTPUT HERE
$galleries_single_shortcode_output = ob_get_contents();
ob_end_clean();
set_transient('galleries_single_shortcode_'.$id.$columns, $galleries_single_shortcode_output, 60 * 60 * 24);
}
return $galleries_single_shortcode_output;
}
add_shortcode('galleries_single', 'galleries_single_shortcode');