$word_limit) array_pop($words);
$res = implode(' ', $words);
$res = trim ($res);
$res = preg_replace("/[.]+$/", "", $res);
if ( '' != $res) {
return $res . '... ';
} else {
return $res;
}
}
}
/*
* Load Files.
*/
//Loading options.php for theme customizer
include_once( get_template_directory() . '/options.php');
//Loads the Options Panel
if ( !function_exists( 'optionsframework_init' ) ) {
define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/options/' );
include_once( get_template_directory() . '/options/options-framework.php' );
}
/*
* Load Jetpack compatibility file.
*/
require( get_template_directory() . '/inc/jetpack.php' );
if ( ! function_exists( 'bueno_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*/
function bueno_setup() {
$defaults = array(
'default-color' => '',
'default-image' => '',
'wp-head-callback' => '_custom_background_cb',
'admin-head-callback' => '',
'admin-preview-callback' => ''
);
add_theme_support( 'custom-background', $defaults );
/**
* Custom functions that act independently of the theme templates
*/
require( get_template_directory() . '/inc/extras.php' );
/**
* Customizer additions
*/
require( get_template_directory() . '/inc/customizer.php' );
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* If you're building a theme based on bueno, use a find and replace
* to change 'bueno' to the name of your theme in all the template files
*/
load_theme_textdomain( 'bueno', get_template_directory() . '/languages' );
/**
* Add editor styles
*/
add_editor_style( 'css/editor-style.css' );
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
/**
* This theme uses wp_nav_menu() in two locations.
*/
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'bueno' ),
'top' => __( 'Top Page Menu', 'bueno' ),
'footer' => __( 'Footer Menu', 'bueno' )
) );
/*
* This theme supports all available post formats.
* See http://codex.wordpress.org/Post_Formats
*
* Structured post formats are formats where Twenty Thirteen handles the
* output instead of the default core HTML output.
*/
add_theme_support( 'structured-post-formats', array(
'link', 'video'
) );
add_theme_support( 'post-formats', array(
'aside', 'audio', 'chat', 'gallery', 'image', 'quote', 'status'
) );
// This theme uses its own gallery styles.
add_filter( 'use_default_gallery_style', '__return_false' );
/**
* Add image sizes
*/
if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
add_theme_support( 'post-thumbnails' );
add_image_size( 'slider-post-thumbnail', 770, 360, true ); // Slider Thumbnail
add_image_size( 'fullwidth-post-thumbnail', 1170, 560, true ); // Fullwidth thumbnail
add_image_size( 'large-thumb', 762, 360, true ); // Large Thumbnail for one column output
add_image_size( 'featured-thumb', 362, 172, true ); // Featured Thumbnail for two column output
add_image_size( 'related-thumb', 160, 160, true ); // Realted Post Image output
add_image_size( 'portfolio-thumb', 270, 320, true ); // Realted Post Image output
}
}
endif; // bueno_setup
add_action( 'after_setup_theme', 'bueno_setup' );
/**
* Register widgetized area and update sidebar with default widgets
*/
function bueno_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'bueno' ),
'id' => 'primary-sidebar',
'before_widget' => '',
'before_title' => '
',
) );
}
add_action( 'widgets_init', 'bueno_widgets_init' );
/**
* Enqueue scripts and styles
*/
function bueno_styles() {
global $wp_styles;
// Bootstrap styles
wp_register_style( 'bueno-bootstrap', get_template_directory_uri() . '/bootstrap/css/bootstrap.css');
wp_register_style( 'bueno-responsive', get_template_directory_uri() . '/bootstrap/css/responsive.css');
wp_enqueue_style('bueno-bootstrap');
wp_enqueue_style('bueno-responsive');
// Main stylesheet
wp_enqueue_style( 'bueno-style', get_stylesheet_uri() );
// Slider styles
wp_register_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css');
wp_enqueue_style('flexslider');
// Popup styles
wp_register_style( 'magnific', get_template_directory_uri() . '/css/magnific-popup.css');
wp_enqueue_style('magnific');
// Loads the Internet Explorer specific stylesheet.
wp_enqueue_style( 'bueno_ie', get_template_directory_uri() . '/css/ie.css' );
$wp_styles->add_data( 'bueno_ie', 'conditional', 'lt IE 9' );
}
function bueno_scripts() {
wp_enqueue_script( 'bueno-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );
wp_enqueue_script( 'bueno-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'bueno-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
}
// Menu scripts
wp_enqueue_script('superfish', get_template_directory_uri() . '/js/superfish.js', array('jquery'), '1.4.8', true);
wp_enqueue_script('mobilemenu', get_template_directory_uri() . '/js/jquery.mobilemenu.js', array('jquery'), '1.0', true);
wp_enqueue_script('sf_Touchscreen', get_template_directory_uri() . '/js/sfmenu-touch.js', array('jquery'), '1.0', true);
// Slider
wp_enqueue_script('flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array('jquery'), '2.1', true);
// PopUp
wp_enqueue_script('magnific', get_template_directory_uri() . '/js/jquery.magnific-popup.js', array('jquery'), '0.8.9', true);
// Bootstrap JS
wp_enqueue_script('bootstrap-custom', get_template_directory_uri() . '/js/bootstrap.js', array('jquery'), '1.0', true);
// Easing effect
wp_enqueue_script('jquery-easing', get_template_directory_uri() . '/js/jquery.easing.1.3.js', array('jquery'), '1.3', true);
// Debounced Resize plugin
wp_enqueue_script('jquery-debounced-resize', get_template_directory_uri() . '/js/jquery.debouncedresize.js', array('jquery'), '1.0', true);
// Custom Script File
wp_enqueue_script('custom', get_template_directory_uri() . '/js/custom.js', array('jquery'), '1.0', true);
}
add_action( 'wp_enqueue_scripts', 'bueno_scripts', 10, 2 );
add_action( 'wp_enqueue_scripts', 'bueno_styles', 10, 2 );
/**
* Adding class 'active' to current menu item
*/
add_filter( 'nav_menu_css_class', 'bueno_active_item_classes', 10, 2 );
function bueno_active_item_classes($classes = array(), $menu_item = false){
if(in_array('current-menu-item', $menu_item->classes)){
$classes[] = 'active';
}
return $classes;
}
/*-----------------------------------------------------------------------------------*/
/* Custom Gallery
/*-----------------------------------------------------------------------------------*/
if ( ! function_exists( 'bueno_featured_gallery' ) ) :
function bueno_featured_gallery() {
$pattern = get_shortcode_regex();
if ( preg_match( "/$pattern/s", get_the_content(), $match ) && 'gallery' == $match[2] ) {
add_filter( 'shortcode_atts_gallery', 'bueno_gallery_atts' );
echo do_shortcode_tag( $match );
}
}
endif;
function bueno_gallery_atts( $atts ) {
$atts['size'] = 'large';
return $atts;
}
/*-----------------------------------------------------------------------------------*/
/* Get link URL for link post type
/*-----------------------------------------------------------------------------------*/
function bueno_get_link_url() {
$has_url = get_the_post_format_url();
return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
}
/*-----------------------------------------------------------------------------------*/
/* Breabcrumbs
/*-----------------------------------------------------------------------------------*/
if (! function_exists( 'bueno_breadcrumb' )) {
function bueno_breadcrumb() {
$showOnHome = 0; // 1 - show "breadcrumbs" on home page, 0 - hide
$delimiter = '/'; // divider
$home = 'Home'; // text for link "Home"
$showCurrent = 1; // 1 - show title current post/page, 0 - hide
$before = ''; // open tag for active breadcrumb
$after = ''; // close tag for active breadcrumb
global $post;
$homeLink = home_url();
if (is_front_page()) {
if ($showOnHome == 1) echo '';
} else {
echo '- ' . $home . '
' . $delimiter . ' ';
if ( is_home() ) {
echo $before . 'Blog' . $after;
} elseif ( is_category() ) {
$thisCat = get_category(get_query_var('cat'), false);
if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' ');
echo $before . 'Category Archives: "' . single_cat_title('', false) . '"' . $after;
} elseif ( is_search() ) {
echo $before . 'Search for: "' . get_search_query() . '"' . $after;
} elseif ( is_day() ) {
echo '- ' . get_the_time('Y') . '
' . $delimiter . ' ';
echo '- ' . get_the_time('F') . '
' . $delimiter . ' ';
echo $before . get_the_time('d') . $after;
} elseif ( is_month() ) {
echo '- ' . get_the_time('Y') . '
' . $delimiter . ' ';
echo $before . get_the_time('F') . $after;
} elseif ( is_year() ) {
echo $before . get_the_time('Y') . $after;
} elseif ( is_single() && !is_attachment() ) {
if ( get_post_type() != 'post' ) {
$post_name = get_post_type();
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo '- ' . $post_type->labels->singular_name . '
';
if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
} else {
$cat = get_the_category(); $cat = $cat[0];
$cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
if ($showCurrent == 0) $cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats);
echo $cats;
if ($showCurrent == 1) echo $before . get_the_title() . $after;
}
} elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
$post_type = get_post_type_object(get_post_type());
echo $before . $post_type->labels->singular_name . $after;
} elseif ( is_attachment() ) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID); $cat = $cat[0];
echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
echo '- ' . $parent->post_title . '
';
if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
} elseif ( is_page() && !$post->post_parent ) {
if ($showCurrent == 1) echo $before . get_the_title() . $after;
} elseif ( is_page() && $post->post_parent ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '- ' . get_the_title($page->ID) . '
';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
for ($i = 0; $i < count($breadcrumbs); $i++) {
echo $breadcrumbs[$i];
if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' ';
}
if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
} elseif ( is_tag() ) {
echo $before . 'Tag Archives: "' . single_tag_title('', false) . '"' . $after;
} elseif ( is_author() ) {
global $author;
$userdata = get_userdata($author);
echo $before . 'by ' . $userdata->display_name . $after;
} elseif ( is_404() ) {
echo $before . '404' . $after;
}
/*
if ( get_query_var('paged') ) {
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' (';
echo __(' Page') . ' ' . get_query_var('paged');
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')';
}
*/
echo '
';
}
} // end breadcrumbs()
}
/*-----------------------------------------------------------------------------------*/
/* Sidebar socials
/*-----------------------------------------------------------------------------------*/
add_action( 'before_sidebar', 'bueno_sidebar_socials', 10 );
function bueno_sidebar_socials() {
$social_counter = 0;
$social_nets = array('g_twitter_url', 'g_facebook_url', 'g_linkedin_url', 'g_google_url', 'g_pinterest_url', 'g_rss_url');
foreach ($social_nets as $single_net) {
if ( '' != of_get_option($single_net) ) {
$social_counter++;
}
}
?>
max_num_pages < 2 ) {
return;
}
$paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
$pagenum_link = html_entity_decode( get_pagenum_link() );
$query_args = array();
$url_parts = explode( '?', $pagenum_link );
if ( isset( $url_parts[1] ) ) {
wp_parse_str( $url_parts[1], $query_args );
}
$pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
$pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
$format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
// Set up paginated links.
$links = paginate_links( array(
'base' => $pagenum_link,
'format' => $format,
'total' => $wp_query->max_num_pages,
'current' => $paged,
'mid_size' => 1,
'add_args' => array_map( 'urlencode', $query_args ),
'prev_text' => __( '← Prev', 'bueno' ),
'next_text' => __( 'Next →', 'bueno' ),
'type' => 'list'
) );
if ( $links ) {
?>
id="li-comment-" class="clearfix">
tag
if ( ! preg_match( '#' . get_tag_regex( 'img' ) . '#i', $html, $matches ) || empty( $matches ) )
return $attachment_id;
$matched_html = $matches[0];
// Look for attributes.
if ( ! preg_match_all( '#(src|class)=([\'"])(.+?)\2#is', $matched_html, $matches ) || empty( $matches ) )
return $attachment_id;
$attr = array();
foreach ( $matches[1] as $key => $attribute_name )
$attr[ $attribute_name ] = $matches[3][ $key ];
if ( ! empty( $attr['class'] ) && false !== strpos( $attr['class'], 'wp-image-' ) )
if ( preg_match( '#wp-image-([0-9]+)#i', $attr['class'], $matches ) )
$attachment_id = absint( $matches[1] );
if ( ! $attachment_id && ! empty( $attr['src'] ) )
$attachment_id = attachment_url_to_postid( $attr['src'] );
return $attachment_id;
}
}
/*-----------------------------------------------------------------------------------*/
/* Footer scripts init
/*-----------------------------------------------------------------------------------*/
if (!function_exists('bueno_footer_js')) {
function bueno_footer_js() {
$sf_delay = esc_attr( of_get_option('sf_delay') );
$sf_f_animation = esc_attr( of_get_option('sf_f_animation') );
$sf_sl_animation = esc_attr( of_get_option('sf_sl_animation') );
$sf_speed = esc_attr( of_get_option('sf_speed') );
$sf_arrows = esc_attr( of_get_option('sf_arrows') );
if ('' == $sf_delay) {$sf_delay = 1000;}
if ('' == $sf_f_animation) {$sf_f_animation = 'show';}
if ('' == $sf_sl_animation) {$sf_sl_animation = 'show';}
if ('' == $sf_speed) {$sf_speed = 'normal';}
if ('' == $sf_arrows) {$sf_arrows = 'false';}
?>
ID) || ( 'noimg' == of_get_option('post_image_size') ) ) {
if ( 'image' == get_post_format() ) {
if ( false == bueno_post_format_image() ) {
$classes[] = 'no-thumb';
}
} elseif ( 'gallery' == get_post_format() ) {
$attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image') );
if ( !$attachments ) {
$classes[] = 'no-thumb';
}
} else {
$classes[] = 'no-thumb';
}
}
if ( '' == get_the_title() ) {
$classes[] = 'no-title';
}
return $classes;
}
/*-----------------------------------------------------------------------------------*/
/* Functions for dispalying post meta
/*-----------------------------------------------------------------------------------*/
function bueno_show_post_author() {
if ( 'false' != of_get_option('post_meta_author') ) {
?>