XyzzyB DateDiff Wordpress Plugin
A wordpress plugin to display the difference in days between the current date and specified dates (either upcoming or previous).
Current version:
1.6
Changelog
1.5 -> 1.6
Bugfix
- updated to fix database creation in Wordpress 2.1
Note
1.4 -> 1.5
Features Added
- options for text directly after current, upcoming, and past events
- option to add the text before or after the recurring (year)
- only displays IF show year for recurring events is selected
- option to show recurring events (yes, no)
- option for current event list header text
UI Changes
- options page design tweaks
- change order of past events option now only displays if event order is set to "Number of Days"
Bugfixes
- slashes are now striped from event titles (e.g. Sarah's Birthday would previously display as Sarah/'s Birthday)
Installation
Plugin Setup
- Download the plugin file xyzzyb_datediff.php
- NOTE: if you are using Wordpress 1.* download xyzzyb_datediff_1.5.php
- when uploading to your blog, rename this file from xyzzyb_datediff_1.5.php to xyzzyb_datediff.php
- Upload the file to your WordPress plugins directory (wp-content/plugins)
- Open your Manage Plugins WordPress page
- Locate XyzzyB DateDiff and click Activate
- Note: Installing this plugin will create a new table called [your database prefix]xyzzyb_datediff in your WordPress database. This table is used to store the event information.
Sidebar Setup
- Open the sidebar file (usually sidebar.php) for your theme and add the following text where you want the plugin:
<li>
<?php
if (function_exists('xyzzyb_datediff_display')) xyzzyb_datediff_display
();
?>
</li>
Of course the "li" tags are only necessary if you are placing the the function within the sidebar list.
- Setup the plugin options however you like (XyzzyB DateDiff tab in Options)
Style Setup
- Add (and customize) the following to your theme's 'style.css'
/* XyzzyB Datediff */
/* classes:
* xyzzyb_datediff_list : the ul list that contains all the events
* xyzzyb_datediff_current_event : the event text for an event occuring on the current date
* xyzzyb_datediff_upcoming_event : the event text for an upcoming event
* xyzzyb_datediff_past_event : the event text for a past event
* xyzzyb_datediff_days_until : the number of days until an upcoming event
* xyzzyb_datediff_days_since : the number of days since a past event
*/
.xyzzyb_datediff_list {
font-size: .8em;
}
.xyzzyb_datediff_current {
background-color: #3eb938;
padding: 4px;
font-weight: 600;
color: white;
}
.xyzzyb_datediff_current_event {
}
.xyzzyb_datediff_days_until {
border: 1px solid black;
padding-right: .2em;
padding-left: .2em;
padding-bottom: .1em;
font-weight: 600;
font-size: 1.3em;
background-color: #abeeaa;
color: #000;
}
.xyzzyb_datediff_days_since {
border: 1px solid black;
padding-right: .2em;
padding-left: .2em;
padding-bottom: .1em;
font-weight: 600;
font-size: 1.3em;
background-color: #ff6200;
color: #000;
}
.xyzzyb_datediff_upcoming_event {
color: #548239;
font-weight: 600;
}
.xyzzyb_datediff_past_event {
color: #c35226;
font-weight: 600;
}
Adding Dates
- Go to the plugin's options page
- Under Add New Event type in an event, the event's date in YYYY-MM-DD format, e.g. 2006-10-01 (Note: leading zeros in the month or day are optional)
- Check the box if you want this event to show up every year (birthdays, holidays)
- Click the Update button
Styling
Here are the css classes built into the plugin. Modify your css file (usually style.css) to theme how the plugin displays its data.
- xyzzyb_datediff_list : the ul list that contains all the events
- xyzzyb_datediff_current : the full text for an event occuring on the current date
- xyzzyb_datediff_current_event : the event text for an event occuring on the current date
- xyzzyb_datediff_upcoming_event : the event text for an upcoming event
- xyzzyb_datediff_past_event : the event text for a past event
- xyzzyb_datediff_days_until : the number of days until an upcoming event
- xyzzyb_datediff_days_since : the number of days since a past event
Uninstallation
- Deactivate the plugin.
- Remove the plugin related text you added to the sidebar
Code
Source code for XyzzyB DateDiff.
CategoryProgrammingPHP CategoryProgrammingSQL
There are 7 comments on this page. [Display comments]