| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Disco |
| 5 |
* |
| 6 |
* @package Disco |
| 7 |
* @author Ohidul Islam <wahid0003@gmail.com> |
| 8 |
* @link http://domain.tld |
| 9 |
* @license GPL 2.0+ |
| 10 |
* @copyright 2022 WebAppick |
| 11 |
*/ |
| 12 |
|
| 13 |
namespace Disco\Backend; |
| 14 |
|
| 15 |
use Disco\Engine\Base; |
| 16 |
|
| 17 |
/** |
| 18 |
* Create the settings page in the backend |
| 19 |
*/ |
| 20 |
class Settings_Page extends Base { |
| 21 |
|
| 22 |
/** |
| 23 |
* Initialize the class. |
| 24 |
* |
| 25 |
* @return void|bool |
| 26 |
*/ |
| 27 |
public function initialize() { |
| 28 |
if ( ! parent::initialize() ) { |
| 29 |
return; |
| 30 |
} |
| 31 |
|
| 32 |
// Add the options page and menu item. |
| 33 |
\add_action( 'admin_menu', array( $this, 'add_plugin_admin_menu' ) ); |
| 34 |
|
| 35 |
$realpath = (string) \realpath( __DIR__ ); |
| 36 |
$plugin_basename = \plugin_basename( \plugin_dir_path( $realpath ) . DISCO_TEXTDOMAIN . '.php' ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Register the administration menu for this plugin into the WordPress Dashboard menu. |
| 41 |
* |
| 42 |
* @return void |
| 43 |
* @since 1.0.0 |
| 44 |
*/ |
| 45 |
public function add_plugin_admin_menu() { |
| 46 |
/* |
| 47 |
* Add a settings page for this plugin to the Settings menu |
| 48 |
* |
| 49 |
* |
| 50 |
* |
| 51 |
* - Change 'manage_options' to the capability you see fit |
| 52 |
* For reference: http://codex.wordpress.org/Roles_and_Capabilities |
| 53 |
|
| 54 |
add_options_page( __( 'Page Title', DISCO_TEXTDOMAIN ), DISCO_NAME, 'manage_options', DISCO_TEXTDOMAIN, array( $this, 'display_plugin_admin_page' ) ); |
| 55 |
* |
| 56 |
*/ |
| 57 |
/* |
| 58 |
* Add a settings page for this plugin to the main menu |
| 59 |
* |
| 60 |
*/ |
| 61 |
add_menu_page( |
| 62 |
'Disco', |
| 63 |
DISCO_NAME, |
| 64 |
'manage_options', |
| 65 |
'disco-create-discount', |
| 66 |
array( |
| 67 |
$this, |
| 68 |
'display_plugin_admin_page_create_discount', |
| 69 |
), |
| 70 |
plugins_url( 'disco/assets/disco-menu-icon.png' ), |
| 71 |
10 |
| 72 |
); |
| 73 |
add_submenu_page( |
| 74 |
DISCO_TEXTDOMAIN, |
| 75 |
__( 'Create a Discount', 'disco' ), |
| 76 |
__( 'Create a Discount', 'disco' ), |
| 77 |
'manage_options', |
| 78 |
'create-discount', |
| 79 |
array( |
| 80 |
$this, |
| 81 |
'display_plugin_admin_page_create_discount', |
| 82 |
) |
| 83 |
); |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Render the create discount page for this plugin. |
| 88 |
* |
| 89 |
* @return void |
| 90 |
* @since 1.0.0 |
| 91 |
*/ |
| 92 |
public function display_plugin_admin_page_create_discount() { |
| 93 |
// Create a nonce |
| 94 |
wp_create_nonce( 'disco_create_discount' ); |
| 95 |
|
| 96 |
include_once DISCO_PLUGIN_ROOT . 'backend/views/create_discount.php'; |
| 97 |
} |
| 98 |
|
| 99 |
} |
| 100 |
|