'Header Menu',
)
);
}
add_theme_support('post-thumbnails');
add_theme_support('automatic-feed-links');
add_theme_support( 'title-tag' );
add_theme_support( "custom-header");
add_editor_style( get_stylesheet_directory_uri().'/css/font-colors.css' );
if (!isset($content_width)){$content_width = 800; }
//---Enqueue Scripts & Styles---//
function brewio_enqueue_scripts(){
wp_enqueue_style('brewio_style',get_stylesheet_directory_uri().'/style.css',[],'0.1');
wp_enqueue_script( 'jquery' );
wp_enqueue_script('header_script',get_stylesheet_directory_uri().'/js/header.js',[],'0.1');
do_action('brewio_enqueue_scripts');
}
add_action('wp_enqueue_scripts','brewio_enqueue_scripts');
//--Oembed Wrapper--//
function brewio_oembed_filter($html, $url, $attr, $post_ID) {
$r = ''.$html.'';
return $r;
}
add_filter('embed_oembed_html', 'brewio_oembed_filter', 10, 4) ;
//---Post Loop---//
function brewio_post_loop(){
$classes = get_post_class();
$categories = get_the_category();
?>
>
>
'Filed Under:
cat_ID).'">'.$category->cat_name.'';
echo $category == end($categories) ? '' : ', ';
}; ?>
'.$post->post_title.'
';
if($tribe_is_event == true){
?>
|
';
}
}
}
add_action('brewio_before_body_wrapper','brewio_single_title');
function brewio_single_loop(){?>
>
'',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'next',
'separator' => '',
'nextpagelink' => __( 'Next page' ),
'previouspagelink' => __( 'Previous page' ),
'pagelink' => '%',
'echo' => 1
]); ?>
admin_url('admin-ajax.php'),
]);
}
add_action('wp_enqueue_scripts','brewio_heading_scripts');
//---Checks if is a Beer Filter Page---//
function brewio_is_filter_page(){
global $wp_query;
if(is_post_type_archive('beers') || $wp_query->query_vars['taxonomy'] == 'availability'|| $wp_query->query_vars['pairing'] != null || $wp_query->query_vars['tags'] != null || $wp_query->query_vars['taxonomy'] == 'style'){
return true;
}
else{
return false;
}
}
//---Apply Custom Class To Beer Filter Pages---//
function brewio_filter_body_class($classes){
if(brewio_is_filter_page() == true){
array_push($classes,'beer-filter-page');
return $classes;
}
return $classes;
}
add_filter('body_class','brewio_filter_body_class');
//---Replace Default Theme for Beer Filter Pages---//
function brewio_replace_default_template($template){
global $wp_query;
$queried_template = 'taxonomy-availability-'.$wp_query->query_vars['availability'].'.php';
if(brewio_is_filter_page() == true && locate_template($queried_template) == ''){
$new_template = get_template_directory().'/archive-beers.php';
return $new_template;
}
return $template;
}
add_filter( 'template_include', 'brewio_replace_default_template' );
//---Beer Filtering Header---//
function brewio_beer_filter(){
if(brewio_is_filter_page() == true){
global $wp_query;
$current_filter = $wp_query->query_vars["availability"];
$default_filter = '
- Filter By:
- On Tap Now
- Year-Round Beer
- Seasonal Beer
- Reset
';
?>
[[
'taxonomy' => $_POST['taxonomy'],
'field' => 'slug',
'terms' => $_POST['type'],
]]
];
}
elseif($_POST['type'] != 'reset'){
$query = [
'tax_query' => [
'relation' => 'OR',
[
'taxonomy' => 'availability',
'field' => 'slug',
'terms' => 'on-tap',
'operator' => 'NOT IN',
],
[
'taxonomy' => 'availability',
'field' => 'slug',
'terms' => 'on-tap',
'operator' => 'NOT IN'
]]
];
}
brewio_beer_loop($query);
die();
}
add_action('wp_ajax_brewio_ajax_get_beers','brewio_ajax_get_beers');
add_action('wp_ajax_nopriv_brewio_ajax_get_beers','brewio_ajax_get_beers');
//---Builds Beer Loop Query---//
function brewio_beer_loop_args($query = null){
global $wp_query;
//Initial Array
$defaults = [
'post_type' => 'beers',
'posts_per_page' => -1,
];
//If style is in query vars, filter by that
if($query == null && $wp_query->query_vars["style"] != null){
$defaults = array_merge($defaults,
['tax_query' =>[[
'field' => "slug",
'taxonomy' => "style",
'terms' => $wp_query->query_vars["style"],
]]]);
}
//If a pairing is in query vars, filter by that
if($query == null && $wp_query->query_vars["pairing"] != null){
$defaults = array_merge($defaults,
['tax_query' =>[[
'field' => "slug",
'taxonomy' => "pairing",
'terms' => $wp_query->query_vars["pairing"],
]]]);
}
//If a tag is in query vars, filter by that
if($query == null && $wp_query->query_vars["tags"] != null){
$defaults = array_merge($defaults,
['tax_query' =>[[
'field' => "slug",
'taxonomy' => "tags",
'terms' => $wp_query->query_vars["tags"],
]]]);
}
//If there is a specified query, merge it with the defaults
if($query != null){
$args = array_merge($defaults,$query);
}
//Otherwise, use the defaults
else{
$args = $defaults;
}
return $args;
}
//---Beer Loop---//
function brewio_beer_loop($query = null){
$args = brewio_beer_loop_args($query); //Generates the query array
$the_query = new WP_Query($args);
if($the_query->have_posts()) : while($the_query->have_posts()) : $the_query->the_post();?>
5,
'tax_query' =>[
'relation' => 'OR'
]
];
foreach($styles as $style){
array_push($args['tax_query'],[
'field' => "slug",
'taxonomy' => "style",
'terms' => $style
]);
}
brewio_beer_loop($args);
}
//---Widgets---//
function brewio_widgets(){
register_sidebar([
'name' => 'Left Footer Column',
'id' => 'footer-left-widget',
'description' => 'Customize the left column of the Footer shown on each page',
'before_widget' => ''
]);
register_sidebar([
'name' => 'Center Footer Column',
'id' => 'footer-center-widget',
'description' => 'Customize the center column of the Footer shown on each page',
'before_widget' => ''
]);
register_sidebar([
'name' => 'Right Footer Column',
'id' => 'footer-right-widget',
'description' => 'Customize the right column of the Footer shown on each page',
'before_widget' => ''
]);
register_sidebar([
'name' => 'Sidebar',
'id' => 'sidebar',
'before_title' => '',
'description' => 'Sidebar shown on default page template, and blog archive',
'before_widget' => ''
]);
}
add_action('widgets_init','brewio_widgets');
//---Sidebar---//
function brewio_sidebar(){ ?>
'comment_parent', 'id' => 'comment_ID' );
// constructor – wrapper for the comments list
function __construct() { ?>
Edit this comment','',''); ?> comment_approved == '0') : ?>Your comment is awaiting moderation.