Created
September 22, 2016 07:06
-
-
Save banna360/1cdec7817ef4ce0631421bbc4353cc53 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 | |
// create custom plugin settings menu | |
add_action('admin_menu', 'my_cool_plugin_create_menu'); | |
function my_cool_plugin_create_menu() { | |
//create new top-level menu | |
add_menu_page('Google Ad', 'Google Ad Settings', 'administrator', __FILE__, 'my_cool_plugin_settings_page' , 'dashicons-screenoptions', __FILE__) ); | |
//call register settings function | |
add_action( 'admin_init', 'register_my_cool_plugin_settings' ); | |
} | |
function register_my_cool_plugin_settings() { | |
//register our settings | |
register_setting( 'my-cool-plugin-settings-group', 'core_google_ad' ); | |
} | |
function my_cool_plugin_settings_page() { | |
?> | |
<div class="wrap"> | |
<h1>Google Ad Settings</h1> | |
<form method="post" action="options.php"> | |
<?php settings_fields( 'my-cool-plugin-settings-group' ); ?> | |
<?php do_settings_sections( 'my-cool-plugin-settings-group' ); ?> | |
<table class="form-table"> | |
<tr valign="top"> | |
<th scope="row">Enter Advertisment Code</th> | |
<td> | |
<textarea name="core_google_ad"> | |
<?php echo esc_attr( get_option('core_google_ad') ); ?> | |
</textarea> | |
</td> | |
<small> You can enter any advertisment code here </small> | |
</tr> | |
</table> | |
<?php submit_button(); ?> | |
</form> | |
</div> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment