. See http://diveintomark.org/archives/2002/07/03 // PHP7 compatibility: Since $pn is never passed, we do not need to create "previous" and "next" elements. $p = '« '; $n = ' »'; // Commented out to prevent deprecated each() function from being executed. // @list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable // if($p) $p = ''.($pl ? ''.$p.'' : $p).' '; // if($n) $n = ' '.($nl ? ''.$n.'' : $n).''; $calendar = '' . "\n" . '\n"; if ($day_name_length) { // if the day names should be shown ($day_name_length > 0) // if day_name_length is >3, the full name of the day will be printed foreach ($day_names as $d) $calendar .= ''; $calendar .= "\n"; } if ($weekday > 0) $calendar .= ''; // initial 'empty' days for($day = 1, $days_in_month = gmdate('t', $first_of_month); $day <= $days_in_month; $day++, $weekday++) { if ($weekday == 7) { $weekday = 0; // start a new week $calendar .= "\n"; } if (isset($days [$day]) and is_array($days [$day])) { @list ($link, $classes, $content) = $days [$day]; if (is_null($content)) $content = $day; $calendar .= '' : '>') . ($link ? '' . $content . '' : $content) . ''; } else $calendar .= ""; } if ($weekday != 7) $calendar .= ''; // remaining "empty" days return $calendar . "\n
' . $p . ($month_href ? '' . $title . '' : $title) . $n . "
' . htmlentities($day_name_length < 4 ? mb_substr($d, 0, $day_name_length, 'UTF-8') : $d) . '
 
$day 
\n"; } function plugin_calendar_widget() { global $fp_params; $y = isset($fp_params ['y']) ? $fp_params ['y'] : date('y'); $m = isset($fp_params ['m']) ? $fp_params ['m'] : date('m'); global $fpdb; $q = new FPDB_Query(array( 'fullparse' => false, 'y' => $y, 'm' => $m, 'count' => -1 ), null); $days = array(); while ($q->hasmore()) { list ($id, $entry) = $q->getEntry(); $date = date_from_id($id); $d = (int) $date ['d']; $days [$d] = array( get_day_link($y, $m, str_pad($d, 2, '0', STR_PAD_LEFT)), 'linked-day' ); } // load plugin strings // they're located under plugin.PLUGINNAME/lang/LANGID/ $lang = lang_load('plugin:calendar'); $widget = array(); $widget ['subject'] = $lang ['plugin'] ['calendar'] ['subject']; $widget ['content'] = ''; return $widget; } register_widget('calendar', 'Calendar', 'plugin_calendar_widget');