/** * @param $template * @return string */ function fflcommerce_template_loader($template) { if (is_single() && get_post_type() == 'product') { fflcommerce_add_body_class(array('fflcommerce', 'fflcommerce-product')); $template = locate_template(array('single-product.php', FFLCOMMERCE_TEMPLATE_URL . 'single-product.php')); if (!$template) { $template = FFLCOMMERCE_DIR . '/templates/single-product.php'; } } elseif (is_tax('product_cat')) { fflcommerce_add_body_class(array('fflcommerce', 'fflcommerce-products', 'fflcommerce-product_cat')); global $posts; $templates = array(); if (count($posts)) { $category = get_the_terms($posts[0]->ID, 'product_cat'); $slug = $category[key($category)]->slug; $templates[] = 'taxonomy-product_cat-' . $slug . '.php'; $templates[] = FFLCOMMERCE_TEMPLATE_URL . 'taxonomy-product_cat-' . $slug . '.php'; } $templates[] = 'taxonomy-product_cat.php'; $templates[] = FFLCOMMERCE_TEMPLATE_URL . 'taxonomy-product_cat.php'; $template = locate_template($templates); if (!$template) { $template = FFLCOMMERCE_DIR . '/templates/taxonomy-product_cat.php'; } } elseif (is_tax('product_tag')) { fflcommerce_add_body_class(array('fflcommerce', 'fflcommerce-products', 'fflcommerce-product_tag')); global $posts; $templates = array(); if (count($posts)) { $tag = get_the_terms($posts[0]->ID, 'product_tag'); $slug = $tag[key($tag)]->slug; $templates[] = 'taxonomy-product_tag-' . $slug . '.php'; $templates[] = FFLCOMMERCE_TEMPLATE_URL . 'taxonomy-product_tag-' . $slug . '.php'; } $templates[] = 'taxonomy-product_tag.php'; $templates[] = FFLCOMMERCE_TEMPLATE_URL . 'taxonomy-product_tag.php'; $template = locate_template($templates); if (!$template) { $template = FFLCOMMERCE_DIR . '/templates/taxonomy-product_tag.php'; } } elseif (is_post_type_archive('product') || is_page(fflcommerce_get_page_id('shop'))) { fflcommerce_add_body_class(array('fflcommerce', 'fflcommerce-shop', 'fflcommerce-products')); $template = locate_template(array('archive-product.php', FFLCOMMERCE_TEMPLATE_URL . 'archive-product.php')); if (!$template) { $template = FFLCOMMERCE_DIR . '/templates/archive-product.php'; } } return $template; }
function fflcommerce_page_body_classes() { global $fflcommerce_body_classes; $fflcommerce_body_classes = (array) $fflcommerce_body_classes; if (is_order_tracker()) { fflcommerce_add_body_class(array('fflcommerce', 'fflcommerce-tracker')); } if (is_checkout()) { fflcommerce_add_body_class(array('fflcommerce', 'fflcommerce-checkout')); } if (is_cart()) { fflcommerce_add_body_class(array('fflcommerce', 'fflcommerce-cart')); } if (is_page(fflcommerce_get_page_id('thanks'))) { fflcommerce_add_body_class(array('fflcommerce', 'fflcommerce-thanks')); } if (is_page(fflcommerce_get_page_id('pay'))) { fflcommerce_add_body_class(array('fflcommerce', 'fflcommerce-pay')); } if (is_account()) { fflcommerce_add_body_class(array('fflcommerce', 'fflcommerce-myaccount')); } }