das hab ich entdeckt, und find ich klasse:
http://www.sargant.com/blog/archives/2006/03/rs-event-05/
Was muß ich ändern, damit sich die termine jährlich wiederholen?
PHP
<?php
/*
Plugin Name: RS Event
Plugin URI: http://www.sargant.com/blog/archives/2006/03/rs-event-05/
Description: Adds an "RS Events" panel to the posting sidebar, allowing for a date to be set for the post and then displayed in the blog sidebar.
Author: Robert Sargant
Version: 0.5
Author URI: http://www.sargant.com/
*/
/**
* RS Event (C) Robert Sargant 2006
* Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.0 England & Wales License
* http://creativecommons.org/licenses/by-nc-sa/2.0/uk/
*/
/**
* Add the RS Event controls to the posting sidebar
*/
add_action('dbx_post_sidebar', 'rs_event_sidebar_controls');
/**
* Manipulate RS Event data when modifying posts
*/
add_action('edit_post', 'rs_event_save');
add_action('save_post', 'rs_event_save');
add_action('publish_post', 'rs_event_save');
/**
* RS Event Sidebar Controls
*
* Inserts some drop-down menus as an extra posting sidebar panel.
*/
function rs_event_sidebar_controls()
{
/**
* If there are existing post details, get values to autofill the form
*/
if(isset($_REQUEST['post']))
{
$event_timestamp = get_post_meta($_REQUEST['post'], "rs_event");
if($event_timestamp)
{
list($year, $month, $day, $hour, $minute) = explode(" ", date("Y n j G i", $event_timestamp[0]));
// Cast as int to get rid of the zero
$hour = (int)$hour;
$minute = (int)$minute;
}
}
?>
<fieldset id="rs_events_dbx" class="dbx-box">
<h3 class="dbx-handle">RS Event</h3>
<div class="dbx-content">
<?php _e('Date:') ?>
<br />
<select name="rs_events_day" style="width: 4.5em">
<option value=""><?php _e('Day') ?></option>
<option value="">----</option>
<?php for($d = 1; $d <= 31; $d++) { ?>
<?php if($d == $day) { ?>
<option selected="selected" value="<?php echo $d ?>"><?php echo $d ?></option>
<?php } else { ?>
<option value="<?php echo $d ?>"><?php echo $d ?></option>
<?php } ?>
<?php } ?>
</select>
<select name="rs_events_month" style="width: 6em;">
<option value=""><?php _e('Month') ?></option>
<option value="">----</option>
<?php foreach(array( 1 => "Jan", 2 => "Feb", 3 => "März", 4 => "Apr", 5 => "Mai", 6 => "Jun", 7 => "Jul", 8 => "Aug", 9 => "Sep", 10 => "Okt", 11 => "Nov", 12 => "Dez") as $id => $m) { ?>
<?php if($id == $month) { ?>
<option selected="selected" value="<?php echo $id ?>"><?php _e($m) ?></option>
<?php } else { ?>
<option value="<?php echo $id ?>"><?php _e($m) ?></option>
<?php } ?>
<?php } ?>
</select>
<br />
<select name="rs_events_year" style="width: 7em;">
<option value=""><?php _e('Year') ?></option>
<option value="">----</option>
<?php for($y = date("Y")-1; $y <= date("Y")+12; $y++) { ?>
<?php if($y == $year) { ?>
<option selected="selected" value="<?php echo $y ?>"><?php echo $y ?></option>
<?php } else { ?>
<option value="<?php echo $y ?>"><?php echo $y ?></option>
<?php } ?>
<?php } ?>
</select>
<br />
<br />
<?php _e('Time:') ?>
<br />
<select name="rs_events_hour" style="width: 5em;">
<option value=""><?php _e('Hour') ?></option>
<option value="">----</option>
<?php for($h = 0; $h <= 23; $h++) { ?>
<?php if($h === $hour) { ?>
<option selected="selected" value="<?php echo $h ?>"><?php echo str_pad($h, 2, "0", STR_PAD_LEFT) ?></option>
<?php } else { ?>
<option value="<?php echo $h ?>"><?php echo str_pad($h, 2, "0", STR_PAD_LEFT) ?></option>
<?php } ?>
<?php } ?>
</select>
<select name="rs_events_minute" style="width: 5em;">
<option value=""><?php _e('Min') ?></option>
<option value="">----</option>
<?php for($mi = 0; $mi <= 55; $mi = $mi + 5) { ?>
<?php if($mi === $minute) { ?>
<option selected="selected" value="<?php echo $mi ?>"><?php echo str_pad($mi, 2, "0", STR_PAD_LEFT) ?></option>
<?php } else { ?>
<option value="<?php echo $mi ?>"><?php echo str_pad($mi, 2, "0", STR_PAD_LEFT) ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
</fieldset>
<?php
}
function rs_event_save($id)
{
if(!isset($id))
{
$id = $_REQUEST['post_ID'];
}
if($_REQUEST['rs_events_delete'])
{
delete_post_meta($id, "rs_event");
return true;
}
elseif($_REQUEST['rs_events_year'] && $_REQUEST['rs_events_month'] && $_REQUEST['rs_events_day'])
{
$hour = ($_REQUEST['rs_events_hour']) ? $_REQUEST['rs_events_hour'] : 0;
$minute = ($_REQUEST['rs_events_hour']) ? $_REQUEST['rs_events_minute'] : 0;
$ts = mktime($hour, $minute, 0, $_REQUEST['rs_events_month'], $_REQUEST['rs_events_day'], $_REQUEST['rs_events_year']);
delete_post_meta($id, "rs_event");
add_post_meta($id, "rs_event", $ts);
return true;
}
}
function rs_event_list($args = array())
{
global $wpdb;
$timespan = (isset($args['timespan'])) ? $args['timespan'] : 28 * 24 * 60 * 60;
$date_format = (isset($args['date_format'])) ? $args['date_format'] : "d. F Y";
$time_format = (isset($args['time_format'])) ? $args['time_format'] : "H:i";
$group_by_date = (isset($args['group_by_date'])) ? $args['group_by_date'] : false;
$event_html = (isset($args['event_html'])) ? $args['event_html'] : "%DATE%: <a href='%URL%'>%TITLE%</a>";
$max_events = (isset($args['max_events'])) ? $args['max_events'] : 0;
$lower_time = time();
$upper_time = time() + $timespan;
$query_string = "SELECT
meta.meta_value as date,
post.post_title as title,
post.ID as id
FROM
{$wpdb->postmeta} as meta,
{$wpdb->posts} as post
WHERE
meta.post_id = post.ID
AND
meta.meta_key = 'rs_event'
AND
meta.meta_value >= {$lower_time}
AND
meta.meta_value <= {$upper_time}
ORDER BY
meta.meta_value ASC";
/**
* 0.5.1 - Allow event limiting
*/
if($max_events != 0)
{
$query_string .= " LIMIT {$max_events}";
}
$event_list = $wpdb->get_results($query_string);
echo "<li>";
/**
* If the query has returned an array, do stuff
*/
if(is_array($event_list))
{
/**
* To store previous dates if we have $group_by_date turned on
*/
$previous_date = false;
/**
* Loop through each event
*/
foreach($event_list as $event)
{
/**
* Format the date/time/HTML now
*/
$output_date = date($date_format, $event->date);
$output_time = date($time_format, $event->date);
$output_html = str_replace(array("%URL%", "%DATE%", "%TIME%", "%TITLE%"), array(get_permalink($event->id), $output_date, $output_time, $event->title), $event_html);
/**
* If we are not grouping by date, output as a list item now.
*/
if($group_by_date == false)
{
/**
* If this is not the first entry, output list tags
*/
if($previous_date == true)
{
echo "</li><li>";
}
else
{
$previous_date = true;
}
echo $output_html;
}
/**
* If we are grouping by date
*/
else
{
/**
* If this is a new date, print it
*/
if($output_date != $previous_date)
{
/**
* If this is not the first new date, close and reopen list tags
*/
if($previous_date)
{
echo "</li><li>";
}
echo "$output_date<br />";
$previous_date = $output_date;
}
echo "$output_html<br />";
}
}
}
/**
* If no array returned, say nothing
*/
else
{
_e('Es liegt derzeit nichts an.');
}
echo "</li>";
}
?>
Alles anzeigen