-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
106 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,65 @@ | ||
<?php | ||
|
||
defined('ABSPATH') or exit; | ||
|
||
/** | ||
* Create options page | ||
*/ | ||
function wpt_create_options_page() | ||
{ | ||
if (! current_user_can('administrator')) { | ||
return; | ||
} | ||
|
||
add_submenu_page( | ||
'options-general.php', | ||
WPT_PLUGIN_NAME, | ||
WPT_PLUGIN_NAME, | ||
'manage_options', | ||
'wpt-settings', | ||
fn () => include WPT_DIR_PATH.'/inc/options-content.php' | ||
); | ||
} | ||
|
||
add_action('admin_menu', 'wpt_create_options_page'); | ||
|
||
/** | ||
* Register custom options | ||
*/ | ||
function wpt_register_options() | ||
{ | ||
register_setting('wpt-options', 'wpt_text_option'); | ||
register_setting('wpt-options', 'wpt_radio_option'); | ||
register_setting('wpt-options', 'wpt_select_option'); | ||
} | ||
|
||
add_action('admin_init', 'wpt_register_options'); | ||
<?php defined('ABSPATH') or exit; ?> | ||
|
||
<div class="wrap"> | ||
<h1> | ||
<?php echo WPT_PLUGIN_NAME; ?> | ||
</h1> | ||
|
||
<form method="post" action="options.php"> | ||
<?php settings_fields('wpt-options'); ?> | ||
<?php do_settings_sections('wpt-options'); ?> | ||
|
||
<h2 class="title"> | ||
<?php _e('API', 'wp-plugin-template'); ?> | ||
</h2> | ||
|
||
<table class="form-table"> | ||
<tr valign="top"> | ||
<th scope="row"> | ||
<?php _e('Text', 'wp-plugin-template'); ?> | ||
</th> | ||
<td> | ||
<input type="text" name="wpt_text_option" value="<?php echo esc_attr(get_option('wpt_text_option')); ?>"> | ||
</td> | ||
</tr> | ||
|
||
<tr valign="top"> | ||
<th scope="row"> | ||
<?php _e('Radio', 'wp-plugin-template'); ?> | ||
</th> | ||
<td> | ||
<label> | ||
<input type="radio" name="wpt_radio_option" value="0" <?php checked(0, esc_attr(get_option('wpt_radio_option', 0))); ?>> | ||
<span> | ||
No | ||
</span> | ||
</label> | ||
<br><br> | ||
<label> | ||
<input type="radio" name="wpt_radio_option" value="1" <?php checked(1, esc_attr(get_option('wpt_radio_option', 0))); ?>> | ||
<span> | ||
Yes | ||
</span> | ||
</label> | ||
</td> | ||
</tr> | ||
|
||
<tr valign="top"> | ||
<th scope="row"> | ||
<?php _e('Select', 'wp-plugin-template'); ?> | ||
</th> | ||
<td> | ||
<select name="wpt_select_option"> | ||
<option value="1" <?php selected(get_option('wpt_select_option'), 1); ?>>1</option> | ||
<option value="10" <?php selected(get_option('wpt_select_option'), 10); ?>>10</option> | ||
<option value="25" <?php selected(get_option('wpt_select_option'), 25); ?>>25</option> | ||
</select> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
<hr> | ||
|
||
<?php submit_button(); ?> | ||
</form> | ||
</div> |
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