On this day..'); add_option('ddtd_this_year', TRUE); add_option('ddtd_show_year', TRUE); add_option('ddtd_hide_pass', TRUE); function ddtd_add_option_pages() { if (function_exists('add_options_page')) { add_options_page('Dagon Design - This Day', 'DDThisDay', 8, __FILE__, 'ddtd_options_page'); } } function ddtd_options_page() { global $ddtd_version; if (isset($_POST['set_defaults'])) { echo '

'; update_option('ddtd_count', '10'); update_option('ddtd_sort', 'newestfirst'); update_option('ddtd_header', '

On this day..

'); update_option('ddtd_this_year', TRUE); update_option('ddtd_show_year', TRUE); update_option('ddtd_hide_pass', TRUE); echo 'Default Options Loaded!'; echo '

'; } else if (isset($_POST['info_update'])) { echo '

'; $ipp_check = 0; if (is_numeric($_POST["ddsg_items_per_page"])) { if ((int)$_POST["ddsg_items_per_page"] > 0) { $ipp_check = $_POST["ddsg_items_per_page"]; } } update_option('ddtd_count', (int) $_POST["ddtd_count"]); update_option('ddtd_sort', (string) $_POST["ddtd_sort"]); update_option('ddtd_header', (string) $_POST["ddtd_header"]); update_option('ddtd_this_year', (bool) $_POST["ddtd_this_year"]); update_option('ddtd_show_year', (bool) $_POST["ddtd_show_year"]); update_option('ddtd_hide_pass', (bool) $_POST["ddtd_hide_pass"]); echo 'Configuration Updated!'; echo '

'; } ?>

This Day v

For information and updates, please visit:
http://www.dagondesign.com/articles/wordpress-plugin-this-day/

">
General Options
Max posts to show
Set to 0 for unlimited
Sorting />   Newest posts first
/>   Oldest posts first
Header text
Show other posts from today /> Enabling this will show other posts on the same exact day
(otherwise it will ignore the current year)
Show the year /> This will show the year of each post after the link
Hide password protected posts />
prefix; $ddtd_count = get_option('ddtd_count'); $ddtd_sort = get_option('ddtd_sort'); $ddtd_header = get_option('ddtd_header'); $ddtd_this_year = get_option('ddtd_this_year'); $ddtd_show_year = get_option('ddtd_show_year'); $ddtd_hide_pass = get_option('ddtd_hide_pass'); $the_output = NULL; $curr_month = date("n", strtotime($post->post_date)); $curr_day = date("j", strtotime($post->post_date)); $curr_year = date("Y", strtotime($post->post_date)); $curr_post = $post->ID; $this_year_check = " "; if (!$ddtd_this_year) { $this_year_check = " AND DATE_FORMAT(post_date, '%Y') != {$curr_year} "; } $limit_check = " "; if ($ddtd_count > 0) { $limit_check = " LIMIT $ddtd_count "; } $sort_check = "DESC"; if ($ddtd_sort == "oldestfirst") { $sort_check = "ASC"; } $pass_check = ""; if ($ddtd_hide_pass) { $pass_check = " AND post_password = '' "; } $tposts = (array)$wpdb->get_results(" SELECT ID, post_title, DATE_FORMAT(post_date, '%Y') as post_year FROM {$tp}posts WHERE post_date < NOW() AND ID != {$curr_post} AND post_type = 'post' {$pass_check} AND post_status = 'publish' AND DATE_FORMAT(post_date, '%c') = {$curr_month} AND DATE_FORMAT(post_date, '%e') = {$curr_day} {$this_year_check} ORDER by post_date {$sort_check} {$limit_check} "); if (empty($tposts)) { return ""; } $the_output .= $ddtd_header; $the_output .= ''; return $the_output; } function ddtd_generate($content) { if (is_single()) { return $content . ddtd_show_posts(); } else { return $content; } } add_filter('the_content', 'ddtd_generate'); add_action('admin_menu', 'ddtd_add_option_pages'); ?>