| 1 |
<?php |
| 2 |
|
| 3 |
namespace TSB; |
| 4 |
|
| 5 |
if ( !defined( 'ABSPATH' ) ) { exit; } |
| 6 |
|
| 7 |
class AdminMenu { |
| 8 |
public function __construct() { |
| 9 |
add_action( 'admin_menu', [ $this, 'adminMenu' ] ); |
| 10 |
add_action( 'admin_enqueue_scripts', [$this, 'adminEnqueueScripts'] ); |
| 11 |
} |
| 12 |
|
| 13 |
|
| 14 |
public function adminMenu(){ |
| 15 |
add_submenu_page( |
| 16 |
'edit.php?post_type=tsb', |
| 17 |
__('Help And Demo - bPlugins', 'team-section'), |
| 18 |
__('Help And Demo', 'team-section'), |
| 19 |
'manage_options', |
| 20 |
'team-section-dashboard', |
| 21 |
[$this, 'renderDashboardPage'], |
| 22 |
1 |
| 23 |
); |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
public function renderDashboardPage(){ ?> |
| 29 |
|
| 30 |
|
| 31 |
<div |
| 32 |
id='tsm_team_section_block' |
| 33 |
data-info='<?php echo esc_attr( wp_json_encode( [ |
| 34 |
'version' => TSB_VERSION, |
| 35 |
|
| 36 |
'action' => 'tsbGetBlocks', |
| 37 |
'nonce' => wp_create_nonce( 'tsb_admin_nonce' ), |
| 38 |
'adminUrl' => admin_url(), |
| 39 |
'deleteDataOnUninstall' => (bool) get_option( 'tsbDeleteDataOnUninstall', false ), |
| 40 |
'uninstallNonce' => wp_create_nonce( 'tsb_save_uninstall_option' ), |
| 41 |
] ) ); ?>' |
| 42 |
></div> |
| 43 |
<?php } |
| 44 |
|
| 45 |
function adminEnqueueScripts( $hook ) { |
| 46 |
if( strpos( $hook, 'team-section-dashboard' ) ){ |
| 47 |
$asset_file = TSB_DIR_PATH . 'build/admin-dashboard.asset.php'; |
| 48 |
$asset = file_exists( $asset_file ) ? require $asset_file : [ 'dependencies' => [], 'version' => TSB_VERSION ]; |
| 49 |
|
| 50 |
|
| 51 |
$dependencies = array_unique( array_merge( $asset['dependencies'], [ 'wp-util' ] ) ); |
| 52 |
|
| 53 |
wp_enqueue_style( 'tsb-admin-dashboard', TSB_DIR_URL . 'build/admin-dashboard.css', [], TSB_VERSION ); |
| 54 |
wp_enqueue_script( 'tsb-admin-dashboard', TSB_DIR_URL . 'build/admin-dashboard.js', $dependencies, $asset['version'], true ); |
| 55 |
wp_set_script_translations( 'tsb-admin-dashboard', 'team-section', TSB_DIR_PATH . 'languages' ); |
| 56 |
|
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
} |
| 61 |
|