クラス
Header
Wishlist addition for the navigation header
ソース ソース
ファイル: src/Views/Header.php
class Header { /** * Registers hooks * * @author Evan D Shaw <evandanielshaw@gmail.com> * @return void */ public static function init() { add_action('usces_theme_action_membersystem_after', [get_class(), 'addWishlistToThemeHeader']); add_filter('wp_nav_menu_args', [get_class(), 'removeWishlistPageFromNavMenu'], 10, 1); } /** * Adds wishlist link to header if user is logged in * * @author Evan D Shaw <evandanielshaw@gmail.com> * @return void */ public static function addWishlistToThemeHeader() { if (!usces_is_login()) { return; } ?> <li><a href="<?php echo WCEXWL_PAGE_URL; ?>"><?php _e('My Wishlist', 'wcexwl') ?></a></li> <?php } /** * Removes wishlist link from the default WordPress navigation menu * * @author Evan D Shaw <evandanielshaw@gmail.com> * @global \usc_e_shop $usces * @param array $args * @return array */ public static function removeWishlistPageFromNavMenu($args) { global $usces; if ($usces->is_cart_page($_SERVER['REQUEST_URI']) && 'search_item' !== strtolower((string)$usces->page)) { return $args; } $wid = wcexwl_api_get_wishlist_page_post_id(); $args['exclude'] = !empty($args['exclude']) ? $args['exclude'] . ',' . $wid : $wid; return $args; } }
- addWishlistToThemeHeader — Adds wishlist link to header if user is logged in
- init — Registers hooks
- removeWishlistPageFromNavMenu — Removes wishlist link from the default WordPress navigation menu