| 1 |
<?php |
| 2 |
|
| 3 |
namespace Jet_Form_Builder\Admin\Pages; |
| 4 |
|
| 5 |
use JFB_Components\Admin\Page\Interfaces\Admin_Dashboard_Page_It; |
| 6 |
use Jet_Form_Builder\Admin\Exceptions\Not_Found_Page_Exception; |
| 7 |
use JFB_Components\Admin\Page\Traits\Admin_Dashboard_Page_Trait; |
| 8 |
use JFB_Components\Admin\Vui_Boxes\Traits\With_Boxes_Trait; |
| 9 |
use JFB_Components\Repository\Repository_Item_Instance_Trait; |
| 10 |
use Jet_Form_Builder\Classes\Theme\With_Theme_Info; |
| 11 |
use JFB_Components\Admin\Notices\Traits\With_Notices_Trait; |
| 12 |
|
| 13 |
// If this file is called directly, abort. |
| 14 |
if ( ! defined( 'WPINC' ) ) { |
| 15 |
die; |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Base dashboard page |
| 20 |
*/ |
| 21 |
abstract class Base_Page implements |
| 22 |
Repository_Item_Instance_Trait, |
| 23 |
Admin_Dashboard_Page_It { |
| 24 |
|
| 25 |
use Admin_Dashboard_Page_Trait; |
| 26 |
use With_Notices_Trait; |
| 27 |
use With_Theme_Info; |
| 28 |
use With_Boxes_Trait; |
| 29 |
|
| 30 |
public function rep_item_id(): string { |
| 31 |
return $this->slug(); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* If it returns FALSE, this page is not registered |
| 36 |
* |
| 37 |
* @return bool |
| 38 |
*/ |
| 39 |
public function is_active(): bool { |
| 40 |
return true; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* @throws Not_Found_Page_Exception |
| 45 |
*/ |
| 46 |
public function render() { |
| 47 |
try { |
| 48 |
Pages_Manager::instance()->get_current()->render_page(); |
| 49 |
} catch ( Not_Found_Page_Exception $exception ) { |
| 50 |
wp_die( |
| 51 |
esc_html__( 'You do not have access to view this page.', 'jet-form-builder' ) |
| 52 |
); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Returns current page url |
| 58 |
* |
| 59 |
* @param array $query_args |
| 60 |
* |
| 61 |
* @return string |
| 62 |
*/ |
| 63 |
public function get_url( $query_args = array() ): string { |
| 64 |
return $this->admin_url( |
| 65 |
array_merge( |
| 66 |
array( 'page' => $this->slug() ), |
| 67 |
$query_args |
| 68 |
) |
| 69 |
); |
| 70 |
} |
| 71 |
|
| 72 |
} |
| 73 |
|