Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update Pinecone to alpha 14 #265

Merged
merged 5 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions app/Controllers/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,4 +491,41 @@ public static function termListUrl($taxonomy)
}
return get_permalink($page->ID);
}

public static function isSameDomain($string1, $string2)
{
$url1 = parse_url($string1);
$url2 = parse_url($string2);
if (isset($url1['host']) && isset($url2['host'])) {
if ($url1['host'] == $url2['host']) {
return true;
}
}
return false;
}
greatislander marked this conversation as resolved.
Show resolved Hide resolved

/**
* Create an array of information used for generating the Global Navigation.
*
* @return array list of navigation items, where each item has an URL,
* anchor properties, and anchor label.
*/
public static function getGlobalNavigationLinks()
{
$links = array();
if (has_nav_menu('global_navigation')) {
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( $locations[ 'global_navigation' ] );
$menuitems = wp_get_nav_menu_items( $menu->term_id );
foreach ($menuitems as $menuitem) {
if (App::isSameDomain ($menuitem->url, get_home_url())) {
$props = 'rel="home" aria-current="true"';
} else {
$props = '';
greatislander marked this conversation as resolved.
Show resolved Hide resolved
}
$links[] = array ('url' => $menuitem->url, 'properties' => $props, 'label' => $menuitem->title);
}
}
return $links;
}
}
1 change: 1 addition & 0 deletions app/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* @link https://developer.wordpress.org/reference/functions/register_nav_menus/
*/
register_nav_menus([
'global_navigation' => __('Global Navigation', 'coop-library'),
'primary_navigation' => __('Primary Navigation', 'coop-library')
]);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"node": ">= 10.0.0"
},
"dependencies": {
"@platform-coop-toolkit/pinecone": "^1.0.0-alpha.13",
"@platform-coop-toolkit/pinecone": "^1.0.0-alpha.14",
"@wordpress/a11y": "^2.8.0",
"cookies.js": "^2.1.15"
},
Expand Down
19 changes: 19 additions & 0 deletions resources/views/partials/global-navigation.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@if(App::getGlobalNavigationLinks())
<nav class="global-nav" aria-labelledby="global-nav-label">
<span id="global-nav-label" class="screen-reader-text">global navigation</span>
<ul class="global-nav__list">
@foreach (App::getGlobalNavigationLinks() as $link)
@if($loop->first) <li class="global-nav__list-item global-nav__list-item--first">
@else <li class="global-nav__list-item">
@endif
<a {!! $link['properties'] !!} href="{!! $link['url'] !!}" class="global-nav__link">
@if($loop->first)
@svg('pcc', 'icon icon--pcc', ['focusable' => 'false', 'aria-hidden' => 'true'])
@endif
{!! $link['label'] !!}
</a>
</li>
@endforeach
</ul class="global-nav__list">
</nav>
@endif
5 changes: 3 additions & 2 deletions resources/views/partials/header.blade.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<header role="banner">
<div class="container">
<a class="link link--brand"@if(is_front_page()) aria-current="page"@endif href="{{ ($current_language !== 'en') ? home_url("/$current_language/") : home_url('/') }}">@svg('pcc', 'icon--pcc', ['focusable' => 'false', 'aria-hidden' => 'true'])<span class="brand__title screen-reader-text">{{ get_bloginfo('name', 'display') }}</span></a>
@include('partials.global-navigation')
<a class="link link--brand"@if(is_front_page()) aria-current="page"@endif href="{{ ($current_language !== 'en') ? home_url("/$current_language/") : home_url('/') }}">@svg('resources', 'icon--resources', ['focusable' => 'false', 'aria-hidden' => 'true'])<span class="brand__title screen-reader-text">{{ get_bloginfo('name', 'display') }}</span></a>
<div class="inner">
@if(!is_front_page())
<button class="button button--borderless search-toggle" aria-expanded="false"><span class="screen-reader-text">{{ __('Search', 'coop-library') }} </span>@svg('search', 'icon--search', ['focusable' => 'false', 'aria-hidden' => 'true'])</button>
@include('partials.search-form')
@endif
<nav aria-labelledby="menu-primary-label">
<nav class="nav" aria-labelledby="menu-primary-label">
<button class="button button--borderless menu-toggle" aria-expanded="false">
@svg('menu', 'icon--open', ['focusable' => 'false', 'aria-hidden' => 'true'])
@svg('close', 'icon--close', ['focusable' => 'false', 'aria-hidden' => 'true'])
Expand Down