is_home()) { global $asteria; set_query_var( 'post_type', 'post' ); set_query_var( 'paged', ( get_query_var('paged') ? get_query_var('paged') : 1) ); if(!empty($asteria['enable_cat'])){ $postcount = $asteria['n_posts_field_id']; $postcat = $asteria['posts_cat_id']; set_query_var( 'posts_per_page', ''.$postcount.'' ); if(!empty($asteria['posts_cat_id'])){set_query_var( 'cat', ''.implode(',', $postcat).'' );} } } } add_action( 'pre_get_posts', 'asteria_home_query' ); //Asteria Site title function asteria_wp_title( $title, $sep ) { global $paged, $page; if ( is_feed() ) return $title; // Add the site name. $title .= get_bloginfo( 'name' ); // Add the site description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) $title = "$title $sep $site_description"; // Add a page number if necessary. if ( $paged >= 2 || $page >= 2 ) $title = "$title $sep " . sprintf( __( 'Page %s', 'asteria' ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'asteria_wp_title', 10, 2 ); //Load Other CSS files function asteria_other_css() { if ( !is_admin() ) { wp_enqueue_style( 'asteria-style', get_stylesheet_uri()); global $asteria; if ( ! empty ( $asteria['post_lightbox_id'] ) ) {wp_enqueue_style('fancybox',get_template_directory_uri().'/css/fancybox.css'); } wp_enqueue_style('customfont',get_template_directory_uri().'/fonts/yanone_kaffeesatz.css', 'yanone_kaffeesatz' ); wp_enqueue_style('customfont2',get_template_directory_uri().'/fonts/opensans-light.css', 'open_sans' ); wp_enqueue_style('icons',get_template_directory_uri().'/fonts/font-awesome.css', 'font_awesome' ); } } add_action('wp_enqueue_scripts', 'asteria_other_css'); //Load Default Logo Fonts function asteria_google_fonts() { //Site Title Font wp_register_style('SiteTitleFont','http://fonts.googleapis.com/css?family=Cinzel+Decorative'); global $asteria; if ( !get_option( 'asteria' )) { wp_enqueue_style( 'SiteTitleFont'); } } add_action('wp_print_styles', 'asteria_google_fonts'); //Load Java Scripts to header function asteria_head_js() { if ( !is_admin() ) { wp_enqueue_script('jquery'); wp_enqueue_script('asteria_js',get_template_directory_uri().'/asteria.js'); wp_enqueue_script('asteria_otherjs',get_template_directory_uri().'/js/other.js'); global $asteria; if ( ! empty ( $asteria['post_gallery_id'] ) ) {wp_enqueue_script('asteria_gallery',get_template_directory_uri().'/js/gallery.js');} global $asteria; if ( ! empty ( $asteria['post_lightbox_id'] ) ) {wp_enqueue_script('asteria_fancybox',get_template_directory_uri().'/js/fancybox.js');} wp_enqueue_script('asteria_nivo',get_template_directory_uri().'/js/jquery.nivo.js'); if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); } } add_action('wp_enqueue_scripts', 'asteria_head_js'); //Load RAW Java Scripts add_action('wp_footer', 'znn_load_js'); function znn_load_js() { include(get_template_directory() . '/javascript.php'); } //SIDEBAR function asteria_widgets_init(){ register_sidebar(array( 'name' => __('Right Sidebar', 'asteria'), 'id' => 'sidebar', 'description' => __('Right Sidebar', 'asteria'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

