* @copyright Copyright (c) 2011, Danny Ramirez * @link http://themes.miohki.com/bloggito * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ /* Load the core theme framework. */ require_once( trailingslashit( TEMPLATEPATH ) . 'core/hybrid.php' ); $theme = new Hybrid(); /* Load Bloggito's meta boxes. */ require_once( trailingslashit( TEMPLATEPATH ) . 'inc/admin/meta-box-post-audio.php' ); /* Run bloggito_theme_setup() on the 'after_setup_theme' hook. */ add_action( 'after_setup_theme', 'bloggito_theme_setup' ); /** * The theme setup function. Sets theme features and defines default actions and filters. * * @since 0.1.0 */ function bloggito_theme_setup() { /* Get action/filter hook prefix. */ $prefix = hybrid_get_prefix(); /* Add theme support for core framework features. */ add_theme_support( 'hybrid-core-menus', array( 'primary' ) ); add_theme_support( 'hybrid-core-sidebars', array( 'primary', 'secondary', 'header', 'before-content', 'after-content', 'after-singular' ) ); add_theme_support( 'hybrid-core-widgets' ); add_theme_support( 'hybrid-core-shortcodes' ); add_theme_support( 'hybrid-core-post-meta-box' ); add_theme_support( 'hybrid-core-theme-settings', array( 'about', 'footer' ) ); add_theme_support( 'hybrid-core-drop-downs' ); add_theme_support( 'hybrid-core-seo' ); add_theme_support( 'hybrid-core-template-hierarchy' ); /* Add theme support for core framework extensions. */ add_theme_support( 'theme-layouts', array( '1c', '2c-l', '2c-r' ) ); add_theme_support( 'post-stylesheets' ); add_theme_support( 'dev-stylesheet' ); add_theme_support( 'loop-pagination' ); add_theme_support( 'get-the-image' ); add_theme_support( 'cleaner-gallery' ); /* Add theme support for WordPress Post formats features. */ add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ) ); /* Add theme support for WordPress RSS feed. */ add_theme_support( 'automatic-feed-links' ); /* Add theme support for WordPress Custom Background. */ add_custom_background(); /* Remove meta name="template" from header. */ add_filter( "{$prefix}_meta_template", '__return_false' ); /* Remove meta name="copyright" from header. */ add_filter( "{$prefix}_meta_copyright", '__return_false' ); /* Remove meta name="revised" from header. */ add_filter( "{$prefix}_meta_revised", '__return_false' ); /* Style the content of the Visual Editor to match site's design. */ add_editor_style( 'inc/admin/bloggito-editor-style.css' ); /* Embed width/height defaults. */ add_filter( 'embed_defaults', 'bloggito_embed_defaults' ); /* Change the size of the avatar. */ add_filter( 'bloggito_list_comments_args', 'my_list_comments_args' ); /* Load the primary menu. */ add_action( "{$prefix}_after_hgroup", 'bloggito_get_primary_menu' ); /* Add the header sidebar. */ add_action( "{$prefix}_after_hgroup", 'bloggito_get_header' ); /* Add the before content sidebar. */ add_action( "{$prefix}_after_page_header", 'bloggito_get_before_content' ); /* Add the primary sidebar. */ add_action( "{$prefix}_default_sidebars", 'bloggito_get_primary_sidebar' ); /* Add the secondary sidebar. */ add_action( "{$prefix}_default_sidebars", 'bloggito_get_secondary_sidebar' ); /* Add the after content sidebar. */ add_action( "{$prefix}_after_page_content", 'bloggito_get_after_content' ); /* Add the after singular sidebar. */ add_action( "{$prefix}_after_entry", 'bloggito_get_after_singular' ); /* Load the Loop Navigation. */ add_action( "{$prefix}_after_entry", 'bloggito_get_loop_nav' ); /* Filter the sidebar widgets. */ add_filter( 'sidebars_widgets', 'bloggito_disable_sidebars' ); add_action( 'template_redirect', 'bloggito_one_column' ); /* Style the Audio Metabox in the Post Edit screen. */ add_action( 'admin_head', 'bloggito_audio_css' ); /* Reference the different scripts/styles to be used by the theme. */ add_action( 'wp_enqueue_scripts', 'bloggito_scripts' ); /* Add a class to the body of the Visual Editor. */ add_filter( 'tiny_mce_before_init', 'bloggito_mce_settings' ); } /** * Set a default width for embeds. * * @since 0.1.0 */ function bloggito_embed_defaults( $args ) { $args['width'] = 648; if ( current_theme_supports( 'theme-layouts' ) ) { $layout = theme_layouts_get_layout(); if ( 'layout-2c-l' == $layout || 'layout-2c-r' == $layout ) $args['width'] = 648; } return $args; } /** * Set a default size for the avatar. * * @since 0.1.0 */ function my_list_comments_args() { $args = array( 'style' => 'ol', 'type' => 'all', 'avatar_size' => 60, 'callback' => 'hybrid_comments_callback', 'end-callback' => 'hybrid_comments_end_callback' ); return $args; } /** * Loads the menu-primary.php template. * * @since 0.1.0 */ function bloggito_get_primary_menu() { get_template_part( 'menu', 'primary' ); } /** * Loads the sidebar-header.php template. * * @since 0.1.0 */ function bloggito_get_header() { get_sidebar( 'header' ); } /** * Loads the sidebar-before-content.php template. * * @since 0.1.0 */ function bloggito_get_before_content() { get_sidebar( 'before-content' ); } /** * Loads the sidebar-primary.php template. * * @since 0.1.0 */ function bloggito_get_primary_sidebar() { get_sidebar( 'primary' ); } /** * Loads the sidebar-secondary.php template. * * @since 0.1.0 */ function bloggito_get_secondary_sidebar() { get_sidebar( 'secondary' ); } /** * Loads the sidebar-after-content.php template. * * @since 0.1.0 */ function bloggito_get_after_content() { get_sidebar( 'after-content' ); } /** * Loads the sidebar-after-singular.php template * * @since 0.1.0 */ function bloggito_get_after_singular() { get_sidebar( 'after-singular' ); } /** * Loads the loop-nav.php template. * * @since 0.1.0 */ function bloggito_get_loop_nav() { get_template_part( 'loop-nav' ); } /** * Don't show sidebars if viewing a one-column page. * * @since 0.1.0 */ function bloggito_disable_sidebars( $sidebars_widgets ) { global $wp_query; if ( current_theme_supports( 'theme-layouts' ) && !is_admin() ) { if ( 'layout-1c' == theme_layouts_get_layout() ) { $sidebars_widgets['primary'] = false; $sidebars_widgets['secondary'] = false; } } return $sidebars_widgets; } /** * Set the theme layout to a one-column page if no sidebar is active, * if viewing an attachment or 404 page. * * @since 0.1.0 */ function bloggito_one_column() { if ( !is_active_sidebar( 'primary' ) && !is_active_sidebar( 'secondary' ) ) add_filter( 'get_theme_layout', 'bloggito_theme_layout_one_column' ); elseif ( is_attachment() || is_404() ) add_filter( 'get_theme_layout', 'bloggito_theme_layout_one_column' ); } /** * Filter the 'get_theme_layout' and set one-column as the default layout. * * @since 0.1.0 */ function bloggito_theme_layout_one_column( $layout ) { return 'layout-1c'; } /** * Displays the site's title wrapped in an h1. * * @since 0.1.0 */ function bloggito_site_title() { if ( $title = get_bloginfo( 'name' ) ) $title = '

