';
}
function alx_wc_wrapper_end() {
echo '
';
echo ''Mobile', 'topbar' => 'Topbar', 'header' => 'Header', 'footer' => 'Footer', ) ); } } add_action( 'after_setup_theme', 'alx_setup' ); /* Deregister /* ------------------------------------ */ if ( ! function_exists( 'alx_deregister' ) ) { function alx_deregister() { wp_deregister_style( 'wp-pagenavi' ); } } add_action( 'wp_print_styles', 'alx_deregister', 100 ); /* Register sidebars /* ------------------------------------ */ if ( ! function_exists( 'alx_sidebars' ) ) { function alx_sidebars() { register_sidebar(array( 'name' => 'Primary','id' => 'primary','description' => "Normal full width sidebar", 'before_widget' => '
','before_title' => ''.$link.'
'."\n"; } return $sitename; } } /* Page title /* ------------------------------------ */ if ( ! function_exists( 'alx_page_title' ) ) { function alx_page_title() { global $post; $heading = esc_attr( get_post_meta($post->ID,'_heading',true) ); $subheading = esc_attr( get_post_meta($post->ID,'_subheading',true) ); $title = $heading?$heading:the_title(); if($subheading) { $title = $title.' '.$subheading.''; } return $title; } } /* Blog title /* ------------------------------------ */ if ( ! function_exists( 'alx_blog_title' ) ) { function alx_blog_title() { global $post; $heading = esc_attr( get_theme_mod('blog-heading') ); $subheading = esc_attr( get_theme_mod('blog-subheading') ); if($heading) { $title = $heading; } else { $title = get_bloginfo('name'); } if($subheading) { $title = $title.' '.$subheading.''; } return $title; } } /* Related posts /* ------------------------------------ */ if ( ! function_exists( 'alx_related_posts' ) ) { function alx_related_posts() { wp_reset_postdata(); global $post; // Define shared post arguments $args = array( 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'ignore_sticky_posts' => 1, 'orderby' => 'rand', 'post__not_in' => array($post->ID), 'posts_per_page' => 3 ); // Related by categories if ( get_theme_mod('related-posts') == 'categories' ) { $cats = get_post_meta($post->ID, 'related-cat', true); if ( !$cats ) { $cats = wp_get_post_categories($post->ID, array('fields'=>'ids')); $args['category__in'] = $cats; } else { $args['cat'] = $cats; } } // Related by tags if ( get_theme_mod('related-posts') == 'tags' ) { $tags = get_post_meta($post->ID, 'related-tag', true); if ( !$tags ) { $tags = wp_get_post_tags($post->ID, array('fields'=>'ids')); $args['tag__in'] = $tags; } else { $args['tag_slug__in'] = explode(',', $tags); } if ( !$tags ) { $break = true; } } $query = !isset($break)?new WP_Query($args):new WP_Query; return $query; } } /* Get images attached to post /* ------------------------------------ */ if ( ! function_exists( 'alx_post_images' ) ) { function alx_post_images( $args=array() ) { global $post; $defaults = array( 'numberposts' => -1, 'order' => 'ASC', 'orderby' => 'menu_order', 'post_mime_type' => 'image', 'post_parent' => $post->ID, 'post_type' => 'attachment', ); $args = wp_parse_args( $args, $defaults ); return get_posts( $args ); } } /* Get featured post ids /* ------------------------------------ */ if ( ! function_exists( 'alx_get_featured_post_ids' ) ) { function alx_get_featured_post_ids() { $args = array( 'category' => get_theme_mod('featured-category',''), 'numberposts' => get_theme_mod('featured-posts-count','3') ); $posts = get_posts($args); if ( !$posts ) return false; foreach ( $posts as $post ) $ids[] = $post->ID; return $ids; } } /* ------------------------------------------------------------------------- * * Admin panel functions /* ------------------------------------------------------------------------- */ /* Post formats script /* ------------------------------------ */ if ( ! function_exists( 'alx_post_formats_script' ) ) { function alx_post_formats_script( $hook ) { // Only load on posts, pages if ( !in_array($hook, array('post.php','post-new.php')) ) return; wp_enqueue_script('post-formats', get_template_directory_uri() . '/functions/js/post-formats.js', array( 'jquery' )); } } add_action( 'admin_enqueue_scripts', 'alx_post_formats_script'); /* ------------------------------------------------------------------------- * * Filters /* ------------------------------------------------------------------------- */ /* Body class /* ------------------------------------ */ if ( ! function_exists( 'alx_body_class' ) ) { function alx_body_class( $classes ) { $classes[] = alx_layout_class(); if ( get_theme_mod( 'boxed','off' ) != 'on' ) { $classes[] = 'full-width'; } if ( get_theme_mod( 'boxed','off' ) == 'on' ) { $classes[] = 'boxed'; } if ( has_nav_menu( 'topbar' ) ) { $classes[] = 'topbar-enabled'; } if ( has_nav_menu( 'mobile' ) ) { $classes[] = 'mobile-menu'; } if ( get_theme_mod( 'mobile-sidebar-hide','1' ) == 's1' ) { $classes[] = 'mobile-sidebar-hide-s1'; } if ( get_theme_mod( 'mobile-sidebar-hide','1' ) == 's2' ) { $classes[] = 'mobile-sidebar-hide-s2'; } if ( get_theme_mod( 'mobile-sidebar-hide','1' ) == 's1-s2' ) { $classes[] = 'mobile-sidebar-hide'; } if ( get_theme_mod( 'header-social','on' ) != 'on' ) { $classes[] = 'header-social-hide'; } return $classes; } } add_filter( 'body_class', 'alx_body_class' ); /* Custom rss feed /* ------------------------------------ */ if ( ! function_exists( 'alx_feed_link' ) ) { function alx_feed_link( $output, $feed ) { // Do not redirect comments feed if ( strpos( $output, 'comments' ) ) return $output; // Return feed url return esc_attr( get_theme_mod('rss-feed',$output) ); } } add_filter( 'feed_link', 'alx_feed_link', 10, 2 ); /* Excerpt ending /* ------------------------------------ */ if ( ! function_exists( 'alx_excerpt_more' ) ) { function alx_excerpt_more( $more ) { return '...'; } } add_filter( 'excerpt_more', 'alx_excerpt_more' ); /* Excerpt length /* ------------------------------------ */ if ( ! function_exists( 'alx_excerpt_length' ) ) { function alx_excerpt_length( $length ) { return get_theme_mod('excerpt-length','24',$length); } } add_filter( 'excerpt_length', 'alx_excerpt_length', 999 ); /* Add responsive container to embeds /* ------------------------------------ */ if ( ! function_exists( 'alx_embed_html' ) ) { function alx_embed_html( $html, $url ) { $pattern = '/^https?:\/\/(www\.)?twitter\.com/'; $is_twitter = preg_match( $pattern, $url ); if ( 1 === $is_twitter ) { return $html; } return '