I am creating a plugin (my first) which allows the site admin to display the most used post tags over the last X number of days. This plugin is an evolution of the WP Development question here - Display list of most used tags in the last 30 days.
Forgive me for not knowing the proper jargon.
I have most of the leg-work completed with the admin menu, etc, the only thing I have left is to actually display the results.
The following snippet of code works when I drop it into the single.php file.
<div class="recent-popular-tags">
<h3><?php echo $rpt_options['heading_tags']; ?></h3>
<?php $wpdb->show_errors(); ?>
<?php
global $rpt_options;
$rpt_days = $rpt_options['number_days'];
global $wpdb;
$rpt_term_ids = $wpdb->get_col("
SELECT term_id FROM $wpdb->term_taxonomy
INNER JOIN $wpdb->term_relationships ON $wpdb->term_taxonomy.term_taxonomy_id=$wpdb->term_relationships.term_taxonomy_id
INNER JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->term_relationships.object_id
WHERE DATE_SUB(CURDATE(), INTERVAL $rpt_days DAY) <= $wpdb->posts.post_date");
if(count($rpt_term_ids) > 0){
$rpt_tags = get_tags(array(
'orderby' => 'count',
'order' => 'DESC',
'number' => $rpt_options['number_tags'],
'include' => $rpt_term_ids,
));
foreach ( (array) $rpt_tags as $rpt_tag ) {
echo '<span class="rpt-link"><a href="' . get_tag_link ($rpt_tag->term_id) . '" rel="tag">' . $rpt_tag->name . '</a></span>';
}
}
?>

I'm stuck at converting this code to a variable to append to $content.
Right now, I only have a very simply display function, to test that the number_days and number_tags settings will display the values entered into the settings page. They do.
function rpt_display_content ($content){
global $rpt_options;
if(is_single()){
$rpt_display = '<p>' . $rpt_options['rpt_tags_days'] . $rpt_options['rpt_tags_number'] . '</p>';
$content .= $rpt_display;
}
return $content;
}
add_filter('the_content', 'rpt_display_content');