1280, 'height' => 400, 'header-text' => false );
add_theme_support( 'custom-header', $custom_header_args );
// Add nav menu
register_nav_menu( 'primary', 'Primary Menu' );
// Make the theme translation ready
load_theme_textdomain('hemingway', get_template_directory() . '/languages');
$locale = get_locale();
$locale_file = get_template_directory() . "/languages/$locale.php";
if ( is_readable($locale_file) )
require_once($locale_file);
}
// Enqueue Javascript files
function hemingway_load_javascript_files() {
if ( !is_admin() )
wp_register_script( 'hemingway_global', get_template_directory_uri().'/js/global.js', array('jquery'), '', true );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'hemingway_global' );
}
add_action( 'wp_enqueue_scripts', 'hemingway_load_javascript_files' );
// Enqueue styles
function hemingway_load_style() {
if ( !is_admin() )
wp_register_style('hemingway_googleFonts', 'http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Raleway:700,400' );
wp_register_style('hemingway_style', get_stylesheet_uri() );
wp_enqueue_style( 'hemingway_googleFonts' );
wp_enqueue_style( 'hemingway_style' );
}
add_action('wp_print_styles', 'hemingway_load_style');
// Add footer widget areas
add_action( 'widgets_init', 'hemingway_sidebar_reg' );
function hemingway_sidebar_reg() {
register_sidebar(array(
'name' => __( 'Footer A', 'hemingway' ),
'id' => 'footer-a',
'description' => __( 'Widgets in this area will be shown in the left column in the footer.', 'hemingway' ),
'before_title' => '
',
'after_title' => '
',
'before_widget' => '
',
'after_widget' => '
'
));
register_sidebar(array(
'name' => __( 'Footer B', 'hemingway' ),
'id' => 'footer-b',
'description' => __( 'Widgets in this area will be shown in the middle column in the footer.', 'hemingway' ),
'before_title' => '
',
'after_title' => '
',
'before_widget' => '
',
'after_widget' => '
'
));
register_sidebar(array(
'name' => __( 'Footer C', 'hemingway' ),
'id' => 'footer-c',
'description' => __( 'Widgets in this area will be shown in the right column in the footer.', 'hemingway' ),
'before_title' => '
',
'after_title' => '
',
'before_widget' => '
',
'after_widget' => '
'
));
register_sidebar(array(
'name' => __( 'Sidebar', 'hemingway' ),
'id' => 'sidebar',
'description' => __( 'Widgets in this area will be shown in the sidebar.', 'hemingway' ),
'before_title' => '
',
'after_title' => '
',
'before_widget' => '
',
'after_widget' => '
'
));
}
// Add theme widgets
require_once (get_template_directory() . "/widgets/dribbble-widget.php");
require_once (get_template_directory() . "/widgets/flickr-widget.php");
require_once (get_template_directory() . "/widgets/video-widget.php");
// Set content-width
if ( ! isset( $content_width ) ) $content_width = 676;
// Custom title function
function hemingway_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() )
return $title;
// Add the site name.
$title .= get_bloginfo( 'name' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title = "$title $sep $site_description";
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 )
$title = "$title $sep " . sprintf( __( 'Page %s', 'hemingway' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'hemingway_wp_title', 10, 2 );
// Add classes to next_posts_link and previous_posts_link
add_filter('next_posts_link_attributes', 'hemingway_posts_link_attributes_1');
add_filter('previous_posts_link_attributes', 'hemingway_posts_link_attributes_2');
function hemingway_posts_link_attributes_1() {
return 'class="post-nav-older"';
}
function hemingway_posts_link_attributes_2() {
return 'class="post-nav-newer"';
}
// Menu walker adding "has-children" class to menu li's with children menu items
class hemingway_nav_walker extends Walker_Nav_Menu {
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
$id_field = $this->db_fields['id'];
if ( !empty( $children_elements[ $element->$id_field ] ) ) {
$element->classes[] = 'has-children';
}
Walker_Nav_Menu::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
}
// Add class to body if the post/page has a featured image
add_action('body_class', 'hemingway_if_featured_image_class' );
function hemingway_if_featured_image_class($classes) {
if ( has_post_thumbnail() ) {
array_push($classes, 'has-featured-image');
}
return $classes;
}
// Custom more-link text
add_filter( 'the_content_more_link', 'hemingway_custom_more_link', 10, 2 );
function hemingway_custom_more_link( $more_link, $more_link_text ) {
return str_replace( $more_link_text, __('Continue reading', 'hemingway'), $more_link );
}
// Remove inline styling of attachment
add_shortcode('wp_caption', 'hemingway_fixed_img_caption_shortcode');
add_shortcode('caption', 'hemingway_fixed_img_caption_shortcode');
function hemingway_fixed_img_caption_shortcode($attr, $content = null) {
if ( ! isset( $attr['caption'] ) ) {
if ( preg_match( '#((?:]+>\s*)?]+>(?:\s*)?)(.*)#is', $content, $matches ) ) {
$content = $matches[1];
$attr['caption'] = trim( $matches[2] );
}
}
$output = apply_filters('img_caption_shortcode', '', $attr, $content);
if ( $output != '' ) return $output;
extract(shortcode_atts(array(
'id' => '',
'align' => 'alignnone',
'width' => '',
'caption' => ''
), $attr));
if ( 1 > (int) $width || empty($caption) )
return $content;
if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
return '
'
. do_shortcode( $content ) . '
' . $caption . '
';
}
// Style the admin area
function hemingway_custom_colors() {
echo '';
}
add_action('admin_head', 'hemingway_custom_colors');
// hemingway comment function
if ( ! function_exists( 'hemingway_comment' ) ) :
function hemingway_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
array( // on allow a tags
'href' => array() // and those anchords can only have href attribute
)
);
// Probably a good idea to make sure the data is set
if( isset( $_POST['videourl'] ) )
update_post_meta( $post_id, 'videourl', wp_kses( $_POST['videourl'], $allowed ) );
}
?>