* @copyright Copyright (c) 2011-2013, Jesper Johansen * @link http://wpthemes.jayj.dk/cakifo * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer) */ /* Load the core theme framework */ require_once( trailingslashit( get_template_directory() ) . 'library/hybrid.php' ); new Hybrid(); /* Do theme setup on the `after_setup_theme` hook */ add_action( 'after_setup_theme', 'cakifo_theme_setup', 10 ); /** * Theme setup function. This function adds support for theme features and defines the default theme * actions and filters * * @since Cakifo 1.0.0 */ function cakifo_theme_setup() { /* Get action/filter hook prefix */ $prefix = hybrid_get_prefix(); /* Load Cakifo theme includes */ require_once( trailingslashit( THEME_DIR ) . 'functions/customize.php' ); require_once( trailingslashit( THEME_DIR ) . 'functions/shortcodes.php' ); /* Add theme support for core framework features */ add_theme_support( 'hybrid-core-menus', array( 'primary', 'secondary' ) ); add_theme_support( 'hybrid-core-widgets' ); add_theme_support( 'hybrid-core-shortcodes' ); add_theme_support( 'hybrid-core-theme-settings', array( 'about', 'footer' ) ); add_theme_support( 'hybrid-core-styles', array( 'style' ) ); add_theme_support( 'hybrid-core-scripts' ); /* Add theme support for framework extensions */ add_theme_support( 'theme-layouts', array( '1c', '2c-l', '2c-r', '3c-l', '3c-r', '3c-c' ) ); add_theme_support( 'post-stylesheets' ); add_theme_support( 'loop-pagination' ); add_theme_support( 'get-the-image' ); add_theme_support( 'breadcrumb-trail' ); add_theme_support( 'cleaner-gallery' ); add_theme_support( 'custom-field-series' ); /* Add theme support for theme functions */ add_theme_support( 'cakifo-sidebars', array( 'primary', 'secondary', 'subsidiary', 'subsidiary-two', 'subsidiary-three', 'after-single', 'after-singular', 'error-page' ) ); add_theme_support( 'cakifo-shortcodes' ); add_theme_support( 'cakifo-colorbox' ); add_theme_support( 'cakifo-twitter-button' ); /* Load Theme Settings */ if ( is_admin() ) { require_once( trailingslashit( THEME_DIR ) . 'functions/admin.php' ); } /* Add theme support for WordPress features */ add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'image', 'gallery', 'link', 'quote', 'status', 'video' ) ); add_theme_support( 'automatic-feed-links' ); add_editor_style(); /* Custom background */ add_theme_support( 'custom-background', array( 'default-color' => 'e3ecf2', 'default-image' => get_template_directory_uri() . '/images/bg.png' ) ); /** * Custom header for logo upload */ add_theme_support( 'custom-header', array( 'width' => 400, 'height' => 60, 'flex-width' => true, 'flex-height' => true, 'default-text-color' => cakifo_get_default_link_color_no_hash(), 'wp-head-callback' => 'cakifo_header_style', 'admin-head-callback' => 'cakifo_admin_header_style', 'admin-preview-callback' => 'cakifo_admin_header_image', ) ); // Register the logo from the parent theme images folder as the default logo register_default_headers( array( 'logo' => array( 'description' => __( 'Logo.png from the Cakifo images folder', 'cakifo' ), 'url' => get_template_directory_uri() . '/images/logo.png', 'thumbnail_url' => get_template_directory_uri() . '/images/logo.png', 'width' => 300, 'height' => 59 ) ) ); // If the user is using a child theme, register the logo.png from that as well if ( is_child_theme() && file_exists( get_stylesheet_directory() . '/images/logo.png' ) ) { register_default_headers( array( 'childtheme_logo' => array( 'description' => __( 'Logo.png from the Cakifo child theme images folder', 'cakifo' ), 'url' => get_stylesheet_directory_uri() . '/images/logo.png', 'thumbnail_url' => get_stylesheet_directory_uri() . '/images/logo.png', ) ) ); } // is_child_theme() && file_exists() /* Set $content_width */ hybrid_set_content_width( 630 ); /* Set embed width/height defaults and $content_width for non-default layouts */ add_filter( 'embed_defaults', 'cakifo_content_width' ); /** * Set new image sizes * * Small: For use in archives and searches * Slider: For use in the slider * Recent: For use in the recent posts */ add_image_size( 'small', apply_filters( 'small_thumb_width', 100 ), apply_filters( 'small_thumb_height', 100 ), true ); add_image_size( 'slider', apply_filters( 'slider_image_width', 500 ), apply_filters( 'slider_image_height', 230 ), true ); add_image_size( 'recent', apply_filters( 'recent_image_width', 220 ), apply_filters( 'recent_image_height', 150 ), true ); /* Enqueue theme scripts and styles */ add_action( 'wp_enqueue_scripts', 'cakifo_enqueue_script', 1 ); add_action( 'wp_enqueue_scripts', 'cakifo_enqueue_style' ); /* Output link color in the
*/ add_action( 'wp_head', 'cakifo_print_link_color_style' ); /* Filter the body class */ add_filter( 'body_class', 'cakifo_body_class' ); /* Search Form in the topbar */ add_action( "{$prefix}_close_menu_primary", 'get_search_form' ); /** * If you want the old RSS and Twitter link, do this in your child theme: * remove_action( "{$prefix}_close_menu_primary", 'get_search_form' ); * add_action( "{$prefix}_close_menu_primary", 'cakifo_topbar_rss' ); */ /* Filter the sidebar widgets. */ add_filter( 'sidebars_widgets', 'cakifo_disable_sidebars' ); add_action( 'template_redirect', 'cakifo_theme_layout' ); /* Add the Breadcrumb Trail just after the container is open */ if ( current_theme_supports( 'breadcrumb-trail' ) ) { add_action( "{$prefix}_open_main", 'breadcrumb_trail' ); add_filter( 'breadcrumb_trail_args', 'cakifo_breadcrumb_trail_args' ); } /* Front age customisations */ add_action( 'template_redirect', 'cakifo_front_page' ); add_action( 'wp_footer', 'cakifo_slider_javascript', 100 ); /* Excerpt "Read More" link */ add_filter( 'excerpt_more', 'cakifo_excerpt_more' ); /* Add Custom Field Series */ if ( current_theme_supports( 'custom-field-series' ) ) add_action( "{$prefix}_after_singular", 'custom_field_series' ); /* Add an Author Box after singular posts */ add_action( 'init', 'cakifo_place_author_box' ); /* Get the Image arguments */ add_filter( 'get_the_image_args', 'cakifo_get_the_image_arguments' ); /* wp_list_comments() arguments */ add_filter( "{$prefix}_list_comments_args" , 'cakifo_change_list_comments_args' ); /* Filter default theme options */ add_filter( "{$prefix}_default_theme_settings", 'cakifo_filter_default_theme_settings' ); /* Filter the comment input field types */ add_filter( 'comment_form_default_fields', 'cakifo_html5_comment_fields' ); /* Filter the arguments for wp_link_pages(), used in the loop files */ add_filter( 'wp_link_pages_args', 'cakifo_link_pages_args' ); /* Load all necessary files and hooks for singular pages */ add_filter( "{$prefix}_in_singular", 'cakifo_load_in_singular' ); /* Backward compatibility for the 'show_singular_comments' filter */ add_action( 'init', 'cakifo_compat_show_singular_comments' ); } /** * Load the theme functions, if the theme/child theme supports them. * * @since Cakifo 1.3.0 */ function cakifo_load_theme_support() { $template_directory = trailingslashit( get_template_directory() ); /* Load the Cakifo sidebars if supported */ require_if_theme_supports( 'cakifo-sidebars', $template_directory . 'functions/sidebars.php' ); /* Load the Colorbox Script extention if supported. */ require_if_theme_supports( 'cakifo-colorbox', $template_directory . 'functions/colorbox.php' ); /* Load the Twitter Button extention if supported */ require_if_theme_supports( 'cakifo-twitter-button', $template_directory . 'functions/tweet_button.php' ); } add_action( 'after_setup_theme', 'cakifo_load_theme_support', 12 ); /** * Enqueue theme scripts, includes jQuery, Modernizr, and Flexslider. * * @since Cakifo 1.0.0 */ function cakifo_enqueue_script() { /** * Modernizr enables HTML5 elements & feature detects * * For more/fewer features and optimal performance in your child theme, * use a custom Modernizr build: www.modernizr.com/download/ * * Use wp_deregister_script( 'modernizr' ); and * wp_enqueue_script( 'modernizr', CHILD_THEME_URI . '/js/modernizr-2.x.min.js', '', '2.x' ); * in your child theme functions.php */ wp_enqueue_script( 'modernizr', THEME_URI . '/js/modernizr.js', array(), '2.5.3' ); /* Enqueue jQuery */ wp_enqueue_script( 'jquery' ); /* Enqueue the theme javascript */ wp_enqueue_script( 'cakifo-theme', THEME_URI . '/js/script.js', array( 'jquery' ), '1.4', true ); /* Enqueue the Flexslider jQuery Plugin */ if ( hybrid_get_setting( 'featured_show' ) ) wp_enqueue_script( 'flexslider', THEME_URI . '/js/jquery.flexslider.js', array( 'jquery' ), '2.1', true ); } /** * Enqueue theme styles * * @since Cakifo 1.0.0 */ function cakifo_enqueue_style() { /** * Loads the PT Serif font from Google Fonts. * * The use of PT Serif by default is localized. For languages that use * characters not supported by the font, the font can be disabled. * * To disable in a child theme, use wp_dequeue_style() * function mychild_dequeue_fonts() { * wp_dequeue_style( 'PT-Serif' ); * } * add_action( 'wp_enqueue_scripts', 'mychild_dequeue_fonts', 11 ); */ $protocol = is_ssl() ? 'https' : 'http'; $query_args = array( 'family' => 'PT+Serif:400italic,700italic,400,700', ); wp_enqueue_style( 'PT-Serif', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null ); } /** * Customize the front page * * @since Cakifo 1.0.0 */ function cakifo_front_page() { $prefix = hybrid_get_prefix(); /* If we're not looking at the front page, return */ if ( ! is_home() && ! is_front_page() ) return; /* Remove the breadcrumb trail */ remove_action( "{$prefix}_open_main", 'breadcrumb_trail' ); } /** * Add Flexslider scripts * * @since Cakifo 1.0.0 * @uses apply_filters() The `cakifo_flexslider_args` filter allows you to change the default values. */ function cakifo_slider_javascript() { /* If we're not looking at the front page, return */ if ( ! is_home() && ! is_front_page() ) return; /* If slider is disabled, return */ if ( ! hybrid_get_setting( 'featured_show' ) ) return; /** * Default arguments * @link http://www.woothemes.com/flexslider/ All available arguments and descriptions */ $defaults = array( 'selector' => '.slides-container > .slide', 'animation' => 'slide', 'slideshow' => true, 'slideshowSpeed' => 7000, 'animationSpeed' => 450, 'pauseOnHover' => true, 'video' => true, 'prevText' => esc_js( _x( 'Previous', 'slide', 'cakifo' ) ), 'nextText' => esc_js( _x( 'Next', 'slide', 'cakifo' ) ), 'pauseText' => esc_js( _x( 'Pause', 'slide', 'cakifo' ) ), 'playText' => esc_js( _x( 'Play', 'slide', 'cakifo' ) ), // REMOVE BEFORE RELEASE? 'slideshow' => false, ); $args = array(); /** * Use the `cakifo_flexslider_args` filter to filter the defaults * You can't change the Flexslider callbacks * * For more information about the arguments, see: * * @link https://github.com/jayj/Cakifo/wiki/Child-themes * @link http://www.woothemes.com/flexslider/ */ $args = apply_filters( 'cakifo_flexslider_args', $args ); // Parse incoming $args into an array and merge it with $defaults $args = wp_parse_args( $args, $defaults ); // JSON encode the arguments $json = json_encode( $args ); echo ""; } /** * Change the thumbnail size to 'small' for archives and search pages. * * @since Cakifo 1.1.0 * @param array $args The 'Get the Image' arguments * @return array The filtered arguments */ function cakifo_get_the_image_arguments( $args ) { if ( is_archive() || is_search() ) { $args['size'] = 'small'; $args['image_class'] = 'thumbnail'; } return $args; } /** * Change the arguments of wp_list_comments() * * @since Cakifo 1.3.0 * @param array $args The wp_list_comments() arguments * @return array The filtered wp_list_comments() arguments */ function cakifo_change_list_comments_args( $args ) { $args['avatar_size'] = 48; return $args; } /** * Edit the "More link" for archive excerpts. * * @since Cakifo 1.0.0 * @param string $more The default more link * @return string The changed more link with a more descriptive text */ function cakifo_excerpt_more( $more ) { global $post; if ( is_archive() ) $more = '' . __( 'Continue reading ', 'cakifo' ) . '
'; return $more; } /** * Custom breadcrumb trail arguments. * * @since Cakifo 1.0.0 * @param array $args The 'Breadcrumb' arguments * @return array The filtered 'Breadcrumb' arguments */ function cakifo_breadcrumb_trail_args( $args ) { $args['before'] = __( 'You are here:', 'cakifo' ); // Changes the text before the breadcrumb trail return $args; } /** * Display RSS feed link in the topbar. * * No longer showed by default in version 1.3 * If you still want it, use this in your child theme: *
* remove_action( "{$prefix}_close_menu_primary", 'get_search_form' );
* add_action( "{$prefix}_close_menu_primary", 'cakifo_topbar_rss' );
*
*
* @since Cakifo 1.0.0
* @return string The RSS feed and maybe a Twitter link
*/
function cakifo_topbar_rss() {
echo apply_atomic_shortcode( 'rss_subscribe',
'