'F9F9F9' );
add_theme_support( 'custom-background', $defaults );
// Jetpack infinite scroll
add_theme_support( 'infinite-scroll', array(
'container' => 'posts',
'footer' => 'wrapper',
'type' => 'click'
) );
// Add support for title-tag
add_theme_support('title-tag');
// Add nav menu
register_nav_menu( 'primary', __('Primary Menu','hoffman') );
register_nav_menu( 'social', __('Social Menu','hoffman') );
// Set content-width
global $content_width;
if ( ! isset( $content_width ) ) $content_width = 700;
// Make the theme translation ready
load_theme_textdomain('hoffman', get_template_directory() . '/languages');
$locale = get_locale();
$locale_file = get_template_directory() . "/languages/$locale.php";
if ( is_readable($locale_file) )
require_once($locale_file);
}
// Register and enqueue Javascript files
function hoffman_load_javascript_files() {
if ( !is_admin() ) {
wp_enqueue_script( 'hoffman_flexslider', get_template_directory_uri().'/js/flexslider.min.js', array('jquery'), '', true );
wp_enqueue_script( 'hoffman_global', get_template_directory_uri().'/js/global.js', array('jquery'), '', true );
if ( is_singular() ) {
wp_enqueue_script( "comment-reply" );
}
}
}
add_action( 'wp_enqueue_scripts', 'hoffman_load_javascript_files' );
// Register and enqueue styles
function hoffman_load_style() {
if ( !is_admin() ) {
wp_enqueue_style( 'hoffman_googleFonts', '//fonts.googleapis.com/css?family=Raleway:400,600,700,800|Vollkorn:400,400italic,700,700italic' );
wp_enqueue_style( 'hoffman_genericons', get_template_directory_uri() . '/genericons/genericons.css' );
wp_enqueue_style( 'hoffman_style', get_stylesheet_uri() );
}
}
add_action('wp_print_styles', 'hoffman_load_style');
// Add editor styles
function hoffman_add_editor_styles() {
add_editor_style( 'hoffman-editor-styles.css' );
$font_url = '//fonts.googleapis.com/css?family=Raleway:400,600,700,800|Vollkorn:400,400italic,700,700italic';
add_editor_style( str_replace( ',', '%2C', $font_url ) );
}
add_action( 'init', 'hoffman_add_editor_styles' );
// Add footer widget areas
add_action( 'widgets_init', 'hoffman_widget_areas_reg' );
function hoffman_widget_areas_reg() {
register_sidebar(array(
'name' => __( 'Footer A', 'hoffman' ),
'id' => 'footer-a',
'description' => __( 'Widgets in this area will be shown in the left column in the footer.', 'hoffman' ),
'before_title' => '
',
'before_widget' => ''
));
register_sidebar(array(
'name' => __( 'Footer B', 'hoffman' ),
'id' => 'footer-b',
'description' => __( 'Widgets in this area will be shown in the middle column in the footer.', 'hoffman' ),
'before_title' => '',
'before_widget' => ''
));
register_sidebar(array(
'name' => __( 'Footer C', 'hoffman' ),
'id' => 'footer-c',
'description' => __( 'Widgets in this area will be shown in the right column in the footer.', 'hoffman' ),
'before_title' => '',
'before_widget' => ''
));
}
// Add theme widgets
require_once (get_template_directory() . "/widgets/flickr.php");
require_once (get_template_directory() . "/widgets/recent-comments.php");
require_once (get_template_directory() . "/widgets/recent-posts.php");
// Delist the WordPress widgets replaced by custom theme widgets
function hoffman_unregister_default_widgets() {
unregister_widget('WP_Widget_Recent_Comments');
unregister_widget('WP_Widget_Recent_Posts');
}
add_action('widgets_init', 'hoffman_unregister_default_widgets', 11);
// Check whether the browser supports javascript
function hoffman_html_js_class () {
echo ''. "\n";
}
add_action( 'wp_head', 'hoffman_html_js_class', 1 );
// Add classes to next_posts_link and previous_posts_link
add_filter('next_posts_link_attributes', 'hoffman_posts_link_attributes_1');
add_filter('previous_posts_link_attributes', 'hoffman_posts_link_attributes_2');
function hoffman_posts_link_attributes_1() {
return 'class="post-nav-older"';
}
function hoffman_posts_link_attributes_2() {
return 'class="post-nav-newer"';
}
// Custom more-link text
add_filter( 'the_content_more_link', 'hoffman_custom_more_link', 10, 2 );
function hoffman_custom_more_link( $more_link, $more_link_text ) {
return str_replace( $more_link_text, __('Read more', 'hoffman'), $more_link );
}
// Add class to the post and body elements if the post/page has a featured image
add_filter('post_class','hoffman_if_featured_image_class');
add_filter('body_class','hoffman_if_featured_image_class');
function hoffman_if_featured_image_class($classes) {
global $post;
if ( has_post_thumbnail() ) {
$classes[] = 'has-featured-image';
} else {
$classes[] = 'no-featured-image';
}
return $classes;
}
// Add body class if a custom background is set (and isn't the default bg color)
add_filter('body_class','hoffman_if_custom_background_set');
function hoffman_if_custom_background_set($classes) {
$bg_color = get_background_color();
$bg_image = get_background_image();
if ( !empty( $bg_image ) || $bg_color != 'f9f9f9' ) {
$classes[] = 'has-custom-background';
}
return $classes;
}
// Get comment excerpt length
function hoffman_get_comment_excerpt($comment_ID = 0, $num_words = 20) {
$comment = get_comment( $comment_ID );
$comment_text = strip_tags($comment->comment_content);
$blah = explode(' ', $comment_text);
if (count($blah) > $num_words) {
$k = $num_words;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
$excerpt = '';
for ($i=0; $i<$k; $i++) {
$excerpt .= $blah[$i] . ' ';
}
$excerpt .= ($use_dotdotdot) ? '...' : '';
return apply_filters('get_comment_excerpt', $excerpt);
}
// Style the admin area
function hoffman_custom_colors() {
echo '
';
}
add_action('admin_head', 'hoffman_custom_colors');
// Flexslider function for format-gallery
function hoffman_flexslider($size) {
if ( is_page()) :
$attachment_parent = $post->ID;
else :
$attachment_parent = get_the_ID();
endif;
if($images = get_posts(array(
'post_parent' => $attachment_parent,
'post_type' => 'attachment',
'numberposts' => -1, // show all
'post_status' => null,
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC',
))) { ?>
ID,$size); ?>
-
post_excerpt)) : ?>
comment_type ) :
case 'pingback' :
case 'trackback' :
?>
id="comment-">
', '' ); ?>
id="li-comment-">
add_section( 'hoffman_options',
array(
'title' => __( 'Hoffman Options', 'hoffman' ), //Visible title of section
'priority' => 35, //Determines what order this appears in
'capability' => 'edit_theme_options', //Capability needed to tweak
'description' => __('Allows you to customize theme settings for Hoffman.', 'hoffman'), //Descriptive tooltip
)
);
$wp_customize->add_section( 'hoffman_logo_section' , array(
'title' => __( 'Logo', 'hoffman' ),
'priority' => 40,
'description' => __('Upload a logo to replace the default site name and description in the header', 'hoffman'),
) );
//2. Register new settings to the WP database...
$wp_customize->add_setting( 'accent_color', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record
array(
'default' => '#928452', //Default setting/value to save
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'?
'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)?
'sanitize_callback' => 'sanitize_hex_color'
)
);
$wp_customize->add_setting( 'hoffman_logo',
array(
'sanitize_callback' => 'esc_url_raw'
)
);
//3. Finally, we define the control itself (which links a setting to a section and renders the HTML controls)...
$wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class
$wp_customize, //Pass the $wp_customize object (required)
'hoffman_accent_color', //Set a unique ID for the control
array(
'label' => __( 'Accent Color', 'hoffman' ), //Admin-visible name of the control
'section' => 'colors', //ID of the section this control should render in (can be one of yours, or a WordPress default section)
'settings' => 'accent_color', //Which setting to load and manipulate (serialized is okay)
'priority' => 10, //Determines the order this control appears in for the specified section
)
) );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'hoffman_logo', array(
'label' => __( 'Logo', 'hoffman' ),
'section' => 'hoffman_logo_section',
'settings' => 'hoffman_logo',
) ) );
//4. We can also change built-in settings by modifying properties. For instance, let's make some stuff use live preview JS...
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
}
public static function hoffman_header_output() {
?>
— ' . get_comment_time() . ''; ?>
', 'after' => '
' ) ) ); ?>