for posts and comments.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded
tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
// This theme supports the following post formats.
add_theme_support( 'post-formats', array(
'gallery',
'link',
'quote',
'audio',
'video',
'image',
'status'
) );
// Register WordPress Custom Menus
register_nav_menus( array(
'main-menu' => __( 'Main Navigation', 'activeblog' ),
'top-menu' => __( 'Top Navigation', 'activeblog' ),
));
// Register Post Thumbnails
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150, true );
add_image_size( 'active-featured', 348, 265, true );
add_image_size( 'active-featured-full', 774, 350, true );
add_image_size( 'active-slider', 580, 490, true );
add_image_size( 'active-carousel', 800, 500, true ); //vertical
add_image_size( 'active-featured390', 390, 210, true );
add_image_size( 'active-featured370', 125, 110, true );
add_image_size( 'active-related', 350, 260, true );
add_image_size( 'active-widgetthumb', 90, 90, true );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
// Load Localization Files
$lang_dir = get_template_directory() . '/lang';
load_theme_textdomain('activeblog', $lang_dir);
/*
* Enable support for custom logo.
*
*/
add_theme_support( 'custom-logo', array(
'height' => 72,
'width' => 235,
'flex-width' => true,
) );
/*
* This theme styles the visual editor to resemble the theme style,
* specifically font, colors, icons, and column width.
*/
add_editor_style( array( 'assets/css/editor-style.css' ) );
}
endif;
add_action( 'after_setup_theme', 'activeblog_theme_setup' );
/*-----------------------------------------------------------------------------------*/
/* Stylesheets and Scripts
/*-----------------------------------------------------------------------------------*/
function activeblog_stylesheets_scripts() {
// Add Stylesheets
//------------------------------------------------//
// Default Stylesheet
wp_enqueue_style( ACTIVEBLOG_THEME_NAME . '-style', get_stylesheet_uri() );
// Font-Awesome CSS
wp_enqueue_style( ACTIVEBLOG_THEME_NAME . '-font-awesome', get_template_directory_uri() . '/assets/css/font-awesome.min.css' );
/*---[ Owl Carousel (Slider) Stylesheet ]---*/
wp_register_style( 'owl.carousel', get_template_directory_uri() . '/assets/css/owl.carousel.css' );
wp_enqueue_style( 'owl.carousel' );
if ( get_theme_mod( 'responsive_layout', '1' ) ) {
// Responsive
wp_enqueue_style( ACTIVEBLOG_THEME_NAME . '-responsive', get_template_directory_uri() . '/assets/css/responsive.css' );
}
// Add JavaScripts
//------------------------------------------------//
if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
// Sticky Menu
$activeblog_sticky_menu = get_theme_mod( 'sticky_menu' );
if ( $activeblog_sticky_menu == 'enable' ) {
wp_enqueue_script( ACTIVEBLOG_THEME_NAME . '-stickymenu', get_template_directory_uri() . '/assets/js/stickymenu.js', array( 'jquery' ), '1.0', true );
}
/*---[ Owl Carousel (Slider) Scripts ]---*/
$activeblog_featured_slider = get_theme_mod( 'featured_slider' );
if ( $activeblog_featured_slider ) {
if ( get_theme_mod( 'rtl' ) == 'enable' ) {
wp_register_script( 'owl.carousel-rtl', get_template_directory_uri() . '/assets/js/owl.carousel.rtl.min.js', array( 'jquery' ), '1.0', true );
wp_enqueue_script( 'owl.carousel-rtl' );
} else {
wp_register_script( 'owl.carousel', get_template_directory_uri() . '/assets/js/owl.carousel.min.js', array( 'jquery' ), '1.0', true );
wp_localize_script(
'owl.carousel',
'activeblog_owl_carousel'
);
wp_enqueue_script( 'owl.carousel' );
}
}
// Required jQuery Scripts
$activeblog_responsive_layout = get_theme_mod( 'responsive_layout', '1' );
wp_register_script( ACTIVEBLOG_THEME_NAME . '-theme-scripts', get_template_directory_uri() . '/assets/js/theme-scripts.js', array( 'jquery' ), null, true );
wp_localize_script(
ACTIVEBLOG_THEME_NAME . '-theme-scripts',
'activeblog_themescripts',
array(
'responsive' => ( empty( $activeblog_responsive_layout ) ? '0' : '1' ),
)
);
wp_enqueue_script( ACTIVEBLOG_THEME_NAME . '-theme-scripts' );
global $is_IE;
if ( $is_IE ) {
wp_enqueue_script( 'html5shim', "//html5shim.googlecode.com/svn/trunk/html5.js" );
}
}
add_action( 'wp_enqueue_scripts', 'activeblog_stylesheets_scripts' );
/*-----------------------------------------------------------------------------------*/
/* Add Async Attributes to Scripts
/*-----------------------------------------------------------------------------------*/
function activeblog_add_async_attribute( $tag, $handle ) {
$scripts_to_async = array(
ACTIVEBLOG_THEME_NAME . '-theme-scripts',
ACTIVEBLOG_THEME_NAME . '-slider',
ACTIVEBLOG_THEME_NAME . '-stickymenu'
);
foreach( $scripts_to_async as $async_script ) {
if ( $async_script !== $handle ) return $tag;
return str_replace( ' src', ' async="async" src', $tag );
}
return $tag;
}
add_filter( 'script_loader_tag', 'activeblog_add_async_attribute', 10, 2 );
/*-----------------------------------------------------------------------------------*/
/* Add Admin Scripts
/*-----------------------------------------------------------------------------------*/
function activeblog_admin_scripts() {
wp_enqueue_script( 'select2js', get_template_directory_uri() . '/assets/js/select2.min.js', array( 'jquery' ), '1.0', true );
wp_enqueue_style( 'select2css', get_template_directory_uri() . '/assets/css/select2.css' );
if ( is_customize_preview() ) {
wp_enqueue_style( ACTIVEBLOG_THEME_NAME . '-admin-css', get_template_directory_uri() . '/assets/css/admin-styles.css' );
}
}
add_action( 'admin_enqueue_scripts', 'activeblog_admin_scripts' );
/*-----------------------------------------------------------------------------------*/
/* Load Widgets
/*-----------------------------------------------------------------------------------*/
include trailingslashit( get_template_directory() ) . "inc/widgets/widget-author-info.php"; // Author Info
include trailingslashit( get_template_directory() ) . "inc/widgets/widget-cat-posts.php"; // Category Posts
include trailingslashit( get_template_directory() ) . "inc/widgets/widget-recent-posts.php"; // Recent Posts
include trailingslashit( get_template_directory() ) . "inc/widgets/widget-social.php"; // Social Widget
include trailingslashit( get_template_directory() ) . "inc/widgets/widget-tabs.php"; // Tabs Widget
include trailingslashit( get_template_directory() ) . "inc/widgets/widget-video.php"; // Video Widget
/*-----------------------------------------------------------------------------------*/
/* Register Widget Positions
/*-----------------------------------------------------------------------------------*/
function activeblog_widgets_init() {
register_sidebar(array(
'name' => __('Primary Sidebar', 'activeblog'),
'id' => 'sidebar-1',
'before_widget' => '',
'before_title' => '',
));
if ( get_theme_mod( 'footer_layout','f4c' ) == 'f4c' ) {
$activeblog_sidebars = array( 1, 2, 3, 4 );
foreach( $activeblog_sidebars as $number ) {
register_sidebar( array(
'name' => sprintf( __( 'Footer %s','activeblog' ), $number ),
'id' => 'footer-' . $number,
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
}
} elseif (get_theme_mod( 'footer_layout') == 'f3c' ) {
$activeblog_sidebars = array(1, 2, 3);
foreach( $activeblog_sidebars as $number ) {
register_sidebar( array(
'name' => sprintf( __( 'Footer %s','activeblog' ), $number ),
'id' => 'footer-' . $number,
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
}
} elseif (get_theme_mod( 'footer_layout') == 'f2c' ) {
$activeblog_sidebars = array(1, 2);
foreach( $activeblog_sidebars as $number) {
register_sidebar( array(
'name' => sprintf( __( 'Footer %s','activeblog' ), $number ),
'id' => 'footer-' . $number,
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
}
} else {
register_sidebar( array(
'name' => __('Footer', 'activeblog'),
'id' => 'footer-1',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
}
}
add_action( 'widgets_init', 'activeblog_widgets_init' );
/*-----------------------------------------------------------------------------------*/
/* Thumbnail Upscale
/*
/* Enables upscaling of thumbnails for small media attachments
/*-----------------------------------------------------------------------------------*/
function activeblog_upscale_images( $default, $orig_w, $orig_h, $new_w, $new_h, $crop ) {
if( !$crop )
return null; // let the wordpress default function handle this
$size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
$crop_w = round($new_w / $size_ratio);
$crop_h = round($new_h / $size_ratio);
$s_x = floor( ($orig_w - $crop_w) / 2 );
$s_y = floor( ($orig_h - $crop_h) / 2 );
if(is_array($crop)) {
//Handles left, right and center (no change)
if($crop[ 0 ] === 'left') {
$s_x = 0;
} else if($crop[ 0 ] === 'right') {
$s_x = $orig_w - $crop_w;
}
//Handles top, bottom and center (no change)
if($crop[ 1 ] === 'top') {
$s_y = 0;
} else if($crop[ 1 ] === 'bottom') {
$s_y = $orig_h - $crop_h;
}
}
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
}
add_filter('image_resize_dimensions', 'activeblog_upscale_images', 10, 6);
/*-----------------------------------------------------------------------------------*/
/* Exceprt Length
/*-----------------------------------------------------------------------------------*/
// Limit the Length of Excerpt
function activeblog_excerpt_length( $length ) {
if ( get_theme_mod( 'excerpt_length' ) ) {
$excerpt_length = get_theme_mod( 'excerpt_length', '40' );
} else {
$excerpt_length = '40';
}
return intval($excerpt_length);
}
add_filter( 'excerpt_length', 'activeblog_excerpt_length', 999 );
function activeblog_excerpt($limit) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt);
}
$excerpt = preg_replace('`[[^]]*]`','',$excerpt);
return $excerpt;
}
// Remove […] string
function activeblog_excerpt_more( $more ) {
return '';
}
add_filter('excerpt_more', 'activeblog_excerpt_more');
/*-----------------------------------------------------------------------------------*/
/* Breadcrumb
/*-----------------------------------------------------------------------------------*/
function activeblog_breadcrumb() {
if (!is_home()) {
echo '';
echo ' ';
echo '';
echo __( 'Home','activeblog' );
echo "";
echo "";
echo "";
if (is_category() || is_single()) {
echo " / ";
echo '';
echo '';
the_category(' • ');
echo "";
echo "";
if (is_single()) {
echo " / ";
echo '';
echo '';
the_title();
echo "";
echo "";
}
} elseif (is_page()) {
echo " / ";
echo the_title();
}
}
}
/*-----------------------------------------------------------------------------------*/
/* Button for tinymce
/*-----------------------------------------------------------------------------------*/
/**
* Add Next Page/Page Break Button
* in WordPress Visual Editor
*
*/
function activeblog_add_next_page_button( $buttons, $id ){
/* only add this for content editor */
if ( 'content' != $id )
return $buttons;
/* add next page after more tag button */
array_splice( $buttons, 13, 0, 'wp_page' );
return $buttons;
}
add_filter( 'mce_buttons', 'activeblog_add_next_page_button', 1, 2 );
/*-----------------------------------------------------------------------------------*/
/* Comments Callback
/*-----------------------------------------------------------------------------------*/
if ( ! function_exists( 'activeblog_comments' ) ) {
/**
* Custom comments template.
*
* @param $comment
* @param $args
* @param $depth
*/
function activeblog_comments( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
?>
id="comment-">
comment_approved == '0') : ?>