Skip to content

Instantly share code, notes, and snippets.

@k-ishiwata
Last active March 11, 2019 07:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save k-ishiwata/f3de9c8719838d056340 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: Show Text
Plugin URI: http://www.webopixel.net/wordpress/631.html
Description: プラグイン開発説明用のプラグイン
Author: k.ishiwata
Version: 0.1
Author URI: http://www.webopixel.net
*/
class ShowText {
function __construct() {
add_action('admin_menu', array($this, 'add_pages'));
}
function add_pages() {
add_menu_page('テキスト設定','テキスト設定', 'level_8', __FILE__, array($this,'show_text_option_page'), '', 26);
}
function show_text_option_page() {
if ( isset($_POST['showtext_options'])) {
check_admin_referer('shoptions');
$opt = $_POST['showtext_options'];
update_option('showtext_options', $opt);
?><div class="updated fade"><p><strong>テキストを保存しました。</strong></p></div><?php
}
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br /></div><h2>テキスト設定</h2>
<form action="" method="post">
<?php
wp_nonce_field('shoptions');
$opt = get_option('showtext_options');
$show_text = isset($opt['text']) ? $opt['text']: null;
?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="inputtext">テキスト</label></th>
<td><input name="showtext_options[text]" type="text" id="inputtext" value="<?php echo $show_text ?>" class="regular-text" /></td>
</tr>
</table>
<p class="submit"><input type="submit" name="Submit" class="button-primary" value="変更を保存" /></p>
</form>
<!-- /.wrap --></div>
<?php
}
function get_text() {
$opt = get_option('showtext_options');
return isset($opt['text']) ? $opt['text']: null;
}
}
$showtext = new ShowText;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment