Files
mccans-theme/config.php
2025-06-17 08:01:10 -07:00

232 lines
6.7 KiB
PHP

<?php
use Helpers\McCansHelpers;
return [
"debug" => true,
"flex-file-prefix" => "flex",
"options-pages" => [
"Site Options",
],
/**
* excerpt-length
*
* how many words should the wordpress excerpt be
*/
"excerpt-length" => 100,
/**
* guest-class
*
* if you want wordpress to automatically append a class to the body_class
* list when users are not authenticated, put that class name here. it
* defaults to "guest"
*/
"guest-class" => "guest",
/**
* menu-locations
*
* register your individual menu locations here
*/
"menu-locations" => [
"main-nav" => "Main Navigation",
"footer-nav" => "Footer Customer Support Navigation",
],
/**
* custom-post-types
*
* here is where you can define your custom post types easily
*/
"custom-post-types" => [
[
"slug" => "location",
"archive" => true,
"options-pages" => "Locations Landing Page",
"options" => [
"supports" => ["title", "thumbnail"],
]
],
[
"slug" => "testimonial",
"options" => [
"supports" => ["title", "thumbnail"],
]
],
],
/**
* handlebars
*
* We use handlebars templating extensivly in this theme and code pattern.
* You can adjust the defaults for many attributes here.
*
* Set this to `false` to disable handlebars functionality completely
*/
"handlebars" => [
"additional-helpers" => [
"testimonial" => \Helpers\McCansHelpers::testimonial(),
"locationTile" => \Helpers\McCansHelpers::locationTile(),
"productTile" => \Helpers\McCansHelpers::productTile(),
"renderBlock" => \Helpers\McCansHelpers::renderBlock(),
"renderCallout" => \Helpers\McCansHelpers::renderCallout(),
"productBox" => \Helpers\McCansHelpers::searchResultBox('product'),
"pageBox" => \Helpers\McCansHelpers::searchResultBox('page'),
"usd" => \Helpers\McCansHelpers::usd(),
],
],
/**
* enable
*
* enable individual wordpress features here
*/
"enable" => [
"post-thumbnails",
"menus",
"woocommerce",
"excerpts",
],
/**
* disable
*
* disable individual wordpress features here
*/
"disable" => [
"editor",
"customizer",
"gutenberg",
"patterns",
"emojis",
"revisions",
"meta-generator",
"woocommerce.breadcrumb",
"woocommerce.sidebar",
"woocommerce.result_count",
"woocommerce.page_title",
"woocommerce.archive_description",
"woocommerce.reviews",
],
"actions" => [
"woocommerce_before_single_product_summary" => [function () {
echo site()->render('woocommerce-before-content', [
"additionalTopLevelClass" => "single-product-top",
]);
}, 0],
"woocommerce_single_product_summary" => function () {
echo site()->render('woocommerce-after-content');
},
[
"hook" => "woocommerce_after_single_product_summary",
"priority" => 0,
"callback" => function () {
echo site()->render('woocommerce-before-content');
},
],
"woocommerce_after_single_product" => function () {
echo site()->render('woocommerce-after-content');
},
[
"hook" => "woocommerce_after_single_product_summary",
"priority" => 18,
"callback" => function () {
echo site()->render('woocommerce-after-content');
}
],
[
"hook" => "woocommerce_after_single_product_summary",
"priority" => 19,
"callback" => function () {
echo site()->render('flex_callout_text', [
"headline_1" => "Shop",
"headline_2" => "Related Products",
]);
echo site()->render('woocommerce-before-content', [
"additionalTopLevelClass" => "related-wrapper"
]);
}
],
"woocommerce_before_main_content" => [function () {
// skip this for individual products
if (is_product()) {
return;
}
// shop page
if (is_shop()) {
echo site()->render("shop-top", site()->getPost(wc_get_page_id('shop'), [
"headline",
"intro_text",
"thumbnail",
]));
echo site()->render('woocommerce-before-content');
return;
}
if (is_product_category()) {
echo site()->render("shop-category-slice", site()->getQueriedObject(null, [
"title",
"description",
"thumbnail",
"url",
"acf.intro_headline",
"acf.intro_content",
]));
echo site()->render('woocommerce-before-content');
return;
}
echo site()->render('woocommerce-before-content');
}, 5],
[
"hook" => "woocommerce_after_main_content",
"callback" => function () {
// skip this for individual products
if (is_product()) {
return;
}
echo site()->render('woocommerce-after-content');
},
"priority" => 50,
],
"init" => function () {
remove_all_actions('woocommerce_before_shop_loop_item');
remove_all_actions('woocommerce_before_shop_loop_item_title');
remove_all_actions('woocommerce_shop_loop_item_title');
remove_all_actions('woocommerce_after_shop_loop_item_title');
remove_all_actions('woocommerce_after_shop_loop_item');
add_action('woocommerce_shop_loop_item_title', function () {
global $product;
$data = site()->getPost($product->id, [
"url",
"id",
"title",
"thumbnail",
"woocommerce.price",
"woocommerce.attribute.msrp",
"woocommerce.cartUrl",
"woocommerce.sku",
]);
$data["savings"] = McCansHelpers::calcDifference($data["price"], $data["msrp"]);
echo site()->render("product-tile", $data);
});
}
],
];