| 1 |
<?php |
| 2 |
/** |
| 3 |
* Staff Onboard Class |
| 4 |
* |
| 5 |
* @package Timetics |
| 6 |
*/ |
| 7 |
namespace Timetics\Core\Staffs; |
| 8 |
|
| 9 |
defined( 'ABSPATH' ) || exit; |
| 10 |
|
| 11 |
use Timetics\Utils\Singleton; |
| 12 |
|
| 13 |
/** |
| 14 |
* Onboard Class |
| 15 |
*/ |
| 16 |
class Onboard { |
| 17 |
use Singleton; |
| 18 |
|
| 19 |
/** |
| 20 |
* Initialize the class |
| 21 |
* |
| 22 |
* @return void |
| 23 |
*/ |
| 24 |
public function init() { |
| 25 |
add_action( 'admin_menu', [ $this, 'add_page' ] ); |
| 26 |
add_action( 'admin_init', [ $this, 'setup_onboard_page' ] ); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Add dashboard page for staff onboard |
| 31 |
* |
| 32 |
* @return void |
| 33 |
*/ |
| 34 |
public function add_page() { |
| 35 |
add_dashboard_page( '', '', 'manage_timetics', 'staff-onboard', '' ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Setup onboard page template |
| 40 |
* |
| 41 |
* @return void |
| 42 |
*/ |
| 43 |
public function setup_onboard_page() { |
| 44 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only page parameter check, no form processing |
| 45 |
$page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; |
| 46 |
|
| 47 |
if ( 'staff-onboard' !== $page ) { |
| 48 |
return; |
| 49 |
} |
| 50 |
|
| 51 |
$template = TIMETICS_PLUGIN_DIR . '/templates/staff/onboard.php'; |
| 52 |
|
| 53 |
if ( file_exists( $template ) ) { |
| 54 |
include $template; |
| 55 |
} |
| 56 |
|
| 57 |
$output = ob_get_clean(); |
| 58 |
|
| 59 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 60 |
echo $output; |
| 61 |
|
| 62 |
exit; |
| 63 |
} |
| 64 |
} |
| 65 |
|