| 1 |
<?php |
| 2 |
|
| 3 |
namespace Hostinger\Admin; |
| 4 |
|
| 5 |
use Hostinger\Admin\PluginSettings; |
| 6 |
use Hostinger\WpHelper\Utils; |
| 7 |
use Hostinger\WpMenuManager\Menus; |
| 8 |
|
| 9 |
defined( 'ABSPATH' ) || exit; |
| 10 |
|
| 11 |
class Menu { |
| 12 |
public const MENU_SLUG = 'hostinger-tools'; |
| 13 |
|
| 14 |
public function __construct() { |
| 15 |
add_filter( 'hostinger_admin_menu_bar_items', array( $this, 'add_admin_bar_items' ) ); |
| 16 |
add_filter( 'hostinger_menu_subpages', array( $this, 'sub_menu' ) ); |
| 17 |
} |
| 18 |
|
| 19 |
public function add_admin_bar_items( $menu_items ): array { |
| 20 |
$menu_items[] = array( |
| 21 |
'id' => 'hostinger-tools-admin-bar', |
| 22 |
'title' => __( 'Tools', 'hostinger' ), |
| 23 |
'href' => admin_url( 'admin.php?page=' . self::MENU_SLUG ), |
| 24 |
); |
| 25 |
|
| 26 |
return $menu_items; |
| 27 |
} |
| 28 |
|
| 29 |
public function sub_menu( $submenus ): array { |
| 30 |
$tools_submenu = array( |
| 31 |
'page_title' => __( 'Tools', 'hostinger' ), |
| 32 |
'menu_title' => __( 'Tools', 'hostinger' ), |
| 33 |
'capability' => 'manage_options', |
| 34 |
'menu_slug' => self::MENU_SLUG, |
| 35 |
'callback' => array( $this, 'render_tools_menu_page' ), |
| 36 |
'menu_order' => 10, |
| 37 |
); |
| 38 |
|
| 39 |
$submenus[] = $tools_submenu; |
| 40 |
|
| 41 |
return $submenus; |
| 42 |
} |
| 43 |
|
| 44 |
public function render_tools_menu_page(): void { |
| 45 |
echo wp_kses( Menus::renderMenuNavigation(), 'post' ); |
| 46 |
?> |
| 47 |
<div id="hostinger-tools-vue-app"/> |
| 48 |
|
| 49 |
|
| 50 |
<?php |
| 51 |
} |
| 52 |
} |
| 53 |
|