Initial commit
This commit is contained in:
58
inc/classes/Menus.php
Normal file
58
inc/classes/Menus.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Klasa Menus
|
||||
*
|
||||
* @link https://krzysztof-turek.com
|
||||
*
|
||||
* @package tylkofotografia.pl
|
||||
* @version 0.2
|
||||
*/
|
||||
|
||||
class Menus {
|
||||
|
||||
use Singleton;
|
||||
|
||||
function __construct() {
|
||||
$this->setupHooks();
|
||||
}
|
||||
|
||||
protected function setupHooks() {
|
||||
add_action( 'init', [ $this, 'registerMenus' ]);
|
||||
}
|
||||
|
||||
public function registerMenus()
|
||||
{
|
||||
register_nav_menus([
|
||||
'tf-header-menu' => esc_html__('Header Menu', 'tylkofotografia') ,
|
||||
'tf-footer-menu' => esc_html__('Footer Menu', 'tylkofotografia')
|
||||
]);
|
||||
}
|
||||
|
||||
public function get_menu_id( $location ) {
|
||||
|
||||
$locations = get_nav_menu_locations();
|
||||
|
||||
if (!empty($locations)) {
|
||||
return $locations[$location];
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function get_child_menu_items( $menu_array, $parent_id ) {
|
||||
|
||||
$child_menus = [];
|
||||
|
||||
if ( ! empty( $menu_array ) && is_array( $menu_array ) ) {
|
||||
|
||||
foreach ( $menu_array as $menu ) {
|
||||
if ( intval( $menu->menu_item_parent ) === $parent_id ) {
|
||||
array_push( $child_menus, $menu );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $child_menus;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user