';
}
echo $after_widget;
}
function widget_articles2sidebar($args) {
if (is_page()) {
extract($args);
$options = get_option('widget_articles2sidebar');
if ( !is_array($options) )
$options = array('origin'=>'auto', 'cat' => '', 'link' => 1, 'lmtext' => __('Learn more').' »', 'rmtext' => __('Read more').' »');
$options['link'] = $options['link'];
$options['lmtext'] = htmlspecialchars($options['lmtext'], ENT_QUOTES);
$options['rmtext'] = htmlspecialchars($options['lmtext'], ENT_QUOTES);
switch($options['origin']) {
case 'auto':
case 'both':
case 'page':
// retrieve the category that correspond to the page title
$cat = get_category_by_slug(the_title('','',false));
if ($cat) {
// retrieve that category's posts
$a2sposts = get_posts('category='.$cat->term_id.'&orderby=ID&order=ASC');
foreach ($a2sposts as $a2spost) {
// dislay them
widget_articles2sidebar_content($a2spost,$options,$before_widget,$before_title,$after_title,$after_widget);
}
}
case 'auto':
if (count($a2sposts)) break;
case 'both':
case 'cat':
// retrieve the categories
$cats = get_categories();
foreach ($cats as $cat) {
// retrieve the posts
if ($cat->cat_name == $options['cat']) {
$a2sposts = get_posts('category='.$cat->cat_ID.'&orderby=ID&order=ASC');
foreach ($a2sposts as $a2spost) {
// dislay them
widget_articles2sidebar_content($a2spost,$options,$before_widget,$before_title,$after_title,$after_widget);
}
break;
}
}
}
}
}
function widget_articles2sidebar_control() {
$options = get_option('widget_articles2sidebar');
if ( !is_array($options) )
$options = array('origin'=>'auto', 'cat' => '', 'link' => 1, 'lmtext' => __('Learn more').' »', 'rmtext' => __('Read more').' »');
if ( $_POST['articles2sidebar-submit'] ) {
$options['origin'] = strip_tags(stripslashes($_POST['articles2sidebar-origin']));
$options['cat'] = strip_tags(stripslashes($_POST['articles2sidebar-cat']));
(intval($_POST['articles2sidebar-link'])>0) ? $options['link'] = 1 : $options['link'] = 0;
$options['lmtext'] = strip_tags(stripslashes($_POST['articles2sidebar-lmtext']));
$options['rmtext'] = strip_tags(stripslashes($_POST['articles2sidebar-rmtext']));
if (strip_tags(stripslashes($_POST['articles2sidebar-cat2'])) != '') $options['cat'] = strip_tags(stripslashes($_POST['articles2sidebar-cat2']));
update_option('widget_articles2sidebar', $options);
}
$origin = $options['origin'];
$cat = htmlspecialchars($options['cat'], ENT_QUOTES);
$link = $options['link'];
$lmtext = htmlspecialchars($options['lmtext'], ENT_QUOTES);
$rmtext = htmlspecialchars($options['rmtext'], ENT_QUOTES);
?>
=__('Automatic:')?>
=__('The widget will look for articles in the specified category, if there are none, the widget will look for articles from a category called as the current page.')?>
=__('Both:')?>
=__('The widget will look for articles in the specified category AND articles from a category called as the current page.')?>
=__('Category:')?>
=__('The widget will look for articles in the specified category.')?>
=__('Page:')?>
=__('The widget will look for articles from a category called as the current page.')?>