', ']]>', $text);
$text = strip_tags($text, '
');
$excerpt_length = 50;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, ' ... '.__('Continue reading »').'');
$text = implode(' ', $words);
}
echo $text;
}
if ( function_exists('register_sidebars') ) {
register_sidebar(array(
'name' => 'Right',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '',
));
register_sidebar(array(
'name' => 'Middle',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
));
register_sidebar(array(
'name' => 'Left',
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
));
}
register_sidebar_widget('Search', 'search_widget');
function search_widget() { ?>
posts;
//get home url for base of link
$info = get_bloginfo('url');
$info = apply_filters('bloginfo', $info);
$homeurl = convert_chars($info);
$query = $wp_query->query_vars;
$date->month = $query['m'];
$date->year = $query['year'];
$date->monthnum = $query['monthnum'];
if ( $date->monthnum < 10 ) $date->monthnum = "0" . $date->monthnum;
$date->day = $query['day'];
if ( $date->day < 10 ) $date->day = "0" . $date->day;
foreach($date as $key => $value) {
if($value != '' && $value != 0) $m .= $value;
}
if ($m != '') {
switch(strlen($m)) {
case 4:
//archive is year
$m = (int)$m;
$past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year FROM $tableposts WHERE YEAR(post_date) < '".$m."' AND post_type='post' AND post_status='publish' ORDER BY post_date DESC");
if ($past) {
$link = get_year_link($past->year);
$text = $past->year;
}
break;
case 6:
//archive is month
$thisYear = substr($m, 0, 4);
$thisMonth = substr($m, 4, 2);
if (substr($thisMonth,0,1) == '0')
$thisMonth = substr($m, 5, 1);
$thisMonth = (int)$thisMonth;
$thisYear = (int)$thisYear;
$timestamp = mktime(0, 0, 0, $thisMonth, 1, $thisYear);
$currentdate = date("Y-m-d G:i:s", $timestamp);
//echo $currentdate;
$past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year, MONTH(post_date) as month FROM $tableposts WHERE post_date < '".$currentdate."' AND post_type='post' AND post_status='publish' ORDER BY post_date DESC");
$timestampfordisplay = mktime(0,0,0,$past->month,1,$past->year);
$forDisplay = __(date("F", $timestampfordisplay));
$forDisplay .= " ".date("Y", $timestampfordisplay);
if ($past) {
$link = get_month_link($past->year,$past->month);
$text = $forDisplay;
}
break;
case 8:
//archive is day YYYYMMDD
$thisYear = substr($m, 0, 4);
$thisMonth = substr($m, 4, 2);
$thisDay = substr($m, 6, 2);
if (substr($thisDay,0,1) == '0') {
$thisDay = substr($m, 7, 1);
}
if (substr($thisMonth,0,1) == '0') {
$thisMonth = substr($m, 5, 1);
}
$thisDay = (int)$thisDay;
$thisMonth = (int)$thisMonth;
$thisYear = (int)$thisYear;
$timestamp = mktime(0, 0, 0, $thisMonth, $thisDay, $thisYear);
$currentdate = date("Y-m-d G:i:s", $timestamp);
//echo $currentdate;
$past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year, MONTH(post_date) as month, DAYOFMONTH(post_date) as day FROM $tableposts WHERE post_date < '".$currentdate."' AND post_type='post' AND post_status='publish' ORDER BY post_date DESC");
$timestampfordisplay = mktime(0,0,0,$past->month,$past->day,$past->year);
$forDisplay = __(date("F", $timestampfordisplay));
$forDisplay .= " ".date("j, Y", $timestampfordisplay);
if ($past) {
$link = get_day_link($past->year,$past->month,$past->day);
$text = $forDisplay;
}
break;
}
if($user_text != '') $text = str_replace('%title',$text,$user_text);
if($link) echo $before.''.$text.''.$after;
}
}
function next_archive_link($user_text='',$before='', $after='') {
global $wpdb, $tableposts, $wp_query;
if (!isset($tableposts))
$tableposts = $wpdb->posts;
//get home url for base of link
$info = get_bloginfo('url');
$info = apply_filters('bloginfo', $info);
$homeurl = convert_chars($info);
$query = $wp_query->query_vars;
$date->month = $query['m'];
$date->year = $query['year'];
$date->monthnum = $query['monthnum'];
if ( $date->monthnum < 10 ) $date->monthnum = "0" . $date->monthnum;
$date->day = $query['day'];
if ( $date->day < 10 ) $date->day = "0" . $date->day;
foreach($date as $key => $value) {
if($value != '' && $value != 0) $m .= $value;
}
if ($m != '') {
switch(strlen($m)) {
case 4:
//archive is year
$m = (int)$m;
$m++;
$past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year FROM $tableposts WHERE YEAR(post_date) >= '".$m."' AND post_type='post' AND post_status='publish' ORDER BY post_date ASC");
if ($past) {
$link = get_year_link($past->year);
$text = $past->year;
}
break;
case 6:
//archive is month
$thisYear = substr($m, 0, 4);
$thisMonth = substr($m, 4, 2);
if (substr($thisMonth,0,1) == '0')
$thisMonth = substr($m, 5, 1);
$thisMonth = (int)$thisMonth;
$thisYear = (int)$thisYear;
$timestamp = mktime(0, 0, 0, $thisMonth+1, 1, $thisYear);
$currentdate = date("Y-m-d G:i:s", $timestamp);
//echo $currentdate;
$past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year, MONTH(post_date) as month FROM $tableposts WHERE post_date >= '".$currentdate."' AND post_type='post' AND post_status='publish' ORDER BY post_date ASC");
$timestampfordisplay = mktime(0,0,0,$past->month,1,$past->year);
$forDisplay = __(date("F", $timestampfordisplay));
$forDisplay .= " ".date("Y", $timestampfordisplay);
if ($past) {
$link = get_month_link($past->year, $past->month);
$text = $forDisplay;
}
break;
case 8:
//archive is day YYYYMMDD
$thisYear = substr($m, 0, 4);
$thisMonth = substr($m, 4, 2);
$thisDay = substr($m, 6, 2);
if (substr($thisDay,0,1) == '0')
$thisDay = substr($m, 7, 1);
if (substr($thisMonth,0,1) == '0')
$thisMonth = substr($m, 5, 1);
$thisDay = (int)$thisDay;
$thisMonth = (int)$thisMonth;
$thisYear = (int)$thisYear;
$timestamp = mktime(0, 0, 0, $thisMonth, $thisDay+1, $thisYear);
$currentdate = date("Y-m-d G:i:s", $timestamp);
//echo $currentdate;
$past = $wpdb->get_row("SELECT post_date, YEAR(post_date) as year, MONTH(post_date) as month, DAYOFMONTH(post_date) as day FROM $tableposts WHERE post_date >= '".$currentdate."' AND post_type='post' AND post_status='publish' ORDER BY post_date ASC");
$timestampfordisplay = mktime(0,0,0,$past->month,$past->day,$past->year);
$forDisplay = __(date("F", $timestampfordisplay));
$forDisplay .= " ".date("j, Y", $timestampfordisplay);
if ($past) {
$link = get_day_link($past->year,$past->month,$past->day);
$text = $forDisplay;
}
break;
}
if($user_text != '') $text = str_replace('%title',$text,$user_text);
if($link) echo $before.''.$text.''.$after;
}
}
add_action('admin_menu', 'depo_add_theme_page');
function depo_add_theme_page() {
if ( isset( $_GET['page'] ) && $_GET['page'] == basename(__FILE__) ) {
if ( isset( $_POST['action'] ) && 'save' == $_POST['action'] ) {
if(isset($_POST['author-name'])) {
check_admin_referer('depo-name');
if ( '' == $_POST['author-name'] ) {
delete_option('depo-author-name');
} else {
update_option('depo-author-name', attribute_escape($_POST['author-name']));
}
wp_redirect("themes.php?page=functions.php&saved=true");
die;
}
}
}
add_theme_page(__('DePo Options', 'depo-masthead'), __('DePo Options', 'depo-masthead'), 'edit_themes', basename(__FILE__), 'depo_theme_page');
}
function depo_theme_page() {
if ( isset( $_REQUEST['saved'] ) ) echo ''.__('Options saved.', 'depo-masthead').'
';
?>