for posts and comments.
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'title-tag' );
// Adds support for a custom header image.
add_theme_support( 'custom-header', array(
// Text color and image (empty to use none).
'default-text-color' => '333333',
'default-image' => '',
// Set height and width, with a maximum value for the width.
'height' => 128,
'width' => 960,
'max-width' => 960,
// Support flexible height and width.
'flex-height' => true,
'flex-width' => false,
// Random image rotation off by default.
'random-default' => false,
// Callbacks for styling the header and the admin preview.
'wp-head-callback' => 'blogotron_header_style',
'admin-head-callback' => 'blogotron_admin_header_style',
'admin-preview-callback' => 'blogotron_admin_header_image',
) );
// This theme supports custom background color and image
add_theme_support( 'custom-background', array(
'default-color' => 'f5f5f5',
)
);
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
// This theme uses wp_nav_menu() in one location.
register_nav_menu( 'main', __( 'Main Menu', 'blogotron' ) );
// This theme uses a custom image size for featured images, displayed on "standard" posts.
add_theme_support( 'post-thumbnails' );
add_image_size( 'post-featured-image', 528, 9999 ); // Unlimited height, soft crop
// Adds support Shortcodes in sidebar widgets.
add_filter( 'widget_text', 'do_shortcode' );
}
// Registers main widget area area.
function blogotron_sidebar() {
register_sidebar( array(
'name' => __( 'Main Sidebar', 'blogotron' ),
'id' => 'main-sidebar',
'description' => __( 'Widgets for the sidebar.', 'blogotron' ),
'before_widget' => '',
'before_title' => '
',
) );
}
// Enqueues scripts and styles for front-end.
function blogotron_scripts_styles() {
// Loads our main stylesheet.
wp_enqueue_style( 'blogotron-style', get_stylesheet_uri() );
//Adds main JavaScript.
wp_enqueue_script( 'blogotron-script', get_template_directory_uri() . '/js/script.js', array( 'jquery' ), null, false );
// Enqueue JavaScript translated variables.
$string_js = array(
'iFileBrowse' => __( 'Choose file...', 'blogotron' ),
'iFileNotSelected' => __( 'File is not selected.', 'blogotron' ),
'iSearchText' => __( 'Enter search keyword', 'blogotron' ),
);
wp_localize_script( 'blogotron-script', 'blogotronStringJs', $string_js );
// Loads the Internet Explorer specific stylesheet.
wp_enqueue_style( 'blogotron-ie-style', get_template_directory_uri() . '/styles/ie.css', false, null );
wp_style_add_data( 'blogotron-ie-style', 'conditional', 'lt IE 9' );
// Adds JavaScript to pages with the comment form to support sites with threaded comments (when in use).
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
// Style the header text displayed on the blog.
function blogotron_header_style() {
$text_color = get_header_textcolor();
// If no custom options for text are set, let's bail
if ( get_theme_support( 'custom-header', 'default-text-color' ) == $text_color ) {
return;
}
// If we get this far, we have custom styles. ?>
Header admin panel.
function blogotron_admin_header_style() { ?>
Header admin panel.
function blogotron_admin_header_image() { ?>
', '« %title' );
previous_post_link( '%link
', '%title »' ); ?>
ID );
$thumbnail_image = get_posts( array( 'p' => $thumbnail_id, 'post_type' => 'attachment' ) );
if ( ! empty( $thumbnail_image[0]->post_excerpt ) ) {
printf( '%s
', $thumbnail_image[0]->post_excerpt );
}
}
// Get attachment image, caption and metadata.
function blogotron_the_attachment() {
global $post;
$attachment = wp_prepare_attachment_for_js( get_the_ID() ); ?>
![<?php echo $attachment['title']; ?> <?php echo $attachment['title']; ?>](<?php echo $attachment['url']; ?>)
%s', $attachment['caption'] );
} ?>
comment_type ) :
case 'pingback' :
case 'trackback' :
// Display trackbacks differently than normal comments. ?>
id="comment-">
id="li-comment-">
comment_type
}
add_action( 'after_setup_theme', 'blogotron_setup' );
add_action( 'widgets_init', 'blogotron_sidebar' );
add_action( 'wp_enqueue_scripts', 'blogotron_scripts_styles' );
add_filter( 'comment_class', 'blogotron_comment_class' );
add_action( 'blogotron_page_nav', 'blogotron_page_nav' );
add_action( 'blogotron_post_nav', 'blogotron_post_nav' );
add_action( 'blogotron_the_thumbnail_caption', 'blogotron_the_thumbnail_caption' );
add_action( 'blogotron_the_attachment', 'blogotron_the_attachment' );