| 1 |
<?php |
| 2 |
namespace BTNB\Admin; |
| 3 |
|
| 4 |
if ( !defined( 'ABSPATH' ) ) { exit; } |
| 5 |
|
| 6 |
/** |
| 7 |
* SubMenu class |
| 8 |
* Adds a fallback submenu under Tools when the CPT admin menu is hidden. |
| 9 |
* |
| 10 |
* @package BTN\Admin |
| 11 |
*/ |
| 12 |
class SubMenu { |
| 13 |
/** |
| 14 |
* Constructor. |
| 15 |
* Registers the admin_menu hook. |
| 16 |
*/ |
| 17 |
public function __construct() { |
| 18 |
add_action( 'admin_menu', [ $this, 'adminMenu' ] ); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Adds the 'Button Block' submenu under Tools when the CPT menu is hidden. |
| 23 |
* |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
function adminMenu(){ |
| 27 |
if( 'true' === get_option( 'button_block_option', '' ) ){ |
| 28 |
add_submenu_page( |
| 29 |
'tools.php', |
| 30 |
__('Button Block - bPlugins', 'button-block'), |
| 31 |
__('Button Block', 'button-block'), |
| 32 |
'manage_options', |
| 33 |
'button-block', |
| 34 |
[ \BTNBPlugin::class, 'renderDashboard' ] |
| 35 |
); |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
new SubMenu(); |