.
* @see https://codex.wordpress.org/Title_Tag
*/
add_theme_support( 'title-tag' );
/**
* Shell is now available for translations.
* Add your files into /languages/ directory.
*/
load_theme_textdomain( 'shell', get_template_directory() . '/languages' );
$locale = get_locale();
$locale_file = get_template_directory() . "/languages/$locale.php";
if ( is_readable( $locale_file ) ) {
require_once( $locale_file );
}
/**
* Add callback for custom TinyMCE editor stylesheets. (editor-style.css)
* @see http://codex.wordpress.org/Function_Reference/add_editor_style
*/
add_editor_style();
/**
* This feature enables post and comment RSS feed links to head.
* @see http://codex.wordpress.org/Function_Reference/add_theme_support#Feed_Links
*/
add_theme_support( 'automatic-feed-links' );
/**
* This feature enables post-thumbnail support for a theme.
* @see http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
/**
* This feature enables custom-menu support for a theme.
* @see http://codex.wordpress.org/Template_Tags/register_nav_menu
*/
register_nav_menu( 'primary', __( 'Primary Menu', 'shell' ) );
// WordPress 3.4+
if ( function_exists( 'get_custom_header' ) ) {
add_theme_support('custom-background');
}
// WordPress 3.4+
if ( function_exists( 'get_custom_header' ) ) {
add_theme_support( 'custom-header', array (
// Header image default
'default-image' => get_template_directory_uri() . '/images/default-logo.png',
// Header text display default
'header-text' => false,
// Header image flex width
'flex-width' => true,
// Header image width (in pixels)
'width' => 200,
// Header image flex height
'flex-height' => true,
// Header image height (in pixels)
'height' => 100,
// Admin header style callback
'admin-head-callback' => 'shell_admin_header_style'
));
// gets included in the admin header
function shell_admin_header_style() {
?>
';
global $post;
$homeLink = home_url();
echo '
' . $home . ' ' . $chevron . ' ';
if ( is_category() ) {
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$thisCat = $cat_obj->term_id;
$thisCat = get_category( $thisCat );
$parentCat = get_category($thisCat->parent);
if ( $thisCat->parent != 0 ) {
echo( get_category_parents( $parentCat, TRUE, ' ' . $chevron . ' ' ) );
}
echo $before . __( 'Archive for ','shell' ) . single_cat_title( '', false ) . $after;
} elseif ( is_day() ) {
echo '
' . get_the_time('Y') . ' ' . $chevron . ' ';
echo '
' . get_the_time('F') . ' ' . $chevron . ' ';
echo $before . get_the_time('d') . $after;
} elseif ( is_month() ) {
echo '
' . get_the_time('Y') . ' ' . $chevron . ' ';
echo $before . get_the_time('F') . $after;
} elseif ( is_year() ) {
echo $before . get_the_time('Y') . $after;
} elseif ( is_single() && !is_attachment() ) {
if ( get_post_type() != 'post' ) {
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo '
' . $post_type->labels->singular_name . ' ' . $chevron . ' ';
echo $before . get_the_title() . $after;
} else {
$cat = get_the_category(); $cat = $cat[0];
echo get_category_parents($cat, TRUE, ' ' . $chevron . ' ');
echo $before . get_the_title() . $after;
}
} elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
$post_type = get_post_type_object(get_post_type());
echo $before . $post_type->labels->singular_name . $after;
} elseif ( is_attachment() ) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID); $cat = $cat[0];
echo get_category_parents($cat, TRUE, ' ' . $chevron . ' ');
echo '
' . $parent->post_title . ' ' . $chevron . ' ';
echo $before . get_the_title() . $after;
} elseif ( is_page() && !$post->post_parent ) {
echo $before . get_the_title() . $after;
} elseif ( is_page() && $post->post_parent ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '
' . get_the_title($page->ID) . '';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $chevron . ' ';
echo $before . get_the_title() . $after;
} elseif ( is_search() ) {
echo $before . __('Search results for ','shell') . get_search_query() . $after;
} elseif ( is_tag() ) {
echo $before . __('Posts tagged ','shell') . single_tag_title('', false) . $after;
} elseif ( is_author() ) {
global $author;
$userdata = get_userdata($author);
echo $before . __('All posts by ','shell') . $userdata->display_name . $after;
} elseif ( is_404() ) {
echo $before . __('Error 404 ','shell') . $after;
}
if ( get_query_var('paged') ) {
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
echo __('Page','shell') . ' ' . get_query_var('paged');
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
}
echo '
';
}
}
/**
* A safe way of adding javascripts to a WordPress generated page.
*/
if (!is_admin())
add_action('wp_print_scripts', 'shell_js');
if (!function_exists('shell_js')) {
function shell_js() {
// JavaScript at the bottom for fast page loading.
// except for Modernizr which enables HTML5 elements & feature detects.
wp_enqueue_script('modernizr', get_template_directory_uri() . '/js/modernizr.js', array('jquery'), '2.5.3', false);
wp_enqueue_script('scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '1.0.5', true);
}
}
/**
* Where the post has no post title, but must still display a link to the single-page post view.
*/
add_filter('the_title', 'shell_title');
function shell_title($title) {
if ($title == '') {
return 'Untitled';
} else {
return $title;
}
}
/**
* WordPress Widgets start right here.
*/
function shell_widgets_init() {
register_sidebar(array(
'name' => __('Primary Sidebar Widget', 'shell'),
'description' => __('Area One Primary Widget', 'shell'),
'id' => 'primary-sidebar-widget',
'before_title' => '