for posts and comments.
add_theme_support( 'automatic-feed-links' );
// This theme supports a variety of post formats.
add_theme_support( 'post-formats', array( 'aside', 'image', 'link', 'quote', 'status' ) );
// If sticky header enabled name menu as 'Sticky Header Menu' otherwise 'Top Menu'
if( get_theme_mod( 'agama_sticky_header', false ) ) {
register_nav_menu( 'top', __( 'Sticky Header Menu', 'agama' ) );
}else{
register_nav_menu( 'top', __( 'Top Menu', 'agama' ) );
}
// Register primary menu only if sticky header is not enabled.
if( ! get_theme_mod( 'agama_sticky_header', false ) ) {
register_nav_menu( 'primary', __( 'Primary Menu', 'agama' ) );
}
/*
* This theme supports custom background color and image,
* and here we also set up the default background color.
*/
add_theme_support( 'custom-background', array(
'default-color' => 'e6e6e6',
) );
// This theme uses a custom image size for featured images, displayed on "standard" posts.
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 800, 9999 ); // Unlimited height, soft crop
// Register custom image sizes
add_image_size( 'agama-blog-large', 776, 310, true );
add_image_size( 'agama-blog-medium', 320, 202, true );
add_image_size( 'agama-related-img', 180, 138, true );
add_image_size( 'agama-recent-posts', 700, 441, true );
/*
* Declare WooCommerce Support
*/
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'agama_setup' );
/**
* Backwards Compatibility for Title Tag
*
* @since Agama 1.0
*/
if ( ! function_exists( '_wp_render_title_tag' ) ) {
function agama_slug_render_title() {
?>
'.$title.'';
} else {
// isolate part 1 and part 2.
$title_part_one = strstr($title, ' ', true); // As of PHP 5.3.0
$title_part_two = strstr($title, ' ');
$output = ''.$title_part_one.''.$title_part_two.'
';
}
echo $output;
}
/**
* Get Attachment Image Src
*
* @since Agama v1.0.1
* @return string
*/
function agama_return_image_src( $thumb_size ) {
$att_id = get_post_thumbnail_id();
$att_src = wp_get_attachment_image_src( $att_id, $thumb_size );
return esc_url($att_src[0]);
}
/**
* Check if $page is template page
*
* @since Agama v1.0.1
* @return string
*/
function agama_is_page_template( $page ) {
if( is_page_template( 'page-templates/'.$page ) ) {
return true;
}
return false;
}
/**
* Filter the page menu arguments.
* Makes our wp_nav_menu() fallback -- wp_page_menu() -- show a home link.
*
* @since Agama 1.0
*/
function agama_page_menu_args( $args ) {
if ( ! isset( $args['show_home'] ) )
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'agama_page_menu_args' );
if ( ! function_exists( 'agama_content_nav' ) ) :
/**
* Displays navigation to next/previous pages when applicable.
*
* @since Agama 1.0
*/
function agama_content_nav( $html_id ) {
global $wp_query;
if ( $wp_query->max_num_pages > 1 ) : ?>
comment_type ) :
case 'pingback' :
case 'trackback' :
// Display trackbacks differently than normal comments.
?>
id="comment-">
', '' ); ?>
id="li-comment-">
',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);
$author = sprintf( '%3$s',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'agama' ), get_the_author() ) ),
get_the_author()
);
// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
if ( $tag_list ) {
$utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s by %4$s.', 'agama' );
} elseif ( $categories_list ) {
$utility_text = __( 'This entry was posted in %1$s on %3$s by %4$s.', 'agama' );
} else {
$utility_text = __( 'This entry was posted on %3$s by %4$s.', 'agama' );
}
printf(
$utility_text,
$categories_list,
$tag_list,
$date,
$author
);
}
endif;
/**
* Extend the default WordPress body classes.
*
* @since Agama 1.0
* @param array $classes Existing class values.
* @return array Filtered class values.
*/
function agama_body_class( $classes ) {
$background_color = get_background_color();
$background_image = get_background_image();
if( get_theme_mod( 'agama_sticky_header', false ) ) {
$classes[] = 'sticky_header';
}
if ( ! is_active_sidebar( 'sidebar-1' ) || is_page_template( 'page-templates/full-width.php' ) )
$classes[] = 'full-width';
if( is_page_template( 'page-templates/portfolio-one-column.php' ) ) {
$classes[] = 'portfolio-one-column';
}
if( is_page_template( 'page-templates/portfolio-two-columns.php' ) ) {
$classes[] = 'portfolio-two-columns';
}
if( is_page_template( 'page-templates/portfolio-three-columns.php' ) ) {
$classes[] = 'portfolio-three-columns';
}
if( is_page_template( 'page-templates/portfolio-four-columns.php' ) ) {
$classes[] = 'portfolio-four-columns';
}
if ( is_page_template( 'page-templates/front-page.php' ) ) {
$classes[] = 'template-front-page';
if ( has_post_thumbnail() )
$classes[] = 'has-post-thumbnail';
if ( is_active_sidebar( 'sidebar-2' ) )
$classes[] = 'two-sidebars';
}
if ( empty( $background_image ) ) {
if ( empty( $background_color ) )
$classes[] = 'custom-background-empty';
elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) )
$classes[] = 'custom-background-white';
}
// Enable custom font class only if the font CSS is queued to load.
if ( wp_style_is( 'PTSans', 'queue' ) )
$classes[] = 'custom-font-enabled';
if ( ! is_multi_author() )
$classes[] = 'single-author';
return $classes;
}
add_filter( 'body_class', 'agama_body_class' );
/**
* .article-wrapper Grid, List - Style
*
* @since Agama v1.0.1
*/
function agama_article_wrapper_class() {
if( get_theme_mod('agama_blog_layout', 'list') == 'list' ) {
echo 'list-style';
}
else
if( get_theme_mod('agama_blog_layout', 'list') == 'grid' ) {
echo 'grid-style';
} else {
echo 'list-style';
}
}
/**
* Agama Social Icons
*
* @since Agama v1.0.1
*/
if( ! function_exists( 'agama_social_icons' ) ) {
function agama_social_icons( $tip_position = '' ) {
$_target = esc_attr( get_theme_mod('agama_social_url_target', '_self') ); // URL target
$social = array(
'Facebook' => esc_url( get_theme_mod('social_facebook', '') ),
'Twitter' => esc_url( get_theme_mod('social_twitter', '') ),
'Flickr' => esc_url( get_theme_mod('social_flickr', '') ),
'RSS' => esc_url( get_theme_mod('social_rss', '') ),
'Vimeo' => esc_url( get_theme_mod('social_vimeo', '') ),
'Youtube' => esc_url( get_theme_mod('social_youtube', '') ),
'Instagram' => esc_url( get_theme_mod('social_instagram', '') ),
'Pinterest' => esc_url( get_theme_mod('social_pinterest', '') ),
'Tumblr' => esc_url( get_theme_mod('social_tumblr', '') ),
'Google' => esc_url( get_theme_mod('social_google', '') ),
'Dribbble' => esc_url( get_theme_mod('social_dribbble', '') ),
'Digg' => esc_url( get_theme_mod('social_digg', '') ),
'Linkedin' => esc_url( get_theme_mod('social_linkedin', '') ),
'Blogger' => esc_url( get_theme_mod('social_blogger', '') ),
'Skype' => esc_html( get_theme_mod('social_skype', '') ),
'Forrst' => esc_url( get_theme_mod('social_forrst', '') ),
'Myspace' => esc_url( get_theme_mod('social_myspace', '') ),
'Deviantart'=> esc_url( get_theme_mod('social_deviantart', '') ),
'Yahoo' => esc_url( get_theme_mod('social_yahoo', '') ),
'Reddit' => esc_url( get_theme_mod('social_reddit', '') ),
'PayPal' => esc_url( get_theme_mod('social_paypal', '') ),
'Dropbox' => esc_url( get_theme_mod('social_dropbox', '') ),
'Soundcloud'=> esc_url( get_theme_mod('social_soundcloud', '') ),
'VK' => esc_url( get_theme_mod('social_vk', '') ),
'Email' => esc_url( get_theme_mod('social_email', '') )
);
// Output icons
foreach( $social as $name => $url ) {
if( ! empty( $url ) ) {
echo sprintf( '', strtolower($name), $url, $_target, $tip_position, $name );
}
}
}
}
/**
* Render HTML for blog post date / post format
*
* @since Agama v1.0.1
*/
if( ! function_exists( 'agama_render_blog_post_date' ) ) {
function agama_render_blog_post_date() {
global $post;
// Get post format
$format = get_post_format( $post->ID );
switch( $format ):
case 'aside':
$fa_class = 'fa fa-2x fa-outdent';
break;
case 'image':
$fa_class = 'fa fa-2x fa-picture-o';
break;
case 'link':
$fa_class = 'fa fa-2x fa-link';
break;
case 'quote':
$fa_class = 'fa fa-2x fa-quote-left';
break;
case 'status':
$fa_class = 'fa fa-2x fa-comment';
break;
default: $fa_class = 'fa fa-2x fa-file-text';
endswitch;
// If not single post
if( !is_single() ) {
echo '';
echo '
';
echo sprintf( '%s', get_the_time('d') ); // Get day
echo sprintf( '%s', get_the_time('m, Y') ); // Get month, year
echo '
';
echo '
';
echo sprintf( '', $fa_class );
echo '
';
echo '
';
}
}
}
add_action( 'agama_blog_post_date_and_format', 'agama_render_blog_post_date', 10 );
/**
* Render HTML blog post meta details
*
* @since Agama v1.0.1
*/
if( ! function_exists( 'agama_render_blog_post_meta' ) ) {
function agama_render_blog_post_meta() {
_e( 'By', 'agama' );
echo '';
echo '';
echo ' '.get_the_author_link();
echo '';
echo '';
echo '|';
echo sprintf( '%s', get_the_time('F j, Y') );
// Output next details only on list blog layout or on single post page
if( get_theme_mod('agama_blog_layout', 'list') == 'list' || is_single() ) {
echo '|';
// Get category
$categories = get_the_category();
$separator = ',';
$output = '';
if( $categories ):
foreach($categories as $category) {
$output .= 'name ) ) . '">'.esc_html( $category->cat_name ).''.$separator;
echo trim( $output, $separator );
}
endif;
echo '|';
// Comments number
if( comments_open() ) {
echo sprintf( '%s', get_comments_link(), get_comments_number().__( ' comments', 'agama' ) );
}
}
}
}
add_action( 'agama_blog_post_meta', 'agama_render_blog_post_meta', 10 );
/**
* Infinite Scroll Init
*
* @since 1.0.3
*/
function agama_infinite_scroll_init() { ?>
Theme-Vision' ) ) );
}
}
add_action( 'agama_credits', 'agama_render_credits' );