| 1 |
<?php |
| 2 |
|
| 3 |
namespace BetterLinks\Admin; |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { exit; } |
| 5 |
|
| 6 |
use BetterLinks\Helper; |
| 7 |
|
| 8 |
class Menu |
| 9 |
{ |
| 10 |
/** |
| 11 |
* add plugin menu page and submenu pages |
| 12 |
*/ |
| 13 |
public function __construct() |
| 14 |
{ |
| 15 |
add_action('admin_menu', [$this, 'admin_menu']); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* add admin menu page |
| 20 |
* @return hooks |
| 21 |
*/ |
| 22 |
public function admin_menu() |
| 23 |
{ |
| 24 |
add_menu_page( |
| 25 |
'BetterLinks', |
| 26 |
sprintf('BetterLinks %1$s', Helper::btl_menu_notice() ? '<span class="btl-menu-notice">1</span>' : ''), |
| 27 |
apply_filters('betterlinks/admin/menu_capability', 'manage_options'), |
| 28 |
BETTERLINKS_PLUGIN_SLUG, |
| 29 |
[$this, 'load_main_template'], |
| 30 |
BETTERLINKS_ASSETS_URI . 'images/logo.svg', |
| 31 |
30 |
| 32 |
); |
| 33 |
foreach (Helper::get_menu_items() as $key => $item) { |
| 34 |
add_submenu_page(BETTERLINKS_PLUGIN_SLUG, $item['title'], $item['title'], apply_filters("betterlinks/admin/".$key."_menu_capability", $item['capability']), $key, [$this, 'load_main_template']); |
| 35 |
} |
| 36 |
} |
| 37 |
public function load_main_template() |
| 38 |
{ |
| 39 |
echo '<div id="betterlinksbody" class="betterlinks-body"></div>'; |
| 40 |
} |
| 41 |
} |
| 42 |
|