Here is my functions php for reference :
<?php
define('THEMEROOT', get_stylesheet_directory_uri());
define('IMAGES', THEMEROOT . '/images');
if ( function_exists('register_sidebar') )
register_sidebar();
function arphabet_widgets_init(){
register_sidebar(array(
'top-menu' => __('Top Menu', 'PLUM_THEME-framework'),
'main-menu' => __('Main Menu', 'PLUM_THEME-framework'),
));
}
add_action('widgets_init', 'arphabet_widgets_init');
if (function_exists('register_sidebar')) {
register_sidebar(
array(
'name' => __('Sidebar', 'PLUM_THEME-framework'),
'id' => 'sidebar',
'description' => __('The main sidebar area', 'PLUM_THEME-framework'),
'before_widget' => '<div class="sidebar-widget">',
'after_widget' => '</div> <!--end sidebar-widget-->',
'before_title' => '<h4>',
'after_title' => '</>',
));
}
if (function_exists('add_theme_support')) {
add_theme_support('post-formats', array('link', 'quote', 'gallery'));
add_theme_support('post-thumbnails', array('post'));
}
$wp_filetype = wp_check_filetype(basename($filename), null );
$wp_upload_dir = wp_upload_dir();
$attachment = array(
'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ),
'post_mime_type' => $wp_filetype['type'],
'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
'post_content' => '',
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment( $attachment, $filename, 37 );
// you must first include the image.php file
// for the function wp_generate_attachment_metadata() to work
require_once(ABSPATH . 'wp-admin/includes/image.php');
$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
wp_update_attachment_metadata( $attach_id, $attach_data );
add_post_meta($post_id, '_thumbnail_id', $attach_id);
function plum_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
if (get_comment_type() == 'pingback' || get_comment_type() == 'trackback') : ?>
trackbacks
<?php elseif (get_comment_type() == 'comment') : ?>
comment
<?php endif;
}
?>