ID ) ) { unset ( $shortcode_attributes['author'] ); } else { $shortcode_attributes['author'] = $current_user->ID; } // Save the attributes for use in the later filters self::$shortcode_attributes = $shortcode_attributes; return $shortcode_attributes; } // mla_gallery_attributes_filter /** * Replace the caption value and update captiontag_content as well * * @since 1.01 * * @param array parameter_name => parameter_value pairs * @param string New value for Caption * * @return array item_values with updated 'caption' and 'captiontag_content' */ private static function _update_caption( $item_values, $new_caption ) { $old_caption = $item_values['caption']; $item_values['caption'] = $new_caption; if ( !empty( $item_values['captiontag_content'] ) ) { $item_values['captiontag_content'] = str_replace( $old_caption, $new_caption, $item_values['captiontag_content'] ); } else { if ( $item_values['captiontag'] ) { $item_values['captiontag_content'] = '<' . $item_values['captiontag'] . " class='wp-caption-text gallery-caption' id='" . $item_values['selector'] . '-' . $item_values['attachment_ID'] . "'>\n\t\t" . $new_caption . "\n\t" . $item_values['captiontag'] . ">\n"; } else { $item_values['captiontag_content'] = $new_caption; } } return $item_values; } // _update_caption /** * MLA Gallery Open Template * * @since 1.01 * * @param string template used to generate the HTML markup */ public static function mla_gallery_open_template_filter( $open_template ) { // Check for a display message if ( isset( self::$shortcode_attributes['gallery_open_message'] ) ) { $open_template = '
' . self::$shortcode_attributes['gallery_open_message'] . '
' . $open_template; } return $open_template; } // mla_gallery_open_template_filter /** * MLA Gallery Item Values * * @since 1.01 * * @param array parameter_name => parameter_value pairs */ public static function mla_gallery_item_values_filter( $item_values ) { if ( isset( self::$shortcode_attributes['my_filter'] ) && ( 'allow file deletion' == self::$shortcode_attributes['my_filter'] ) ) { $id = (integer) $item_values['attachment_ID']; if ( current_user_can( 'delete_post', $id ) ) { // Compose a new caption, adding the deletion link. $mla_link_href = "{$item_values['page_url']}?attachment_ID={$id}"; $item_values = self::_update_caption( $item_values, sprintf( '%1$s