= 2 || $page >= 2 )
$title = "$title $sep " . sprintf( esc_html__( 'Page %s', 'azurelo' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'azurelo_wpdocs_filter_wp_title', 10, 2 );
function azurelo_theme_slug_setup() {
add_theme_support( 'title-tag' );
}
add_action( 'after_setup_theme', 'azurelo_theme_slug_setup' );
//-----------------------------------------//
// MENU //
//-----------------------------------------//
function azurelo_register_theme_menus() {
register_nav_menus(
array(
'primary-menu' => esc_html__('Primary Menu', 'azurelo')
)
);
}
add_action('init', 'azurelo_register_theme_menus');
//-----------------------------------------//
// POST //
//-----------------------------------------//
add_theme_support( 'post-formats', array( 'gallery', 'video', 'audio' ) );
add_theme_support( 'automatic-feed-links' );
//algorithm function to display posts
function azurelo_post_algorithm() {
if ( is_archive() ) {
$layout_display = 'default';
if ( get_theme_mod('azurelo_layout_display_archive') ) {
$layout_display = get_theme_mod('azurelo_layout_display_archive');
}
} else {
$layout_display = 'default';
if ( isset($_GET['layout_display']) ) {
$layout_display = $_GET['layout_display'];
} else if ( get_theme_mod('azurelo_layout_display') ) {
$layout_display = get_theme_mod('azurelo_layout_display');
}
}
$i = 0;
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
switch ($layout_display) {
case 'default':
$default_posts_per_page = get_option( 'posts_per_page' );
if ( ($i + 1) > ($default_posts_per_page - 2) ){
get_template_part('templates/post', 'small');
} else if ($i % 4 == 0) {
get_template_part('templates/post', 'big');
} else if ($i % 4 == 3) {
get_template_part('templates/post', 'medium-inline');
} else {
get_template_part('templates/post', 'medium');
}
break;
case 'big':
get_template_part('templates/post', 'big');
break;
case 'medium':
get_template_part('templates/post', 'medium');
break;
case 'medium-inline':
get_template_part('templates/post', 'medium-inline');
break;
case 'small':
get_template_part('templates/post', 'small');
break;
}
$i++;
}
}
}
//-----------------------------------------//
// PAGINATION //
//-----------------------------------------//
function azurelo_pagination() { ?>
=$nb_word) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`[[^]]*]`','',$excerpt);
return $excerpt;
}
function azurelo_wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
//To keep the count accurate, lets get rid of prefetching
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
function azurelo_wpb_track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;
}
azurelo_wpb_set_post_views($post_id);
}
add_action( 'wp_head', 'azurelo_wpb_track_post_views');
//-----------------------------------------//
// THUMBNAILS //
//-----------------------------------------//
add_theme_support('post-thumbnails');
function azurelo_thumb() {
add_image_size( 'azurelo_tiny', 360, 240, true );
add_image_size( 'azurelo_small', 480, 320, true );
add_image_size( 'azurelo_medium', 640, 427, true );
add_image_size( 'azurelo_big', 768, 512, true );
add_image_size( 'azurelo_full', 1160, 774, true );
add_image_size( 'azurelo_full_hd', 1920, 1280, true );
add_image_size( 'azurelo_square_small', 280, 280, true );
add_image_size( 'azurelo_square_medium', 480, 480, true );
add_image_size( 'azurelo_square_big', 640, 640, true );
add_image_size( 'azurelo_slider_small', 640, 560, true );
add_image_size( 'azurelo_slider_large', 1160, 560, true );
add_image_size( 'azurelo_slider_full', 1920, 560, true );
}
add_action( 'after_setup_theme', 'azurelo_thumb' );
function azurelo_post_thumbnail_responsive_size($attr, $attachment, $size = 'thumbnail') {
if ( $size === 'azurelo_full_hd' && isset( $attr['sizes'] ) ) {
if ( is_singular() ) {
$attr['sizes'] = '100vw';
}
} else if ( $size === 'azurelo_big' && isset( $attr['sizes'] ) ) {
if ( is_singular() ) {
$attr['sizes'] = '(max-width: 1023px) 100vw, 1160px';
} else {
if ( ( isset($_GET['layout_config']) && isset($_GET['layout_config']) == 'full_layout') || get_theme_mod('azurelo_layout_config') == 'full_layout' ) {
$attr['sizes'] = '100vw';
} else {
$attr['sizes'] = '(max-width: 1023px) 100vw, 740px';
}
}
} else if ( $size === 'azurelo_medium' && isset( $attr['sizes'] ) ) {
if ( ( isset($_GET['layout_config']) && isset($_GET['layout_config']) == 'full_layout') || get_theme_mod('azurelo_layout_config') == 'full_layout' ) {
$attr['sizes'] = '(max-width: 639px) 100vw, 560px';
} else {
$attr['sizes'] = '(max-width: 639px) 100vw, 480px';
}
} else if ( $size === 'azurelo_square_small' && isset( $attr['sizes'] ) ) {
if ( is_singular() ) {
$attr['sizes'] = '(max-width: 639px) 100vw, 480px';
} else {
$attr['sizes'] = '(max-width: 1023px) 100vw, 280px';
}
} else if ( $size === 'azurelo_tiny' && isset( $attr['sizes'] ) ) {
$attr['sizes'] = '(max-width: 639px) 100vw, (max-width: 1023px) 321px, 360px';
}
return $attr;
}
add_filter('wp_get_attachment_image_attributes', 'azurelo_post_thumbnail_responsive_size', 10 , 3);
//-----------------------------------------//
// COMMENT FORM //
//-----------------------------------------//
add_filter( 'comment_form_fields', 'azurelo_move_comment_field_to_bottom' );
function azurelo_move_comment_field_to_bottom( $fields ) {
$comment_field = $fields['comment'];
unset( $fields['comment'] );
$fields['comment'] = $comment_field;
return $fields;
}
function azurelo_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
id="comment-">
__('Sidebar', 'azurelo'),
'id' => 'sidebar',
'before_widget' => '',
'before_title' => ''
));
}
}
add_action( 'widgets_init', 'azurelo_widgets_init' );
// Widgets
include(get_template_directory() . '/inc/widget/widget_latest.php');
include(get_template_directory() . '/inc/widget/widget_comment.php');
include(get_template_directory() . '/inc/widget/widget_about.php');
?>