' . $title . '

'; /* Display the title and create a filter hook for developers to use. */ echo apply_atomic( 'site_title', $title ); } /** * Displays the site's description wrapped in an h2. * * @since 0.1.0 */ function bloggito_site_description() { if ( $desc = get_bloginfo( 'description' ) ) $desc = '

' . $desc . '

'; /* Display the site's description and create a filter hook for developers to use. */ echo apply_atomic( 'site_description', $desc ); } /** * Displays meta information for the the current post-date/time as 'x time ago'. * * @since 0.1.0 */ function bloggito_posted_on() { printf( __( '', hybrid_get_parent_textdomain() ), esc_url( get_permalink() ), esc_attr( get_the_time() ), esc_attr( get_the_date( 'c' ) ), human_time_diff( get_the_time('U'), current_time('timestamp') ) ); } /** * Displays the featured image * * @since 0.1.0 */ function bloggito_featured_image() { if ( !has_post_format( 'image' ) && has_post_thumbnail() && current_theme_supports( 'get-the-image' ) ) { do_atomic( 'before_featured_image' ); echo ''; do_atomic( 'after_featured_image' ); } } /** * Adds CSS styling to style the Audio Metabox in the Post Edit Screen. * * @since 0.1.0 */ function bloggito_audio_css() { echo ''; } /** * Creates a custom field of `bloggito_audio` with a url value of the mp3 file * and adds the required Javascript to run the JPlayer. * * @since 0.1.0 */ function bloggito_jplayer_audio() { global $post; $mp3 = get_post_meta( $post->ID , 'bloggito_audio', true ); if ( has_post_format( 'audio', $post->ID ) ) { ?> * * @since 0.1.0 * @link http://moronicbajebus.com/ */ function bloggito_mce_settings( $initArray ) { $initArray['body_class'] = 'hentry'; return $initArray; } ?>