tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
add_image_size( 'astromag-blog', 750, 450, true );
add_image_size( 'astromag-logo', 300, 90, true );
add_image_size( 'astromag-blog-page', 400, 400, true );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary_menu' => esc_html__( 'Primary Menu', 'astromag' ),
'right_side_menu' => esc_html__( 'Right Side Menu', 'astromag' ),
) );
/*
* 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',
) );
function astromag_add_editor_styles() {
add_editor_style( 'custom-editor-style.css' );
}
add_action( 'admin_init', 'astromag_add_editor_styles' );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'astromag_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', array(
'height' => 90,
'width' => 300,
'flex-width' => true,
'flex-height' => true,
) );
}
endif;
add_action( 'after_setup_theme', 'astromag_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function astromag_content_width() {
// This variable is intended to be overruled from themes.
// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$GLOBALS['content_width'] = apply_filters( 'astromag_content_width', 640 );
}
add_action( 'after_setup_theme', 'astromag_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function astromag_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Post Sidebar', 'astromag' ),
'id' => 'post-sidebar',
'description' => esc_html__( 'Add widgets in single article post.', 'astromag' ),
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Page Sidebar', 'astromag' ),
'id' => 'page-sidebar',
'description' => esc_html__( 'Add widgets in page.', 'astromag' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'AstroMag Home', 'astromag' ),
'id' => 'astromag-home',
'description' => esc_html__( 'Add widgets in Astro Homepage.', 'astromag' ),
'before_widget' => '',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'astromag' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'astromag' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 1', 'astromag' ),
'id' => 'footer-1',
'description' => esc_html__( 'Add widgets here.', 'astromag' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 2', 'astromag' ),
'id' => 'footer-2',
'description' => esc_html__( 'Add widgets here.', 'astromag' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer 3', 'astromag' ),
'id' => 'footer-3',
'description' => esc_html__( 'Add widgets here.', 'astromag' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'astromag_widgets_init' );
/**
* astromag post view count.
*/
if ( ! function_exists( 'astromag_post_view_count' ) ) :
/** * get the value of view. */
function astromag_post_view_count($postID) {
$count_key = 'astromag_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count ==''){
$count = 1;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '1');
} else {
$count++;
update_post_meta($postID, $count_key, $count);
}
}
endif;
/**
* Enqueue scripts and styles.
*/
function astromag_scripts() {
// frow css
wp_enqueue_style( 'frow', get_template_directory_uri().'/assets/css/frow.css', array(), '4.0.0', 'all' );
// default css
wp_enqueue_style( 'astromag-defaultcss', get_template_directory_uri().'/assets/css/default.css', array(), '1.0', 'all' );
// custom css
wp_enqueue_style( 'astromag-customcss', get_template_directory_uri().'/assets/css/custom.css', array(), '1.0', 'all' );
// fontawesome css
wp_enqueue_style( 'fontawesome', get_template_directory_uri().'/assets/css/all.css', array(), '6.0.0', 'all' );
// woocommerce css
if ( class_exists( 'WooCommerce' ) ) {
wp_enqueue_style( 'astromag-woocomerce-style', get_template_directory_uri() . '/assets/css/woocommerce.css' );
}
wp_enqueue_style( 'astromag-style', get_stylesheet_uri() );
// Internet Explorer HTML5 support
wp_enqueue_script( 'html5hiv',get_template_directory_uri().'/assets/js/html5.js', array(), '3.7.0', false );
wp_script_add_data( 'html5hiv', 'conditional', 'lt IE 9' );
// theme-script js
wp_enqueue_script( 'astromag-themejs', get_template_directory_uri() . '/assets/js/theme-script.js', array('jquery'), '', true );
// skip to content js
wp_enqueue_script( 'astromag-skip-link-focus-fix-js', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.js', array(), '1.0', true );
// responsive-nav js
wp_enqueue_script( 'responsive-nav', get_template_directory_uri() . '/assets/js/responsive-nav.js', array(), '1.0', true );
// check if infinite scroll enabled from theme option
if( get_theme_mod( 'section_three_enable_inf_scroll', 'enable' ) == 'enable' ) {
// infinite scroll
wp_enqueue_script( 'infinite-scroll', get_template_directory_uri() . '/assets/js/infinite-scroll.pkgd.js', array('jquery'), '4.0.1', true );
}
// main js
wp_enqueue_script( 'astromag-main-js', get_template_directory_uri() . '/assets/js/main.js', array('jquery'), '1.0', true );
// comment reply
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'astromag_scripts' );
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Functions which enhance the theme by hooking into WordPress.
*/
require get_template_directory() . '/inc/template-functions.php';
/**
* Kirki framework additions.
*/
require get_template_directory() . '/inc/kirki/kirki.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
if ( defined( 'JETPACK__VERSION' ) ) {
require get_template_directory() . '/inc/jetpack.php';
}
/**
* Load woocommerce compatibility file.
*/
if ( class_exists( 'WooCommerce' ) ) {
require get_template_directory() . '/inc/woocommerce.php';
}
function astromag_customize_css() {
?>
@add_query_arg( 'paged', '%#%' ),
'format' => '',
'current' => $paged,
'total' => $query->max_num_pages,
'prev_text' => '« Previous',
'next_text' => 'Next »',
);
if ( $wp_rewrite->using_permalinks() )
$pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ).'/%#%/', '' );
if ( ! empty( $wp_query->query_vars['s'] ) )
$pagination['add_args'] = array( 's' => get_query_var( 's' ) );
return paginate_links( $pagination );
}