-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
116 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* @package mimizuku | ||
* @author inc2734 | ||
* @license GPL-2.0+ | ||
*/ | ||
|
||
namespace Mimizuku\App\Setup; | ||
|
||
class Drawer_Nav { | ||
|
||
public function __construct() { | ||
add_filter( 'wp_nav_menu', [ $this, 'wp_nav_menu' ], 10, 2 ); | ||
add_filter( 'nav_menu_css_class', [ $this, 'classes' ], 10, 4 ); | ||
} | ||
|
||
/** | ||
* Sets up attributs | ||
* | ||
* @return void | ||
* @see https://developer.wordpress.org/reference/functions/wp_nav_menu/ | ||
*/ | ||
public function wp_nav_menu( $nav_menu, $args ) { | ||
if ( 'drawer-nav' !== $args->theme_location ) { | ||
return $nav_menu; | ||
} | ||
|
||
return preg_replace( | ||
'/<ul class="sub-menu">/ms', | ||
'<div class="_p-drawer__toggle" data-c="drawer__toggle" aria-expanded="false"><i class="fa fa-angle-right"></i></div><ul class="_p-drawer__submenu" data-c="drawer__submenu" aria-hidden="true">', | ||
$nav_menu | ||
); | ||
} | ||
|
||
/** | ||
* Sets up classes | ||
* | ||
* @return void | ||
* @see https://developer.wordpress.org/reference/classes/walker_nav_menu/ | ||
*/ | ||
public function classes( $classes, $item, $args, $depth ) { | ||
if ( 'drawer-nav' !== $args->theme_location ) { | ||
return $classes; | ||
} | ||
|
||
if ( $depth > 0 ) { | ||
$classes[] = '_p-drawer__subitem'; | ||
} else { | ||
$classes[] = '_p-drawer__item'; | ||
} | ||
return $classes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* @package mimizuku | ||
* @author inc2734 | ||
* @license GPL-2.0+ | ||
*/ | ||
|
||
namespace Mimizuku\App\Setup; | ||
|
||
class Global_Nav { | ||
|
||
public function __construct() { | ||
add_filter( 'wp_nav_menu', [ $this, 'wp_nav_menu' ], 10, 2 ); | ||
add_filter( 'nav_menu_css_class', [ $this, 'classes' ], 10, 4 ); | ||
} | ||
|
||
/** | ||
* Sets up attributs | ||
* | ||
* @return void | ||
* @see https://developer.wordpress.org/reference/functions/wp_nav_menu/ | ||
*/ | ||
public function wp_nav_menu( $nav_menu, $args ) { | ||
if ( 'global-nav' !== $args->theme_location ) { | ||
return $nav_menu; | ||
} | ||
|
||
$nav_menu = preg_replace( | ||
'/menu-item-has-children(.*?)"/ms', | ||
'menu-item-has-children$1" aria-haspopup="true"', | ||
$nav_menu | ||
); | ||
|
||
$nav_menu = preg_replace( | ||
'/<ul class="sub-menu">/ms', | ||
'<ul class="_c-menu__submenu" data-c="menu__submenu" aria-hidden="true">', | ||
$nav_menu | ||
); | ||
|
||
return $nav_menu; | ||
} | ||
|
||
/** | ||
* Sets up classes | ||
* | ||
* @return void | ||
* @see https://developer.wordpress.org/reference/classes/walker_nav_menu/ | ||
*/ | ||
public function classes( $classes, $item, $args, $depth ) { | ||
if ( 'global-nav' !== $args->theme_location ) { | ||
return $classes; | ||
} | ||
|
||
if ( $depth > 0 ) { | ||
$classes[] = '_c-menu__subitem'; | ||
} else { | ||
$classes[] = '_c-menu__item'; | ||
} | ||
return $classes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters