* @copyright Copyright (c) 2013, Danny Ramirez * @link (Alku, http://demo.dronix.me/alku) * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GPL 2 or later */ /* Load Hybrid Core framework. */ require_once( trailingslashit( get_template_directory() ) . 'core/hybrid.php' ); new Hybrid(); /* Attach our theme setup to the 'after_setup_theme' hook. */ add_action( 'after_setup_theme', 'alku_theme_setup' ); /** * Theme setup function. * * This function adds support for theme features and the various extensions * and utilities of the Hybrid Core framework. It also defines the default * actions and filters. * * @since 0.1.0 */ function alku_theme_setup() { /* Get our theme's prefix. */ $prefix = hybrid_get_prefix(); /* Add theme support for Hybrid Core features. */ add_theme_support( 'hybrid-core-menus', array( 'primary' ) ); add_theme_support( 'hybrid-core-sidebars', array( 'primary' ) ); add_theme_support( 'hybrid-core-widgets' ); add_theme_support( 'hybrid-core-shortcodes' ); add_theme_support( 'hybrid-core-template-hierarchy' ); add_theme_support( 'hybrid-core-scripts', array( 'comment-reply' ) ); add_theme_support( 'hybrid-core-styles', array( 'gallery', 'parent', 'style' ) ); /* Add theme support for Hybrid Core extensions. */ add_theme_support( 'theme-layouts', array( '1c', '2c-l', '2c-r' ), array( 'default' => '2c-l' ) ); add_theme_support( 'post-stylesheets' ); add_theme_support( 'loop-pagination' ); add_theme_support( 'get-the-image' ); add_theme_support( 'cleaner-gallery' ); /* Add theme support for WordPress features. */ add_theme_support( 'automatic-feed-links' ); add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'image', 'gallery', 'link', 'quote', 'status', 'video') ); /* Add theme support for Alku features. */ add_theme_support( 'alku-custom-fonts' ); /* Lets make the visual editor match our theme styles. */ add_editor_style(); /* Add some custom styles and scripts. */ add_action( 'wp_enqueue_scripts', 'alku_scripts_styles' ); /* Lets add a custom body class. */ add_filter( 'body_class', 'alku_body_class' ); /* Lets add our own shortcodes. */ add_action( 'init', 'alku_register_shortcodes', 11 ); /* Filter the sidebar widgets. */ add_filter( 'sidebars_widgets', 'alku_disable_sidebars' ); add_action( 'template_redirect', 'alku_one_column' ); /* Add some custom User Profile fields. */ add_filter( 'user_contactmethods', 'alku_user_contact_methods' ); /* Set default embeds width. */ hybrid_set_content_width( 600 ); add_filter( 'embed_defaults', 'alku_embed_defaults' ); /* Lets filter `the_content`. */ add_filter( 'the_content', 'alku_extend_the_content' ); } /** * Registers and enqueues our custom stylesheets and javascripts. * * @since 0.1.0 */ function alku_scripts_styles() { /* Use the .min script if SCRIPT_DEBUG is turned off. */ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; $protocol = is_ssl() ? 'https' : 'http'; $query_args = array( 'family' => 'Open+Sans:400italic,300,400,600,700,800' ); /* Register our fonts styles. */ wp_register_style( 'alku-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null ); wp_register_style( 'alku-icon-fonts', trailingslashit( THEME_URI ) . "css/elusive-webfont{$suffix}.css", array(), null ); /* Enqueue our fonts if current theme supports Alku's custom fonts. */ if ( current_theme_supports( 'alku-custom-fonts' ) ) { wp_enqueue_style( 'alku-fonts' ); wp_enqueue_style( 'alku-icon-fonts' ); } /* Register our scripts */ wp_register_script( 'alku-flexslider', trailingslashit( THEME_URI ) . "js/jquery.flexslider{$suffix}.js", array( 'jquery' ), '20130101', true ); wp_register_script( 'alku-fitvids', trailingslashit( THEME_URI ) . "js/jquery.fitvids{$suffix}.js", array( 'jquery' ), '20130101', true ); wp_register_script( 'alku-custom-scripts', trailingslashit( THEME_URI ) . "js/jquery.custom.js", array( 'jquery' ), '20130101', true ); /* Enqueue our scripts. */ wp_enqueue_script( 'alku-fitvids' ); wp_enqueue_script( 'alku-flexslider' ); wp_enqueue_script( 'alku-custom-scripts' ); } /** * Creates an additional
class * * @since 0.1.0 */ function alku_body_class( $classes ) { /* If Alku's custom fonts are enabled. */ if ( current_theme_supports( 'alku-custom-fonts' ) ) $classes[] = 'custom-font-enabled'; return $classes; } /** * Removes some of Hybrid Core default shortcodes with our own and creates * additional ones. * * @since 0.1.0 */ function alku_register_shortcodes() { /* Remove some of Hybrid Core shortcodes. */ remove_shortcode( 'comment-published' ); /* Add our own shortcodes. */ add_shortcode( 'comment-published', 'alku_comment_published_shortcode' ); add_shortcode( 'hc-link', 'alku_hc_link_shortcode' ); add_shortcode( 'author-info', 'alku_author_info_shortcode' ); add_shortcode( 'gallery-slider', 'alku_gallery_slider_shortcode' ); } /** * Shortcode for displaying the published date and time of an individual comment wrapped * in a link . * * @since 0.1.0 * @return string */ function alku_comment_published_shortcode() { global $comment; $link = '' . sprintf( '', esc_url( get_comment_link( $comment->comment_ID ) ), get_comment_time( 'c' ), sprintf( __( '%1$s at %2$s', 'alku' ), get_comment_date(), get_comment_time() ) ) . ''; return $link; } /** * Shortcode for displaying a link back to Hybrid Core. * * @since 0.1.0 */ function alku_hc_link_shortcode() { return '' . __( 'Hybrid Core', 'hybrid-core' ) . ''; } /** * Shortcode for displaying information regarding the * author of a post. * * @since 0.1.0 */ function alku_author_info_shortcode( $attr ) { $attr = shortcode_atts( array( 'container_class' => 'author-info', 'header_tag' => 'h2', 'header_class' => 'username', 'show_avatar' => true, 'github' => is_archive() ? get_user_meta( get_query_var( 'author' ), 'github', true ) : get_user_meta( get_the_author_meta( 'ID' ), 'github', true ), 'twitter' => is_archive() ? get_user_meta( get_query_var( 'author' ), 'twitter', true ) : get_user_meta( get_the_author_meta( 'ID' ), 'twitter', true ), 'dribbble' => is_archive() ? get_user_meta( get_query_var( 'author' ), 'dribbble', true ) : get_user_meta( get_the_author_meta( 'ID' ), 'dribbble', true ), 'avatar' => is_archive() ? get_avatar( get_query_var( 'author' ) ) : get_avatar( get_the_author_meta( 'ID' ) ), 'author_url' => is_archive() ? get_the_author_meta( 'user_url', get_query_var( 'author' ) ) : get_author_posts_url( get_the_author_meta( 'ID' ) ), 'author_description' => wpautop( get_the_author_meta( 'description', get_query_var( 'author' )) ) ), $attr ); extract( $attr ); if ( 'true' == $show_avatar ) $output = "