/** * Queues Shopp storefront javascript and styles as needed * * @author Jonathan Davis * @since 1.1 * * @return void **/ public function behaviors() { $Shopp = Shopp::object(); if (is_ssl()) { $urls = array('option_siteurl', 'option_home', 'option_url', 'option_wpurl', 'option_stylesheet_url', 'option_template_url', 'script_loader_src'); foreach ($urls as $filter) { add_filter($filter, 'force_ssl'); } } // Replace the WordPress canonical link remove_action('wp_head', 'rel_canonical'); add_action('wp_head', array($this, 'header')); add_action('wp_footer', array($this, 'footer')); wp_enqueue_style('shopp.catalog', SHOPP_ADMIN_URI . '/styles/catalog.css', array(), 20110511, 'screen'); wp_enqueue_style('shopp.icons', SHOPP_ADMIN_URI . '/styles/icons.css', array(), 20110511, 'screen'); wp_enqueue_style('shopp', Shopp::template_url('shopp.css'), array(), 20110511, 'screen'); wp_enqueue_style('shopp.colorbox', SHOPP_ADMIN_URI . '/styles/colorbox.css', array(), 20110511, 'screen'); $orderhistory = is_account_page() && isset($_GET['id']) && !empty($_GET['id']); if (is_thanks_page() || $orderhistory) { wp_enqueue_style('shopp.printable', SHOPP_ADMIN_URI . '/styles/printable.css', array(), 20110511, 'print'); } $loading = shopp_setting('script_loading'); if (!$loading || 'global' == $loading || !empty($page)) { shopp_enqueue_script('colorbox'); shopp_enqueue_script('shopp'); shopp_enqueue_script('catalog'); shopp_enqueue_script('cart'); if (is_catalog_page()) { shopp_custom_script('catalog', "var pricetags = {};\n"); } } if (is_checkout_page()) { shopp_enqueue_script('address'); shopp_enqueue_script('checkout'); } if (is_confirm_page()) { shopp_enqueue_script('checkout'); } if (is_account_page()) { shopp_enqueue_script('address'); $regions = Lookup::country_zones(); $js = 'var regions=' . json_encode($regions); add_storefrontjs($js, true); } }
/** * Provides markup for a navigation breadcrumb list * * @api `shopp('storefront.breadcrumb')` * @since 1.0 * * @param string $result The output * @param array $options The options * @param ShoppStorefront $O The working object * @return string The breadcrumb markup **/ public static function breadcrumb($result, $options, $O) { $Shopp = Shopp::object(); $defaults = array('separator' => ' » ', 'depth' => 7, 'wrap' => '<ul class="breadcrumb">', 'endwrap' => '</ul>', 'before' => '<li>', 'after' => '</li>'); $options = array_merge($defaults, $options); extract($options); $linked = $before . '%2$s<a href="%3$s">%1$s</a>' . $after; $list = $before . '%2$s<span>%1$s</span>' . $after; $CatalogPage = shopp_get_page('catalog'); $Storefront = ShoppStorefront(); // Add the Store front page (aka catalog page) $breadcrumb = array($CatalogPage->title() => Shopp::url(false, 'catalog')); if (is_account_page()) { $Page = shopp_get_page('account'); $breadcrumb += array($Page->title() => Shopp::url(false, 'account')); $request = $Storefront->account['request']; if (isset($Storefront->dashboard[$request])) { $breadcrumb += array($Storefront->dashboard[$request]->label => Shopp::url(false, 'account')); } } elseif (is_cart_page()) { $Page = shopp_get_page('cart'); $breadcrumb += array($Page->title() => Shopp::url(false, 'cart')); } elseif (is_checkout_page()) { $Cart = shopp_get_page('cart'); $Checkout = shopp_get_page('checkout'); $breadcrumb += array($Cart->title() => Shopp::url(false, 'cart')); $breadcrumb += array($Checkout->title() => Shopp::url(false, 'checkout')); } elseif (is_confirm_page()) { $Cart = shopp_get_page('cart'); $Checkout = shopp_get_page('checkout'); $Confirm = shopp_get_page('confirm'); $breadcrumb += array($Cart->title() => Shopp::url(false, 'cart')); $breadcrumb += array($Checkout->title() => Shopp::url(false, 'checkout')); $breadcrumb += array($Confirm->title() => Shopp::url(false, 'confirm')); } elseif (is_thanks_page()) { $Page = shopp_get_page('thanks'); $breadcrumb += array($Page->title() => Shopp::url(false, 'thanks')); } elseif (is_shopp_taxonomy()) { $taxonomy = ShoppCollection()->taxonomy; $ancestors = array_reverse(get_ancestors(ShoppCollection()->id, $taxonomy)); foreach ($ancestors as $ancestor) { $term = get_term($ancestor, $taxonomy); $breadcrumb[$term->name] = get_term_link($term->slug, $taxonomy); } $breadcrumb[shopp('collection', 'get-name')] = shopp('collection', 'get-url'); } elseif (is_shopp_collection()) { // collections $breadcrumb[ShoppCollection()->name] = shopp('collection', 'get-url'); } elseif (is_shopp_product()) { $categories = get_the_terms(ShoppProduct()->id, ProductCategory::$taxon); if ($categories) { $term = array_shift($categories); $ancestors = array_reverse(get_ancestors($term->term_id, ProductCategory::$taxon)); foreach ($ancestors as $ancestor) { $parent_term = get_term($ancestor, ProductCategory::$taxon); $breadcrumb[$parent_term->name] = get_term_link($parent_term->slug, ProductCategory::$taxon); } $breadcrumb[$term->name] = get_term_link($term->slug, $term->taxonomy); } $breadcrumb[shopp('product.get-name')] = shopp('product.get-url'); } $names = array_keys($breadcrumb); $last = end($names); $trail = ''; foreach ($breadcrumb as $name => $link) { $trail .= sprintf($last == $name ? $list : $linked, $name, empty($trail) ? '' : $separator, $link); } return $wrap . $trail . $endwrap; }