' )); register_sidebar(array( 'name' => __('Footer Widgets', 'asteria'), 'id' => 'foot_sidebar', 'description' => __('Widget Area for the Footer', 'asteria'), 'before_widget' => '
  • ', 'after_widget' => '
    ', 'before_title' => '

    ', 'after_title' => '

    ' )); } add_action( 'widgets_init', 'asteria_widgets_init' ); //asteria get the first image of the post Function function asteria_get_images($overrides = '', $exclude_thumbnail = false) { return get_posts(wp_parse_args($overrides, array( 'numberposts' => -1, 'post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'exclude' => $exclude_thumbnail ? array(get_post_thumbnail_id()) : array(), 'orderby' => 'menu_order ID' ))); } //Custom Excerpt Length function asteria_excerptlength_teaser($length) { return 20; } function asteria_excerptlength_index($length) { return 12; } function asteria_excerptmore($more) { return '...'; } function asteria_excerpt($length_callback='', $more_callback='') { global $post; if(function_exists($length_callback)){ add_filter('excerpt_length', $length_callback); } if(function_exists($more_callback)){ add_filter('excerpt_more', $more_callback); } $output = get_the_excerpt(); $output = apply_filters('wptexturize', $output); $output = apply_filters('convert_chars', $output); $output = '

    '.$output.'

    '; echo $output; } //Asteria CUSTOM Search Form function asteria_search_form( $form ) { $form = ''; return $form; } add_filter( 'get_search_form', 'asteria_search_form' ); //**************TASTERIA COMMENTS******************// function asteria_comment($comment, $args, $depth) { $GLOBALS['comment'] = $comment; ?>
  • id="li-comment-">
    comment_approved == '0') : ?>
    $depth, 'max_depth' => $args['max_depth']))) ?>
    ','') ?>
  • id="li-comment-">
    comment_approved == '0') : ?>
    %s :'), get_comment_author_link()) ?>
    ''. __( 'Leave a Reply', 'asteria' ) . '', 'fields' => apply_filters( 'comment_form_default_fields', array( 'author' => '

    ', 'email' => '', 'url' => '

    ') )); return $arg; } add_filter( 'comments_form_defaults', 'asteria_comment_form' ); //WOOCOMMERCE SUPPORT if (class_exists('Woocommerce')) { add_action('woocommerce_before_main_content', 'asteria_wrapper_start', 10); add_action('woocommerce_after_main_content', 'asteria_wrapper_end', 10); function asteria_wrapper_start() { echo '
    '; } function asteria_wrapper_end() { echo '
    '; } //Remove Sidebars from all woocommerce pages remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10); } //**************ASTERIA SETUP******************// function asteria_setup() { //Custom Thumbnail Size if ( function_exists( 'add_image_size' ) ) { add_image_size( 'asteriathumb', 387, 260, true ); //(cropped) } //Woocommerce Support add_theme_support( 'woocommerce' ); //Custom Background add_theme_support( 'custom-background', array( 'default-color' => 'f7f7f7' ) ); add_theme_support('automatic-feed-links'); //Post Thumbnail add_theme_support( 'post-thumbnails' ); // Make theme available for translation load_theme_textdomain('asteria', get_template_directory() . '/languages'); //Register Menus register_nav_menus( array( 'primary' => __( 'Header Navigation', 'asteria' ) ) ); } add_action( 'after_setup_theme', 'asteria_setup' ); /*Mobile Detection*/ function asteria_is_mobile() { static $is_mobile; if ( isset($is_mobile) ) return $is_mobile; if ( empty($_SERVER['HTTP_USER_AGENT']) ) { $is_mobile = false; } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false ) { $is_mobile = true; } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') == false) { $is_mobile = true; } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') !== false) { $is_mobile = false; } else { $is_mobile = false; } return $is_mobile; } /* ----------------------------------------------------------------------------- Underconstruction / Maintenance Mode ----------------------------------------------------------------------------- */ function asteria_under_contruction(){ global $asteria; if(!empty($asteria['offline_id'])){ // if user is logged in, don't show the construction page if ( is_user_logged_in() ) { return; } // You could check the remote ip // $ips = array( '127.0.0.1', '192.168.0.1', '208.117.46.9' ); // if ( in_array( $_SERVER['REMOTE_ADDR'], $ips ) ) { // return; // } $protocol = $_SERVER["SERVER_PROTOCOL"]; if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0'; // 503 is recommended : http://bit.ly/YdGkXl header( "$protocol 503 Service Unavailable", true, 503 ); // or header( "$protocol 200 Ok", true, 200 ); header( 'Content-Type: text/html; charset=utf-8' ); // adjust the Retry-After value (in seconds) header( 'Retry-After: 3600' ); ?> is_preview() && ! is_admin() ) add_action( 'wp_footer', 'asteria_customize_preview', 21); $wp_customize->add_section( 'asteria_section_one', array( 'title' => 'Asteria Element Colors', 'description' => 'Change the color of each element', 'priority' => 35, ) ); $wp_customize->add_section( 'asteria_section_two', array( 'title' => 'Asteria Text Colors', 'description' => 'Change the color of each element', 'priority' => 35, ) ); $wp_customize->add_setting('asteria[sec_color_id]',array('type' => 'option','transport' => 'postMessage')); $wp_customize->add_setting('asteria[primtxt_color_id]',array('type' => 'option','transport' => 'postMessage')); $wp_customize->add_setting('asteria[sectxt_color_id]',array('type' => 'option','transport' => 'postMessage')); $wp_customize->add_setting('asteria[menutxt_color_id]',array('type' => 'option','transport' => 'postMessage')); $wp_customize->add_setting('asteria[leavreplytxt_color_id]',array('type' => 'option','transport' => 'postMessage')); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'live_sec_elm', array( 'label' => __( 'Secondary Element background Color', 'asteria' ), 'section' => 'asteria_section_one', 'settings' => 'asteria[sec_color_id]', ) ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'live_prim_txt', array( 'label' => __( 'Site wide Text Color', 'asteria' ), 'section' => 'asteria_section_two', 'settings' => 'asteria[primtxt_color_id]', ) ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'live_sec_txt', array( 'label' => __( 'Text Color on secondary elements', 'asteria' ), 'section' => 'asteria_section_two', 'settings' => 'asteria[sectxt_color_id]', ) ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'live_leavreply_txt', array( 'label' => __( '"Leave a Reply" Text Color', 'asteria' ), 'section' => 'asteria_section_two', 'settings' => 'asteria[leavreplytxt_color_id]', ) ) ); } add_action( 'customize_register', 'asteria_customizer' ); function asteria_customizer_live_preview() { wp_enqueue_script( 'live_fontselect', get_template_directory_uri() . '/admin/js/jquery.fontselect.min.js', array( 'jquery', 'customize-preview' ), '', true ); } // end asteria_customizer_live_preview add_action( 'customize_preview_init', 'asteria_customizer_live_preview' ); function asteria_customize_preview() { ?>