Skip to content

Instantly share code, notes, and snippets.

@k-ishiwata
Last active Mar 11, 2019
Embed
What would you like to do?
<?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