This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Plugin Name: Time Machine Version: 0.0.5.4 Plugin URI: http://blog.urosevic.net/wordpress/time-machine/ Author: Aleksandar Urošević Author URI: http://urosevic.net/ Description: List all public posts published in past on today date, including all years of blogging */ function time_machine_init() { if ( !function_exists("register_sidebar_widget") ) return; register_sidebar_widget(__('Time Machine', 'tm'), "time_machine"); register_widget_control(__('Time Machine', 'tm'), "tm_widget_control"); load_plugin_textdomain('tm', PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)).'/languages', dirname(plugin_basename(__FILE__)).'/languages'); } function tm_widget_control() { // Configuration panel for Time Machine Widget $options = get_option("time_machine"); if ( !is_array( $options ) ) { $options = array( "title" => __('Time Machine', 'tm'), "message" => __('No entry on current day in past', 'tm'), "showifno" => "1", "posts" => "10", "private" => "0", "exclude_pages" => "1", "exclude_current" => "0", "display_commentnum" => "0" ); update_option("time_machine", $options); } if ( $_POST['tm-Submit'] ) { $options['title'] = htmlspecialchars($_POST['tm-wTitle']); $options['message'] = htmlspecialchars($_POST['tm-wMessage']); $options['posts'] = htmlspecialchars($_POST['tm-wPosts']); $options['showifno']= htmlspecialchars($_POST['tm-wShowIfNo']); $options['include_private'] = htmlspecialchars($_POST['tm-wIncludePrivate']); $options['exclude_pages'] = htmlspecialchars($_POST['tm-wExcludePages']); $options['exclude_current'] = htmlspecialchars($_POST['tm-wExcludeCurrent']); $options['display_commentnum'] = htmlspecialchars($_POST['tm-wDisplayCommentNum']); update_option("time_machine", $options); } ?>






10




/>
/>
/>
/>
/>

"1" ) { $tm_private = "AND post_password=''"; } else { $tm_private = ""; } // exclude pages from listing? if ( $options['exclude_pages'] == "1" ) { $tm_pages = "AND post_type <> 'page'"; } else { $tm_pages = ""; } // do we need to exclude current year from query? if ( $options['exclude_current'] == "1" ) { $tm_current = "AND `post_date_gmt` NOT LIKE '".gmdate("Y")."-%-% %:%:%'"; } else { $tm_current = ""; } // setup SQL query $q = "SELECT ID, post_title, post_date, comment_count FROM $wpdb->posts WHERE post_status='publish' AND post_type <> 'attachment' $tm_private $tm_pages AND `post_date` LIKE '$tm_time' $tm_current ORDER BY `post_date` LIMIT ".$options['posts']; // extract WP args extract($args); // execute SQL query and track error $r = $wpdb->get_results($q, OBJECT); // well, to display widget or not? if ( ( $options['showifno'] != "1" && $r ) || $options['showifno'] == "1" ) { // print beginning of widget echo "$before_widget $before_title ".$options['title']." $after_title$after_widget"; } // do not show widget if there is no posts and we don't want to show it // flush SQL query $wpdb->flush(); } // Check for uninstall hook if ( function_exists('register_uninstall_hook') ) register_uninstall_hook(__FILE__, 'tm_uninstall'); // Delete options from database function tm_uninstall() { delete_option("time_machine"); } // initialise Time Machin plugin add_action("widgets_init", "time_machine_init"); ?>