Created
June 1, 2019 00:59
-
-
Save mymizan/0e7263d20ad3234a7a54e2297277cce6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: YM Options Page | |
Plugin URI: https://yakub.xyz/ | |
Description: The plugin shows you how to build an options page | |
Author: M Yakub Mizan | |
Version: 1.0.0 | |
Author URI: https://yakub.xyz | |
*/ | |
class YM_Options_Page { | |
/** | |
* This is the place where we define our hooks | |
* They run when the class is instantiated. | |
**/ | |
public function __construct() | |
{ | |
//hook the function that will call the add_options_page to add the options | |
add_action( 'admin_menu', array($this, 'menu_callback') ); | |
} | |
public function menu_callback() | |
{ | |
add_options_page( 'YM Options Page', 'Ym Options', 'manage_options', 'ym-options', array($this, 'menu_markup') ); | |
} | |
public function menu_markup() | |
{ | |
if ( !current_user_can( 'manage_options' ) ) { | |
wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); | |
} | |
?> | |
<div class="wrap"> | |
<h1>YM Options</h1> | |
</div> | |
<?php | |
} | |
} | |
new YM_Options_Page(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment